@mui/x-charts 7.0.0-beta.2 → 7.0.0-beta.3

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 (124) hide show
  1. package/BarChart/BarChart.d.ts +21 -5
  2. package/BarChart/BarChart.js +27 -5
  3. package/CHANGELOG.md +73 -9
  4. package/ChartsGrid/ChartsGrid.d.ts +30 -0
  5. package/ChartsGrid/ChartsGrid.js +128 -0
  6. package/ChartsGrid/chartsGridClasses.d.ts +13 -0
  7. package/ChartsGrid/chartsGridClasses.js +14 -0
  8. package/ChartsGrid/index.d.ts +2 -0
  9. package/ChartsGrid/index.js +27 -0
  10. package/ChartsGrid/package.json +6 -0
  11. package/ChartsSurface.js +6 -4
  12. package/ChartsXAxis/ChartsXAxis.js +2 -2
  13. package/ChartsYAxis/ChartsYAxis.js +2 -2
  14. package/Gauge/Gauge.d.ts +13 -0
  15. package/Gauge/Gauge.js +156 -0
  16. package/Gauge/GaugeContainer.d.ts +19 -0
  17. package/Gauge/GaugeContainer.js +216 -0
  18. package/Gauge/GaugeProvider.d.ts +117 -0
  19. package/Gauge/GaugeProvider.js +96 -0
  20. package/Gauge/GaugeReferenceArc.d.ts +2 -0
  21. package/Gauge/GaugeReferenceArc.js +44 -0
  22. package/Gauge/GaugeValueArc.d.ts +2 -0
  23. package/Gauge/GaugeValueArc.js +51 -0
  24. package/Gauge/GaugeValueText.d.ts +15 -0
  25. package/Gauge/GaugeValueText.js +77 -0
  26. package/Gauge/gaugeClasses.d.ts +14 -0
  27. package/Gauge/gaugeClasses.js +15 -0
  28. package/Gauge/index.d.ts +7 -0
  29. package/Gauge/index.js +87 -0
  30. package/Gauge/package.json +6 -0
  31. package/Gauge/utils.d.ts +19 -0
  32. package/Gauge/utils.js +75 -0
  33. package/LineChart/LineChart.d.ts +24 -5
  34. package/LineChart/LineChart.js +31 -5
  35. package/PieChart/PieArc.d.ts +4 -4
  36. package/PieChart/PieArc.js +9 -9
  37. package/PieChart/PieArcLabelPlot.js +13 -13
  38. package/PieChart/PieChart.d.ts +22 -0
  39. package/PieChart/PieChart.js +22 -0
  40. package/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
  41. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +2 -0
  42. package/ResponsiveChartContainer/useChartContainerDimensions.js +76 -0
  43. package/ScatterChart/ScatterChart.d.ts +18 -0
  44. package/ScatterChart/ScatterChart.js +25 -0
  45. package/esm/BarChart/BarChart.js +27 -5
  46. package/esm/ChartsGrid/ChartsGrid.js +121 -0
  47. package/esm/ChartsGrid/chartsGridClasses.js +6 -0
  48. package/esm/ChartsGrid/index.js +2 -0
  49. package/esm/ChartsSurface.js +6 -4
  50. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  51. package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
  52. package/esm/Gauge/Gauge.js +149 -0
  53. package/esm/Gauge/GaugeContainer.js +211 -0
  54. package/esm/Gauge/GaugeProvider.js +85 -0
  55. package/esm/Gauge/GaugeReferenceArc.js +35 -0
  56. package/esm/Gauge/GaugeValueArc.js +42 -0
  57. package/esm/Gauge/GaugeValueText.js +69 -0
  58. package/esm/Gauge/gaugeClasses.js +7 -0
  59. package/esm/Gauge/index.js +7 -0
  60. package/esm/Gauge/utils.js +68 -0
  61. package/esm/LineChart/LineChart.js +31 -5
  62. package/esm/PieChart/PieArc.js +9 -9
  63. package/esm/PieChart/PieArcLabelPlot.js +13 -13
  64. package/esm/PieChart/PieChart.js +22 -0
  65. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
  66. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  67. package/esm/ScatterChart/ScatterChart.js +25 -0
  68. package/esm/hooks/useTicks.js +2 -3
  69. package/esm/index.js +2 -0
  70. package/hooks/useTicks.d.ts +1 -2
  71. package/hooks/useTicks.js +2 -3
  72. package/index.d.ts +2 -0
  73. package/index.js +23 -1
  74. package/legacy/BarChart/BarChart.js +27 -5
  75. package/legacy/ChartsGrid/ChartsGrid.js +119 -0
  76. package/legacy/ChartsGrid/chartsGridClasses.js +6 -0
  77. package/legacy/ChartsGrid/index.js +2 -0
  78. package/legacy/ChartsSurface.js +5 -3
  79. package/legacy/ChartsXAxis/ChartsXAxis.js +1 -1
  80. package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
  81. package/legacy/Gauge/Gauge.js +146 -0
  82. package/legacy/Gauge/GaugeContainer.js +215 -0
  83. package/legacy/Gauge/GaugeProvider.js +87 -0
  84. package/legacy/Gauge/GaugeReferenceArc.js +37 -0
  85. package/legacy/Gauge/GaugeValueArc.js +44 -0
  86. package/legacy/Gauge/GaugeValueText.js +66 -0
  87. package/legacy/Gauge/gaugeClasses.js +7 -0
  88. package/legacy/Gauge/index.js +7 -0
  89. package/legacy/Gauge/utils.js +84 -0
  90. package/legacy/LineChart/LineChart.js +31 -5
  91. package/legacy/PieChart/PieArc.js +10 -10
  92. package/legacy/PieChart/PieArcLabelPlot.js +14 -14
  93. package/legacy/PieChart/PieChart.js +22 -0
  94. package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -77
  95. package/legacy/ResponsiveChartContainer/useChartContainerDimensions.js +73 -0
  96. package/legacy/ScatterChart/ScatterChart.js +25 -0
  97. package/legacy/hooks/useTicks.js +2 -3
  98. package/legacy/index.js +3 -1
  99. package/modern/BarChart/BarChart.js +27 -5
  100. package/modern/ChartsGrid/ChartsGrid.js +121 -0
  101. package/modern/ChartsGrid/chartsGridClasses.js +6 -0
  102. package/modern/ChartsGrid/index.js +2 -0
  103. package/modern/ChartsSurface.js +6 -4
  104. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  105. package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
  106. package/modern/Gauge/Gauge.js +149 -0
  107. package/modern/Gauge/GaugeContainer.js +208 -0
  108. package/modern/Gauge/GaugeProvider.js +85 -0
  109. package/modern/Gauge/GaugeReferenceArc.js +35 -0
  110. package/modern/Gauge/GaugeValueArc.js +42 -0
  111. package/modern/Gauge/GaugeValueText.js +69 -0
  112. package/modern/Gauge/gaugeClasses.js +7 -0
  113. package/modern/Gauge/index.js +7 -0
  114. package/modern/Gauge/utils.js +68 -0
  115. package/modern/LineChart/LineChart.js +31 -5
  116. package/modern/PieChart/PieArc.js +9 -9
  117. package/modern/PieChart/PieArcLabelPlot.js +13 -13
  118. package/modern/PieChart/PieChart.js +22 -0
  119. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -66
  120. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +66 -0
  121. package/modern/ScatterChart/ScatterChart.js +25 -0
  122. package/modern/hooks/useTicks.js +2 -3
  123. package/modern/index.js +3 -1
  124. package/package.json +4 -4
@@ -26,14 +26,36 @@ export interface PieChartProps extends Omit<ResponsiveChartContainerProps, 'seri
26
26
  * @default null
27
27
  */
28
28
  leftAxis?: null | string | ChartsYAxisProps;
29
+ /**
30
+ * The series to display in the pie chart.
31
+ */
29
32
  series: MakeOptional<PieSeriesType<MakeOptional<PieValueType, 'id'>>, 'type'>[];
33
+ /**
34
+ * The configuration of the tooltip.
35
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
36
+ * @default { trigger: 'item' }
37
+ */
30
38
  tooltip?: ChartsTooltipProps;
39
+ /**
40
+ * The configuration of axes highlight.
41
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
42
+ * @default { x: 'none', y: 'none' }
43
+ */
31
44
  axisHighlight?: ChartsAxisHighlightProps;
32
45
  /**
46
+ * The props of the legend.
47
+ * @default { direction: 'column', position: { vertical: 'middle', horizontal: 'right' } }
33
48
  * @deprecated Consider using `slotProps.legend` instead.
34
49
  */
35
50
  legend?: ChartsLegendProps;
51
+ /**
52
+ * Callback fired when a pie arc is clicked.
53
+ */
36
54
  onItemClick?: PiePlotProps['onItemClick'];
55
+ /**
56
+ * Overridable component slots.
57
+ * @default {}
58
+ */
37
59
  slots?: PieChartSlots;
38
60
  /**
39
61
  * The props used for each component slot.
@@ -109,6 +109,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
109
109
  // | These PropTypes are generated from the TypeScript type definitions |
110
110
  // | To update them edit the TypeScript types and run "yarn proptypes" |
111
111
  // ----------------------------------------------------------------------
112
+ /**
113
+ * The configuration of axes highlight.
114
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
115
+ * @default { x: 'none', y: 'none' }
116
+ */
112
117
  axisHighlight: _propTypes.default.shape({
113
118
  x: _propTypes.default.oneOf(['band', 'line', 'none']),
114
119
  y: _propTypes.default.oneOf(['band', 'line', 'none'])
@@ -191,6 +196,8 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
191
196
  tickSize: _propTypes.default.number
192
197
  }), _propTypes.default.string]),
193
198
  /**
199
+ * The props of the legend.
200
+ * @default { direction: 'column', position: { vertical: 'middle', horizontal: 'right' } }
194
201
  * @deprecated Consider using `slotProps.legend` instead.
195
202
  */
196
203
  legend: _propTypes.default.shape({
@@ -216,6 +223,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
216
223
  right: _propTypes.default.number,
217
224
  top: _propTypes.default.number
218
225
  }),
226
+ /**
227
+ * Callback fired when a pie arc is clicked.
228
+ */
219
229
  onItemClick: _propTypes.default.func,
220
230
  /**
221
231
  * Indicate which axis to display the right of the charts.
@@ -244,6 +254,9 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
244
254
  tickNumber: _propTypes.default.number,
245
255
  tickSize: _propTypes.default.number
246
256
  }), _propTypes.default.string]),
257
+ /**
258
+ * The series to display in the pie chart.
259
+ */
247
260
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
248
261
  /**
249
262
  * If `true`, animations are skipped.
@@ -255,9 +268,18 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
255
268
  * @default {}
256
269
  */
257
270
  slotProps: _propTypes.default.object,
271
+ /**
272
+ * Overridable component slots.
273
+ * @default {}
274
+ */
258
275
  slots: _propTypes.default.object,
259
276
  sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
260
277
  title: _propTypes.default.string,
278
+ /**
279
+ * The configuration of the tooltip.
280
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
281
+ * @default { trigger: 'item' }
282
+ */
261
283
  tooltip: _propTypes.default.shape({
262
284
  axisContent: _propTypes.default.elementType,
263
285
  classes: _propTypes.default.object,
@@ -9,77 +9,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
- var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
13
- var _ownerWindow = _interopRequireDefault(require("@mui/utils/ownerWindow"));
14
12
  var _styles = require("@mui/material/styles");
15
13
  var _ChartContainer = require("../ChartContainer");
14
+ var _useChartContainerDimensions = require("./useChartContainerDimensions");
16
15
  var _jsxRuntime = require("react/jsx-runtime");
17
16
  const _excluded = ["width", "height"];
18
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
- const useChartDimensions = (inWidth, inHeight) => {
21
- const rootRef = React.useRef(null);
22
- const displayError = React.useRef(false);
23
- const [width, setWidth] = React.useState(0);
24
- const [height, setHeight] = React.useState(0);
25
-
26
- // Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
27
- const computeSize = React.useCallback(() => {
28
- const mainEl = rootRef?.current;
29
- if (!mainEl) {
30
- return;
31
- }
32
- const win = (0, _ownerWindow.default)(mainEl);
33
- const computedStyle = win.getComputedStyle(mainEl);
34
- const newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
35
- const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
36
- setWidth(newWidth);
37
- setHeight(newHeight);
38
- }, []);
39
- React.useEffect(() => {
40
- // Ensure the error detection occurs after the first rendering.
41
- displayError.current = true;
42
- }, []);
43
- (0, _useEnhancedEffect.default)(() => {
44
- if (inWidth !== undefined && inHeight !== undefined) {
45
- return () => {};
46
- }
47
- computeSize();
48
- const elementToObserve = rootRef.current;
49
- if (typeof ResizeObserver === 'undefined') {
50
- return () => {};
51
- }
52
- let animationFrame;
53
- const observer = new ResizeObserver(() => {
54
- // See https://github.com/mui/mui-x/issues/8733
55
- animationFrame = requestAnimationFrame(() => {
56
- computeSize();
57
- });
58
- });
59
- if (elementToObserve) {
60
- observer.observe(elementToObserve);
61
- }
62
- return () => {
63
- if (animationFrame) {
64
- window.cancelAnimationFrame(animationFrame);
65
- }
66
- if (elementToObserve) {
67
- observer.unobserve(elementToObserve);
68
- }
69
- };
70
- }, [computeSize, inHeight, inWidth]);
71
- if (process.env.NODE_ENV !== 'production') {
72
- if (displayError.current && inWidth === undefined && width === 0) {
73
- console.error(`MUI X Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
74
- displayError.current = false;
75
- }
76
- if (displayError.current && inHeight === undefined && height === 0) {
77
- console.error(`MUI X Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
78
- displayError.current = false;
79
- }
80
- }
81
- return [rootRef, inWidth ?? width, inHeight ?? height];
82
- };
83
19
  const ResizableContainer = (0, _styles.styled)('div', {
84
20
  name: 'MuiResponsiveChart',
85
21
  slot: 'Container'
@@ -106,7 +42,7 @@ const ResponsiveChartContainer = exports.ResponsiveChartContainer = /*#__PURE__*
106
42
  height: inHeight
107
43
  } = props,
108
44
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
109
- const [containerRef, width, height] = useChartDimensions(inWidth, inHeight);
45
+ const [containerRef, width, height] = (0, _useChartContainerDimensions.useChartContainerDimensions)(inWidth, inHeight);
110
46
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ResizableContainer, {
111
47
  ref: containerRef,
112
48
  ownerState: {
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number) => [React.RefObject<HTMLDivElement>, number, number];
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.useChartContainerDimensions = void 0;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
10
+ var _ownerWindow = _interopRequireDefault(require("@mui/utils/ownerWindow"));
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
+ const useChartContainerDimensions = (inWidth, inHeight) => {
14
+ const rootRef = React.useRef(null);
15
+ const displayError = React.useRef(false);
16
+ const [width, setWidth] = React.useState(0);
17
+ const [height, setHeight] = React.useState(0);
18
+
19
+ // Adaptation of the `computeSizeAndPublishResizeEvent` from the grid.
20
+ const computeSize = React.useCallback(() => {
21
+ const mainEl = rootRef?.current;
22
+ if (!mainEl) {
23
+ return;
24
+ }
25
+ const win = (0, _ownerWindow.default)(mainEl);
26
+ const computedStyle = win.getComputedStyle(mainEl);
27
+ const newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
28
+ const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
29
+ setWidth(newWidth);
30
+ setHeight(newHeight);
31
+ }, []);
32
+ React.useEffect(() => {
33
+ // Ensure the error detection occurs after the first rendering.
34
+ displayError.current = true;
35
+ }, []);
36
+ (0, _useEnhancedEffect.default)(() => {
37
+ if (inWidth !== undefined && inHeight !== undefined) {
38
+ return () => {};
39
+ }
40
+ computeSize();
41
+ const elementToObserve = rootRef.current;
42
+ if (typeof ResizeObserver === 'undefined') {
43
+ return () => {};
44
+ }
45
+ let animationFrame;
46
+ const observer = new ResizeObserver(() => {
47
+ // See https://github.com/mui/mui-x/issues/8733
48
+ animationFrame = requestAnimationFrame(() => {
49
+ computeSize();
50
+ });
51
+ });
52
+ if (elementToObserve) {
53
+ observer.observe(elementToObserve);
54
+ }
55
+ return () => {
56
+ if (animationFrame) {
57
+ window.cancelAnimationFrame(animationFrame);
58
+ }
59
+ if (elementToObserve) {
60
+ observer.unobserve(elementToObserve);
61
+ }
62
+ };
63
+ }, [computeSize, inHeight, inWidth]);
64
+ if (process.env.NODE_ENV !== 'production') {
65
+ if (displayError.current && inWidth === undefined && width === 0) {
66
+ console.error(`MUI X Charts: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
67
+ displayError.current = false;
68
+ }
69
+ if (displayError.current && inHeight === undefined && height === 0) {
70
+ console.error(`MUI X Charts: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
71
+ displayError.current = false;
72
+ }
73
+ }
74
+ return [rootRef, inWidth ?? width, inHeight ?? height];
75
+ };
76
+ exports.useChartContainerDimensions = useChartContainerDimensions;
@@ -9,14 +9,32 @@ import { ChartsLegendProps, ChartsLegendSlotProps, ChartsLegendSlots } from '../
9
9
  import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
10
10
  import { ChartsAxisSlots, ChartsAxisSlotProps } from '../models/axis';
11
11
  import { ChartsVoronoiHandlerProps } from '../ChartsVoronoiHandler/ChartsVoronoiHandler';
12
+ import { ChartsGridProps } from '../ChartsGrid';
12
13
  export interface ScatterChartSlots extends ChartsAxisSlots, ScatterPlotSlots, ChartsLegendSlots, ChartsTooltipSlots {
13
14
  }
14
15
  export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotSlotProps, ChartsLegendSlotProps, ChartsTooltipSlotProps {
15
16
  }
16
17
  export interface ScatterChartProps extends Omit<ResponsiveChartContainerProps, 'series'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsVoronoiHandlerProps, 'onItemClick'> {
18
+ /**
19
+ * The series to display in the scatter chart.
20
+ */
17
21
  series: MakeOptional<ScatterSeriesType, 'type'>[];
22
+ /**
23
+ * The configuration of the tooltip.
24
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
25
+ * @default { trigger: 'item' }
26
+ */
18
27
  tooltip?: ChartsTooltipProps;
28
+ /**
29
+ * The configuration of axes highlight.
30
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
31
+ * @default { x: 'none', y: 'none' }
32
+ */
19
33
  axisHighlight?: ChartsAxisHighlightProps;
34
+ /**
35
+ * Option to display a cartesian grid in the background.
36
+ */
37
+ grid?: Pick<ChartsGridProps, 'vertical' | 'horizontal'>;
20
38
  /**
21
39
  * If true, the interaction will not use the Voronoi cell and fall back to hover events.
22
40
  * @default false
@@ -15,6 +15,7 @@ var _ChartsTooltip = require("../ChartsTooltip");
15
15
  var _ChartsLegend = require("../ChartsLegend");
16
16
  var _ChartsAxisHighlight = require("../ChartsAxisHighlight");
17
17
  var _ChartsVoronoiHandler = require("../ChartsVoronoiHandler/ChartsVoronoiHandler");
18
+ var _ChartsGrid = require("../ChartsGrid");
18
19
  var _jsxRuntime = require("react/jsx-runtime");
19
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -43,6 +44,7 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
43
44
  margin,
44
45
  colors,
45
46
  sx,
47
+ grid,
46
48
  topAxis,
47
49
  leftAxis,
48
50
  rightAxis,
@@ -74,6 +76,9 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
74
76
  bottomAxis: bottomAxis,
75
77
  slots: slots,
76
78
  slotProps: slotProps
79
+ }), grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, {
80
+ vertical: grid.vertical,
81
+ horizontal: grid.horizontal
77
82
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, {
78
83
  slots: slots,
79
84
  slotProps: slotProps,
@@ -94,6 +99,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
94
99
  // | These PropTypes are generated from the TypeScript type definitions |
95
100
  // | To update them edit the TypeScript types and run "yarn proptypes" |
96
101
  // ----------------------------------------------------------------------
102
+ /**
103
+ * The configuration of axes highlight.
104
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
105
+ * @default { x: 'none', y: 'none' }
106
+ */
97
107
  axisHighlight: _propTypes.default.shape({
98
108
  x: _propTypes.default.oneOf(['band', 'line', 'none']),
99
109
  y: _propTypes.default.oneOf(['band', 'line', 'none'])
@@ -148,6 +158,13 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
148
158
  * @default false
149
159
  */
150
160
  disableVoronoi: _propTypes.default.bool,
161
+ /**
162
+ * Option to display a cartesian grid in the background.
163
+ */
164
+ grid: _propTypes.default.shape({
165
+ horizontal: _propTypes.default.bool,
166
+ vertical: _propTypes.default.bool
167
+ }),
151
168
  /**
152
169
  * The height of the chart in px. If not defined, it takes the height of the parent element.
153
170
  * @default undefined
@@ -239,6 +256,9 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
239
256
  tickNumber: _propTypes.default.number,
240
257
  tickSize: _propTypes.default.number
241
258
  }), _propTypes.default.string]),
259
+ /**
260
+ * The series to display in the scatter chart.
261
+ */
242
262
  series: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
243
263
  /**
244
264
  * The props used for each component slot.
@@ -252,6 +272,11 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
252
272
  slots: _propTypes.default.object,
253
273
  sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
254
274
  title: _propTypes.default.string,
275
+ /**
276
+ * The configuration of the tooltip.
277
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
278
+ * @default { trigger: 'item' }
279
+ */
255
280
  tooltip: _propTypes.default.shape({
256
281
  axisContent: _propTypes.default.elementType,
257
282
  classes: _propTypes.default.object,
@@ -10,6 +10,7 @@ import { ChartsTooltip } from '../ChartsTooltip';
10
10
  import { ChartsLegend } from '../ChartsLegend';
11
11
  import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
12
12
  import { ChartsClipPath } from '../ChartsClipPath';
13
+ import { ChartsGrid } from '../ChartsGrid';
13
14
  import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
14
15
  import { jsx as _jsx } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -39,6 +40,7 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
39
40
  tooltip,
40
41
  axisHighlight,
41
42
  legend,
43
+ grid,
42
44
  topAxis,
43
45
  leftAxis,
44
46
  rightAxis,
@@ -89,6 +91,9 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
89
91
  disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
90
92
  children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
91
93
  onAxisClick: onAxisClick
94
+ }), grid && /*#__PURE__*/_jsx(ChartsGrid, {
95
+ vertical: grid.vertical,
96
+ horizontal: grid.horizontal
92
97
  }), /*#__PURE__*/_jsx("g", {
93
98
  clipPath: `url(#${clipPathId})`,
94
99
  children: /*#__PURE__*/_jsx(BarPlot, {
@@ -121,11 +126,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
121
126
  // | To update them edit the TypeScript types and run "yarn proptypes" |
122
127
  // ----------------------------------------------------------------------
123
128
  /**
124
- * Object `{ x, y }` that defines how the charts highlight the mouse position along the x- and y-axes.
125
- * The two properties accept the following values:
126
- * - 'none': display nothing.
127
- * - 'line': display a line at the current mouse position.
128
- * - 'band': display a band at the current mouse position. Only available with band scale.
129
+ * The configuration of axes highlight.
130
+ * Default is set to 'band' in the bar direction.
131
+ * Depends on `layout` prop.
132
+ * @see See {@link https://mui.com/x/react-charts/tooltip/#highlights highlight docs} for more details.
129
133
  */
130
134
  axisHighlight: PropTypes.shape({
131
135
  x: PropTypes.oneOf(['band', 'line', 'none']),
@@ -176,11 +180,22 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
176
180
  * @default false
177
181
  */
178
182
  disableAxisListener: PropTypes.bool,
183
+ /**
184
+ * Option to display a cartesian grid in the background.
185
+ */
186
+ grid: PropTypes.shape({
187
+ horizontal: PropTypes.bool,
188
+ vertical: PropTypes.bool
189
+ }),
179
190
  /**
180
191
  * The height of the chart in px. If not defined, it takes the height of the parent element.
181
192
  * @default undefined
182
193
  */
183
194
  height: PropTypes.number,
195
+ /**
196
+ * The direction of the bar elements.
197
+ * @default 'vertical'
198
+ */
184
199
  layout: PropTypes.oneOf(['horizontal', 'vertical']),
185
200
  /**
186
201
  * Indicate which axis to display the left of the charts.
@@ -275,6 +290,9 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
275
290
  tickNumber: PropTypes.number,
276
291
  tickSize: PropTypes.number
277
292
  }), PropTypes.string]),
293
+ /**
294
+ * The series to display in the bar chart.
295
+ */
278
296
  series: PropTypes.arrayOf(PropTypes.object).isRequired,
279
297
  /**
280
298
  * If `true`, animations are skipped.
@@ -293,6 +311,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
293
311
  slots: PropTypes.object,
294
312
  sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
295
313
  title: PropTypes.string,
314
+ /**
315
+ * The configuration of the tooltip.
316
+ * @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
317
+ */
296
318
  tooltip: PropTypes.shape({
297
319
  axisContent: PropTypes.elementType,
298
320
  classes: PropTypes.object,
@@ -0,0 +1,121 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
+ const _excluded = ["vertical", "horizontal"];
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import composeClasses from '@mui/utils/composeClasses';
7
+ import { styled } from '@mui/material/styles';
8
+ import { CartesianContext } from '../context/CartesianContextProvider';
9
+ import { useTicks } from '../hooks/useTicks';
10
+ import { getChartsGridUtilityClass, chartsGridClasses } from './chartsGridClasses';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ const GridRoot = styled('g', {
14
+ name: 'MuiChartsGrid',
15
+ slot: 'Root',
16
+ overridesResolver: (props, styles) => styles.root
17
+ })(({
18
+ theme
19
+ }) => ({
20
+ [`& .${chartsGridClasses.line}`]: {
21
+ stroke: (theme.vars || theme).palette.divider,
22
+ shapeRendering: 'crispEdges',
23
+ strokeWidth: 1
24
+ }
25
+ }));
26
+ const useUtilityClasses = ({
27
+ classes
28
+ }) => {
29
+ const slots = {
30
+ root: ['root'],
31
+ verticalLine: ['line', 'verticalLine'],
32
+ horizontalLine: ['line', 'horizontalLine']
33
+ };
34
+ return composeClasses(slots, getChartsGridUtilityClass, classes);
35
+ };
36
+ /**
37
+ * Demos:
38
+ *
39
+ * - [Axis](https://mui.com/x/react-charts/axis/)
40
+ *
41
+ * API:
42
+ *
43
+ * - [ChartsGrid API](https://mui.com/x/api/charts/charts-axis/)
44
+ */
45
+ function ChartsGrid(props) {
46
+ const {
47
+ vertical,
48
+ horizontal
49
+ } = props,
50
+ other = _objectWithoutPropertiesLoose(props, _excluded);
51
+ const {
52
+ xAxis,
53
+ xAxisIds,
54
+ yAxis,
55
+ yAxisIds
56
+ } = React.useContext(CartesianContext);
57
+ const classes = useUtilityClasses(props);
58
+ const horizontalAxisId = yAxisIds[0];
59
+ const verticalAxisId = xAxisIds[0];
60
+ const {
61
+ scale: xScale,
62
+ tickNumber: xTickNumber,
63
+ tickInterval: xTickInterval
64
+ } = xAxis[verticalAxisId];
65
+ const {
66
+ scale: yScale,
67
+ tickNumber: yTickNumber,
68
+ tickInterval: yTickInterval
69
+ } = yAxis[horizontalAxisId];
70
+ const xTicks = useTicks({
71
+ scale: xScale,
72
+ tickNumber: xTickNumber,
73
+ tickInterval: xTickInterval
74
+ });
75
+ const yTicks = useTicks({
76
+ scale: yScale,
77
+ tickNumber: yTickNumber,
78
+ tickInterval: yTickInterval
79
+ });
80
+ return /*#__PURE__*/_jsxs(GridRoot, _extends({}, other, {
81
+ className: classes.root,
82
+ children: [vertical && xTicks.map(({
83
+ formattedValue,
84
+ offset
85
+ }) => /*#__PURE__*/_jsx("line", {
86
+ y1: yScale.range()[0],
87
+ y2: yScale.range()[1],
88
+ x1: offset,
89
+ x2: offset,
90
+ className: classes.verticalLine
91
+ }, formattedValue)), horizontal && yTicks.map(({
92
+ formattedValue,
93
+ offset
94
+ }) => /*#__PURE__*/_jsx("line", {
95
+ y1: offset,
96
+ y2: offset,
97
+ x1: xScale.range()[0],
98
+ x2: xScale.range()[1],
99
+ className: classes.horizontalLine
100
+ }, formattedValue))]
101
+ }));
102
+ }
103
+ process.env.NODE_ENV !== "production" ? ChartsGrid.propTypes = {
104
+ // ----------------------------- Warning --------------------------------
105
+ // | These PropTypes are generated from the TypeScript type definitions |
106
+ // | To update them edit the TypeScript types and run "yarn proptypes" |
107
+ // ----------------------------------------------------------------------
108
+ /**
109
+ * Override or extend the styles applied to the component.
110
+ */
111
+ classes: PropTypes.object,
112
+ /**
113
+ * Displays horizontal grid.
114
+ */
115
+ horizontal: PropTypes.bool,
116
+ /**
117
+ * Displays vertical grid.
118
+ */
119
+ vertical: PropTypes.bool
120
+ } : void 0;
121
+ export { ChartsGrid };
@@ -0,0 +1,6 @@
1
+ import generateUtilityClass from '@mui/utils/generateUtilityClass';
2
+ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
3
+ export function getChartsGridUtilityClass(slot) {
4
+ return generateUtilityClass('MuiChartsGrid', slot);
5
+ }
6
+ export const chartsGridClasses = generateUtilityClasses('MuiChartsGrid', ['root', 'line', 'horizontalLine', 'verticalLine']);
@@ -0,0 +1,2 @@
1
+ export * from './ChartsGrid';
2
+ export * from './chartsGridClasses';
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className"];
3
+ const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className", "title", "desc"];
4
4
  import { styled } from '@mui/material/styles';
5
5
  import PropTypes from 'prop-types';
6
6
  import * as React from 'react';
@@ -17,7 +17,9 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
17
17
  width,
18
18
  height,
19
19
  viewBox,
20
- disableAxisListener = false
20
+ disableAxisListener = false,
21
+ title,
22
+ desc
21
23
  } = props,
22
24
  other = _objectWithoutPropertiesLoose(props, _excluded);
23
25
  const svgView = _extends({
@@ -34,9 +36,9 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
34
36
  ref: ref
35
37
  }, other, {
36
38
  children: [/*#__PURE__*/_jsx("title", {
37
- children: props.title
39
+ children: title
38
40
  }), /*#__PURE__*/_jsx("desc", {
39
- children: props.desc
41
+ children: desc
40
42
  }), children]
41
43
  }));
42
44
  });
@@ -8,7 +8,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
9
9
  import { CartesianContext } from '../context/CartesianContextProvider';
10
10
  import { DrawingContext } from '../context/DrawingProvider';
11
- import useTicks from '../hooks/useTicks';
11
+ import { useTicks } from '../hooks/useTicks';
12
12
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';
13
13
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
14
14
  import { ChartsText } from '../ChartsText';
@@ -8,7 +8,7 @@ import { unstable_composeClasses as composeClasses } from '@mui/utils';
8
8
  import { useThemeProps, useTheme } from '@mui/material/styles';
9
9
  import { CartesianContext } from '../context/CartesianContextProvider';
10
10
  import { DrawingContext } from '../context/DrawingProvider';
11
- import useTicks from '../hooks/useTicks';
11
+ import { useTicks } from '../hooks/useTicks';
12
12
  import { AxisRoot } from '../internals/components/AxisSharedComponents';
13
13
  import { ChartsText } from '../ChartsText';
14
14
  import { getAxisUtilityClass } from '../ChartsAxis/axisClasses';