[charts] Fix slotProps.legend.position and direction in RadarChart - #23254
Merged
Conversation
`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.
Deploy previewBundle size
PerformanceTotal duration: 1,414.74 ms -229.27 ms(-13.9%) | Renders: 63 (+0) | Paint: 1,998.06 ms -260.28 ms(-11.5%)
…and 4 more (+17 within noise) — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
JCQuintas
marked this pull request as ready for review
July 30, 2026 10:38
slotProps.legend.position and direction in RadarChartslotProps.legend.position and direction in RadarChart
Contributor
There was a problem hiding this comment.
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.positionandslotProps.legend.directionfromuseRadarChartPropsintoChartsWrapperso layout is computed correctly. - Add regression tests asserting the resulting
grid-template-areaswhen 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #23251
useRadarChartPropsbuiltchartsWrapperPropswithoutlegendPosition/legendDirection, soChartsWrapperalways fell back to the default grid layout (legend on top) andslotProps.legend.position/slotProps.legend.directionhad no effect onRadarChart.Every other chart already forwards those two props (
BarChart,LineChart,ScatterChart,PieChart,FunnelChart,Heatmap); radar was the only one missing them.Computed
grid-template-areaswithslotProps={{ legend: { position: { vertical: 'bottom' } } }}:RadarChart"legend" "chart""chart" "legend"RadarChartProis fixed as well since it shares the same hook.