Skip to content

Commit

Permalink
Add includePruned as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
keisuke-umezawa committed Aug 20, 2024
1 parent 947c5bb commit 6498a55
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
3 changes: 2 additions & 1 deletion optuna_dashboard/ts/components/GraphHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ export const GraphHistory: FC<{
studies: StudyDetail[]
logScale: boolean
includePruned: boolean
}> = ({ studies, logScale }) => {
}> = ({ studies, logScale, includePruned }) => {
const theme = useTheme()
const colorTheme = usePlotlyColorTheme(theme.palette.mode)
return (
<PlotHistory
studies={studies}
logScale={logScale}
includePruned={includePruned}
colorTheme={colorTheme}
/>
)
Expand Down
26 changes: 22 additions & 4 deletions tslib/react/src/components/PlotHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ interface HistoryPlotInfo {
export const PlotHistory: FC<{
studies: Optuna.Study[]
logScale?: boolean
includePruned?: boolean
colorTheme?: Partial<Plotly.Template>
}> = ({ studies, logScale, colorTheme }) => {
const filterPrunedTrial = false

}> = ({ studies, logScale, includePruned, colorTheme }) => {
const { graphComponentState, notifyGraphDidRender } = useGraphComponentState()

const theme = useTheme()
Expand All @@ -52,6 +51,8 @@ export const PlotHistory: FC<{
>("number")

const [logScaleInternal, setLogScaleInternal] = useState<boolean>(false)
const [includePrunedInternal, setIncludePrunedInternal] =
useState<boolean>(true)

const [markerSize, setMarkerSize] = useState<number>(5)

Expand All @@ -61,7 +62,7 @@ export const PlotHistory: FC<{
const trials = useFilteredTrialsFromStudies(
studies,
[selected],
filterPrunedTrial
includePruned === undefined ? !includePrunedInternal : !includePruned
)

const historyPlotInfos = studies.map((study, index) => {
Expand All @@ -82,6 +83,10 @@ export const PlotHistory: FC<{
setLogScaleInternal(!logScaleInternal)
}

const handleIncludePrunedChange = () => {
setIncludePrunedInternal(!includePrunedInternal)
}

const handleXAxisChange = (e: ChangeEvent<HTMLInputElement>) => {
if (e.target.value === "number") {
setXAxis("number")
Expand Down Expand Up @@ -189,6 +194,19 @@ export const PlotHistory: FC<{
/>
</FormControl>
) : null}
{includePruned === undefined ? (
<FormControl
component="fieldset"
sx={{ marginBottom: theme.spacing(2) }}
>
<FormLabel component="legend"> Include PRUNED trials:</FormLabel>
<Switch
checked={includePrunedInternal}
onChange={handleIncludePrunedChange}
value="enable"
/>
</FormControl>
) : null}
<FormControl>
<FormLabel component="legend">Marker size:</FormLabel>
<Slider
Expand Down

0 comments on commit 6498a55

Please sign in to comment.