@mui/x-charts 7.0.0-alpha.2 → 7.0.0-alpha.4

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 (142) hide show
  1. package/BarChart/BarElement.d.ts +5 -1
  2. package/BarChart/BarElement.js +24 -1
  3. package/BarChart/index.d.ts +2 -1
  4. package/BarChart/index.js +15 -4
  5. package/CHANGELOG.md +364 -0
  6. package/ChartsLegend/index.d.ts +1 -0
  7. package/ChartsLegend/index.js +11 -0
  8. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +5 -2
  9. package/ChartsTooltip/ChartsAxisTooltipContent.js +93 -73
  10. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -2
  11. package/ChartsTooltip/ChartsItemTooltipContent.js +38 -57
  12. package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +7 -0
  13. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +174 -0
  14. package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +8 -0
  15. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +99 -0
  16. package/ChartsTooltip/index.d.ts +4 -0
  17. package/ChartsTooltip/index.js +44 -0
  18. package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +14 -0
  19. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +174 -0
  20. package/ChartsVoronoiHandler/index.d.ts +1 -0
  21. package/ChartsVoronoiHandler/index.js +16 -0
  22. package/ChartsVoronoiHandler/package.json +6 -0
  23. package/ChartsYAxis/ChartsYAxis.js +6 -4
  24. package/LineChart/extremums.js +25 -8
  25. package/LineChart/index.d.ts +1 -1
  26. package/LineChart/index.js +11 -11
  27. package/PieChart/PieArc.d.ts +5 -2
  28. package/PieChart/PieArc.js +17 -2
  29. package/PieChart/PieArcLabel.d.ts +1 -1
  30. package/PieChart/PieArcLabel.js +5 -10
  31. package/PieChart/PieArcLabelPlot.d.ts +5 -1
  32. package/PieChart/PieArcLabelPlot.js +91 -3
  33. package/PieChart/PieArcPlot.d.ts +5 -1
  34. package/PieChart/PieArcPlot.js +90 -3
  35. package/PieChart/index.d.ts +3 -1
  36. package/PieChart/index.js +26 -4
  37. package/README.md +0 -1
  38. package/ScatterChart/Scatter.js +15 -6
  39. package/ScatterChart/ScatterChart.d.ts +7 -1
  40. package/ScatterChart/ScatterChart.js +18 -1
  41. package/ScatterChart/index.d.ts +1 -1
  42. package/ScatterChart/index.js +8 -8
  43. package/SparkLineChart/SparkLineChart.js +1 -0
  44. package/context/InteractionProvider.d.ts +10 -0
  45. package/context/InteractionProvider.js +21 -1
  46. package/esm/BarChart/BarElement.js +26 -2
  47. package/esm/BarChart/index.js +2 -1
  48. package/esm/ChartsLegend/index.js +2 -1
  49. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +95 -75
  50. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
  51. package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +168 -0
  52. package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
  53. package/esm/ChartsTooltip/index.js +5 -1
  54. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +168 -0
  55. package/esm/ChartsVoronoiHandler/index.js +1 -0
  56. package/esm/ChartsYAxis/ChartsYAxis.js +6 -4
  57. package/esm/LineChart/extremums.js +25 -8
  58. package/esm/LineChart/index.js +1 -1
  59. package/esm/PieChart/PieArc.js +18 -2
  60. package/esm/PieChart/PieArcLabel.js +7 -11
  61. package/esm/PieChart/PieArcLabelPlot.js +92 -3
  62. package/esm/PieChart/PieArcPlot.js +91 -3
  63. package/esm/PieChart/index.js +3 -1
  64. package/esm/ScatterChart/Scatter.js +15 -6
  65. package/esm/ScatterChart/ScatterChart.js +18 -1
  66. package/esm/ScatterChart/index.js +1 -1
  67. package/esm/SparkLineChart/SparkLineChart.js +1 -0
  68. package/esm/context/InteractionProvider.js +21 -1
  69. package/esm/hooks/useAxisEvents.js +20 -27
  70. package/esm/hooks/useInteractionItemProps.js +4 -1
  71. package/esm/index.js +1 -0
  72. package/esm/internals/defaultizeValueFormatter.js +4 -3
  73. package/esm/internals/utils.js +11 -0
  74. package/hooks/useAxisEvents.js +20 -27
  75. package/hooks/useInteractionItemProps.d.ts +2 -2
  76. package/hooks/useInteractionItemProps.js +4 -1
  77. package/index.d.ts +1 -0
  78. package/index.js +12 -1
  79. package/internals/defaultizeColor.d.ts +1 -0
  80. package/internals/defaultizeValueFormatter.d.ts +3 -1
  81. package/internals/defaultizeValueFormatter.js +3 -3
  82. package/internals/utils.d.ts +6 -0
  83. package/internals/utils.js +12 -0
  84. package/legacy/BarChart/BarElement.js +26 -2
  85. package/legacy/BarChart/index.js +2 -1
  86. package/legacy/ChartsLegend/index.js +2 -1
  87. package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
  88. package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +40 -55
  89. package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
  90. package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +89 -0
  91. package/legacy/ChartsTooltip/index.js +5 -1
  92. package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +162 -0
  93. package/legacy/ChartsVoronoiHandler/index.js +1 -0
  94. package/legacy/ChartsYAxis/ChartsYAxis.js +6 -4
  95. package/legacy/LineChart/extremums.js +29 -14
  96. package/legacy/LineChart/index.js +1 -1
  97. package/legacy/PieChart/PieArc.js +18 -2
  98. package/legacy/PieChart/PieArcLabel.js +7 -11
  99. package/legacy/PieChart/PieArcLabelPlot.js +92 -3
  100. package/legacy/PieChart/PieArcPlot.js +91 -3
  101. package/legacy/PieChart/index.js +3 -1
  102. package/legacy/ScatterChart/Scatter.js +18 -7
  103. package/legacy/ScatterChart/ScatterChart.js +18 -1
  104. package/legacy/ScatterChart/index.js +1 -1
  105. package/legacy/SparkLineChart/SparkLineChart.js +1 -0
  106. package/legacy/context/InteractionProvider.js +21 -1
  107. package/legacy/hooks/useAxisEvents.js +20 -27
  108. package/legacy/hooks/useInteractionItemProps.js +6 -1
  109. package/legacy/index.js +2 -1
  110. package/legacy/internals/defaultizeValueFormatter.js +4 -3
  111. package/legacy/internals/utils.js +11 -0
  112. package/models/seriesType/config.d.ts +5 -1
  113. package/models/seriesType/scatter.d.ts +6 -1
  114. package/modern/BarChart/BarElement.js +26 -2
  115. package/modern/BarChart/index.js +2 -1
  116. package/modern/ChartsLegend/index.js +2 -1
  117. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
  118. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
  119. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
  120. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
  121. package/modern/ChartsTooltip/index.js +5 -1
  122. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +166 -0
  123. package/modern/ChartsVoronoiHandler/index.js +1 -0
  124. package/modern/ChartsYAxis/ChartsYAxis.js +6 -4
  125. package/modern/LineChart/extremums.js +25 -8
  126. package/modern/LineChart/index.js +1 -1
  127. package/modern/PieChart/PieArc.js +18 -2
  128. package/modern/PieChart/PieArcLabel.js +7 -11
  129. package/modern/PieChart/PieArcLabelPlot.js +92 -3
  130. package/modern/PieChart/PieArcPlot.js +91 -3
  131. package/modern/PieChart/index.js +3 -1
  132. package/modern/ScatterChart/Scatter.js +15 -6
  133. package/modern/ScatterChart/ScatterChart.js +18 -1
  134. package/modern/ScatterChart/index.js +1 -1
  135. package/modern/SparkLineChart/SparkLineChart.js +1 -0
  136. package/modern/context/InteractionProvider.js +21 -1
  137. package/modern/hooks/useAxisEvents.js +20 -27
  138. package/modern/hooks/useInteractionItemProps.js +4 -1
  139. package/modern/index.js +2 -1
  140. package/modern/internals/defaultizeValueFormatter.js +3 -3
  141. package/modern/internals/utils.js +11 -0
  142. package/package.json +6 -4
@@ -7,6 +7,7 @@ import { ChartsAxis } from '../ChartsAxis';
7
7
  import { ChartsTooltip } from '../ChartsTooltip';
8
8
  import { ChartsLegend } from '../ChartsLegend';
9
9
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
10
+ import { ChartsVoronoiHandler } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
10
11
  import { jsx as _jsx } from "react/jsx-runtime";
11
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
12
13
  /**
@@ -25,6 +26,8 @@ var ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props, re
25
26
  series = props.series,
26
27
  tooltip = props.tooltip,
27
28
  axisHighlight = props.axisHighlight,
29
+ voronoiMaxRadius = props.voronoiMaxRadius,
30
+ disableVoronoi = props.disableVoronoi,
28
31
  legend = props.legend,
29
32
  width = props.width,
30
33
  height = props.height,
@@ -52,7 +55,9 @@ var ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props, re
52
55
  xAxis: xAxis,
53
56
  yAxis: yAxis,
54
57
  sx: sx,
55
- children: [/*#__PURE__*/_jsx(ChartsAxis, {
58
+ children: [!disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, {
59
+ voronoiMaxRadius: voronoiMaxRadius
60
+ }), /*#__PURE__*/_jsx(ChartsAxis, {
56
61
  topAxis: topAxis,
57
62
  leftAxis: leftAxis,
58
63
  rightAxis: rightAxis,
@@ -126,6 +131,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
126
131
  * @default false
127
132
  */
128
133
  disableAxisListener: PropTypes.bool,
134
+ /**
135
+ * If true, the interaction will not use the Voronoi cell and fall back to hover events.
136
+ * @default false
137
+ */
138
+ disableVoronoi: PropTypes.bool,
129
139
  /**
130
140
  * The height of the chart in px. If not defined, it takes the height of the parent element.
131
141
  * @default undefined
@@ -218,6 +228,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
218
228
  x: PropTypes.number.isRequired,
219
229
  y: PropTypes.number.isRequired
220
230
  })).isRequired,
231
+ disableHover: PropTypes.bool,
221
232
  highlightScope: PropTypes.shape({
222
233
  faded: PropTypes.oneOf(['global', 'none', 'series']),
223
234
  highlighted: PropTypes.oneOf(['item', 'none', 'series'])
@@ -283,6 +294,12 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
283
294
  x: PropTypes.number,
284
295
  y: PropTypes.number
285
296
  }),
297
+ /**
298
+ * Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
299
+ * If `undefined`, the radius is assumed to be infinite.
300
+ * @default undefined
301
+ */
302
+ voronoiMaxRadius: PropTypes.number,
286
303
  /**
287
304
  * The width of the chart in px. If not defined, it takes the width of the parent element.
288
305
  * @default undefined
@@ -1,3 +1,3 @@
1
- export * from './ScatterPlot';
2
1
  export * from './ScatterChart';
2
+ export * from './ScatterPlot';
3
3
  export * from './Scatter';
@@ -84,6 +84,7 @@ var SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props
84
84
  sx: sx,
85
85
  disableAxisListener: (!showTooltip || (tooltip == null ? void 0 : tooltip.trigger) !== 'axis') && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
86
86
  children: [plotType === 'bar' && /*#__PURE__*/_jsx(BarPlot, {
87
+ skipAnimation: true,
87
88
  slots: slots,
88
89
  slotProps: slotProps,
89
90
  sx: {
@@ -8,6 +8,7 @@ export var InteractionContext = /*#__PURE__*/React.createContext({
8
8
  x: null,
9
9
  y: null
10
10
  },
11
+ useVoronoiInteraction: false,
11
12
  dispatch: function dispatch() {
12
13
  return null;
13
14
  }
@@ -18,6 +19,21 @@ var dataReducer = function dataReducer(prevState, action) {
18
19
  return _extends({}, prevState, {
19
20
  item: action.data
20
21
  });
22
+ case 'exitChart':
23
+ if (prevState.item === null && prevState.axis.x === null && prevState.axis.y === null) {
24
+ return prevState;
25
+ }
26
+ return _extends({}, prevState, {
27
+ axis: {
28
+ x: null,
29
+ y: null
30
+ },
31
+ item: null
32
+ });
33
+ case 'updateVoronoiUsage':
34
+ return _extends({}, prevState, {
35
+ useVoronoiInteraction: action.useVoronoiInteraction
36
+ });
21
37
  case 'leaveItem':
22
38
  if (prevState.item === null || Object.keys(action.data).some(function (key) {
23
39
  return action.data[key] !== prevState.item[key];
@@ -29,6 +45,9 @@ var dataReducer = function dataReducer(prevState, action) {
29
45
  item: null
30
46
  });
31
47
  case 'updateAxis':
48
+ if (action.data.x === prevState.axis.x && action.data.y === prevState.axis.y) {
49
+ return prevState;
50
+ }
32
51
  return _extends({}, prevState, {
33
52
  axis: action.data
34
53
  });
@@ -43,7 +62,8 @@ export function InteractionProvider(_ref) {
43
62
  axis: {
44
63
  x: null,
45
64
  y: null
46
- }
65
+ },
66
+ useVoronoiInteraction: false
47
67
  }),
48
68
  _React$useReducer2 = _slicedToArray(_React$useReducer, 2),
49
69
  data = _React$useReducer2[0],
@@ -4,6 +4,10 @@ import { InteractionContext } from '../context/InteractionProvider';
4
4
  import { CartesianContext } from '../context/CartesianContextProvider';
5
5
  import { SVGContext, DrawingContext } from '../context/DrawingProvider';
6
6
  import { isBandScale } from '../internals/isBandScale';
7
+ import { getSVGPoint } from '../internals/utils';
8
+ function getAsANumber(value) {
9
+ return value instanceof Date ? value.getTime() : value;
10
+ }
7
11
  export var useAxisEvents = function useAxisEvents(disableAxisListener) {
8
12
  var svgRef = React.useContext(SVGContext);
9
13
  var _React$useContext = React.useContext(DrawingContext),
@@ -44,17 +48,18 @@ export var useAxisEvents = function useAxisEvents(disableAxisListener) {
44
48
  value: value
45
49
  };
46
50
  }
47
- var closestIndex = axisData == null ? void 0 : axisData.findIndex(function (v, index) {
48
- if (v > value) {
49
- // @ts-ignore
50
- if (index === 0 || Math.abs(value - v) <= Math.abs(value - axisData[index - 1])) {
51
+ var valueAsNumber = getAsANumber(value);
52
+ var closestIndex = axisData == null ? void 0 : axisData.findIndex(function (pointValue, index) {
53
+ var v = getAsANumber(pointValue);
54
+ if (v > valueAsNumber) {
55
+ if (index === 0 || Math.abs(valueAsNumber - v) <= Math.abs(valueAsNumber - getAsANumber(axisData[index - 1]))) {
51
56
  return true;
52
57
  }
53
58
  }
54
- if (v <= value) {
59
+ if (v <= valueAsNumber) {
55
60
  if (index === axisData.length - 1 ||
56
61
  // @ts-ignore
57
- Math.abs(value - v) < Math.abs(value - axisData[index + 1])) {
62
+ Math.abs(value - v) < Math.abs(value - getAsANumber(axisData[index + 1]))) {
58
63
  return true;
59
64
  }
60
65
  }
@@ -80,37 +85,25 @@ export var useAxisEvents = function useAxisEvents(disableAxisListener) {
80
85
  y: -1
81
86
  };
82
87
  dispatch({
83
- type: 'updateAxis',
84
- data: {
85
- x: null,
86
- y: null
87
- }
88
+ type: 'exitChart'
88
89
  });
89
90
  };
90
91
  var handleMouseMove = function handleMouseMove(event) {
91
- // Get mouse coordinate in global SVG space
92
- var pt = svgRef.current.createSVGPoint();
93
- pt.x = event.clientX;
94
- pt.y = event.clientY;
95
- var svgPt = pt.matrixTransform(svgRef.current.getScreenCTM().inverse());
92
+ var svgPoint = getSVGPoint(svgRef.current, event);
96
93
  mousePosition.current = {
97
- x: svgPt.x,
98
- y: svgPt.y
94
+ x: svgPoint.x,
95
+ y: svgPoint.y
99
96
  };
100
- var outsideX = svgPt.x < left || svgPt.x > left + width;
101
- var outsideY = svgPt.y < top || svgPt.y > top + height;
97
+ var outsideX = svgPoint.x < left || svgPoint.x > left + width;
98
+ var outsideY = svgPoint.y < top || svgPoint.y > top + height;
102
99
  if (outsideX || outsideY) {
103
100
  dispatch({
104
- type: 'updateAxis',
105
- data: {
106
- x: null,
107
- y: null
108
- }
101
+ type: 'exitChart'
109
102
  });
110
103
  return;
111
104
  }
112
- var newStateX = getUpdate(xAxis[usedXAxis], svgPt.x);
113
- var newStateY = getUpdate(yAxis[usedYAxis], svgPt.y);
105
+ var newStateX = getUpdate(xAxis[usedXAxis], svgPoint.x);
106
+ var newStateY = getUpdate(yAxis[usedYAxis], svgPoint.y);
114
107
  dispatch({
115
108
  type: 'updateAxis',
116
109
  data: {
@@ -1,11 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { InteractionContext } from '../context/InteractionProvider';
3
3
  import { HighlighContext } from '../context/HighlightProvider';
4
- export var useInteractionItemProps = function useInteractionItemProps(scope) {
4
+ export var useInteractionItemProps = function useInteractionItemProps(scope, skip) {
5
5
  var _React$useContext = React.useContext(InteractionContext),
6
6
  dispatchInteraction = _React$useContext.dispatch;
7
7
  var _React$useContext2 = React.useContext(HighlighContext),
8
8
  dispatchHighlight = _React$useContext2.dispatch;
9
+ if (skip) {
10
+ return function () {
11
+ return {};
12
+ };
13
+ }
9
14
  var getInteractionItemProps = function getInteractionItemProps(data) {
10
15
  var onMouseEnter = function onMouseEnter() {
11
16
  dispatchInteraction({
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.0.0-alpha.2
2
+ * @mui/x-charts v7.0.0-alpha.4
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -18,6 +18,7 @@ export * from './ChartsYAxis';
18
18
  export * from './ChartsTooltip';
19
19
  export * from './ChartsLegend';
20
20
  export * from './ChartsAxisHighlight';
21
+ export * from './ChartsVoronoiHandler';
21
22
  export * from './BarChart';
22
23
  export * from './LineChart';
23
24
  export * from './PieChart';
@@ -2,9 +2,10 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  function defaultizeValueFormatter(series, defaultValueFormatter) {
3
3
  var defaultizedSeries = {};
4
4
  Object.keys(series).forEach(function (seriesId) {
5
- defaultizedSeries[seriesId] = _extends({
6
- valueFormatter: defaultValueFormatter
7
- }, series[seriesId]);
5
+ var _series$seriesId$valu;
6
+ defaultizedSeries[seriesId] = _extends({}, series[seriesId], {
7
+ valueFormatter: (_series$seriesId$valu = series[seriesId].valueFormatter) != null ? _series$seriesId$valu : defaultValueFormatter
8
+ });
8
9
  });
9
10
  return defaultizedSeries;
10
11
  }
@@ -2,4 +2,15 @@
2
2
  export function getSymbol(shape) {
3
3
  var symbolNames = 'circle cross diamond square star triangle wye'.split(/ /);
4
4
  return symbolNames.indexOf(shape) || 0;
5
+ }
6
+ /**
7
+ * Transform mouse event position to corrdinates inside the SVG.
8
+ * @param svg The SVG element
9
+ * @param event The mouseEvent to transform
10
+ */
11
+ export function getSVGPoint(svg, event) {
12
+ var pt = svg.createSVGPoint();
13
+ pt.x = event.clientX;
14
+ pt.y = event.clientY;
15
+ return pt.matrixTransform(svg.getScreenCTM().inverse());
5
16
  }
@@ -46,7 +46,11 @@ export type ChartSeries<T extends ChartSeriesType> = ChartsSeriesConfig[T] exten
46
46
  } ? ChartsSeriesConfig[T]['seriesInput'] & {
47
47
  stackedData: [number, number][];
48
48
  } : ChartsSeriesConfig[T]['seriesInput'];
49
- export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConfig[T]['series'] & ChartSeries<T>;
49
+ export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConfig[T] extends {
50
+ canBeStacked: true;
51
+ } ? ChartsSeriesConfig[T]['series'] & {
52
+ stackedData: [number, number][];
53
+ } : ChartsSeriesConfig[T]['series'];
50
54
  export type ChartItemIdentifier<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
51
55
  type ExtremumGetterParams<T extends ChartSeriesType> = {
52
56
  series: {
@@ -10,6 +10,11 @@ export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType>, C
10
10
  data: ScatterValueType[];
11
11
  markerSize?: number;
12
12
  label?: string;
13
+ /**
14
+ * If true, the interaction will not use element hover for this series.
15
+ * @default false
16
+ */
17
+ disableHover?: boolean;
13
18
  }
14
19
  /**
15
20
  * An object that allows to identify a single scatter item.
@@ -20,5 +25,5 @@ export type ScatterItemIdentifier = {
20
25
  seriesId: DefaultizedScatterSeriesType['id'];
21
26
  dataIndex: number;
22
27
  };
23
- export interface DefaultizedScatterSeriesType extends DefaultizedProps<ScatterSeriesType, CommonDefaultizedProps> {
28
+ export interface DefaultizedScatterSeriesType extends DefaultizedProps<ScatterSeriesType, CommonDefaultizedProps | 'color'> {
24
29
  }
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
3
  const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style"];
4
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
5
6
  import composeClasses from '@mui/utils/composeClasses';
6
7
  import { useSlotProps } from '@mui/base/utils';
7
8
  import generateUtilityClass from '@mui/utils/generateUtilityClass';
@@ -39,7 +40,7 @@ export const BarElementPath = styled(animated.rect, {
39
40
  transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
40
41
  opacity: ownerState.isFaded && 0.3 || 1
41
42
  }));
42
- export function BarElement(props) {
43
+ function BarElement(props) {
43
44
  const {
44
45
  id,
45
46
  dataIndex,
@@ -89,4 +90,27 @@ export function BarElement(props) {
89
90
  ownerState
90
91
  });
91
92
  return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
92
- }
93
+ }
94
+ process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
95
+ // ----------------------------- Warning --------------------------------
96
+ // | These PropTypes are generated from the TypeScript type definitions |
97
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
98
+ // ----------------------------------------------------------------------
99
+ classes: PropTypes.object,
100
+ dataIndex: PropTypes.number.isRequired,
101
+ highlightScope: PropTypes.shape({
102
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
103
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
104
+ }),
105
+ /**
106
+ * The props used for each component slot.
107
+ * @default {}
108
+ */
109
+ slotProps: PropTypes.object,
110
+ /**
111
+ * Overridable component slots.
112
+ * @default {}
113
+ */
114
+ slots: PropTypes.object
115
+ } : void 0;
116
+ export { BarElement };
@@ -1,2 +1,3 @@
1
+ export * from './BarChart';
1
2
  export * from './BarPlot';
2
- export * from './BarChart';
3
+ export * from './BarElement';
@@ -1,2 +1,3 @@
1
1
  export * from './ChartsLegend';
2
- export * from './chartsLegendClasses';
2
+ export * from './chartsLegendClasses';
3
+ export * from './utils';
@@ -1,81 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import clsx from 'clsx';
4
- import Typography from '@mui/material/Typography';
3
+ import PropTypes from 'prop-types';
5
4
  import { useSlotProps } from '@mui/base/utils';
6
5
  import { SeriesContext } from '../context/SeriesContextProvider';
7
6
  import { CartesianContext } from '../context/CartesianContextProvider';
8
- import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
7
+ import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
9
8
  import { jsx as _jsx } from "react/jsx-runtime";
10
- import { jsxs as _jsxs } from "react/jsx-runtime";
11
- export function DefaultChartsAxisContent(props) {
12
- const {
13
- series,
14
- axis,
15
- dataIndex,
16
- axisValue,
17
- sx,
18
- classes
19
- } = props;
20
- if (dataIndex == null) {
21
- return null;
22
- }
23
- const axisFormatter = axis.valueFormatter ?? (v => v.toLocaleString());
24
- return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
25
- sx: sx,
26
- className: classes.root,
27
- children: /*#__PURE__*/_jsxs(ChartsTooltipTable, {
28
- className: classes.table,
29
- children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/_jsx("thead", {
30
- children: /*#__PURE__*/_jsx(ChartsTooltipRow, {
31
- children: /*#__PURE__*/_jsx(ChartsTooltipCell, {
32
- colSpan: 3,
33
- children: /*#__PURE__*/_jsx(Typography, {
34
- children: axisFormatter(axisValue)
35
- })
36
- })
37
- })
38
- }), /*#__PURE__*/_jsx("tbody", {
39
- children: series.map(({
40
- color,
41
- id,
42
- label,
43
- valueFormatter,
44
- data
45
- }) => {
46
- const formattedValue = valueFormatter(data[dataIndex]);
47
- if (formattedValue == null) {
48
- return null;
49
- }
50
- return /*#__PURE__*/_jsxs(ChartsTooltipRow, {
51
- className: classes.row,
52
- children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
53
- className: clsx(classes.markCell, classes.cell),
54
- children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
55
- ownerState: {
56
- color
57
- },
58
- boxShadow: 1,
59
- className: classes.mark
60
- })
61
- }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
62
- className: clsx(classes.labelCell, classes.cell),
63
- children: label ? /*#__PURE__*/_jsx(Typography, {
64
- children: label
65
- }) : null
66
- }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
67
- className: clsx(classes.valueCell, classes.cell),
68
- children: /*#__PURE__*/_jsx(Typography, {
69
- children: formattedValue
70
- })
71
- })]
72
- }, id);
73
- })
74
- })]
75
- })
76
- });
77
- }
78
- export function ChartsAxisTooltipContent(props) {
9
+ function ChartsAxisTooltipContent(props) {
79
10
  const {
80
11
  content,
81
12
  contentProps,
@@ -110,7 +41,7 @@ export function ChartsAxisTooltipContent(props) {
110
41
  const relevantAxis = React.useMemo(() => {
111
42
  return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
112
43
  }, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
113
- const Content = content ?? DefaultChartsAxisContent;
44
+ const Content = content ?? DefaultChartsAxisTooltipContent;
114
45
  const chartTooltipContentProps = useSlotProps({
115
46
  elementType: Content,
116
47
  externalSlotProps: contentProps,
@@ -126,4 +57,94 @@ export function ChartsAxisTooltipContent(props) {
126
57
  ownerState: {}
127
58
  });
128
59
  return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
129
- }
60
+ }
61
+ process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
62
+ // ----------------------------- Warning --------------------------------
63
+ // | These PropTypes are generated from the TypeScript type definitions |
64
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
65
+ // ----------------------------------------------------------------------
66
+ axisData: PropTypes.shape({
67
+ x: PropTypes.shape({
68
+ index: PropTypes.number,
69
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
70
+ }),
71
+ y: PropTypes.shape({
72
+ index: PropTypes.number,
73
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
74
+ })
75
+ }).isRequired,
76
+ classes: PropTypes.object.isRequired,
77
+ content: PropTypes.elementType,
78
+ contentProps: PropTypes.shape({
79
+ axis: PropTypes.shape({
80
+ axisId: PropTypes.string,
81
+ classes: PropTypes.object,
82
+ data: PropTypes.array,
83
+ dataKey: PropTypes.string,
84
+ disableLine: PropTypes.bool,
85
+ disableTicks: PropTypes.bool,
86
+ fill: PropTypes.string,
87
+ hideTooltip: PropTypes.bool,
88
+ id: PropTypes.string.isRequired,
89
+ label: PropTypes.string,
90
+ labelFontSize: PropTypes.number,
91
+ labelStyle: PropTypes.object,
92
+ max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
93
+ min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
94
+ position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
95
+ scale: PropTypes.func.isRequired,
96
+ scaleType: PropTypes.oneOf(['time']).isRequired,
97
+ slotProps: PropTypes.object,
98
+ slots: PropTypes.object,
99
+ stroke: PropTypes.string,
100
+ tickFontSize: PropTypes.number,
101
+ tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
102
+ tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
103
+ tickLabelStyle: PropTypes.object,
104
+ tickMaxStep: PropTypes.number,
105
+ tickMinStep: PropTypes.number,
106
+ tickNumber: PropTypes.number.isRequired,
107
+ tickSize: PropTypes.number,
108
+ valueFormatter: PropTypes.func
109
+ }),
110
+ axisData: PropTypes.shape({
111
+ x: PropTypes.shape({
112
+ index: PropTypes.number,
113
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
114
+ }),
115
+ y: PropTypes.shape({
116
+ index: PropTypes.number,
117
+ value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
118
+ })
119
+ }),
120
+ axisValue: PropTypes.any,
121
+ classes: PropTypes.object,
122
+ dataIndex: PropTypes.number,
123
+ series: PropTypes.arrayOf(PropTypes.shape({
124
+ area: PropTypes.bool,
125
+ color: PropTypes.string.isRequired,
126
+ connectNulls: PropTypes.bool,
127
+ curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
128
+ data: PropTypes.arrayOf(PropTypes.number).isRequired,
129
+ dataKey: PropTypes.string,
130
+ disableHighlight: PropTypes.bool,
131
+ highlightScope: PropTypes.shape({
132
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
133
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
134
+ }),
135
+ id: PropTypes.string.isRequired,
136
+ label: PropTypes.string,
137
+ showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
138
+ stack: PropTypes.string,
139
+ stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
140
+ stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
141
+ type: PropTypes.oneOf(['line']).isRequired,
142
+ valueFormatter: PropTypes.func.isRequired,
143
+ xAxisKey: PropTypes.string,
144
+ yAxisKey: PropTypes.string
145
+ })),
146
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
147
+ }),
148
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
149
+ } : void 0;
150
+ export { ChartsAxisTooltipContent };
@@ -1,64 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import * as React from 'react';
3
- import clsx from 'clsx';
3
+ import PropTypes from 'prop-types';
4
4
  import { useSlotProps } from '@mui/base/utils';
5
5
  import { SeriesContext } from '../context/SeriesContextProvider';
6
- import { ChartsTooltipTable, ChartsTooltipCell, ChartsTooltipMark, ChartsTooltipPaper, ChartsTooltipRow } from './ChartsTooltipTable';
6
+ import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
- export function DefaultChartsItemContent(props) {
10
- const {
11
- series,
12
- itemData,
13
- sx,
14
- classes
15
- } = props;
16
- if (itemData.dataIndex === undefined) {
17
- return null;
18
- }
19
- const {
20
- displayedLabel,
21
- color
22
- } = series.type === 'pie' ? {
23
- color: series.data[itemData.dataIndex].color,
24
- displayedLabel: series.data[itemData.dataIndex].label
25
- } : {
26
- color: series.color,
27
- displayedLabel: series.label
28
- };
29
-
30
- // TODO: Manage to let TS understand series.data and series.valueFormatter are coherent
31
- // @ts-ignore
32
- const formattedValue = series.valueFormatter(series.data[itemData.dataIndex]);
33
- return /*#__PURE__*/_jsx(ChartsTooltipPaper, {
34
- sx: sx,
35
- className: classes.root,
36
- children: /*#__PURE__*/_jsx(ChartsTooltipTable, {
37
- className: classes.table,
38
- children: /*#__PURE__*/_jsx("tbody", {
39
- children: /*#__PURE__*/_jsxs(ChartsTooltipRow, {
40
- className: classes.row,
41
- children: [/*#__PURE__*/_jsx(ChartsTooltipCell, {
42
- className: clsx(classes.markCell, classes.cell),
43
- children: /*#__PURE__*/_jsx(ChartsTooltipMark, {
44
- ownerState: {
45
- color
46
- },
47
- className: classes.mark
48
- })
49
- }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
50
- className: clsx(classes.labelCell, classes.cell),
51
- children: displayedLabel
52
- }), /*#__PURE__*/_jsx(ChartsTooltipCell, {
53
- className: clsx(classes.valueCell, classes.cell),
54
- children: formattedValue
55
- })]
56
- })
57
- })
58
- })
59
- });
60
- }
61
- export function ChartsItemTooltipContent(props) {
8
+ function ChartsItemTooltipContent(props) {
62
9
  const {
63
10
  content,
64
11
  itemData,
@@ -67,7 +14,7 @@ export function ChartsItemTooltipContent(props) {
67
14
  contentProps
68
15
  } = props;
69
16
  const series = React.useContext(SeriesContext)[itemData.type].series[itemData.seriesId];
70
- const Content = content ?? DefaultChartsItemContent;
17
+ const Content = content ?? DefaultChartsItemTooltipContent;
71
18
  const chartTooltipContentProps = useSlotProps({
72
19
  elementType: Content,
73
20
  externalSlotProps: contentProps,
@@ -80,4 +27,39 @@ export function ChartsItemTooltipContent(props) {
80
27
  ownerState: {}
81
28
  });
82
29
  return /*#__PURE__*/_jsx(Content, _extends({}, chartTooltipContentProps));
83
- }
30
+ }
31
+ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
32
+ // ----------------------------- Warning --------------------------------
33
+ // | These PropTypes are generated from the TypeScript type definitions |
34
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
35
+ // ----------------------------------------------------------------------
36
+ classes: PropTypes.object.isRequired,
37
+ content: PropTypes.elementType,
38
+ contentProps: PropTypes.shape({
39
+ classes: PropTypes.object,
40
+ itemData: PropTypes.shape({
41
+ dataIndex: PropTypes.number,
42
+ seriesId: PropTypes.string.isRequired,
43
+ type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
44
+ }),
45
+ series: PropTypes.shape({
46
+ color: PropTypes.string,
47
+ data: PropTypes.arrayOf(PropTypes.number).isRequired,
48
+ highlightScope: PropTypes.shape({
49
+ faded: PropTypes.oneOf(['global', 'none', 'series']),
50
+ highlighted: PropTypes.oneOf(['item', 'none', 'series'])
51
+ }),
52
+ id: PropTypes.string.isRequired,
53
+ type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired,
54
+ valueFormatter: PropTypes.func.isRequired
55
+ }),
56
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
57
+ }),
58
+ itemData: PropTypes.shape({
59
+ dataIndex: PropTypes.number,
60
+ seriesId: PropTypes.string.isRequired,
61
+ type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
62
+ }).isRequired,
63
+ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
64
+ } : void 0;
65
+ export { ChartsItemTooltipContent };