-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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] Decouple margin
and axis-size
#16418
Conversation
CodSpeed Performance ReportMerging #16418 will not alter performanceComparing Summary
|
86b3461
to
12e239f
Compare
@alexfauquette having the config in either the plugin or in the component cause a re-render which slows up the chart. An alternative could be to get rid of eg: <LineChart
xAxis={[
{
data: ['A', 'B', 'C', 'D'],
scaleType: 'point',
position: 'right',
},
]}
series={[{ data: [40, 30, 20, 10] }]}
height={200}
/> |
Sounds reasonable. Wwe will need to find a hack to let the You would still have the plugin in the following order "dimensions > series > axes" but the dimensions could have a selector that uses xAxis and yAxis config if available. The If later we want to adapt the size according the real space an axis takes we will also need to take into account the zoom and the tick we render. I assume the idea is then to have something like
|
By the way, the removal of leftAxis, ... can be done in a non breaking way. We can deprecate the props and keep default the same |
12e239f
to
7ee2fe4
Compare
I was effectively thinking of this issue #16387 about multiple axis as a nice example of what this new axis config could fix :) I'm good with the API, and adding |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -201,12 +191,14 @@ const SparkLineChart = React.forwardRef(function SparkLineChart( | |||
data: Array.from({ length: data.length }, (_, index) => index), | |||
hideTooltip: xAxis === undefined, | |||
...xAxis, | |||
position: 'none', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mui/xcharts one possible disadvantage of the current approach is that the axis is being counted for sizing purposes even if ChartsAxis
is not present in the document.
Since we have "defaults", I guess it would be difficult to prevent this kind of behavior :/
You have an error in one of the screen shots (the About the sparkling, it's not an issue for me. It's part of the tradeoff we discussed. If someone does not render the axes (like us in the sparkling) or do a custom rendering. They should update the position and sizing of the axis. |
The following props have been removed from the axis config: `topAxis`, `rightAxis`, `bottomAxis`, and `leftAxis`. | ||
|
||
Replaced the `topAxis`, `rightAxis`, `bottomAxis` and `leftAxis` props by a `position` prop in the axis config that accepts `'top' | 'right' | 'bottom' | 'left' | 'none'`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks a bit duplicated with the title. Maybe something more like
The following props have been removed topAxis
, rightAxis
, bottomAxis
, and leftAxis
.
To modify the axis placement, use the new position
property in the axis config.
It accepts 'top' | 'right' | 'bottom' | 'left' | 'none'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also at the end a small sentence to highlight why doing that:
Notice this new API allows you to [stack multiple axes on the same side of the chart](link to the demo)
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment, not a blocker, but probably something we want to tackle post-merge.
* It's used for leaving some space for extra information such as the x- and y-axis or legend. | ||
* Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this up to date? The axes are no longer part of the margin, are they?
Also, we now also accept a single number, right?
Fixes #16387
Fixes #16383
Changelog
Breaking change
Replace
topAxis
,rightAxis
,bottomAxis
, andleftAxis
props byposition
in the axis configThe following props have been removed from the axis config:
topAxis
,rightAxis
,bottomAxis
, andleftAxis
.Replaced the
topAxis
,rightAxis
,bottomAxis
andleftAxis
props by aposition
prop in the axis config that accepts'top' | 'right' | 'bottom' | 'left' | 'none'
.If you were previously disabling an axis by setting it to
null
, you should now set itsposition
to'none'
.Remove
position
prop fromChartsXAxis
andChartsYAxis
The
position
prop has been removed from theChartsXAxis
andChartsYAxis
components. Configure it directly in the axis config.