Skip to content

[charts-premium] Add range bar chart#20275

Merged
bernardobelchior merged 22 commits intomui:masterfrom
bernardobelchior:add-range-bar-chart
Dec 24, 2025
Merged

[charts-premium] Add range bar chart#20275
bernardobelchior merged 22 commits intomui:masterfrom
bernardobelchior:add-range-bar-chart

Conversation

@bernardobelchior
Copy link
Copy Markdown
Member

@bernardobelchior bernardobelchior commented Nov 10, 2025

@bernardobelchior bernardobelchior added type: new feature Expand the scope of the product to solve a new problem. scope: charts Changes related to the charts. labels Nov 10, 2025
@mui-bot
Copy link
Copy Markdown

mui-bot commented Nov 10, 2025

Deploy preview: https://deploy-preview-20275--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 🔺+28B(+0.01%) 🔺+15B(+0.01%)
@mui/x-charts-pro 🔺+66B(+0.01%) 🔺+3B(0.00%)
@mui/x-charts-premium 🔺+9.22KB(+2.02%) 🔺+3.08KB(+2.26%)
@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 81261f3

@bernardobelchior bernardobelchior force-pushed the add-range-bar-chart branch 2 times, most recently from 3132d05 to b55bb79 Compare November 11, 2025 10:43
@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, 2025
@github-actions
Copy link
Copy Markdown
Contributor

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 13, 2025
@bernardobelchior bernardobelchior force-pushed the add-range-bar-chart branch 3 times, most recently from 4f6c9f8 to db5058c Compare November 14, 2025 17:42
@bernardobelchior bernardobelchior changed the title WIP: Add range bar chart [charts-pro] Add range bar chart Nov 17, 2025
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 17, 2025
@github-actions
Copy link
Copy Markdown
Contributor

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 17, 2025
Copy link
Copy Markdown
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

Look nice. For the click event and the animation sections you could keep the demo and remove all the text details by saying "more details in the corresponding section of the bar chart page"

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 24, 2025

CodSpeed Performance Report

Merging #20275 will not alter performance

Comparing bernardobelchior:add-range-bar-chart (81261f3) with master (6119976)

Summary

✅ 14 untouched

Copy link
Copy Markdown
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

Looks clean, might worth a second look about package code splitting

@prakhargupta1 prakhargupta1 added the plan: Pro Impact at least one Pro user. label Nov 25, 2025
@github-actions
Copy link
Copy Markdown
Contributor

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

} from '@mui/x-charts/internals';

const rangeBarValueFormatter = (v: RangeBarValueType | null) =>
v == null ? '' : `[${v[0]}, ${v[1]}]`;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should it be wrapped in () like scatter instead of []?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using parenthesis indicates it's a coordinate (x, y). Using square brackets indicates it's an inclusive range [start, end]. That's why I chose it. Why do you think parenthesis would be better here? I think it might be a bit confusing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just consistency, didn't really think about it. I saw [1, 1] and thought it looked odd

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Personally I prefer the notation $\left\lbrace 1 \right\rbrace$ ;)

end: number;
};

export interface RangeBarSeriesType
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand why

Comment on lines +229 to +232
// @ts-ignore This is safe because users need to opt in to use range bar series.
// In that case, they should import the module augmentation from `x-charts-pro/moduleAugmentation/rangeBarOnClick`
// Which adds the proper type to the series data.
// TODO(v9): Remove this ts-expect-error when we can make the breaking change to ChartsAxisData.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we still need this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not if I add "../x-charts-premium/src/moduleAugmentation/rangeBarOnClick.ts" to the tsconfig.json as well 😄

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That should be fine no? Like we are ignoring this because we don't have the override in dev.

Does it solve solve the issue when building as well (prod)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've opted to keep this since we'll remove it in the next major

@@ -0,0 +1,2 @@
/** [start, end] */
export type RangeBarValueType = [number, number];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't this be moved to the premium now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can't because of these tricks we're doing to make ChartsAxisData work

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, this is a return value change right? We can't directly always override the type because the user might be using the "bar" value?

Could we make the override more generic?

seriesValues: Record<
  string,
  ChartsTypeFeatureFlags['seriesValuesOverride'] extends never ? number | null | undefined : ChartsTypeFeatureFlags['seriesValuesOverride']
>;

export interface ChartsTypeFeatureFlags {}

// On packages/x-charts-premium/src/moduleAugmentation/rangeBarOnClick.ts

declare module '@mui/x-charts/models' {
  interface ChartsTypeFeatureFlags {
    seriesValuesOverride: RangeBarValueType | number | null | undefined;
  }
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I managed to make a small adaptation to make this work. Good suggestion! Thanks

Copy link
Copy Markdown
Member

@alexfauquette alexfauquette left a comment

Choose a reason for hiding this comment

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

minors comments or some that could be dressed in follow up PRs

import { RangeBarPreviewPlot } from '../ChartZoomSlider/internals/previews/RangeBarPreviewPlot';

export interface BarChartPremiumProps extends BarChartProProps {}
seriesPreviewPlotMap.set('rangeBar', RangeBarPreviewPlot);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume this pattern might need some documentation for those using composition . Can be done in a follow up

- No animation when highlighting or fading bars;
- The event of the `onItemClick` handler is a `MouseEvent` instead of a `React.MouseEvent`. To avoid breaking changes, the type of `onItemClick` was not changed, but you can import a type overload to fix it: `import type {} from '@mui/x-charts/moduleAugmentation/barChartBatchRendererOnItemClick'`.
- The event of the `onItemClick` handler is a `MouseEvent` instead of a `React.MouseEvent`. To avoid breaking changes, the type of `onItemClick` was not changed, but you can import a type overload to fix it: `import type {} from '@mui/x-charts/moduleAugmentation/barChartBatchRendererOnItemClick'`;
- It is not available for [range bar charts](/x/react-charts/range-bar/).
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added this disclaimer for now. Not sure if we need to create a batch version of the range bar for now, but it might be interesting in the future.

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

Labels

plan: Premium Impact at least one Premium user. scope: charts Changes related to the charts. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[charts] Range bar chart

6 participants