Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
alexfauquette merged 2 commits into
mui:masterfrom
alexfauquette:fix-default-axis
Apr 15, 2024
Merged

[charts] Do not document the usage of DEFAULT_X_AXIS_KEY and DEFAULT_Y_AXIS_KEY#12780
alexfauquette merged 2 commits into
mui:masterfrom
alexfauquette:fix-default-axis

Conversation

@alexfauquette
Copy link
Copy Markdown
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. scope: charts Changes related to the charts. labels Apr 15, 2024
@mui-bot
Copy link
Copy Markdown

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 requested a review from JCQuintas April 15, 2024 09:41
@alexfauquette alexfauquette merged commit 93e7245 into mui:master Apr 15, 2024
DungTiger pushed a commit to DungTiger/mui-x that referenced this pull request Jul 23, 2024
thomasmoon pushed a commit to thomasmoon/mui-x that referenced this pull request Sep 9, 2024
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[charts] Misconception about default axis ids

3 participants