-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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-pro] Zoom axis filtering #14121
Conversation
Deploy preview: https://deploy-preview-14121--material-ui-x.netlify.app/ Updated pages: |
CodSpeed Performance ReportMerging #14121 will not alter performanceComparing Summary
|
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com> Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
ff44c6a
to
75fea9a
Compare
Sorry for the force push. I forgot to create a new branch to discuss code variation. Here is the proposal I miss published #14131 From your last commits, I assume we are not considering the same feature. You are removing points based on the zoom state. But for me the feature was the opposite: defining the zoom state (when not controlled by the user) based on points to render. Here is a Echart example echarts.mp4Here is a demo of the proposed PR barchart.mp4Could you details what you would like to acceive by removing those data points from the rendering? I fear it creates bad artefects |
@alexfauquette no worries, I can deal with force pushes 😆 I think in the end our target is both my implementation and yours. I think some of these behaviours are indeed a bit odd, but I'm copying from echarts. Filtering behaves differently on X vs Y axis. You can see on the examples below. For line charts you can see the behaviours Mode: Screen.Recording.2024-08-07.at.11.58.32.movMode: Screen.Recording.2024-08-07.at.11.58.07.mov |
Axis interactionGoalFor me, the main goal is that when zooming on the x-axis, then the y-axis can zoom in/out to show the relevant part of the chart. For example in the next drawing, if the x-axis is set to filter, the two out-sider from the left and the right are ignored when computing the y-axis extremums, which makes the chart zoom on the data point along the y-axis Code perspectiveHere is a basic representation of the data pipeline. With green dot where you are implementing filtering logic (the I don't see how in the For me the only point where this can be done is before doing the per axis computation (the blue spot) Filtering on plotAbout how Echarts display data, I would not copy exactly their behavior. As a user I would be annoyed to have those data points removed from the display, and it seems I'm not the only one 😇 apache/echarts#3637 For me the way axis zoom can impact other axes is something to keep. It's what users asked in #12083 |
Gotcha, so I was reaching for the more complex goal which isn't necessary 😅 Would you say the goal then is: When zooming on the ? |
Yes, and this
And that seems to be all we need. What changesBefore the extremum getters were looping other series to find their max/min values along one axis. Now they need to do that while taking care that the second axis is not filtering out those data points. |
No, it's not the scale but the |
@alexfauquette should be fixed. Moving the dataset binding to the |
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 last renaming point to fix
That's a very nice feature. Could benefit a changelog highlight
You can do so by adding ## Changelog
to the PR description. The following content will be copy/pasted by the changelog generation script, such that we do not forget it
packages/x-charts/src/context/CartesianProvider/computeValue.ts
Outdated
Show resolved
Hide resolved
packages/x-charts/src/context/CartesianProvider/computeValue.ts
Outdated
Show resolved
Hide resolved
) => { | ||
const xAxis = React.useMemo(() => defaultizeAxis(inXAxis, 'x'), [inXAxis]); | ||
const yAxis = React.useMemo(() => defaultizeAxis(inYAxis, 'y'), [inYAxis]); | ||
const xAxis = React.useMemo(() => defaultizeAxis(inXAxis, dataset, 'x'), [inXAxis, dataset]); |
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.
For me this would be clearer but maybe it causes TS issues. DOes not really matter
const xAxis = React.useMemo(() => defaultizeAxis(inXAxis, dataset, 'x'), [inXAxis, dataset]); | |
const xAxis = React.useMemo(() => normalize(defaultizeAxis(inXAxis, 'x'), dataset, 'x'), [inXAxis, dataset]); |
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 last renaming point to fix
That's a very nice feature. Could benefit a changelog highlight
You can do so by adding ## Changelog
to the PR description. The following content will be copy/pasted by the changelog generation script, such that we do not forget it
Co-authored-by: Alexandre Fauquette <45398769+alexfauquette@users.noreply.github.com> Signed-off-by: Jose C Quintas Jr <juniorquintas@gmail.com>
Resolves #12083, #13973
ECharts filter behaviour: line, bar, scatter
Changelog
💫 Allow filtering the axis on zoom, making the axis adapt by removing values outside the view.