From b33ab76e7293a676ac1e760efff3448273cf23e1 Mon Sep 17 00:00:00 2001 From: keisuke-umezawa Date: Thu, 15 Jul 2021 10:56:53 +0900 Subject: [PATCH] Add x log scale --- .../static/components/GraphSlice.tsx | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/optuna_dashboard/static/components/GraphSlice.tsx b/optuna_dashboard/static/components/GraphSlice.tsx index 188826a8..3c06840f 100644 --- a/optuna_dashboard/static/components/GraphSlice.tsx +++ b/optuna_dashboard/static/components/GraphSlice.tsx @@ -33,15 +33,16 @@ export const GraphSlice: FC<{ const trials: Trial[] = study !== null ? study.trials : [] const [objectiveId, setObjectiveId] = useState(0) const [selected, setSelected] = useState(null) - const [logScale, setLogScale] = useState(false) + const [logXScale, setLogXScale] = useState(false) + const [logYScale, setLogYScale] = useState(false) const paramNames = study?.union_search_space.map((s) => s.name) if (selected === null && paramNames && paramNames.length > 0) { setSelected(paramNames[0]) } useEffect(() => { - plotSlice(trials, objectiveId, selected, logScale) - }, [trials, objectiveId, selected, logScale]) + plotSlice(trials, objectiveId, selected, logXScale, logYScale) + }, [trials, objectiveId, selected, logXScale, logYScale]) const handleObjectiveChange = ( event: React.ChangeEvent<{ value: unknown }> @@ -53,9 +54,14 @@ export const GraphSlice: FC<{ setSelected(e.target.value as string) } - const handleLogScaleChange = (e: ChangeEvent) => { + const handleLogXScaleChange = (e: ChangeEvent) => { e.preventDefault() - setLogScale(!logScale) + setLogXScale(!logXScale) + } + + const handleLogYScaleChange = (e: ChangeEvent) => { + e.preventDefault() + setLogYScale(!logYScale) } return ( @@ -88,10 +94,18 @@ export const GraphSlice: FC<{ - Log scale: + Log x scale: + + + Log y scale: + @@ -108,7 +122,8 @@ const plotSlice = ( trials: Trial[], objectiveId: number, selected: string | null, - logScale: boolean + logXScale: boolean, + logYScale: boolean ) => { if (document.getElementById(plotDomId) === null) { return @@ -123,6 +138,7 @@ const plotSlice = ( }, xaxis: { title: selected || "", + type: logXScale ? "log" : "linear", zerolinecolor: "#f2f5fa", zerolinewidth: 1.5, linecolor: "#f2f5fa", @@ -133,7 +149,7 @@ const plotSlice = ( }, yaxis: { title: "Objective Values", - type: logScale ? "log" : "linear", + type: logYScale ? "log" : "linear", zerolinecolor: "#f2f5fa", zerolinewidth: 2, linecolor: "#f2f5fa", @@ -183,6 +199,7 @@ const plotSlice = ( ] layout["xaxis"] = { title: selected, + type: logXScale ? "log" : "linear", zerolinecolor: "#f2f5fa", zerolinewidth: 1.5, linecolor: "#f2f5fa", @@ -215,6 +232,7 @@ const plotSlice = ( ] layout["xaxis"] = { title: selected, + type: logXScale ? "log" : "linear", zerolinecolor: "#f2f5fa", zerolinewidth: 1.5, linecolor: "#f2f5fa",