[charts-premium] Add range bar chart#20275
Conversation
|
Deploy preview: https://deploy-preview-20275--material-ui-x.netlify.app/ Updated pages:
Bundle size report
|
3132d05 to
b55bb79
Compare
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
7901862 to
b9ee648
Compare
4f6c9f8 to
db5058c
Compare
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
676c5d0 to
a1003eb
Compare
alexfauquette
left a comment
There was a problem hiding this comment.
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"
71ef24a to
1bbeadf
Compare
CodSpeed Performance ReportMerging #20275 will not alter performanceComparing Summary
|
9eba5a6 to
0f73843
Compare
alexfauquette
left a comment
There was a problem hiding this comment.
Looks clean, might worth a second look about package code splitting
|
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]}]`; |
There was a problem hiding this comment.
Should it be wrapped in () like scatter instead of []?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Just consistency, didn't really think about it. I saw [1, 1] and thought it looked odd
There was a problem hiding this comment.
Personally I prefer the notation
packages/x-charts-premium/src/moduleAugmentation/rangeBarOnClick.ts
Outdated
Show resolved
Hide resolved
| end: number; | ||
| }; | ||
|
|
||
| export interface RangeBarSeriesType |
| // @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. |
There was a problem hiding this comment.
Not if I add "../x-charts-premium/src/moduleAugmentation/rangeBarOnClick.ts" to the tsconfig.json as well 😄
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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]; | |||
There was a problem hiding this comment.
Can't this be moved to the premium now?
There was a problem hiding this comment.
We can't because of these tricks we're doing to make ChartsAxisData work
There was a problem hiding this comment.
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;
}
}There was a problem hiding this comment.
I managed to make a small adaptation to make this work. Good suggestion! Thanks
alexfauquette
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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/). |
There was a problem hiding this comment.
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.
Fixes #20350.
Depends on:
BarChartPremium#20643Adds a range bar chart. Future improvements.