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] Use <circle /> instead of <path /> for line marks by default #15220

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Oct 31, 2024

Previously the notion of shape was not working for line mark. It was always rendering a path with d={d3.circle()}

Now the shape is working, and if it's a circle we render a circle otherwise a path with the appropriate d3 shape.

This modification is a breaking change because it modifies the SVG component which for example break our tests on mark.click which expect an, event coming from the path

Changelog

Chart breakingchange

The experimentalMarkRendering prop has been removed from the LineChart component.
The line mark are now <circle /> element by default.
And you can chose another shape by adding a shape property to your line series.

The codemod only removes the experimentalMarkRendering prop.
If you relied on the fact that marks were path elements, you need to update your logic.

@mui-bot
Copy link

mui-bot commented Oct 31, 2024

@oliviertassinari oliviertassinari added the component: charts This is the name of the generic UI component, not the React module! label Nov 1, 2024
Copy link

codspeed-hq bot commented Nov 1, 2024

CodSpeed Performance Report

Merging #15220 will not alter performance

Comparing alexfauquette:perf-line (012200d) with master (3fe74a9)

Summary

✅ 6 untouched benchmarks

@romgrk romgrk mentioned this pull request Nov 2, 2024
@alexfauquette alexfauquette marked this pull request as ready for review January 8, 2025 14:17
Copy link

github-actions bot commented Jan 8, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 8, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 9, 2025
Notice that using another shape than "circle" will render a `<path />` instead of the `<circle />` for mark elements.
This modification implies a small drop of rendering performances (around +50ms to render 1.000 marks).

{{"demo": "CustomeLineMarks.js"}}
Copy link
Member

Choose a reason for hiding this comment

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

Custome should be Custom


## CustomeLineMarks

Notice that using another shape than "circle" will render a `<path />` instead of the `<circle />` for mark elements.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Notice that using another shape than "circle" will render a `<path />` instead of the `<circle />` for mark elements.
Notice that using another shape than "circle" renders a `<path />` instead of the `<circle />` for mark elements.

Comment on lines +153 to +158
The `experimentalMarkRendering` prop has been removed from the LineChart component.
The line mark are now `<circle />` element by default.
And you can chose another shape by adding a `shape` property to your line series.

The codemod only removes the `experimentalMarkRendering` prop.
If you relied on the fact that marks were `path` elements, you need to update your logic.
Copy link
Member

Choose a reason for hiding this comment

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

Probably should add this to the changelog in PR description

@@ -85,7 +85,7 @@ describe('LineChart - click event', () => {
onMarkClick={() => {}}
/>,
);
const marks = document.querySelectorAll<HTMLElement>('path.MuiMarkElement-root');
const marks = document.querySelectorAll<HTMLElement>('circle.MuiMarkElement-root');
Copy link
Member

Choose a reason for hiding this comment

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

Cant we target only .MuiMarkElement-root?

Comment on lines 75 to 80
/**
* The shape of the mark elements.
* Notice that using something else than 'circle' will render <path /> instead of <circle /> leading to a small performance decrease.
* @default 'circle'
*/
shape?: 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/**
* The shape of the mark elements.
* Notice that using something else than 'circle' will render <path /> instead of <circle /> leading to a small performance decrease.
* @default 'circle'
*/
shape?: 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
/**
* The shape of the mark elements.
* Using 'circle' renders a `<circle />` element, while all other options render a `<path />` instead. The path causes a small decrease in performance.
* @default 'circle'
*/
shape?: 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';

Copy link
Member

Choose a reason for hiding this comment

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

Original felt a bit odd starting with a negative

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: charts This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants