@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
@@ -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,
@@ -1,10 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { MarkElementOwnerState } from './markElementClasses';
3
3
  export type CircleMarkElementProps = Omit<MarkElementOwnerState, 'isFaded' | 'isHighlighted'> & Omit<React.SVGProps<SVGPathElement>, 'ref' | 'id'> & {
4
- /**
5
- * The shape of the marker.
6
- */
7
- shape: 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
8
4
  /**
9
5
  * If `true`, animations are skipped.
10
6
  * @default false
@@ -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 {
@@ -69,10 +69,6 @@ export interface LineChartProps extends Omit<ChartContainerProps, 'series' | 'pl
69
69
  * @default false
70
70
  */
71
71
  skipAnimation?: boolean;
72
- /**
73
- * If `true` marks will render `<circle />` instead of `<path />` and drop theme override for faster rendering.
74
- */
75
- experimentalMarkRendering?: boolean;
76
72
  }
77
73
  /**
78
74
  * Demos:
@@ -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
  */
@@ -14,7 +14,11 @@ interface LineHighlightElementOwnerState {
14
14
  }
15
15
  export declare function getHighlightElementUtilityClass(slot: string): string;
16
16
  export declare const lineHighlightElementClasses: LineHighlightElementClasses;
17
- export type LineHighlightElementProps = LineHighlightElementOwnerState & Omit<React.SVGProps<SVGCircleElement>, 'ref' | 'id'>;
17
+ export type LineHighlightElementProps = (LineHighlightElementOwnerState & ({
18
+ shape: 'circle';
19
+ } & Omit<React.SVGProps<SVGCircleElement>, 'ref' | 'id'>)) | (LineHighlightElementOwnerState & {
20
+ shape: 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
21
+ } & Omit<React.SVGProps<SVGPathElement>, 'ref' | 'id'>);
18
22
  /**
19
23
  * Demos:
20
24
  *
@@ -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,
@@ -24,12 +24,6 @@ export interface MarkPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<
24
24
  * @param {LineItemIdentifier} lineItemIdentifier The line mark item identifier.
25
25
  */
26
26
  onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, lineItemIdentifier: LineItemIdentifier) => void;
27
- /**
28
- * If `true` the mark element will only be able to render circle.
29
- * Giving fewer customization options, but saving around 40ms per 1.000 marks.
30
- * @default false
31
- */
32
- experimentalRendering?: boolean;
33
27
  }
34
28
  /**
35
29
  * Demos:
@@ -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.
@@ -1,9 +1,11 @@
1
1
  import { getExtremumX, getExtremumY } from "./extremums.js";
2
2
  import formatter from "./formatter.js";
3
3
  import getColor from "./getColor.js";
4
+ import legendGetter from "./legend.js";
4
5
  export const plugin = {
5
6
  colorProcessor: getColor,
6
7
  seriesProcessor: formatter,
8
+ legendGetter,
7
9
  xExtremumGetter: getExtremumX,
8
10
  yExtremumGetter: getExtremumY
9
11
  };
@@ -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 = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAxisClick", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className", "experimentalMarkRendering"];
5
+ const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAxisClick", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className"];
6
6
  import useId from '@mui/utils/useId';
7
7
  import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
8
8
  import { calculateMargins } from "../internals/calculateMargins.js";
@@ -44,8 +44,7 @@ export const useLineChartProps = props => {
44
44
  loading,
45
45
  highlightedItem,
46
46
  onHighlightChange,
47
- className,
48
- experimentalMarkRendering
47
+ className
49
48
  } = props,
50
49
  other = _objectWithoutPropertiesLoose(props, _excluded);
51
50
  const id = useId();
@@ -106,8 +105,7 @@ export const useLineChartProps = props => {
106
105
  slots,
107
106
  slotProps,
108
107
  onItemClick: onMarkClick,
109
- skipAnimation,
110
- experimentalRendering: experimentalMarkRendering
108
+ skipAnimation
111
109
  };
112
110
  const overlayProps = {
113
111
  slots,
@@ -11,7 +11,7 @@ import { ChartsLegend } from "../ChartsLegend/index.js";
11
11
  import { PiePlot } from "./PiePlot.js";
12
12
  import { ChartsOverlay } from "../ChartsOverlay/index.js";
13
13
  import { ChartsSurface } from "../ChartsSurface/index.js";
14
- import { ChartDataProvider } from "../context/index.js";
14
+ import { ChartDataProvider } from "../ChartDataProvider/index.js";
15
15
  import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
16
16
  import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
17
17
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -1,6 +1,8 @@
1
1
  import formatter from "./formatter.js";
2
2
  import getColor from "./getColor.js";
3
+ import legendGetter from "./legend.js";
3
4
  export const plugin = {
4
5
  colorProcessor: getColor,
5
- seriesProcessor: formatter
6
+ seriesProcessor: formatter,
7
+ legendGetter
6
8
  };
@@ -14,7 +14,7 @@ import { ChartsVoronoiHandler } from "../ChartsVoronoiHandler/ChartsVoronoiHandl
14
14
  import { ChartsGrid } from "../ChartsGrid/index.js";
15
15
  import { useScatterChartProps } from "./useScatterChartProps.js";
16
16
  import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.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 { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
20
20
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -1,9 +1,11 @@
1
1
  import { getExtremumX, getExtremumY } from "./extremums.js";
2
2
  import formatter from "./formatter.js";
3
3
  import getColor from "./getColor.js";
4
+ import legendGetter from "./legend.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
  };
@@ -17,7 +17,7 @@ function AnimationProvider(props) {
17
17
 
18
18
  // We use the value of `isAnimationDisabledEnvironment` as the initial value of `skipAnimation` to avoid
19
19
  // re-rendering the component on environments where matchMedia is not supported, hence skipAnimation will always be true.
20
- const [skipAnimation, setSkipAnimation] = React.useState(isAnimationDisabledEnvironment || undefined);
20
+ const [skipAnimation, setSkipAnimation] = React.useState(process.env.NODE_ENV === 'test' ? isAnimationDisabledEnvironment || undefined : undefined);
21
21
  useIsomorphicLayoutEffect(() => {
22
22
  if (isAnimationDisabledEnvironment) {
23
23
  return undefined;
@@ -33,8 +33,8 @@ export declare const selectorChartsInteractionItem: ((state: import("../internal
33
33
  dependencyRecomputations: () => number;
34
34
  resetDependencyRecomputations: () => void;
35
35
  } & {
36
- argsMemoize: typeof import("reselect").weakMapMemoize;
37
36
  memoize: typeof import("reselect").weakMapMemoize;
37
+ argsMemoize: typeof import("reselect").weakMapMemoize;
38
38
  };
39
39
  export declare const selectorChartsInteractionAxis: ((state: import("../internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../internals").ChartsSeriesConfig> & import("../internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
40
40
  cacheKey: import("../internals").ChartStateCacheKey;
@@ -64,8 +64,8 @@ export declare const selectorChartsInteractionAxis: ((state: import("../internal
64
64
  dependencyRecomputations: () => number;
65
65
  resetDependencyRecomputations: () => void;
66
66
  } & {
67
- argsMemoize: typeof import("reselect").weakMapMemoize;
68
67
  memoize: typeof import("reselect").weakMapMemoize;
68
+ argsMemoize: typeof import("reselect").weakMapMemoize;
69
69
  };
70
70
  export declare const selectorChartsInteractionXAxis: ((state: import("../internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../internals").ChartsSeriesConfig> & import("../internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
71
71
  cacheKey: import("../internals").ChartStateCacheKey;
@@ -107,8 +107,8 @@ export declare const selectorChartsInteractionXAxis: ((state: import("../interna
107
107
  dependencyRecomputations: () => number;
108
108
  resetDependencyRecomputations: () => void;
109
109
  } & {
110
- argsMemoize: typeof import("reselect").weakMapMemoize;
111
110
  memoize: typeof import("reselect").weakMapMemoize;
111
+ argsMemoize: typeof import("reselect").weakMapMemoize;
112
112
  };
113
113
  export declare const selectorChartsInteractionYAxis: ((state: import("../internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../internals").ChartsSeriesConfig> & import("../internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
114
114
  cacheKey: import("../internals").ChartStateCacheKey;
@@ -150,8 +150,8 @@ export declare const selectorChartsInteractionYAxis: ((state: import("../interna
150
150
  dependencyRecomputations: () => number;
151
151
  resetDependencyRecomputations: () => void;
152
152
  } & {
153
- argsMemoize: typeof import("reselect").weakMapMemoize;
154
153
  memoize: typeof import("reselect").weakMapMemoize;
154
+ argsMemoize: typeof import("reselect").weakMapMemoize;
155
155
  };
156
156
  export declare const selectorChartsInteractionItemIsDefined: ((state: import("../internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../internals").ChartsSeriesConfig> & import("../internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
157
157
  cacheKey: import("../internals").ChartStateCacheKey;
@@ -195,16 +195,16 @@ export declare const selectorChartsInteractionItemIsDefined: ((state: import("..
195
195
  dependencyRecomputations: () => number;
196
196
  resetDependencyRecomputations: () => void;
197
197
  } & {
198
- argsMemoize: typeof import("reselect").weakMapMemoize;
199
198
  memoize: typeof import("reselect").weakMapMemoize;
199
+ argsMemoize: typeof import("reselect").weakMapMemoize;
200
200
  }];
201
201
  recomputations: () => number;
202
202
  resetRecomputations: () => void;
203
203
  dependencyRecomputations: () => number;
204
204
  resetDependencyRecomputations: () => void;
205
205
  } & {
206
- argsMemoize: typeof import("reselect").weakMapMemoize;
207
206
  memoize: typeof import("reselect").weakMapMemoize;
207
+ argsMemoize: typeof import("reselect").weakMapMemoize;
208
208
  };
209
209
  export declare const selectorChartsInteractionXAxisIsDefined: ((state: import("../internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../internals").ChartsSeriesConfig> & import("../internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
210
210
  cacheKey: import("../internals").ChartStateCacheKey;
@@ -266,16 +266,16 @@ export declare const selectorChartsInteractionXAxisIsDefined: ((state: import(".
266
266
  dependencyRecomputations: () => number;
267
267
  resetDependencyRecomputations: () => void;
268
268
  } & {
269
- argsMemoize: typeof import("reselect").weakMapMemoize;
270
269
  memoize: typeof import("reselect").weakMapMemoize;
270
+ argsMemoize: typeof import("reselect").weakMapMemoize;
271
271
  }];
272
272
  recomputations: () => number;
273
273
  resetRecomputations: () => void;
274
274
  dependencyRecomputations: () => number;
275
275
  resetDependencyRecomputations: () => void;
276
276
  } & {
277
- argsMemoize: typeof import("reselect").weakMapMemoize;
278
277
  memoize: typeof import("reselect").weakMapMemoize;
278
+ argsMemoize: typeof import("reselect").weakMapMemoize;
279
279
  };
280
280
  export declare const selectorChartsInteractionYAxisIsDefined: ((state: import("../internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../internals").ChartsSeriesConfig> & import("../internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
281
281
  cacheKey: import("../internals").ChartStateCacheKey;
@@ -337,16 +337,16 @@ export declare const selectorChartsInteractionYAxisIsDefined: ((state: import(".
337
337
  dependencyRecomputations: () => number;
338
338
  resetDependencyRecomputations: () => void;
339
339
  } & {
340
- argsMemoize: typeof import("reselect").weakMapMemoize;
341
340
  memoize: typeof import("reselect").weakMapMemoize;
341
+ argsMemoize: typeof import("reselect").weakMapMemoize;
342
342
  }];
343
343
  recomputations: () => number;
344
344
  resetRecomputations: () => void;
345
345
  dependencyRecomputations: () => number;
346
346
  resetDependencyRecomputations: () => void;
347
347
  } & {
348
- argsMemoize: typeof import("reselect").weakMapMemoize;
349
348
  memoize: typeof import("reselect").weakMapMemoize;
349
+ argsMemoize: typeof import("reselect").weakMapMemoize;
350
350
  };
351
351
  export declare const selectorChartsInteractionIsVoronoiEnabled: ((state: import("../internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("../internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("../internals").ChartsSeriesConfig> & import("../internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types").UseChartInteractionState & Partial<{}> & {
352
352
  cacheKey: import("../internals").ChartStateCacheKey;
@@ -376,7 +376,7 @@ export declare const selectorChartsInteractionIsVoronoiEnabled: ((state: import(
376
376
  dependencyRecomputations: () => number;
377
377
  resetDependencyRecomputations: () => void;
378
378
  } & {
379
- argsMemoize: typeof import("reselect").weakMapMemoize;
380
379
  memoize: typeof import("reselect").weakMapMemoize;
380
+ argsMemoize: typeof import("reselect").weakMapMemoize;
381
381
  };
382
382
  export {};
@@ -1,3 +1 @@
1
1
  export * from './HighlightedProvider';
2
- export { ChartDataProvider } from './ChartDataProvider';
3
- export type { ChartDataProviderProps } from './ChartDataProvider';
package/context/index.js CHANGED
@@ -1,2 +1 @@
1
- export * from "./HighlightedProvider/index.js";
2
- export { ChartDataProvider } from "./ChartDataProvider/index.js";
1
+ export * from "./HighlightedProvider/index.js";