Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add color scale setting #632

Merged
merged 33 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
48df828
Create base UI
gen740 Sep 7, 2023
45f5813
add color palettes
gen740 Sep 7, 2023
30e0ac5
Update
gen740 Sep 12, 2023
f95ac90
Merge branch 'main' into add_color_scale_setting
gen740 Sep 12, 2023
8863946
Implement color theme
gen740 Sep 13, 2023
167f631
Change all plotly template.
gen740 Sep 22, 2023
85e3a1f
Merge branch 'main' into add_color_scale_setting
gen740 Sep 27, 2023
2006dd0
Merge branch 'main' into add_color_scale_setting
gen740 Sep 27, 2023
5e3898b
revert `optuna_dashboard/index.html`
gen740 Oct 3, 2023
45db781
Delete unnecessary blank line.
gen740 Oct 3, 2023
49fa791
Fix typo
gen740 Nov 17, 2023
70752dd
Merge branch 'main' into add_color_scale_setting
gen740 Nov 17, 2023
0d4f0b4
Update optuna_dashboard/ts/components/Settings.tsx
gen740 Nov 17, 2023
0346f66
Format
gen740 Nov 17, 2023
5f5efb4
Merge branch 'main' into add_color_scale_setting
gen740 Nov 17, 2023
59a251a
Merge branch 'main' into add_color_scale_setting
gen740 Dec 11, 2023
651ac76
Update optuna_dashboard/ts/components/Settings.tsx
gen740 Dec 28, 2023
4ec52d2
Delete grid color scale
gen740 Dec 28, 2023
1a61af6
Apply changes to GraphRank.tsx
gen740 Dec 28, 2023
0d5db75
Rename PlotlyDarkTheme to PlotlyCloroTemplates
gen740 Dec 28, 2023
5c6baf7
Delete unnecessary console.log
gen740 Dec 28, 2023
cdb8c48
format
gen740 Dec 28, 2023
54706ea
Add coloTheme to useEffect watch list
gen740 Jan 11, 2024
b99b877
Update setting UI to Popover
gen740 Jan 19, 2024
af6f5cb
Use Modal instead of Popover
gen740 Jan 19, 2024
fc3dda0
Merge branch 'main' into add_color_scale_setting
gen740 Jan 19, 2024
ab31b63
format
gen740 Jan 19, 2024
1525e37
Delete "getColorTemplate" Function
gen740 Jan 21, 2024
280f6a5
Merge branch 'main' into add_color_scale_setting
gen740 Feb 2, 2024
2a7cf2c
[Delete] Delete `prettier-ignore`
gen740 Feb 6, 2024
2c07611
Merge branch 'main' into add_color_scale_setting
gen740 Feb 6, 2024
9229780
Apply format
gen740 Feb 6, 2024
4b74031
Update biome.json
gen740 Feb 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions optuna_dashboard/ts/components/AppDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { FC } from "react"
import { useRecoilState, useRecoilValue } from "recoil"
import { styled, useTheme, Theme, CSSObject } from "@mui/material/styles"
import Modal from "@mui/material/Modal"
import { Settings } from "./Settings"
import Box from "@mui/material/Box"
import MuiDrawer from "@mui/material/Drawer"
import MuiAppBar, { AppBarProps as MuiAppBarProps } from "@mui/material/AppBar"
Expand Down Expand Up @@ -28,6 +30,8 @@ import Brightness4Icon from "@mui/icons-material/Brightness4"
import Brightness7Icon from "@mui/icons-material/Brightness7"
import TableViewIcon from "@mui/icons-material/TableView"
import RateReviewIcon from "@mui/icons-material/RateReview"
import SettingsIcon from "@mui/icons-material/Settings"

import MenuIcon from "@mui/icons-material/Menu"
import GitHubIcon from "@mui/icons-material/GitHub"
import OpenInNewIcon from "@mui/icons-material/OpenInNew"
Expand Down Expand Up @@ -160,6 +164,16 @@ export const AppDrawer: FC<{
setOpen(false)
}

const [settingOpen, setSettingOpen] = React.useState(false)

const handleSettingOpen = () => {
setSettingOpen(true)
}

const handleSettingClose = () => {
setSettingOpen(false)
}

return (
<Box sx={{ display: "flex", width: "100%" }}>
<AppBar position="fixed" open={open}>
Expand Down Expand Up @@ -328,6 +342,37 @@ export const AppDrawer: FC<{
</ListItemButton>
</ListItem>
)}
<ListItem key="Settings" disablePadding sx={styleListItem}>
<ListItemButton
sx={styleListItemButton}
onClick={handleSettingOpen}
>
<ListItemIcon sx={styleListItemIcon}>
<SettingsIcon />
</ListItemIcon>
<ListItemText primary="Settings" sx={styleListItemText} />
</ListItemButton>
<Modal
open={settingOpen}
onClose={handleSettingClose}
aria-labelledby="modal-modal-title"
aria-describedby="modal-modal-description"
>
<Box
sx={{
position: "absolute",
top: "10%",
left: "10%",
overflow: "auto",
width: "80%",
height: "80%",
bgcolor: "background.paper",
}}
>
<Settings />
</Box>
</Modal>
</ListItem>
<ListItem key="DarkMode" disablePadding sx={styleListItem}>
<ListItemButton
sx={styleListItemButton}
Expand Down
22 changes: 17 additions & 5 deletions optuna_dashboard/ts/components/GraphContour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import {
Box,
} from "@mui/material"
import blue from "@mui/material/colors/blue"
import { plotlyDarkTemplate } from "./PlotlyDarkMode"
import { useMergedUnionSearchSpace } from "../searchSpace"
import { getColorTemplate } from "./PlotlyColorTemplates"
import { useRecoilValue } from "recoil"
import { plotlyColorTheme } from "../state"
import { getAxisInfo } from "../graphUtil"

const plotDomId = "graph-contour"
Expand Down Expand Up @@ -47,9 +49,18 @@ export const Contour: FC<{
setYParam(param || null)
}

const colorTheme = useRecoilValue<PlotlyColorTheme>(plotlyColorTheme)

useEffect(() => {
if (study != null) {
plotContour(study, objectiveId, xParam, yParam, theme.palette.mode)
plotContour(
study,
objectiveId,
xParam,
yParam,
theme.palette.mode,
colorTheme
)
}
}, [study, objectiveId, xParam, yParam, theme.palette.mode])
gen740 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -130,7 +141,8 @@ const plotContour = (
objectiveId: number,
xParam: SearchSpaceItem | null,
yParam: SearchSpaceItem | null,
mode: string
mode: string,
colorTheme: PlotlyColorTheme
) => {
if (document.getElementById(plotDomId) === null) {
return
Expand All @@ -140,7 +152,7 @@ const plotContour = (
const filteredTrials = trials.filter((t) => filterFunc(t, objectiveId))
if (filteredTrials.length < 2 || xParam === null || yParam === null) {
plotly.react(plotDomId, [], {
template: mode === "dark" ? plotlyDarkTemplate : {},
template: getColorTemplate(mode, colorTheme),
})
return
}
Expand All @@ -166,7 +178,7 @@ const plotContour = (
b: 50,
},
uirevision: "true",
template: mode === "dark" ? plotlyDarkTemplate : {},
template: getColorTemplate(mode, colorTheme),
}

// TODO(c-bata): Support parameters that only have the single value
Expand Down
17 changes: 11 additions & 6 deletions optuna_dashboard/ts/components/GraphEdf.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as plotly from "plotly.js-dist-min"
import React, { FC, useEffect, useMemo } from "react"
import { Typography, useTheme, Box } from "@mui/material"
import { plotlyDarkTemplate } from "./PlotlyDarkMode"
import { Target, useFilteredTrialsFromStudies } from "../trialFilter"
import { getColorTemplate } from "./PlotlyColorTemplates"
import { plotlyColorTheme } from "../state"
import { useRecoilValue } from "recoil"

const getPlotDomId = (objectiveId: number) => `graph-edf-${objectiveId}`

Expand Down Expand Up @@ -30,9 +32,11 @@ export const GraphEdf: FC<{
return e
})

const colorTheme = useRecoilValue<PlotlyColorTheme>(plotlyColorTheme)

useEffect(() => {
plotEdf(edfPlotInfos, target, domId, theme.palette.mode)
}, [studies, target, theme.palette.mode])
plotEdf(edfPlotInfos, target, domId, theme.palette.mode, colorTheme)
}, [studies, target, theme.palette.mode, colorTheme])

return (
<Box>
Expand All @@ -51,14 +55,15 @@ const plotEdf = (
edfPlotInfos: EdfPlotInfo[],
target: Target,
domId: string,
mode: string
mode: string,
colorTheme: PlotlyColorTheme
) => {
if (document.getElementById(domId) === null) {
return
}
if (edfPlotInfos.length === 0) {
plotly.react(domId, [], {
template: mode === "dark" ? plotlyDarkTemplate : {},
template: getColorTemplate(mode, colorTheme),
})
return
}
Expand All @@ -77,7 +82,7 @@ const plotEdf = (
r: 50,
b: 50,
},
template: mode === "dark" ? plotlyDarkTemplate : {},
template: getColorTemplate(mode, colorTheme),
}

const plotData: Partial<plotly.PlotData>[] = edfPlotInfos.map((h) => {
Expand Down
22 changes: 18 additions & 4 deletions optuna_dashboard/ts/components/GraphHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import {
useTheme,
Slider,
} from "@mui/material"
import { plotlyDarkTemplate } from "./PlotlyDarkMode"
import {
useFilteredTrialsFromStudies,
Target,
useObjectiveAndUserAttrTargetsFromStudies,
} from "../trialFilter"
import { getColorTemplate } from "./PlotlyColorTemplates"
import { plotlyColorTheme } from "../state"
import { useRecoilValue } from "recoil"

const plotDomId = "graph-history"

Expand Down Expand Up @@ -60,16 +62,27 @@ export const GraphHistory: FC<{
return h
})

const colorTheme = useRecoilValue<PlotlyColorTheme>(plotlyColorTheme)

useEffect(() => {
plotHistory(
historyPlotInfos,
selected,
xAxis,
logScale,
theme.palette.mode,
colorTheme,
markerSize
)
}, [studies, selected, logScale, xAxis, theme.palette.mode, markerSize])
}, [
studies,
selected,
logScale,
xAxis,
theme.palette.mode,
colorTheme,
markerSize,
])

const handleObjectiveChange = (event: SelectChangeEvent<string>) => {
setTarget(event.target.value)
Expand Down Expand Up @@ -179,14 +192,15 @@ const plotHistory = (
xAxis: "number" | "datetime_start" | "datetime_complete",
logScale: boolean,
mode: string,
colorTheme: PlotlyColorTheme,
markerSize: number
) => {
if (document.getElementById(plotDomId) === null) {
return
}
if (historyPlotInfos.length === 0) {
plotly.react(plotDomId, [], {
template: mode === "dark" ? plotlyDarkTemplate : {},
template: getColorTemplate(mode, colorTheme),
})
return
}
Expand All @@ -207,7 +221,7 @@ const plotHistory = (
type: xAxis === "number" ? "linear" : "date",
},
showlegend: historyPlotInfos.length === 1 ? false : true,
template: mode === "dark" ? plotlyDarkTemplate : {},
template: getColorTemplate(mode, colorTheme),
}

const getAxisX = (trial: Trial): number | Date => {
Expand Down
17 changes: 13 additions & 4 deletions optuna_dashboard/ts/components/GraphHyperparameterImportances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import * as plotly from "plotly.js-dist-min"
import React, { FC, useEffect } from "react"
import { Typography, useTheme, Box, Card, CardContent } from "@mui/material"

import { plotlyDarkTemplate } from "./PlotlyDarkMode"
import { actionCreator } from "../action"
import { useParamImportanceValue, useStudyDirections } from "../state"
const plotDomId = "graph-hyperparameter-importances"
import { getColorTemplate } from "./PlotlyColorTemplates"
import { plotlyColorTheme } from "../state"
import { useRecoilValue } from "recoil"

export const GraphHyperparameterImportance: FC<{
studyId: number
Expand All @@ -22,14 +24,20 @@ export const GraphHyperparameterImportance: FC<{
study?.objective_names ||
study?.directions.map((d, i) => `Objective ${i}`) ||
[]
const colorTheme = useRecoilValue<PlotlyColorTheme>(plotlyColorTheme)

useEffect(() => {
action.updateParamImportance(studyId)
}, [numCompletedTrials])

useEffect(() => {
if (importances !== null && nObjectives === importances.length) {
plotParamImportance(importances, objectiveNames, theme.palette.mode)
plotParamImportance(
importances,
objectiveNames,
theme.palette.mode,
colorTheme
)
}
}, [nObjectives, importances, theme.palette.mode])

Expand All @@ -51,7 +59,8 @@ export const GraphHyperparameterImportance: FC<{
const plotParamImportance = (
importances: ParamImportance[][],
objectiveNames: string[],
mode: string
mode: string,
colorTheme: PlotlyColorTheme
) => {
const layout: Partial<plotly.Layout> = {
xaxis: {
Expand All @@ -71,7 +80,7 @@ const plotParamImportance = (
bargap: 0.15,
bargroupgap: 0.1,
uirevision: "true",
template: mode === "dark" ? plotlyDarkTemplate : {},
template: getColorTemplate(mode, colorTheme),
}

if (document.getElementById(plotDomId) === null) {
Expand Down
11 changes: 8 additions & 3 deletions optuna_dashboard/ts/components/GraphIntermediateValues.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import * as plotly from "plotly.js-dist-min"
import React, { FC, useEffect } from "react"
import { Box, Typography, useTheme, CardContent, Card } from "@mui/material"
import { plotlyDarkTemplate } from "./PlotlyDarkMode"
import { getColorTemplate } from "./PlotlyColorTemplates"
import { plotlyColorTheme } from "../state"
import { useRecoilValue } from "recoil"

const plotDomId = "graph-intermediate-values"

Expand All @@ -11,16 +13,18 @@ export const GraphIntermediateValues: FC<{
logScale: boolean
}> = ({ trials, includePruned, logScale }) => {
const theme = useTheme()
const colorTheme = useRecoilValue<PlotlyColorTheme>(plotlyColorTheme)

useEffect(() => {
plotIntermediateValue(
trials,
theme.palette.mode,
colorTheme,
false,
!includePruned,
logScale
)
}, [trials, theme.palette.mode, false, includePruned, logScale])
}, [trials, theme.palette.mode, colorTheme, includePruned, logScale])

return (
<Card>
Expand All @@ -40,6 +44,7 @@ export const GraphIntermediateValues: FC<{
const plotIntermediateValue = (
trials: Trial[],
mode: string,
colorTheme: PlotlyColorTheme,
filterCompleteTrial: boolean,
filterPrunedTrial: boolean,
logScale: boolean
Expand All @@ -64,7 +69,7 @@ const plotIntermediateValue = (
type: "linear",
},
uirevision: "true",
template: mode === "dark" ? plotlyDarkTemplate : {},
template: getColorTemplate(mode, colorTheme),
}
if (trials.length === 0) {
plotly.react(plotDomId, [], layout)
Expand Down
Loading
Loading