Skip to content

[charts] Fix slotProps.legend.position and direction in RadarChart - #23254

Merged
JCQuintas merged 1 commit into
mui:masterfrom
JCQuintas:worktree-radar-legend-position
Jul 30, 2026
Merged

[charts] Fix slotProps.legend.position and direction in RadarChart#23254
JCQuintas merged 1 commit into
mui:masterfrom
JCQuintas:worktree-radar-legend-position

Conversation

@JCQuintas

Copy link
Copy Markdown
Member

Fixes #23251

useRadarChartProps built chartsWrapperProps without legendPosition/legendDirection, so ChartsWrapper always fell back to the default grid layout (legend on top) and slotProps.legend.position / slotProps.legend.direction had no effect on RadarChart.

Every other chart already forwards those two props (BarChart, LineChart, ScatterChart, PieChart, FunnelChart, Heatmap); radar was the only one missing them.

Computed grid-template-areas with slotProps={{ legend: { position: { vertical: 'bottom' } } }}:

before after
RadarChart "legend" "chart" "chart" "legend"

RadarChartPro is fixed as well since it shares the same hook.

`useRadarChartProps` did not forward the legend position/direction to
`ChartsWrapper`, so the legend was always laid out at the top regardless of
`slotProps.legend`. Fixes mui#23251.
@JCQuintas JCQuintas self-assigned this Jul 30, 2026
@JCQuintas JCQuintas added type: bug It doesn't behave as expected. scope: charts Changes related to the charts. labels Jul 30, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-23254--material-ui-x.netlify.app/
QR code for https://deploy-preview-23254--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 🔺+92B(+0.02%) 🔺+12B(+0.01%)
@mui/x-charts-pro 🔺+92B(+0.02%) 🔺+5B(0.00%)
@mui/x-charts-premium 🔺+92B(+0.01%) 🔺+3B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-scheduler 0B(0.00%) 0B(0.00%)
@mui/x-scheduler-premium 0B(0.00%) 0B(0.00%)
@mui/x-chat 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

Total duration: 1,414.74 ms -229.27 ms(-13.9%) | Renders: 63 (+0) | Paint: 1,998.06 ms -260.28 ms(-11.5%)

Test Duration Renders
BarChart with big data amount 139.63 ms 🔺+26.48 ms(+23.4%) 2 (+0)
CandlestickChart with big data amount (webgl renderer) 110.74 ms ▼-29.04 ms(-20.8%) 5 (+0)
ScatterChartPro with big data amount and zoomed in (batch renderer) 6.76 ms ▼-24.89 ms(-78.6%) 2 (+0)
LineChart with big data amount (with marks) 49.64 ms ▼-18.99 ms(-27.7%) 2 (+0)
LineChart with date axis and big data amount 33.27 ms ▼-14.05 ms(-29.7%) 2 (+0)

…and 4 more (+17 within noise) — details

Metric alarms

Test Metric Change
BarChart with big data amount bench:paint 🔺 +61.46 ms

Check out the code infra dashboard for more information about this PR.

@JCQuintas
JCQuintas marked this pull request as ready for review July 30, 2026 10:38
@JCQuintas
JCQuintas requested a review from alexfauquette as a code owner July 30, 2026 10:38
@JCQuintas JCQuintas changed the title [charts] Apply slotProps.legend.position and direction in RadarChart [charts] Fix slotProps.legend.position and direction in RadarChart Jul 30, 2026
@JCQuintas
JCQuintas requested a review from Copilot July 30, 2026 11:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes RadarChart (and by extension RadarChartPro) so that legend layout in ChartsWrapper correctly reacts to slotProps.legend.position and slotProps.legend.direction, aligning radar’s behavior with other chart components.

Changes:

  • Forward slotProps.legend.position and slotProps.legend.direction from useRadarChartProps into ChartsWrapper so layout is computed correctly.
  • Add regression tests asserting the resulting grid-template-areas when changing legend position (bottom) and direction (vertical/side).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/x-charts/src/RadarChart/useRadarChartProps.ts Forwards legendPosition/legendDirection into chartsWrapperProps so ChartsWrapper can compute the correct grid layout.
packages/x-charts/src/RadarChart/RadarChart.test.tsx Adds regression coverage ensuring legend positioning/direction affects the wrapper grid layout as expected.

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

@noraleonte noraleonte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👀 👌

@JCQuintas
JCQuintas merged commit 6ab7e60 into mui:master Jul 30, 2026
25 of 26 checks passed
@JCQuintas
JCQuintas deleted the worktree-radar-legend-position branch July 30, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: charts Changes related to the charts. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[charts] RadarChart does not apply slotProps.legend.position

3 participants