Skip to content

refactor: Update explainers plots#467

Closed
Felipedino wants to merge 1 commit intodevelopfrom
refactor/explainer-plots
Closed

refactor: Update explainers plots#467
Felipedino wants to merge 1 commit intodevelopfrom
refactor/explainer-plots

Conversation

@Felipedino
Copy link
Collaborator

This pull request introduces several improvements to the DashAI explainers UI, focusing on better theming support for plots, improved layout responsiveness, and enhanced visual consistency. The most significant changes are the addition of theme-aware styling for Plotly plots, updates to grid alignment and sizing, and minor UI tweaks to ensure components stretch and fill available space.

Theming and Plot Improvements:

  • Added a new applyThemeToLayout function in ExplainersPlot.jsx to dynamically apply MUI theme colors and fonts to Plotly plot layouts, ensuring visual consistency with the rest of the app. This includes background, text, grid, axis, and legend theming, as well as handling polar plots and update menus. (DashAI/front/src/components/explainers/ExplainersPlot.jsx)
  • Integrated the new theming logic using useTheme and useMemo, and updated the plot rendering to use the themed layout. Also adjusted Plotly config for a cleaner look by disabling mode bar and responsiveness. (DashAI/front/src/components/explainers/ExplainersPlot.jsx) [1] [2]

Layout and Responsiveness:

  • Changed the alignment of the explainers grid from center to stretch to allow cards to expand and fill the available vertical space. (DashAI/front/src/components/explainers/ExplainersGrid.jsx)
  • Updated the ExplainersCard and its plot section to use width: "100%", making cards and plots more responsive and better fitting their containers. (DashAI/front/src/components/explainers/ExplanainersCard.jsx) [1] [2]
  • Adjusted the plot container in ExplainersPlot to use width: "100%" instead of alignItems: "flex-start", further improving layout flexibility. (DashAI/front/src/components/explainers/ExplainersPlot.jsx)
image

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

Copilot AI review requested due to automatic review settings March 4, 2026 21:21
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 refactors the DashAI explainers UI to improve Plotly plot theming integration with the MUI theme and adjust explainer layout behavior to better stretch/fill available space.

Changes:

  • Added theme-aware Plotly layout transformation (applyThemeToLayout) and memoized themed layout usage in ExplainersPlot.
  • Adjusted Plotly container/card sizing to use full-width styles and tweaked Plotly config (modebar/responsive).
  • Updated explainers grid alignment to stretch and adjusted card layout to better fill container width.

Reviewed changes

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

File Description
DashAI/front/src/components/explainers/ExplainersPlot.jsx Adds theme-to-Plotly layout mapping, memoizes themed layout, and updates plot container sizing/config.
DashAI/front/src/components/explainers/ExplanainersCard.jsx Updates card and plot section sizing to use full width in compact/full layouts.
DashAI/front/src/components/explainers/ExplainersGrid.jsx Changes grid cross-axis alignment to stretch cards vertically.

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

Comment on lines 169 to 172
{!loading && explainer.status === 3 ? (
<Plot
data={explainersPlots[currentPlot].data}
layout={{
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 render path assumes explainersPlots[currentPlot] exists. If the plot fetch fails (catch runs) or the API returns an empty list, loading is set to false and this will throw when accessing .data. Add a guard (e.g., check explainersPlots.length > 0) and render an error/empty state instead of crashing.

Copilot uses AI. Check for mistakes.
const textColor = theme.palette.text.primary;
const gridColor = theme.palette.divider;

// Strip backend-provided fixed dimensions so our responsive sizing takes over
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 comment says backend width/height are stripped so “responsive sizing takes over”, but the rendered Plot still sets fixed width/height and config.responsive is false. Consider updating the comment to match the actual behavior, or (if the intent is responsiveness) switch to Plotly autosizing (autosize: true, useResizeHandler, and avoid fixed dimensions).

Suggested change
// Strip backend-provided fixed dimensions so our responsive sizing takes over
// Strip backend-provided fixed dimensions so that frontend-controlled sizing/layout can be applied

Copilot uses AI. Check for mistakes.
@@ -1,4 +1,4 @@
import { React, useEffect, useState } from "react";
import { React, useEffect, useMemo, useState } from "react";
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.

react does not export a named React symbol, so import { React, ... } from "react"; will fail at runtime/build. Use either import React from "react"; (default import) or remove React entirely and only import the hooks you use (e.g. import { useEffect, useMemo, useState } from "react";).

Suggested change
import { React, useEffect, useMemo, useState } from "react";
import React, { useEffect, useMemo, useState } from "react";

Copilot uses AI. Check for mistakes.
bgcolor:
theme.palette.ui?.borderLight ?? theme.palette.background.paper,
bordercolor: gridColor,
font: { color: "#000000" },
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.

updatemenus is forcing font.color to #000000, which will be unreadable in dark mode (the app supports theme.palette.mode === "dark"). Prefer using the theme text color (or deriving from theme.palette.text.*) instead of a hard-coded black.

Suggested change
font: { color: "#000000" },
font: { ...(menu.font ?? {}), color: textColor },

Copilot uses AI. Check for mistakes.
@Felipedino Felipedino closed this Mar 4, 2026
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