Refactor based on umezawa's comment

This commit is contained in:
nabenabe0928
2023-12-24 09:11:01 +01:00
parent df16f7372c
commit ad25ad9a22
@@ -123,12 +123,11 @@ const plotTimeline = (trials: Trial[], mode: string) => {
const starts = bars.map((b) => b.datetime_start ?? new Date())
const runDurations = bars.map((b, i) => {
const startTime = starts[i].getTime()
const completeTime = b.datetime_complete?.getTime() ?? startTime
const completeTime = isRunning
? maxDatetime.getTime()
: b.datetime_complete?.getTime() ?? startTime
// By using 1 as the min value, we can recognize these bars at least when zooming in.
return Math.max(
1,
!isRunning ? completeTime - startTime : maxDatetime.getTime() - startTime
)
return Math.max(1, completeTime - startTime)
})
const trace: Partial<plotly.PlotData> = {
type: "bar",