diff --git a/optuna_dashboard/ts/components/Settings.tsx b/optuna_dashboard/ts/components/Settings.tsx index 328521c0..5598b9ca 100644 --- a/optuna_dashboard/ts/components/Settings.tsx +++ b/optuna_dashboard/ts/components/Settings.tsx @@ -3,13 +3,14 @@ import React, { FC, useState } from "react" import { Typography, Select, + Switch, MenuItem, Grid, SelectChangeEvent, } from "@mui/material" -import { useRecoilValue, useSetRecoilState } from "recoil" -import { plotlyColorTheme } from "../state" +import { useRecoilValue, useSetRecoilState, useRecoilState } from "recoil" +import { plotlyColorTheme, plotBackendRenderingState } from "../state" export const Settings: FC = () => { const colorTheme = useRecoilValue(plotlyColorTheme) @@ -28,6 +29,11 @@ export const Settings: FC = () => { setPlotlyColorTheme({ dark: darkModeColor, light: event.target.value }) } + const [plotBackendRendering, setPlotBackendRendering] = useRecoilState(plotBackendRenderingState) + const handleBackendRenderingChange = () => { + setPlotBackendRendering(!plotBackendRendering) + } + return ( @@ -68,6 +74,19 @@ export const Settings: FC = () => { GGPlot2 + + + + Use Plotlypy + + + + + ) } diff --git a/optuna_dashboard/ts/state.ts b/optuna_dashboard/ts/state.ts index dd07319e..1954c98e 100644 --- a/optuna_dashboard/ts/state.ts +++ b/optuna_dashboard/ts/state.ts @@ -51,6 +51,11 @@ export const plotlyColorTheme = atom({ }, }) +export const plotBackendRenderingState = atom({ + key: "plotBackendRendering", + default: false, +}) + export const plotlypyIsAvailableState = atom({ key: "plotlypyIsAvailable", default: true, @@ -115,10 +120,10 @@ export const usePlotlyColorTheme = (mode: string): Partial => { } export const useBackendRender = (): boolean => { - const query = useQuery() + const plotBackendRendering = useRecoilValue(plotBackendRenderingState) const plotlypyIsAvailable = useRecoilValue(plotlypyIsAvailableState) - if (query.get("plotlypy_rendering") === "true") { + if (plotBackendRendering) { if (plotlypyIsAvailable) { return true }