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] Filter item outside the drawing area for perf #14281

Merged
merged 19 commits into from
Nov 11, 2024

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Aug 21, 2024

I noticed that zooming on 5% of the data takes as much time to render than a full zoom out. The more we zoom the faster it should render since less elements are to plot

For Bar charts, zoning on 5% of a 1,000 bars (only shows 50 bars out of the 1,000) makes the rendering time move from 100ms to 28ms

@alexfauquette alexfauquette added performance component: charts This is the name of the generic UI component, not the React module! labels Aug 21, 2024
@mui-bot
Copy link

mui-bot commented Aug 21, 2024

Deploy preview: https://deploy-preview-14281--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against db09b3d

Copy link

codspeed-hq bot commented Aug 21, 2024

CodSpeed Performance Report

Merging #14281 will not alter performance

Comparing alexfauquette:filter-with-zoom (db09b3d) with master (7c4c924)

Summary

✅ 3 untouched benchmarks

🆕 3 new benchmarks

Benchmarks breakdown

Benchmark master alexfauquette:filter-with-zoom Change
🆕 BarChartPro with big data amount N/A 351.8 ms N/A
🆕 LineChartPro with big data amount N/A 534.5 ms N/A
🆕 ScatterChartPro with big data amount N/A 151.6 ms N/A

@@ -1,5 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';

import type {} from '../typeOverloads';
Copy link
Member Author

Choose a reason for hiding this comment

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

Otherwise TS was not understading that pro component have zoom options

Comment on lines +168 to +175
if (
result.x > xMax ||
result.x + result.width < xMin ||
result.y > yMax ||
result.y + result.height < yMin
) {
return null;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

That, plus the line .filter((rectangle) => rectangle !== null); ar the only modification. in this function. The rest is an indentation diff leading to some prettier modification

@alexfauquette alexfauquette marked this pull request as ready for review September 12, 2024 08:49
@@ -24,7 +24,7 @@ describe('ScatterChart', () => {
async () => {
const { findByText } = render(
<ScatterChart
xAxis={[{ data: xData }]}
xAxis={[{ data: xData, valueFormatter: (v) => v.toLocaleString('en-US') }]}
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know why but I had an issue on my computer. The default locale of .toLocaleString was not the same in the test and in the render (1 000 vs 1,000)

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 7, 2024
Copy link

github-actions bot commented Nov 7, 2024

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

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 8, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 11, 2024
Copy link

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

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 11, 2024
@JCQuintas JCQuintas enabled auto-merge (squash) November 11, 2024 12:38
@JCQuintas JCQuintas merged commit dc87d16 into mui:master Nov 11, 2024
17 checks passed
@@ -43,7 +43,7 @@ describe('ScatterChartPro', () => {
valueFormatter: (v) => v.toLocaleString('en-US'),
},
]}
zoom={[{ axisId: 'x', start: 0.25, end: 0.75 }]}
zoom={[{ axisId: 'x', start: 2, end: 7 }]}
Copy link
Member Author

Choose a reason for hiding this comment

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

@JCQuintas does this filter something? From what I understood, the zoom feature you implemented takes a ratio, so 2, 7 will just add lot of white space around the data and then we don't test the impact of removing points which are outside of the drawing area

Copy link
Member

Choose a reason for hiding this comment

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

  /**
   * The starting percentage of the zoom range. In the range of 0 to 100.
   *
   * @default 0
   */
  start: number;
  /**
   * The ending percentage of the zoom range. In the range of 0 to 100.
   *
   * @default 100
   */
  end: number;

Copy link
Member

Choose a reason for hiding this comment

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

internally we use the ratio, externally is a range from 0...100

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks I forgot we those test have thousands of points and then 0.25% was still significant for other charts 👍

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I had to remove a lot of datapoints for the CI to work with the Scatter. It still seems flaky, so we might need to adjust, fix or disable it if it continues like this 😓

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

Successfully merging this pull request may close these issues.

3 participants