Apply PlotHistory to standalone

This commit is contained in:
keisuke-umezawa
2024-08-20 22:51:12 +09:00
parent 270c406425
commit c1802ae6c2
5 changed files with 19 additions and 9 deletions
@@ -173,7 +173,7 @@ export const StudyDetail: FC<{
</Typography>
<Card sx={{ margin: theme.spacing(2) }}>
<CardContent>
<PlotHistory study={study} />
{!!study && <PlotHistory studies={[study]} />}
</CardContent>
</Card>
<Grid container spacing={0}>
@@ -14,12 +14,13 @@ const meta: Meta<typeof PlotHistory> = {
(Story, storyContext) => {
const { study } = useMockStudy(storyContext.parameters?.studyId)
if (!study) return <p>loading...</p>
const studies = [study]
return (
<ThemeProvider theme={storyContext.parameters?.theme}>
<CssBaseline />
<Story
args={{
study,
studies,
}}
/>
</ThemeProvider>
+13 -5
View File
@@ -84,6 +84,7 @@ export const PlotHistory: FC<{
}
}
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
useEffect(() => {
if (graphComponentState !== "componentWillMount") {
plotHistory(
@@ -93,9 +94,16 @@ export const PlotHistory: FC<{
logScale,
colorThemeUsed,
markerSize
)
)?.then(notifyGraphDidRender)
}
}, [graphComponentState, studies, selected, logScale, xAxis, colorThemeUsed, markerSize])
}, [
historyPlotInfos,
selected,
xAxis,
colorThemeUsed,
markerSize,
graphComponentState,
])
return (
<Grid container direction="row">
@@ -122,8 +130,8 @@ export const PlotHistory: FC<{
value={selected.identifier()}
onChange={handleObjectiveChange}
>
{targets.map((t, i) => (
<MenuItem value={t.identifier()} key={i}>
{targets.map((t) => (
<MenuItem value={t.identifier()} key={t.identifier()}>
{t.toLabel(studies[0].metric_names)}
</MenuItem>
))}
@@ -324,5 +332,5 @@ const plotHistory = (
})
}
plotData.push(...infeasiblePlotData)
plotly.react(plotDomId, plotData, layout)
return plotly.react(plotDomId, plotData, layout)
}
@@ -14,12 +14,13 @@ const meta: Meta<typeof PlotParallelCoordinate> = {
(Story, storyContext) => {
const { study } = useMockStudy(storyContext.parameters?.studyId)
if (!study) return <p>loading...</p>
const studies = [study]
return (
<ThemeProvider theme={storyContext.parameters?.theme}>
<CssBaseline />
<Story
args={{
study,
studies,
}}
/>
</ThemeProvider>
+1 -1
View File
@@ -18,7 +18,7 @@ describe("PlotHistory Tests", async () => {
}) => <div data-testid={dataTestId}>{children}</div>
return render(
<Wrapper dataTestId={dataTestId}>
<PlotHistory study={study} />
<PlotHistory studies={[study]} />
</Wrapper>
)
}