From 186f7ac95201de6cf6ccc8c60e9d9cd84dafd54e Mon Sep 17 00:00:00 2001 From: hrntsm Date: Fri, 22 Sep 2023 21:16:33 +0900 Subject: [PATCH] Add redirect to history --- optuna_dashboard/ts/components/GraphHistory.tsx | 15 +++++++++++++++ .../ts/components/GraphParetoFront.tsx | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/optuna_dashboard/ts/components/GraphHistory.tsx b/optuna_dashboard/ts/components/GraphHistory.tsx index 280c02fc..d79afa70 100644 --- a/optuna_dashboard/ts/components/GraphHistory.tsx +++ b/optuna_dashboard/ts/components/GraphHistory.tsx @@ -69,6 +69,21 @@ export const GraphHistory: FC<{ theme.palette.mode, markerSize ) + const element = document.getElementById(plotDomId) + if (element != null && studies.length === 1) { + // @ts-ignore + element.on("plotly_click", function (data) { + const link = + URL_PREFIX + + `/studies/${studies[0].id}}/trials?numbers=${data.points[0].x}` + console.log(link) + window.location.href = link + }) + return () => { + // @ts-ignore + element.removeAllListeners("plotly_click") + } + } }, [studies, selected, logScale, xAxis, theme.palette.mode, markerSize]) const handleObjectiveChange = (event: SelectChangeEvent) => { diff --git a/optuna_dashboard/ts/components/GraphParetoFront.tsx b/optuna_dashboard/ts/components/GraphParetoFront.tsx index 0e3f1daa..b73a49cb 100644 --- a/optuna_dashboard/ts/components/GraphParetoFront.tsx +++ b/optuna_dashboard/ts/components/GraphParetoFront.tsx @@ -42,7 +42,9 @@ export const GraphParetoFront: FC<{ const plotTextInfo = JSON.parse( data.points[0].text.replace(/
/g, "") ) - const link =URL_PREFIX + `/studies/${study.id}}/trials?numbers=${plotTextInfo.number}` + const link = + URL_PREFIX + + `/studies/${study.id}}/trials?numbers=${plotTextInfo.number}` window.location.href = link }) return () => {