Only show last 100 elements

This commit is contained in:
keisuke-umezawa committed 2023-05-17 21:39:43 +09:00
1 parent 818cb9c2a3
commit f23cf0746b
1 file changed
+3 -1
@@ -5,6 +5,7 @@ import { plotlyDarkTemplate } from "./PlotlyDarkMode"
import { makeHovertext } from "../graphUtil"
const plotDomId = "graph-timeline"
const maxBars = 100
export const GraphTimeline: FC<{
study: StudyDetail | null
@@ -43,6 +44,7 @@ export const GraphTimeline: FC<{
}
const plotTimeline = (trials: Trial[], mode: string) => {
const lastTrials = trials.slice(-maxBars) // Only show last elements
const cm: Record<TrialState, string> = {
Complete: "blue",
Fail: "red",
@@ -74,7 +76,7 @@ const plotTimeline = (trials: Trial[], mode: string) => {
plotly.react(plotDomId, [], layout)
for (const s of Object.keys(cm) as TrialState[]) {
const bars = trials.filter((t) => t.state === s)
const bars = lastTrials.filter((t) => t.state === s)
if (bars.length === 0) {
continue
}