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

[docs] Add charts migration guide #15276

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion docs/data/migration/migration-charts-v7/migration-charts-v7.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,70 @@
These changes were done for consistency, improve stability and make room for new features.
Below are described the steps you need to make to migrate from v7 to v8.

## Run codemods

The `preset-safe` codemod will automatically adjust the bulk of your code to account for breaking changes in v8. You can run `v8.0.0/charts/preset-safe` targeting only Charts or `v8.0.0/preset-safe` to target the other packages as well.

Check warning on line 34 in docs/data/migration/migration-charts-v7/migration-charts-v7.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.Will] Avoid using 'will'. Raw Output: {"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/data/migration/migration-charts-v7/migration-charts-v7.md", "range": {"start": {"line": 34, "column": 27}}}, "severity": "WARNING"}

You can either run it on a specific file, folder, or your entire codebase when choosing the `<path>` argument.

<!-- #default-branch-switch -->

```bash
// Charts specific
npx @mui/x-codemod@latest v8.0.0/charts/preset-safe <path>

// Target the other packages as well
npx @mui/x-codemod@latest v8.0.0/preset-safe <path>
```

:::info
The list is currently empty, but as we move forward with development during the alpha and beta phases, we'll feed this page with all changes in the API.
If you want to run the transformers one by one, check out the transformers included in the [preset-safe codemod for the Charts](https://github.com/mui/mui-x/blob/HEAD/packages/x-codemod/README.md#preset-safe-for-charts-v800) for more details.
:::

Breaking changes that are handled by this codemod are denoted by a ✅ emoji in the table of contents on the right side of the screen.

If you have already applied the `v8.0.0/charts/preset-safe` (or `v8.0.0/preset-safe`) codemod, then you should not need to take any further action on these items.

All other changes must be handled manually.

:::warning
Not all use cases are covered by codemods. In some scenarios, like props spreading or cross-file dependencies, the changes are not properly identified and therefore must be handled manually.

For example, if a codemod tries to rename a prop, but this prop is hidden with the spread operator, it won't be transformed as expected.

```tsx
<PieChart {...pickerProps} /> // The codemod will not modify the content of `pickerProps`.
```

After running the codemods, make sure to test your application and that you don't have any console errors.

Feel free to [open an issue](https://github.com/mui/mui-x/issues/new/choose) for support if you need help to proceed with your migration.
:::

## Series properties renaming

Some properties got deprecated in v7 in favor of a more consistent naming convention.
Those deprecated properties got removed in v8.

The impacted properties are:

- The `xAxisKey`, `yAxisKey`, and `zAxisKey` are renamed `xAxisId`, `yAxisId`, and `zAxisId`.
- The `highlighted` and `faded` properties of `series.highlightScope` are renamed `highlight` and `fade`.
Comment on lines +74 to +80
Copy link
Member

Choose a reason for hiding this comment

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

There is no codemod for this yet 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, because I assume few people do

<LineChart
  series={[{ data: [ ... ], xAxisKey: 'axis1', highlightScope: { highlight: 'series' } }]}
/>

In our realistic demo we always move those information in distinct part, like

const highlightScope = { highlight: 'series' };

<LineChart
  series={[{ data: [ ... ], xAxisKey: 'axis1', highlightScope }]}
/>

// or even

const series= [
  { ...}
].map(...)

<LineChart
  series={series}
  { /* ... */ }
/>


## Legend props propagation ✅

The `legend` props of charts single components got removed.
To pass props to the legend, use the `slotProps.legend`.

```diff
- <PieChart legend={{ ... }} />
+ <PieChart slotProps={{ legend: { ... } }} />
```

## Remove Pie Chart axes

The `<PieChart />` got by error the code to render axes.
This code is removed in v8, which implies removing the following props: `axisHighlight`, `topAxis`, `rightAxis`, `bottomAxis`, and `leftAxis`.
Comment on lines +92 to +95
Copy link
Member

Choose a reason for hiding this comment

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

Same for this

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, for this one I assume nobody used those


This should not impact your code.
If you used axes in a pie chart please open an issue, we would be curious to get more information about the use-case.

Check warning on line 98 in docs/data/migration/migration-charts-v7/migration-charts-v7.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.We] Try to avoid using first-person plural like 'we'. Raw Output: {"message": "[Google.We] Try to avoid using first-person plural like 'we'.", "location": {"path": "docs/data/migration/migration-charts-v7/migration-charts-v7.md", "range": {"start": {"line": 98, "column": 55}}}, "severity": "WARNING"}

Check failure on line 98 in docs/data/migration/migration-charts-v7/migration-charts-v7.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [MUI.CorrectReferenceAllCases] Use 'use case' instead of 'use-case' Raw Output: {"message": "[MUI.CorrectReferenceAllCases] Use 'use case' instead of 'use-case'", "location": {"path": "docs/data/migration/migration-charts-v7/migration-charts-v7.md", "range": {"start": {"line": 98, "column": 109}}}, "severity": "ERROR"}
24 changes: 24 additions & 0 deletions packages/x-codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ npx @mui/x-codemod@latest v8.0.0/preset-safe <path|folder>
The corresponding sub-sections are listed below

- [`preset-safe-for-tree-view`](#preset-safe-for-tree-view-v800)
- [`preset-safe-for-charts`](#preset-safe-for-charts-v800)

### Tree View codemods

Expand Down Expand Up @@ -99,6 +100,29 @@ Renames the `TreeItem2` component to `TreeItem` (same for any subcomponents or u
+import { TreeItem } from '@mui/x-tree-view/TreeItem';
```

### Charts codemods

#### `preset-safe` for charts v8.0.0

The `preset-safe` codemods for charts.

```bash
npx @mui/x-codemod@latest v8.0.0/charts/preset-safe <path|folder>
```

The list includes these transformers

- [`rename-legend-to-slots-legend`](#rename-legend-to-slots-legend)

#### `rename-legend-to-slots-legend`

Place the `legend` props propagation by the `slotProps.legend`.

```diff
- <PieChart legend={{ hidden: true }} />
+ <PieChart slotProps={{ legend: { hidden: true } }} />
```

## v7.0.0

### 🚀 `preset-safe` for v7.0.0
Expand Down
Loading