mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[charts] Add bar batch renderer

Open bernardobelchior opened this issue 1 month ago • 11 comments

Part of https://github.com/mui/mui-x/issues/12960.

Here's a PR where bar charts default to the batch renderer so you can test it and check Argos.

Differences from the individual bar plot:

  1. When the border radius is greater than half the bar's width or height, the batch plot handles it differently:
Before/After

Before

image

After

image
  1. CSS styling of single bars is no longer possible. For this reason, when onItemClick is set, cursor: pointer is not applied to bars.
  2. Transparent highlight style: for performance reasons, the highlighted state creates a highlighted bar on top of the original bar. Applying transparency to the highlighted bar can cause the original bar to be partially visible.
  3. No animation when highlighting or fading bars.

bernardobelchior avatar Nov 26 '25 11:11 bernardobelchior

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

Updated pages:

Bundle size report

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 🔺+6.97KB(+2.01%) 🔺+2.29KB(+2.21%)
@mui/x-charts-pro 🔺+6.84KB(+1.52%) 🔺+2.08KB(+1.53%)
@mui/x-charts-premium 🔺+6.85KB(+1.53%) 🔺+2.16KB(+1.61%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by :no_entry_sign: dangerJS against 7e9b8bbb95b64ab022b7d692da701d6f04c9894a

mui-bot avatar Nov 26 '25 11:11 mui-bot

CodSpeed Performance Report

Merging #20457 will not alter performance

Comparing bernardobelchior:batch-bar-plot (7e9b8bb) with master (139a02a)[^unexpected-base] [^unexpected-base]: No successful run was found on master (262e368) during the generation of this report, so 139a02a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Summary

✅ 13 untouched

codspeed-hq[bot] avatar Nov 26 '25 12:11 codspeed-hq[bot]

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

github-actions[bot] avatar Nov 27 '25 10:11 github-actions[bot]

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

github-actions[bot] avatar Dec 01 '25 15:12 github-actions[bot]

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

github-actions[bot] avatar Dec 04 '25 11:12 github-actions[bot]

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

github-actions[bot] avatar Dec 04 '25 14:12 github-actions[bot]

In the demo, zooming in throws this runtime error, I guess a rebase will fix it? Screenshot 2025-12-10 at 5 08 28 PM

prakhargupta1 avatar Dec 10 '25 11:12 prakhargupta1

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

github-actions[bot] avatar Dec 10 '25 12:12 github-actions[bot]

It seems like the click handle is not getting the correct element 🤔

You can see on the video below, that I click on multiple bars before the dataindex or seriesId change

https://github.com/user-attachments/assets/6e5c86db-47f6-4a83-b8bf-f1b6e6518bf8

JCQuintas avatar Dec 10 '25 14:12 JCQuintas

In the demo, zooming in throws this runtime error, I guess a rebase will fix it?

Fixed in the most recent commit, good catch!

bernardobelchior avatar Dec 10 '25 15:12 bernardobelchior

It seems like the click handle is not getting the correct element 🤔

You can see on the video below, that I click on multiple bars before the dataindex or seriesId change

The issue was caused by pointermove reporting subpixel values, but click reporting rounded values in Chrome. I'm now rounding both values to ensure the click and highlight are consistent.

bernardobelchior avatar Dec 10 '25 16:12 bernardobelchior

About the animation, what about not having it? 😇

When rendering that much data, we are not facing nice dashboard, but serious one for people that don't have 500ms to lose on bar chart growing

alexfauquette avatar Dec 11 '25 16:12 alexfauquette

About the animation, what about not having it? 😇

Yeah, I also considered that option, but I'm not sure what's best.

You can always disable animation if you want to by using skipAnimation, so having an animation by default is acceptable because users can turn it off.

We just need to think if the current animation is acceptable. If not, then we can remove or improve it. I'll take another look at animations to see what we can do here.

bernardobelchior avatar Dec 11 '25 16:12 bernardobelchior

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

github-actions[bot] avatar Dec 16 '25 09:12 github-actions[bot]