Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[charts] Do not document the usage of DEFAULT_X_AXIS_KEY and DEFAULT_Y_AXIS_KEY #12780

Merged
merged 2 commits into from Apr 15, 2024

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Apr 15, 2024

Fix #12531

The root cause of the issue was that:

  • if yAxis is not defined, we internally create a default axis configuration with id DEFAULT_Y_AXIS_KEY.
  • if yAxis is defined without an id, the auto-generated ids are deaultized-y-axis-0, deaultized-y-axis-1, deaultized-y-axis-2, ...

To fix this, I propose to allow providing props such as rightAxis with empty config which will render the first axis. Which match how series work:

const { xAxis, yAxis, xAxisIds, yAxisIds } = axisData;
const defaultXAxisId = xAxisIds[0];
const defaultYAxisId = yAxisIds[0];
const data = stackingGroups.flatMap(({ ids: groupIds }, groupIndex) => {
return groupIds.flatMap((seriesId) => {
const xAxisKey = series[seriesId].xAxisKey ?? defaultXAxisId;
const yAxisKey = series[seriesId].yAxisKey ?? defaultYAxisId;
const xAxisConfig = xAxis[xAxisKey];
const yAxisConfig = yAxis[yAxisKey];

This allow me to remove all references to DEFAULT_X_AXIS_KEY and DEFAULT_Y_AXIS_KEY in the docs

@alexfauquette alexfauquette added docs Improvements or additions to the documentation component: charts This is the name of the generic UI component, not the React module! labels Apr 15, 2024
@mui-bot
Copy link

mui-bot commented Apr 15, 2024

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

Updated pages:

Generated by 🚫 dangerJS against ccf6bb6

@alexfauquette alexfauquette merged commit 93e7245 into mui:master Apr 15, 2024
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: charts This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[charts] Misconception about default axis ids
3 participants