@mui/x-charts 8.0.0-alpha.8 → 8.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/BarChart/BarChart.js +1 -1
  2. package/BarChart/plugin.js +2 -0
  3. package/CHANGELOG.md +436 -3
  4. package/ChartContainer/ChartContainer.d.ts +2 -2
  5. package/ChartContainer/ChartContainer.js +2 -2
  6. package/ChartContainer/useChartContainerProps.d.ts +1 -1
  7. package/{context/ChartDataProvider → ChartDataProvider}/ChartDataProvider.d.ts +7 -7
  8. package/{context/ChartDataProvider → ChartDataProvider}/ChartDataProvider.js +4 -4
  9. package/ChartDataProvider/package.json +6 -0
  10. package/ChartDataProvider/useChartDataProviderProps.d.ts +13 -0
  11. package/ChartsSurface/ChartsSurface.d.ts +1 -1
  12. package/ChartsSurface/ChartsSurface.js +1 -1
  13. package/ChartsTooltip/utils.js +2 -0
  14. package/Gauge/GaugeProvider.js +2 -0
  15. package/LineChart/AreaPlot.js +43 -10
  16. package/LineChart/CircleMarkElement.d.ts +0 -4
  17. package/LineChart/CircleMarkElement.js +2 -7
  18. package/LineChart/LineChart.d.ts +0 -4
  19. package/LineChart/LineChart.js +1 -5
  20. package/LineChart/LineHighlightElement.d.ts +5 -1
  21. package/LineChart/LineHighlightElement.js +29 -9
  22. package/LineChart/LineHighlightPlot.js +4 -2
  23. package/LineChart/LinePlot.js +43 -9
  24. package/LineChart/MarkPlot.d.ts +0 -6
  25. package/LineChart/MarkPlot.js +6 -12
  26. package/LineChart/plugin.js +2 -0
  27. package/LineChart/useLineChartProps.js +3 -5
  28. package/PieChart/PieChart.js +1 -1
  29. package/PieChart/plugin.js +3 -1
  30. package/ScatterChart/ScatterChart.js +1 -1
  31. package/ScatterChart/plugin.js +2 -0
  32. package/context/AnimationProvider/AnimationProvider.js +1 -1
  33. package/context/InteractionSelectors.d.ts +11 -11
  34. package/context/index.d.ts +0 -2
  35. package/context/index.js +1 -2
  36. package/hooks/useLegend.js +8 -13
  37. package/index.d.ts +1 -0
  38. package/index.js +3 -2
  39. package/internals/defaultizeColor.d.ts +2 -0
  40. package/internals/index.d.ts +1 -2
  41. package/internals/index.js +1 -2
  42. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +5 -5
  43. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  44. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
  45. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
  46. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +1 -0
  47. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.d.ts +90 -126
  48. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.js +3 -1
  49. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +0 -1
  50. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +11 -11
  51. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
  52. package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -1
  53. package/models/seriesType/line.d.ts +11 -0
  54. package/modern/BarChart/BarChart.js +1 -1
  55. package/modern/BarChart/plugin.js +2 -0
  56. package/modern/ChartContainer/ChartContainer.js +2 -2
  57. package/modern/{context/ChartDataProvider → ChartDataProvider}/ChartDataProvider.js +4 -4
  58. package/modern/ChartsSurface/ChartsSurface.js +1 -1
  59. package/modern/ChartsTooltip/utils.js +2 -0
  60. package/modern/Gauge/GaugeProvider.js +2 -0
  61. package/modern/LineChart/AreaPlot.js +43 -10
  62. package/modern/LineChart/CircleMarkElement.js +2 -7
  63. package/modern/LineChart/LineChart.js +1 -5
  64. package/modern/LineChart/LineHighlightElement.js +29 -9
  65. package/modern/LineChart/LineHighlightPlot.js +4 -2
  66. package/modern/LineChart/LinePlot.js +43 -9
  67. package/modern/LineChart/MarkPlot.js +6 -12
  68. package/modern/LineChart/plugin.js +2 -0
  69. package/modern/LineChart/useLineChartProps.js +3 -5
  70. package/modern/PieChart/PieChart.js +1 -1
  71. package/modern/PieChart/plugin.js +3 -1
  72. package/modern/ScatterChart/ScatterChart.js +1 -1
  73. package/modern/ScatterChart/plugin.js +2 -0
  74. package/modern/context/AnimationProvider/AnimationProvider.js +1 -1
  75. package/modern/context/index.js +1 -2
  76. package/modern/hooks/useLegend.js +8 -13
  77. package/modern/index.js +3 -2
  78. package/modern/internals/index.js +1 -2
  79. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +1 -0
  80. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.js +3 -1
  81. package/node/BarChart/BarChart.js +2 -2
  82. package/node/BarChart/plugin.js +2 -0
  83. package/node/ChartContainer/ChartContainer.js +2 -2
  84. package/node/{context/ChartDataProvider → ChartDataProvider}/ChartDataProvider.js +4 -4
  85. package/node/ChartsSurface/ChartsSurface.js +1 -1
  86. package/node/ChartsTooltip/utils.js +1 -0
  87. package/node/Gauge/GaugeProvider.js +2 -2
  88. package/node/LineChart/AreaPlot.js +43 -10
  89. package/node/LineChart/CircleMarkElement.js +2 -7
  90. package/node/LineChart/LineChart.js +2 -6
  91. package/node/LineChart/LineHighlightElement.js +29 -9
  92. package/node/LineChart/LineHighlightPlot.js +4 -2
  93. package/node/LineChart/LinePlot.js +43 -9
  94. package/node/LineChart/MarkPlot.js +6 -12
  95. package/node/LineChart/plugin.js +2 -0
  96. package/node/LineChart/useLineChartProps.js +3 -5
  97. package/node/PieChart/PieChart.js +2 -2
  98. package/node/PieChart/plugin.js +3 -1
  99. package/node/ScatterChart/ScatterChart.js +2 -2
  100. package/node/ScatterChart/plugin.js +2 -0
  101. package/node/context/AnimationProvider/AnimationProvider.js +1 -1
  102. package/node/context/index.js +1 -12
  103. package/node/hooks/useLegend.js +8 -14
  104. package/node/index.js +12 -1
  105. package/node/internals/index.js +1 -13
  106. package/node/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +12 -0
  107. package/node/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.js +3 -1
  108. package/package.json +3 -3
  109. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +0 -13
  110. /package/{context/ChartDataProvider → ChartDataProvider}/index.d.ts +0 -0
  111. /package/{context/ChartDataProvider → ChartDataProvider}/index.js +0 -0
  112. /package/{context/ChartDataProvider → ChartDataProvider}/useChartDataProviderProps.js +0 -0
  113. /package/modern/{context/ChartDataProvider → ChartDataProvider}/index.js +0 -0
  114. /package/modern/{context/ChartDataProvider → ChartDataProvider}/useChartDataProviderProps.js +0 -0
  115. /package/node/{context/ChartDataProvider → ChartDataProvider}/index.js +0 -0
  116. /package/node/{context/ChartDataProvider → ChartDataProvider}/useChartDataProviderProps.js +0 -0
@@ -21,7 +21,7 @@ export const selectorChartRawYAxis = createSelector(selectorChartCartesianAxisSt
21
21
  */
22
22
 
23
23
  const selectorChartZoomMap = createSelector(selectorChartZoomState, zoom => zoom?.zoomData && createZoomMap(zoom?.zoomData));
24
- const selectorChartZoomOptionsLookup = createSelector(selectorChartZoomState, zoom => zoom?.optionsLookup);
24
+ const selectorChartZoomOptionsLookup = createSelector(selectorChartZoomState, () => undefined);
25
25
  const selectorChartXFilter = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartSeriesConfig, selectorChartSeriesProcessed], (zoomMap, zoomOptions, seriesConfig, formattedSeries) => zoomMap && zoomOptions && createAxisFilterMapper({
26
26
  zoomMap,
27
27
  zoomOptions,
@@ -42,6 +42,7 @@ const selectorChartZoomAxisFilters = createSelector([selectorChartXFilter, selec
42
42
  return undefined;
43
43
  }
44
44
  const xFilters = xAxis.reduce((acc, axis, index) => {
45
+ // @ts-expect-error The type is defined in the pro package
45
46
  const filter = xMapper(axis, index);
46
47
  if (filter !== null) {
47
48
  acc[axis.id] = filter;
@@ -49,6 +50,7 @@ const selectorChartZoomAxisFilters = createSelector([selectorChartXFilter, selec
49
50
  return acc;
50
51
  }, {});
51
52
  const yFilters = yAxis.reduce((acc, axis, index) => {
53
+ // @ts-expect-error The type is defined in the pro package
52
54
  const filter = yMapper(axis, index);
53
55
  if (filter !== null) {
54
56
  acc[axis.id] = filter;
@@ -53,7 +53,6 @@ export interface UseChartCartesianAxisState {
53
53
  * @ignore - state populated by the useChartProZoomPlugin
54
54
  */
55
55
  zoom?: {
56
- optionsLookup: Record<AxisId, DefaultizedZoomOptions>;
57
56
  isInteracting: boolean;
58
57
  zoomData: ZoomData[];
59
58
  };
@@ -28,8 +28,8 @@ export declare const selectorChartsInteractionItem: ((state: import("../../coreP
28
28
  dependencyRecomputations: () => number;
29
29
  resetDependencyRecomputations: () => void;
30
30
  } & {
31
- argsMemoize: typeof import("reselect").weakMapMemoize;
32
31
  memoize: typeof import("reselect").weakMapMemoize;
32
+ argsMemoize: typeof import("reselect").weakMapMemoize;
33
33
  };
34
34
  export declare const selectorChartsInteractionAxis: ((state: import("../../corePlugins/useChartId/useChartId.types").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../../..").ChartsSeriesConfig> & import("./useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
35
35
  cacheKey: import("../../models").ChartStateCacheKey;
@@ -59,8 +59,8 @@ export declare const selectorChartsInteractionAxis: ((state: import("../../coreP
59
59
  dependencyRecomputations: () => number;
60
60
  resetDependencyRecomputations: () => void;
61
61
  } & {
62
- argsMemoize: typeof import("reselect").weakMapMemoize;
63
62
  memoize: typeof import("reselect").weakMapMemoize;
63
+ argsMemoize: typeof import("reselect").weakMapMemoize;
64
64
  };
65
65
  export declare const selectorChartsInteractionXAxis: ((state: import("../../corePlugins/useChartId/useChartId.types").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../../..").ChartsSeriesConfig> & import("./useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
66
66
  cacheKey: import("../../models").ChartStateCacheKey;
@@ -102,8 +102,8 @@ export declare const selectorChartsInteractionXAxis: ((state: import("../../core
102
102
  dependencyRecomputations: () => number;
103
103
  resetDependencyRecomputations: () => void;
104
104
  } & {
105
- argsMemoize: typeof import("reselect").weakMapMemoize;
106
105
  memoize: typeof import("reselect").weakMapMemoize;
106
+ argsMemoize: typeof import("reselect").weakMapMemoize;
107
107
  };
108
108
  export declare const selectorChartsInteractionYAxis: ((state: import("../../corePlugins/useChartId/useChartId.types").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../../..").ChartsSeriesConfig> & import("./useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
109
109
  cacheKey: import("../../models").ChartStateCacheKey;
@@ -145,8 +145,8 @@ export declare const selectorChartsInteractionYAxis: ((state: import("../../core
145
145
  dependencyRecomputations: () => number;
146
146
  resetDependencyRecomputations: () => void;
147
147
  } & {
148
- argsMemoize: typeof import("reselect").weakMapMemoize;
149
148
  memoize: typeof import("reselect").weakMapMemoize;
149
+ argsMemoize: typeof import("reselect").weakMapMemoize;
150
150
  };
151
151
  export declare const selectorChartsInteractionItemIsDefined: ((state: import("../../corePlugins/useChartId/useChartId.types").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../../..").ChartsSeriesConfig> & import("./useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
152
152
  cacheKey: import("../../models").ChartStateCacheKey;
@@ -190,16 +190,16 @@ export declare const selectorChartsInteractionItemIsDefined: ((state: import("..
190
190
  dependencyRecomputations: () => number;
191
191
  resetDependencyRecomputations: () => void;
192
192
  } & {
193
- argsMemoize: typeof import("reselect").weakMapMemoize;
194
193
  memoize: typeof import("reselect").weakMapMemoize;
194
+ argsMemoize: typeof import("reselect").weakMapMemoize;
195
195
  }];
196
196
  recomputations: () => number;
197
197
  resetRecomputations: () => void;
198
198
  dependencyRecomputations: () => number;
199
199
  resetDependencyRecomputations: () => void;
200
200
  } & {
201
- argsMemoize: typeof import("reselect").weakMapMemoize;
202
201
  memoize: typeof import("reselect").weakMapMemoize;
202
+ argsMemoize: typeof import("reselect").weakMapMemoize;
203
203
  };
204
204
  export declare const selectorChartsInteractionXAxisIsDefined: ((state: import("../../corePlugins/useChartId/useChartId.types").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../../..").ChartsSeriesConfig> & import("./useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
205
205
  cacheKey: import("../../models").ChartStateCacheKey;
@@ -261,16 +261,16 @@ export declare const selectorChartsInteractionXAxisIsDefined: ((state: import(".
261
261
  dependencyRecomputations: () => number;
262
262
  resetDependencyRecomputations: () => void;
263
263
  } & {
264
- argsMemoize: typeof import("reselect").weakMapMemoize;
265
264
  memoize: typeof import("reselect").weakMapMemoize;
265
+ argsMemoize: typeof import("reselect").weakMapMemoize;
266
266
  }];
267
267
  recomputations: () => number;
268
268
  resetRecomputations: () => void;
269
269
  dependencyRecomputations: () => number;
270
270
  resetDependencyRecomputations: () => void;
271
271
  } & {
272
- argsMemoize: typeof import("reselect").weakMapMemoize;
273
272
  memoize: typeof import("reselect").weakMapMemoize;
273
+ argsMemoize: typeof import("reselect").weakMapMemoize;
274
274
  };
275
275
  export declare const selectorChartsInteractionYAxisIsDefined: ((state: import("../../corePlugins/useChartId/useChartId.types").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../../..").ChartsSeriesConfig> & import("./useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
276
276
  cacheKey: import("../../models").ChartStateCacheKey;
@@ -332,16 +332,16 @@ export declare const selectorChartsInteractionYAxisIsDefined: ((state: import(".
332
332
  dependencyRecomputations: () => number;
333
333
  resetDependencyRecomputations: () => void;
334
334
  } & {
335
- argsMemoize: typeof import("reselect").weakMapMemoize;
336
335
  memoize: typeof import("reselect").weakMapMemoize;
336
+ argsMemoize: typeof import("reselect").weakMapMemoize;
337
337
  }];
338
338
  recomputations: () => number;
339
339
  resetRecomputations: () => void;
340
340
  dependencyRecomputations: () => number;
341
341
  resetDependencyRecomputations: () => void;
342
342
  } & {
343
- argsMemoize: typeof import("reselect").weakMapMemoize;
344
343
  memoize: typeof import("reselect").weakMapMemoize;
344
+ argsMemoize: typeof import("reselect").weakMapMemoize;
345
345
  };
346
346
  export declare const selectorChartsInteractionIsVoronoiEnabled: ((state: import("../../corePlugins/useChartId/useChartId.types").UseChartIdState & import("../../corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../../..").ChartsSeriesConfig> & import("./useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
347
347
  cacheKey: import("../../models").ChartStateCacheKey;
@@ -371,6 +371,6 @@ export declare const selectorChartsInteractionIsVoronoiEnabled: ((state: import(
371
371
  dependencyRecomputations: () => number;
372
372
  resetDependencyRecomputations: () => void;
373
373
  } & {
374
- argsMemoize: typeof import("reselect").weakMapMemoize;
375
374
  memoize: typeof import("reselect").weakMapMemoize;
375
+ argsMemoize: typeof import("reselect").weakMapMemoize;
376
376
  };
@@ -40,6 +40,6 @@ export declare const selectorChartZAxis: ((state: import("../../corePlugins/useC
40
40
  dependencyRecomputations: () => number;
41
41
  resetDependencyRecomputations: () => void;
42
42
  } & {
43
- argsMemoize: typeof import("reselect").weakMapMemoize;
44
43
  memoize: typeof import("reselect").weakMapMemoize;
44
+ argsMemoize: typeof import("reselect").weakMapMemoize;
45
45
  };
@@ -1,10 +1,11 @@
1
- import { SeriesProcessor } from './seriesProcessor.types';
1
+ import { LegendGetter, SeriesProcessor } from './seriesProcessor.types';
2
2
  import { CartesianChartSeriesType, ChartSeriesType } from '../../../../models/seriesType/config';
3
3
  import { ColorProcessor } from './colorProcessor.types';
4
4
  import { CartesianExtremumGetter } from './extremumGetter.types';
5
5
  export type ChartSeriesTypeConfig<TSeriesType extends ChartSeriesType> = {
6
6
  seriesProcessor: SeriesProcessor<TSeriesType>;
7
7
  colorProcessor: ColorProcessor<TSeriesType>;
8
+ legendGetter: LegendGetter<TSeriesType>;
8
9
  } & (TSeriesType extends CartesianChartSeriesType ? {
9
10
  xExtremumGetter: CartesianExtremumGetter<TSeriesType>;
10
11
  yExtremumGetter: CartesianExtremumGetter<TSeriesType>;
@@ -46,12 +46,23 @@ export interface LineSeriesType extends CommonSeriesType<number | null>, Cartesi
46
46
  * @default 'monotoneX'
47
47
  */
48
48
  curve?: CurveType;
49
+ /**
50
+ * If `true`, step curve starts and end at the first and last point.
51
+ * By default the line is extended to fill the space before and after.
52
+ */
53
+ strictStepCurve?: boolean;
49
54
  /**
50
55
  * Define which items of the series should display a mark.
51
56
  * If can be a boolean that applies to all items.
52
57
  * Or a callback that gets some item properties and returns true if the item should be displayed.
53
58
  */
54
59
  showMark?: boolean | ((params: ShowMarkParams) => boolean);
60
+ /**
61
+ * The shape of the mark elements.
62
+ * Using 'circle' renders a `<circle />` element, while all other options render a `<path />` instead. The path causes a small decrease in performance.
63
+ * @default 'circle'
64
+ */
65
+ shape?: 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
55
66
  /**
56
67
  * Do not render the line highlight item if set to `true`.
57
68
  * @default false
@@ -14,7 +14,7 @@ import { ChartsGrid } from "../ChartsGrid/index.js";
14
14
  import { ChartsOnAxisClickHandler } from "../ChartsOnAxisClickHandler/index.js";
15
15
  import { ChartsOverlay } from "../ChartsOverlay/ChartsOverlay.js";
16
16
  import { useBarChartProps } from "./useBarChartProps.js";
17
- import { ChartDataProvider } from "../context/index.js";
17
+ import { ChartDataProvider } from "../ChartDataProvider/index.js";
18
18
  import { ChartsSurface } from "../ChartsSurface/index.js";
19
19
  import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
20
20
  import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
@@ -1,9 +1,11 @@
1
1
  import { getExtremumX, getExtremumY } from "./extremums.js";
2
2
  import formatter from "./formatter.js";
3
+ import legendGetter from "./legend.js";
3
4
  import getColor from "./getColor.js";
4
5
  export const plugin = {
5
6
  seriesProcessor: formatter,
6
7
  colorProcessor: getColor,
8
+ legendGetter,
7
9
  xExtremumGetter: getExtremumX,
8
10
  yExtremumGetter: getExtremumY
9
11
  };
@@ -3,7 +3,7 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { ChartDataProvider } from "../context/ChartDataProvider/index.js";
6
+ import { ChartDataProvider } from "../ChartDataProvider/index.js";
7
7
  import { useChartContainerProps } from "./useChartContainerProps.js";
8
8
  import { ChartsSurface } from "../ChartsSurface/index.js";
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -14,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  *
15
15
  * Demos:
16
16
  *
17
- * - [Composition](http://localhost:3001/x/react-charts/composition/)
17
+ * - [Composition](https://mui.com/x/api/charts/composition/)
18
18
  *
19
19
  * API:
20
20
  *
@@ -4,9 +4,9 @@ import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import { useChartDataProviderProps } from "./useChartDataProviderProps.js";
7
- import { AnimationProvider } from "../AnimationProvider/index.js";
8
- import { HighlightedProvider } from "../HighlightedProvider/index.js";
9
- import { ChartProvider } from "../ChartProvider/index.js";
7
+ import { AnimationProvider } from "../context/AnimationProvider/index.js";
8
+ import { HighlightedProvider } from "../context/HighlightedProvider/index.js";
9
+ import { ChartProvider } from "../context/ChartProvider/index.js";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  /**
12
12
  * Orchestrates the data providers for the chart components and hooks.
@@ -15,7 +15,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
15
15
  *
16
16
  * Demos:
17
17
  *
18
- * - [Composition](http://localhost:3001/x/react-charts/composition/)
18
+ * - [Composition](https://mui.com/x/api/charts/composition/)
19
19
  *
20
20
  * API:
21
21
  *
@@ -41,7 +41,7 @@ const ChartsSurfaceStyles = styled('svg', {
41
41
  *
42
42
  * Demos:
43
43
  *
44
- * - [Composition](http://localhost:3001/x/react-charts/composition/)
44
+ * - [Composition](https://mui.com/x/api/charts/composition/)
45
45
  *
46
46
  * API:
47
47
  *
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import * as React from 'react';
2
4
  import { useSvgRef } from "../hooks/index.js";
3
5
  /**
@@ -1,4 +1,6 @@
1
1
  // @ignore - do not document.
2
+ 'use client';
3
+
2
4
  import * as React from 'react';
3
5
  import { getPercentageValue } from "../internals/getPercentageValue.js";
4
6
  import { getArcRatios, getAvailableRadius } from "./utils.js";
@@ -10,6 +10,7 @@ import { area as d3Area } from '@mui/x-charts-vendor/d3-shape';
10
10
  import { AreaElement, areaElementClasses } from "./AreaElement.js";
11
11
  import { getValueToPositionMapper } from "../hooks/useScale.js";
12
12
  import getCurveFactory from "../internals/getCurve.js";
13
+ import { isBandScale } from "../internals/isBandScale.js";
13
14
  import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
14
15
  import { useLineSeries } from "../hooks/useSeries.js";
15
16
  import { useSkipAnimation } from "../context/AnimationProvider/index.js";
@@ -59,9 +60,12 @@ const useAggregatedData = () => {
59
60
  stackedData,
60
61
  data,
61
62
  connectNulls,
62
- baseline
63
+ baseline,
64
+ curve,
65
+ strictStepCurve
63
66
  } = series[seriesId];
64
- const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
67
+ const xScale = xAxis[xAxisId].scale;
68
+ const xPosition = getValueToPositionMapper(xScale);
65
69
  const yScale = yAxis[yAxisId].scale;
66
70
  const xData = xAxis[xAxisId].data;
67
71
  const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
@@ -73,7 +77,42 @@ const useAggregatedData = () => {
73
77
  throw new Error(`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
74
78
  }
75
79
  }
76
- const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => {
80
+ const shouldExpand = curve?.includes('step') && !strictStepCurve && isBandScale(xScale);
81
+ const formattedData = xData?.flatMap((x, index) => {
82
+ const nullData = data[index] == null;
83
+ if (shouldExpand) {
84
+ const rep = [{
85
+ x,
86
+ y: stackedData[index],
87
+ nullData,
88
+ isExtension: false
89
+ }];
90
+ if (!nullData && (index === 0 || data[index - 1] == null)) {
91
+ rep.unshift({
92
+ x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
93
+ y: stackedData[index],
94
+ nullData,
95
+ isExtension: true
96
+ });
97
+ }
98
+ if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
99
+ rep.push({
100
+ x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
101
+ y: stackedData[index],
102
+ nullData,
103
+ isExtension: true
104
+ });
105
+ }
106
+ return rep;
107
+ }
108
+ return {
109
+ x,
110
+ y: stackedData[index],
111
+ nullData
112
+ };
113
+ }) ?? [];
114
+ const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
115
+ const areaPath = d3Area().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y0(d => {
77
116
  if (typeof baseline === 'number') {
78
117
  return yScale(baseline);
79
118
  }
@@ -89,13 +128,7 @@ const useAggregatedData = () => {
89
128
  }
90
129
  return value;
91
130
  }).y1(d => d.y && yScale(d.y[1]));
92
- const curve = getCurveFactory(series[seriesId].curve);
93
- const formattedData = xData?.map((x, index) => ({
94
- x,
95
- y: stackedData[index]
96
- })) ?? [];
97
- const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
98
- const d = areaPath.curve(curve)(d3Data) || '';
131
+ const d = areaPath.curve(getCurveFactory(curve))(d3Data) || '';
99
132
  return _extends({}, series[seriesId], {
100
133
  gradientId,
101
134
  d,
@@ -2,11 +2,10 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["x", "y", "id", "classes", "color", "dataIndex", "onClick", "skipAnimation", "shape"];
5
+ const _excluded = ["x", "y", "id", "classes", "color", "dataIndex", "onClick", "skipAnimation"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { useTheme } from '@mui/material/styles';
9
- import { warnOnce } from '@mui/x-internals/warning';
10
9
  import { animated, useSpring } from '@react-spring/web';
11
10
  import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
12
11
  import { useItemHighlighted } from "../context/index.js";
@@ -36,13 +35,9 @@ function CircleMarkElement(props) {
36
35
  color,
37
36
  dataIndex,
38
37
  onClick,
39
- skipAnimation,
40
- shape
38
+ skipAnimation
41
39
  } = props,
42
40
  other = _objectWithoutPropertiesLoose(props, _excluded);
43
- if (shape !== 'circle') {
44
- warnOnce([`MUI X: The mark element of your line chart have shape "${shape}" which is not supported when using \`experimentalRendering=true\`.`, 'Only "circle" are supported with `experimentalRendering`.'].join('\n'), 'error');
45
- }
46
41
  const theme = useTheme();
47
42
  const getInteractionItemProps = useInteractionItemProps();
48
43
  const {
@@ -18,7 +18,7 @@ import { ChartsOnAxisClickHandler } from "../ChartsOnAxisClickHandler/index.js";
18
18
  import { ChartsOverlay } from "../ChartsOverlay/index.js";
19
19
  import { useLineChartProps } from "./useLineChartProps.js";
20
20
  import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
21
- import { ChartDataProvider } from "../context/index.js";
21
+ import { ChartDataProvider } from "../ChartDataProvider/index.js";
22
22
  import { ChartsSurface } from "../ChartsSurface/index.js";
23
23
  import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
24
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -117,10 +117,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
117
117
  * If `true`, render the line highlight item.
118
118
  */
119
119
  disableLineItemHighlight: PropTypes.bool,
120
- /**
121
- * If `true` marks will render `<circle />` instead of `<path />` and drop theme override for faster rendering.
122
- */
123
- experimentalMarkRendering: PropTypes.bool,
124
120
  /**
125
121
  * Option to display a cartesian grid in the background.
126
122
  */
@@ -2,13 +2,15 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["x", "y", "id", "classes", "color"];
5
+ const _excluded = ["x", "y", "id", "classes", "color", "shape"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
+ import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from '@mui/x-charts-vendor/d3-shape';
8
9
  import composeClasses from '@mui/utils/composeClasses';
9
10
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
10
11
  import { styled } from '@mui/material/styles';
11
12
  import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
13
+ import { getSymbol } from "../internals/getSymbol.js";
12
14
  import { jsx as _jsx } from "react/jsx-runtime";
13
15
  export function getHighlightElementUtilityClass(slot) {
14
16
  return generateUtilityClass('MuiHighlightElement', slot);
@@ -24,7 +26,18 @@ const useUtilityClasses = ownerState => {
24
26
  };
25
27
  return composeClasses(slots, getHighlightElementUtilityClass, classes);
26
28
  };
27
- const HighlightElement = styled('circle', {
29
+ const HighlightPathElement = styled('path', {
30
+ name: 'MuiHighlightElement',
31
+ slot: 'Root',
32
+ overridesResolver: (_, styles) => styles.root
33
+ })(({
34
+ ownerState
35
+ }) => ({
36
+ transform: `translate(${ownerState.x}px, ${ownerState.y}px)`,
37
+ transformOrigin: `${ownerState.x}px ${ownerState.y}px`,
38
+ fill: ownerState.color
39
+ }));
40
+ const HighlightCircleElement = styled('circle', {
28
41
  name: 'MuiHighlightElement',
29
42
  slot: 'Root',
30
43
  overridesResolver: (_, styles) => styles.root
@@ -51,7 +64,8 @@ function LineHighlightElement(props) {
51
64
  y,
52
65
  id,
53
66
  classes: innerClasses,
54
- color
67
+ color,
68
+ shape
55
69
  } = props,
56
70
  other = _objectWithoutPropertiesLoose(props, _excluded);
57
71
  const ownerState = {
@@ -62,14 +76,19 @@ function LineHighlightElement(props) {
62
76
  y
63
77
  };
64
78
  const classes = useUtilityClasses(ownerState);
65
- return /*#__PURE__*/_jsx(HighlightElement, _extends({
66
- pointerEvents: "none",
67
- ownerState: ownerState,
68
- className: classes.root,
79
+ const Element = shape === 'circle' ? HighlightCircleElement : HighlightPathElement;
80
+ const additionalProps = shape === 'circle' ? {
69
81
  cx: 0,
70
82
  cy: 0,
71
83
  r: other.r === undefined ? 5 : other.r
72
- }, other));
84
+ } : {
85
+ d: d3Symbol(d3SymbolsFill[getSymbol(shape)])()
86
+ };
87
+ return /*#__PURE__*/_jsx(Element, _extends({
88
+ pointerEvents: "none",
89
+ ownerState: ownerState,
90
+ className: classes.root
91
+ }, additionalProps, other));
73
92
  }
74
93
  process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
75
94
  // ----------------------------- Warning --------------------------------
@@ -77,6 +96,7 @@ process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
77
96
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
78
97
  // ----------------------------------------------------------------------
79
98
  classes: PropTypes.object,
80
- id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired
99
+ id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
100
+ shape: PropTypes.oneOf(['circle', 'cross', 'diamond', 'square', 'star', 'triangle', 'wye']).isRequired
81
101
  } : void 0;
82
102
  export { LineHighlightElement };
@@ -70,7 +70,8 @@ function LineHighlightPlot(props) {
70
70
  yAxisId = defaultYAxisId,
71
71
  stackedData,
72
72
  data,
73
- disableHighlight
73
+ disableHighlight,
74
+ shape = 'circle'
74
75
  } = series[seriesId];
75
76
  if (disableHighlight || data[highlightedIndex] == null) {
76
77
  return null;
@@ -95,7 +96,8 @@ function LineHighlightPlot(props) {
95
96
  id: seriesId,
96
97
  color: colorGetter(highlightedIndex),
97
98
  x: x,
98
- y: y
99
+ y: y,
100
+ shape: shape
99
101
  }, slotProps?.lineHighlight), `${seriesId}`);
100
102
  });
101
103
  })
@@ -10,6 +10,7 @@ import { line as d3Line } from '@mui/x-charts-vendor/d3-shape';
10
10
  import { LineElement, lineElementClasses } from "./LineElement.js";
11
11
  import { getValueToPositionMapper } from "../hooks/useScale.js";
12
12
  import getCurveFactory from "../internals/getCurve.js";
13
+ import { isBandScale } from "../internals/isBandScale.js";
13
14
  import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
14
15
  import { useLineSeries } from "../hooks/useSeries.js";
15
16
  import { useSkipAnimation } from "../context/AnimationProvider/index.js";
@@ -57,9 +58,12 @@ const useAggregatedData = () => {
57
58
  yAxisId = defaultYAxisId,
58
59
  stackedData,
59
60
  data,
60
- connectNulls
61
+ connectNulls,
62
+ curve,
63
+ strictStepCurve
61
64
  } = series[seriesId];
62
- const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
65
+ const xScale = xAxis[xAxisId].scale;
66
+ const xPosition = getValueToPositionMapper(xScale);
63
67
  const yScale = yAxis[yAxisId].scale;
64
68
  const xData = xAxis[xAxisId].data;
65
69
  const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
@@ -71,13 +75,43 @@ const useAggregatedData = () => {
71
75
  throw new Error(`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
72
76
  }
73
77
  }
74
- const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
75
- const formattedData = xData?.map((x, index) => ({
76
- x,
77
- y: stackedData[index]
78
- })) ?? [];
79
- const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
80
- const d = linePath.curve(getCurveFactory(series[seriesId].curve))(d3Data) || '';
78
+ const shouldExpand = curve?.includes('step') && !strictStepCurve && isBandScale(xScale);
79
+ const formattedData = xData?.flatMap((x, index) => {
80
+ const nullData = data[index] == null;
81
+ if (shouldExpand) {
82
+ const rep = [{
83
+ x,
84
+ y: stackedData[index],
85
+ nullData,
86
+ isExtension: false
87
+ }];
88
+ if (!nullData && (index === 0 || data[index - 1] == null)) {
89
+ rep.unshift({
90
+ x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
91
+ y: stackedData[index],
92
+ nullData,
93
+ isExtension: true
94
+ });
95
+ }
96
+ if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
97
+ rep.push({
98
+ x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
99
+ y: stackedData[index],
100
+ nullData,
101
+ isExtension: true
102
+ });
103
+ }
104
+ return rep;
105
+ }
106
+ return {
107
+ x,
108
+ y: stackedData[index],
109
+ nullData
110
+ };
111
+ }) ?? [];
112
+ const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
113
+ const linePath = d3Line().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y(d => yScale(d.y[1]));
114
+ const d = linePath.curve(getCurveFactory(curve))(d3Data) || '';
81
115
  return _extends({}, series[seriesId], {
82
116
  gradientId,
83
117
  d,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick", "experimentalRendering"];
5
+ const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
6
6
  import PropTypes from 'prop-types';
7
7
  import * as React from 'react';
8
8
  import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
@@ -32,8 +32,7 @@ function MarkPlot(props) {
32
32
  slots,
33
33
  slotProps,
34
34
  skipAnimation: inSkipAnimation,
35
- onItemClick,
36
- experimentalRendering
35
+ onItemClick
37
36
  } = props,
38
37
  other = _objectWithoutPropertiesLoose(props, _excluded);
39
38
  const skipAnimation = useSkipAnimation(inSkipAnimation);
@@ -50,7 +49,6 @@ function MarkPlot(props) {
50
49
  const {
51
50
  instance
52
51
  } = useChartContext();
53
- const Mark = slots?.mark ?? (experimentalRendering ? CircleMarkElement : MarkElement);
54
52
  if (seriesData === undefined) {
55
53
  return null;
56
54
  }
@@ -70,7 +68,8 @@ function MarkPlot(props) {
70
68
  yAxisId = defaultYAxisId,
71
69
  stackedData,
72
70
  data,
73
- showMark = true
71
+ showMark = true,
72
+ shape = 'circle'
74
73
  } = series[seriesId];
75
74
  if (showMark === false) {
76
75
  return null;
@@ -84,6 +83,7 @@ function MarkPlot(props) {
84
83
  const clipId = cleanId(`${chartId}-${seriesId}-line-clip`); // We assume that if displaying line mark, the line will also be rendered
85
84
 
86
85
  const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
86
+ const Mark = slots?.mark ?? (shape === 'circle' ? CircleMarkElement : MarkElement);
87
87
  return /*#__PURE__*/_jsx("g", {
88
88
  clipPath: `url(#${clipId})`,
89
89
  children: xData?.map((x, index) => {
@@ -131,7 +131,7 @@ function MarkPlot(props) {
131
131
  return /*#__PURE__*/_jsx(Mark, _extends({
132
132
  id: seriesId,
133
133
  dataIndex: index,
134
- shape: "circle",
134
+ shape: shape,
135
135
  color: colorGetter(index),
136
136
  x: x,
137
137
  y: y // Don't know why TS doesn't get from the filter that y can't be null
@@ -154,12 +154,6 @@ process.env.NODE_ENV !== "production" ? MarkPlot.propTypes = {
154
154
  // | These PropTypes are generated from the TypeScript type definitions |
155
155
  // | To update them edit the TypeScript types and run "pnpm proptypes" |
156
156
  // ----------------------------------------------------------------------
157
- /**
158
- * If `true` the mark element will only be able to render circle.
159
- * Giving fewer customization options, but saving around 40ms per 1.000 marks.
160
- * @default false
161
- */
162
- experimentalRendering: PropTypes.bool,
163
157
  /**
164
158
  * Callback fired when a line mark item is clicked.
165
159
  * @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.