Skip to content

[charts] Add radial bar overview demo with custom overlays#22776

Merged
JCQuintas merged 21 commits into
mui:masterfrom
JCQuintas:nice-radial-bar
Jun 17, 2026
Merged

[charts] Add radial bar overview demo with custom overlays#22776
JCQuintas merged 21 commits into
mui:masterfrom
JCQuintas:nice-radial-bar

Conversation

@JCQuintas

Copy link
Copy Markdown
Member

Summary

Adds an overview demo to the Radial Bars docs page, showcasing the RadialBarChart with custom SVG overlays.

The demo visualizes average trust in others across Europe (Eurostat ilc_pw03, population aged 16+) between 2013 and 2025, inspired by The European Correspondent's infographic:

  • Blue bars: 2025 trust (real chart series, keeps tooltips/highlight)
  • Orange arc line: 2013 reference level, drawn per country
  • Trend markers: up/down triangle offset from the relevant bar by a static distance
  • Dashed EU average ring (Eurostat EU27 2025 figure)
  • Custom item tooltip showing 2025, 2013, and the change

Details

  • Overlays are passed as children and read the polar scales through the public useRotationAxis / useRadiusAxis / useDrawingArea hooks (shared usePolarGeometry helper) — no internals.
  • New dataset dataset/europeanYouthTrust.ts.
  • Overview section moved to the top of the page; copy made capability-focused.

@JCQuintas
JCQuintas requested a review from alexfauquette as a code owner June 11, 2026 15:22
@JCQuintas JCQuintas self-assigned this Jun 11, 2026
@JCQuintas JCQuintas added docs Improvements or additions to the documentation. scope: charts Changes related to the charts. labels Jun 11, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploy preview

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 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(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-license 0B(0.00%) 0B(0.00%)

Details of bundle changes


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

@JCQuintas JCQuintas added the type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. label Jun 11, 2026
Comment on lines +11 to +12
const CURRENT_COLOR = '#1976d2';
const PREVIOUS_COLOR = '#d32f2f';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

might be clearer

Suggested change
const CURRENT_COLOR = '#1976d2';
const PREVIOUS_COLOR = '#d32f2f';
const COLOR_2025 = '#1976d2';
const COLOR_2013 = '#d32f2f';

scaleType: 'linear',
min: 0,
max: 10,
minRadius: 130,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume this will get transformed into a percentage after PR merged :)

} from '../dataset/europeanYouthTrust';

function TrustTooltipContent() {
const item = useItemTooltip();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm surprised you're using the item and not the axis tooltip. The tooltip content is about both 2013 and 2025. Not only the bar item (2025 values)

Comment on lines +197 to +201
<Stack
spacing={0.75}
sx={{ position: 'absolute', top: 8, left: 8, pointerEvents: 'none' }}
>
{items.map((item) => (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

might be nice to add a breaking point for mobile view. To make the legend a row

Image

Comment on lines +250 to +272
/**
* Reads the polar scales through chart hooks and exposes helpers to place
* custom SVG relative to the chart center. Returns `null` before the scales
* are ready.
*/
export function usePolarGeometry() {
const { left, top, width, height } = useDrawingArea();
const rotationAxis = useRotationAxis();
const radiusAxis = useRadiusAxis();

if (!rotationAxis || !radiusAxis) {
return null;
}

return {
cx: left + width / 2,
cy: top + height / 2,
angleScale: rotationAxis.scale,
bandwidth: rotationAxis.scale.bandwidth(),
radiusScale: radiusAxis.scale,
point: (radius, angle) => [radius * Math.sin(angle), -radius * Math.cos(angle)],
};
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Look like a nice helper hook

<RadialBarChart
dataset={europeanYouthTrust}
height={600}
margin={{ top: 24, bottom: 24, left: 24, right: 24 }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You might need extra left/right margin to get the legend visible (60px probably)

Image Image Image

I tested with smaller inner radius, and 60px margins on left/right

It does not solve every thing. Maybe at some point the label should be shrink. But I don't have easy solution imediatly

@alexfauquette alexfauquette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@JCQuintas
JCQuintas merged commit 26fe49a into mui:master Jun 17, 2026
19 of 21 checks passed
@JCQuintas
JCQuintas deleted the nice-radial-bar branch June 17, 2026 11:52
mbrookes pushed a commit to mbrookes/mui-x that referenced this pull request Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to the documentation. scope: charts Changes related to the charts. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants