diff --git a/optuna_dashboard/ts/components/GraphEdf.tsx b/optuna_dashboard/ts/components/GraphEdf.tsx
index 234b2e6f..d067f8f3 100644
--- a/optuna_dashboard/ts/components/GraphEdf.tsx
+++ b/optuna_dashboard/ts/components/GraphEdf.tsx
@@ -1,10 +1,11 @@
+import { useTheme } from "@mui/material"
import { GraphContainer, PlotEdf, useGraphComponentState } from "@optuna/react"
import * as plotly from "plotly.js-dist-min"
import React, { FC, useEffect } from "react"
import { StudyDetail } from "ts/types/optuna"
import { CompareStudiesPlotType } from "../apiClient"
import { useAPIClient } from "../apiClientProvider"
-import { useBackendRender } from "../state"
+import { useBackendRender, usePlotlyColorTheme } from "../state"
export const GraphEdf: FC<{
studies: StudyDetail[]
@@ -13,7 +14,15 @@ export const GraphEdf: FC<{
if (useBackendRender()) {
return
} else {
- return
+ const theme = useTheme()
+ const colorTheme = usePlotlyColorTheme(theme.palette.mode)
+ return (
+
+ )
}
}
diff --git a/tslib/react/src/components/PlotEdf.tsx b/tslib/react/src/components/PlotEdf.tsx
index 56dce17e..65281dcf 100644
--- a/tslib/react/src/components/PlotEdf.tsx
+++ b/tslib/react/src/components/PlotEdf.tsx
@@ -17,10 +17,13 @@ const getPlotDomId = (objectiveId: number) => `plot-edf-${objectiveId}`
export const PlotEdf: FC<{
studies: Optuna.Study[]
objectiveId: number
-}> = ({ studies, objectiveId }) => {
+ colorTheme?: Partial
+}> = ({ studies, objectiveId, colorTheme }) => {
const { graphComponentState, notifyGraphDidRender } = useGraphComponentState()
const theme = useTheme()
+ const colorThemeUsed =
+ colorTheme ?? (theme.palette.mode === "dark" ? plotlyDarkTemplate : {})
const domId = getPlotDomId(objectiveId)
const target = useMemo(
@@ -39,11 +42,11 @@ export const PlotEdf: FC<{
// biome-ignore lint/correctness/useExhaustiveDependencies:
useEffect(() => {
if (graphComponentState !== "componentWillMount") {
- plotEdf(edfPlotInfos, target, domId, theme.palette.mode)?.then(
+ plotEdf(edfPlotInfos, target, domId, colorThemeUsed)?.then(
notifyGraphDidRender
)
}
- }, [studies, target, theme.palette.mode, graphComponentState])
+ }, [studies, target, colorThemeUsed, graphComponentState])
return (
@@ -65,14 +68,14 @@ const plotEdf = (
edfPlotInfos: EdfPlotInfo[],
target: Target,
domId: string,
- mode: string
+ colorTheme: Partial
) => {
if (document.getElementById(domId) === null) {
return
}
if (edfPlotInfos.length === 0) {
return plotly.react(domId, [], {
- template: mode === "dark" ? plotlyDarkTemplate : {},
+ template: colorTheme,
})
}
@@ -90,7 +93,7 @@ const plotEdf = (
r: 50,
b: 50,
},
- template: mode === "dark" ? plotlyDarkTemplate : {},
+ template: colorTheme,
legend: {
x: 1.0,
y: 0.95,