Skip to content

Conversation

@alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Dec 10, 2025

Follow up on top of #20611

@alexfauquette alexfauquette requested review from a team and prakhargupta1 as code owners December 10, 2025 14:08
@mui-bot
Copy link

mui-bot commented Dec 10, 2025

Deploy preview: https://deploy-preview-20613--material-ui-x.netlify.app/

Updated pages:

Bundle size report

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 🔺+357B(+0.10%) 🔺+85B(+0.08%)
@mui/x-charts-pro 🔺+365B(+0.08%) 🔺+109B(+0.08%)
@mui/x-charts-premium 🔺+357B(+0.08%) 🔺+82B(+0.06%)
@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%)

Details of bundle changes

Generated by 🚫 dangerJS against 25ce936

@bernardobelchior
Copy link
Member

Wrong PR title 😄

@alexfauquette alexfauquette changed the title [charts] Extract pie layout computation [charts] Extract FocusedPieArc from PieArcPlot Dec 11, 2025
@alexfauquette alexfauquette added accessibility a11y type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: charts Changes related to the charts. labels Dec 11, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 11, 2025

CodSpeed Performance Report

Merging #20613 will not alter performance

Comparing alexfauquette:extract-pie-focuse (25ce936) with master (86a6268)1

Summary

✅ 13 untouched

Footnotes

  1. No successful run was found on master (345f34f) during the generation of this report, so 86a6268 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

'x-charts/src/BarChart/AnimatedBarElement.tsx',
'x-charts/src/RadarChart/RadarDataProvider/RadarDataProvider.tsx',
'x-charts/src/LineChart/FocusedLineMark.tsx',
'x-charts/src/PieChart/FocusedPieArc.tsx',
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this technically documented in the accessibility docs? Should we add it there instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

This stuff will create a cross link between docs pages and the component API page.

Those components API are empty. They are just here to be display, so I prefer avoiding adding noise

Comment on lines 565 to 566
{ "name": "UsePieSeriesContextReturnValue", "kind": "TypeAlias" },
{ "name": "UsePieSeriesReturnValue", "kind": "TypeAlias" },
Copy link
Member

@bernardobelchior bernardobelchior Dec 11, 2025

Choose a reason for hiding this comment

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

Probably needs to be re-generated

/>
))}
{/* Render the focus indicator last, so it can align nicely over all arcs */}
{focusedItem && (
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this technically a breaking change? Someone using PieArcPlot will now be missing the outline, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes but it's a legal breaking change O:)

image

const isFaded = !isHighlighted && isItemFaded(currentItem);
const isFocused = isItemFocused({ seriesType: 'pie', seriesId, dataIndex: itemIndex });

// TODO v9: Replace the second argument with the result of useSeriesLayout
Copy link
Member

Choose a reason for hiding this comment

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

Why can't we use it now?

Copy link
Member Author

Choose a reason for hiding this comment

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

A simplified version to illustrate the issue

export fucntion PiePlot(){
  const innerRadius = usePieSeriesLayout()

  return <g>
    <PieArcPlot innerRadius={innerRadius} /> // This component calls useTransformData()
    <PieArcLabelPlot innerRadius={innerRadius} /> // This component calls useTransformData()
  </g>
}

The issue is that PiePlot, PieArcPlot, and PieArcLabelPlot are all exported.

If I use directly the result of usePieSeriesLayout() in the useTransformData() the innerRadius prop would have no effect which is a breaking change

Copy link
Member

Choose a reason for hiding this comment

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

I don't see how we would fix this in the future then 🤔

Like, shouldn't we default to the value of pieSeriesLayout to prevent inconsistency?

  const pieSeriesLayout = usePieSeriesLayout();
  const layout = pieSeriesLayout[seriesId]

  const arcSizes = applyArcModifiers(
    series,
    {
      radius: {
        inner: series.innerRadius ?? layout.radius.innerRadius
        ...
      }
    },
    isHighlighted,
    isFaded,
  );

Copy link
Member Author

@alexfauquette alexfauquette Dec 11, 2025

Choose a reason for hiding this comment

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

In the future, we could

  • remove the PiePlot
  • remove innerRadius props from PieArcPlot to only use the seriesLayout

Then we will be able to do

const pieSeriesLayout = usePieSeriesLayout();
const layout = pieSeriesLayout[seriesId]

const arcSizes = applyArcModifiers(
    series,
    layout,
    isHighlighted,
    isFaded,
  );

By the way series.innerRadius ?? layout.radius.innerRadius is nto correct, because :

  • series.innerRadius is the user config. It can be a percentage like "90%"
  • layout.radius.innerRadius is the equivalent in px of the series.innerRadius

The only thing that interest us from series is the series.faded.inneRadius and series.highlighted.inneRadius

/**
* Function that returns arc properties after applying transformation from highlight/fade states.
*/
export function applyArcModifiers(
Copy link
Member

Choose a reason for hiding this comment

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

"apply" makes it feel like this function is mutable, but it just returns the modifiers, so I'd suggest calling it getArcModifiers or getPieArcModifiers if you want to be more explicit

Copy link
Member Author

Choose a reason for hiding this comment

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

But it does not get the modifiers, it applies the focused and highlighted objects when relevant

Copy link
Member

Choose a reason for hiding this comment

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

We could call it getArcProperties instead or getModifiedArcProperties, for example. Not a blocker, though

DefaultizedPieSeriesType,
'cornerRadius' | 'paddingAngle' | 'id' | 'highlighted' | 'faded' | 'data'
>,
seriesLayout: Pick<PieSeriesLayout, 'radius'>,
Copy link
Member

Choose a reason for hiding this comment

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

If we're just picking the radius, why not simplify the type?

Suggested change
seriesLayout: Pick<PieSeriesLayout, 'radius'>,
layoutRadius: PieSeriesLayout['radius'],

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's easier to have a split that match hooks.

  • seriesDef is a subset of the useSeries
  • seriesLayout is a subset of the useSeriesLayout

Copy link
Member

Choose a reason for hiding this comment

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

I usually prefer simpler types so that functions are easier to test. IMO, the called function doesn't need to know where the data comes from, that's the calling function's responsibility. Not a big deal, though, just style preference

@alexfauquette alexfauquette enabled auto-merge (squash) December 11, 2025 18:17
@alexfauquette alexfauquette merged commit 9bda61c into mui:master Dec 12, 2025
22 checks passed
A-s-h-o-k pushed a commit to A-s-h-o-k/mui-x that referenced this pull request Dec 14, 2025
mapache-salvaje pushed a commit to mapache-salvaje/mui-x that referenced this pull request Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility a11y 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.

4 participants