Skip to content

Update hpo and explainers plots#468

Open
Felipedino wants to merge 2 commits intodevelopfrom
refactor/hpo-plots
Open

Update hpo and explainers plots#468
Felipedino wants to merge 2 commits intodevelopfrom
refactor/hpo-plots

Conversation

@Felipedino
Copy link
Collaborator

This pull request focuses on improving the visual consistency of Plotly plots across the application by introducing a utility to apply the current MUI theme to all Plotly layouts. It also makes several layout and styling adjustments to ensure better responsiveness and alignment in the UI components that display plots and explainers.

Thematic Plot Styling and Consistency:

  • Added a new utility function applyThemeToLayout in plotlyTheme.js to apply MUI theme colors and styles to Plotly layouts, ensuring consistent appearance with the rest of the UI. This function strips backend-provided fixed dimensions so that sizing can be controlled by the frontend.
  • Updated ExplainersPlot.jsx, HyperparameterPlots.jsx, and ResultsTabHyperparameters.jsx to use applyThemeToLayout and the current MUI theme via useTheme(), ensuring all Plotly charts match the application's theme. [1] [2] [3]

Plot Responsiveness and Layout Improvements:

  • Modified the layout and configuration of Plotly plots throughout the codebase for better responsiveness, width handling, and to remove unwanted mode bars where appropriate. This includes changes to plot width, height, and config options in all relevant components. [1] [2] [3] [4] [5] [6]

UI Layout and Alignment Adjustments:

  • Improved grid and alignment settings in ExplainersGrid.jsx and ExplanainersCard.jsx to ensure cards and plot sections stretch and fill available space, resulting in a more consistent and visually appealing layout. [1] [2] [3]
  • Adjusted container and item widths in several components to use full width where appropriate, enhancing the responsiveness of the UI. [1] [2]

Loading State and Error Handling:

  • Improved loading state handling in ResultsTabHyperparameters.jsx by displaying a spinner while plots are being fetched and processed, and by handling errors and failed states more gracefully. [1] [2]

These changes collectively enhance the user experience by ensuring that plots are visually integrated with the application's theme, are more responsive, and that layout and loading behaviors are more robust.

image

There is a problem with dropdown of plotly: plotly/plotly.py#3120
So now it have a ugly color.
image

Still have a bug, when select other hyperparameter in the plot, the plot title disappear.
image

Copilot AI review requested due to automatic review settings March 4, 2026 21:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a shared Plotly theming utility to align Plotly charts with the current MUI theme, and applies it across results/hyperparameter and explainer plot components while adjusting layout/styling for better UI consistency.

Changes:

  • Added applyThemeToLayout utility to theme Plotly layouts using the active MUI theme and remove backend-fixed sizing.
  • Updated hyperparameter and explainer plot components to apply the themed layout and adjust Plotly sizing/config.
  • Tweaked explainer grid/card layout so plot sections/cards stretch to fill available width.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
DashAI/front/src/utils/plotlyTheme.js New utility to apply MUI theme values to Plotly layout (including updatemenus/polar handling).
DashAI/front/src/pages/results/components/ResultsTabHyperparameters.jsx Uses the theme + applyThemeToLayout for hyperparameter plots; adds loading state.
DashAI/front/src/components/models/HyperparameterPlots.jsx Applies themed layouts and makes plots more responsive via width/height handling.
DashAI/front/src/components/explainers/ExplanainersCard.jsx Adjusts card/container widths to better fill available space.
DashAI/front/src/components/explainers/ExplainersPlot.jsx Applies themed layout to explainer plots and changes Plotly config/layout sizing.
DashAI/front/src/components/explainers/ExplainersGrid.jsx Changes grid alignment to stretch cards vertically.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +51 to +58
updatemenus: baseLayout.updatemenus.map((menu) => ({
...menu,
bgcolor:
theme.palette.ui?.borderLight ?? theme.palette.background.paper,
bordercolor: gridColor,
font: { color: "#000000" },
activecolor: theme.palette.primary.main,
})),
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applyThemeToLayout hard-codes updatemenus[].font.color to #000000 and replaces the entire menu.font object. In dark mode the dropdown text will be unreadable against the borderLight background, and replacing the font object can discard backend-provided font size/family. Consider deriving the font color from the theme (e.g., theme.palette.text.primary or theme.palette.getContrastText(menuBg)) and merging with any existing menu.font instead of overwriting it.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +59
title: {
...baseLayout?.title,
font: { ...baseLayout?.title?.font, color: textColor },
},
...(baseLayout?.updatemenus && {
updatemenus: baseLayout.updatemenus.map((menu) => ({
...menu,
bgcolor:
theme.palette.ui?.borderLight ?? theme.palette.background.paper,
bordercolor: gridColor,
font: { color: "#000000" },
activecolor: theme.palette.primary.main,
})),
}),
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Plotly hyperparameter dropdowns (generated in the backend via method: "update") change layout.title/layout.xaxis.title using string shorthands. When the user selects a new option, Plotly can reset the title/axis title font to its default (black), which effectively makes the title disappear on dark backgrounds. To keep theming consistent, consider normalizing baseLayout.title to {text: ...} if it’s a string, and also rewriting updatemenus[].buttons[].args[1].title / args[1].xaxis.title to object form with themed font.color so updates don’t drop the theme.

Copilot uses AI. Check for mistakes.
Comment on lines 112 to 126
<Grid container spacing={2} direction="column">
<Grid container direction="column">
<Plot
data={historicalPlot["data"]}
layout={{
...historicalPlot["layout"],
width: 900,
height: 380,
}}
data={historicalPlot?.data}
layout={{ ...themedHistoricalLayout, width: 900, height: 380 }}
config={{ staticPlot: false }}
/>
</Grid>
<Grid container direction="column">
<Plot
data={slicePlot["data"]}
layout={{
...slicePlot["layout"],
width: 900,
height: 380,
}}
data={slicePlot?.data}
layout={{ ...themedSliceLayout, width: 900, height: 380 }}
config={{ staticPlot: false }}
/>
</Grid>
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component renders <Plot> even when no plots were fetched/parsed (e.g., optimizables === 0 or the request fails), passing undefined for data. react-plotly.js expects data to be an array and may throw or render inconsistently. Consider adding a guard (similar to HyperparameterPlots.jsx) to render a fallback message when historicalPlot/slicePlot are still null after loading completes.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants