Skip to content

Conversation

@bernardobelchior
Copy link
Member

@bernardobelchior bernardobelchior commented Nov 26, 2025

Part of #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 bernardobelchior added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: charts Changes related to the charts. labels Nov 26, 2025
@mui-bot
Copy link

mui-bot commented Nov 26, 2025

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 🔺+7.08KB(+2.04%) 🔺+2.24KB(+2.17%)
@mui/x-charts-pro 🔺+6.95KB(+1.54%) 🔺+2.05KB(+1.50%)
@mui/x-charts-premium 🔺+6.96KB(+1.55%) 🔺+2.13KB(+1.58%)
@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 🚫 dangerJS against b94d8bc

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 26, 2025

CodSpeed Performance Report

Merging #20457 will not alter performance

Comparing bernardobelchior:batch-bar-plot (b94d8bc) with master (dcbbc64)1

Summary

✅ 14 untouched

Footnotes

  1. No successful run was found on master (7bdee0b) during the generation of this report, so dcbbc64 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@github-actions
Copy link

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 Nov 27, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 27, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Dec 1, 2025
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

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

@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Dec 3, 2025
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

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 Dec 4, 2025
@github-actions
Copy link

github-actions bot commented Dec 4, 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 Dec 4, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Dec 4, 2025
@bernardobelchior bernardobelchior marked this pull request as ready for review December 9, 2025 09:29
Copy link
Member

@JCQuintas JCQuintas left a comment

Choose a reason for hiding this comment

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

Works nicely, gj on the tooltip/highlight as well 👍

I've left some comments on possible improvements

import { getBarItemAtPosition } from './getBarItemAtPosition';
import { useStore } from '../internals/store/useStore';

export function useInteractionItemProps() {
Copy link
Member

Choose a reason for hiding this comment

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

Should we use this and useOnItemClick on the default bar renderer as well?

It feels like it could be useful if we render stuff on top of charts, or if using things like canvas

Copy link
Member Author

Choose a reason for hiding this comment

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

It feels like it could be useful if we render stuff on top of charts

Well, if we want to render stuff on top of charts and don't want them to influence the clicks, we should add pointer-events: none to that stuff. I think it would be weird to hijack clicks from elements that would normally receive them.

It's unfortunate we need to maintain two code paths, but I suppose that's the price to pay for better performance.

Copy link
Member

Choose a reason for hiding this comment

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

Is the performance much better?

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 think we have another option. If we want to implement a batch bar plot like the one in this PR, we can't use onClick event to detect clicks, so the only way is to calculate the clicked bar like we do in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I don't mean that.

I meant to say that we should maybe use the way it is calculated in this PR (based on pointer only) everywhere

Copy link
Member Author

Choose a reason for hiding this comment

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

We could, but it would be a breaking change because the event source would have changed.

It also changes event handling slightly, which might break stuff that users are relying on.

I guess this is something that we'd need to investigate deeper

@prakhargupta1
Copy link
Member

prakhargupta1 commented Dec 10, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance scope: charts Changes related to the charts. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants