From ad25ad9a225df0084786c8f79d4ba4143c2d4002 Mon Sep 17 00:00:00 2001 From: nabenabe0928 Date: Sun, 24 Dec 2023 09:11:01 +0100 Subject: [PATCH] Refactor based on umezawa's comment --- optuna_dashboard/ts/components/GraphTimeline.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/optuna_dashboard/ts/components/GraphTimeline.tsx b/optuna_dashboard/ts/components/GraphTimeline.tsx index b382def5..122f778b 100644 --- a/optuna_dashboard/ts/components/GraphTimeline.tsx +++ b/optuna_dashboard/ts/components/GraphTimeline.tsx @@ -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 = { type: "bar",