@mui/x-charts 8.6.0 → 8.7.0

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 (140) hide show
  1. package/BarChart/BarPlot.js +11 -150
  2. package/BarChart/useBarPlotData.d.ts +8 -0
  3. package/BarChart/useBarPlotData.js +146 -0
  4. package/CHANGELOG.md +104 -1
  5. package/ChartContainer/ChartContainer.d.ts +1 -21
  6. package/ChartContainer/ChartContainer.js +0 -8
  7. package/ChartContainer/index.d.ts +8 -1
  8. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  9. package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
  10. package/ChartsReferenceLine/ChartsXReferenceLine.js +48 -1
  11. package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
  12. package/ChartsReferenceLine/ChartsYReferenceLine.js +48 -1
  13. package/ChartsReferenceLine/index.d.ts +3 -1
  14. package/ChartsSurface/ChartsSurface.js +2 -1
  15. package/ChartsTooltip/ChartsTooltipContainer.js +6 -3
  16. package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  17. package/ChartsTooltip/utils.js +18 -29
  18. package/LineChart/AreaPlot.js +5 -115
  19. package/LineChart/LinePlot.js +5 -99
  20. package/LineChart/useAreaPlotData.d.ts +12 -0
  21. package/LineChart/useAreaPlotData.js +125 -0
  22. package/LineChart/useLinePlotData.d.ts +11 -0
  23. package/LineChart/useLinePlotData.js +108 -0
  24. package/ScatterChart/Scatter.js +22 -48
  25. package/ScatterChart/useScatterPlotData.d.ts +8 -0
  26. package/ScatterChart/useScatterPlotData.js +33 -0
  27. package/context/ChartApi.d.ts +22 -0
  28. package/context/ChartApi.js +5 -0
  29. package/context/ChartProvider/ChartContext.js +1 -0
  30. package/context/index.d.ts +2 -1
  31. package/context/useChartApiContext.d.ts +1 -1
  32. package/esm/BarChart/BarPlot.js +12 -152
  33. package/esm/BarChart/useBarPlotData.d.ts +8 -0
  34. package/esm/BarChart/useBarPlotData.js +139 -0
  35. package/esm/ChartContainer/ChartContainer.d.ts +1 -21
  36. package/esm/ChartContainer/ChartContainer.js +0 -8
  37. package/esm/ChartContainer/index.d.ts +8 -1
  38. package/esm/ChartContainer/index.js +6 -1
  39. package/esm/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  40. package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
  41. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +47 -0
  42. package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
  43. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +47 -0
  44. package/esm/ChartsReferenceLine/index.d.ts +3 -1
  45. package/esm/ChartsReferenceLine/index.js +2 -1
  46. package/esm/ChartsSurface/ChartsSurface.js +2 -1
  47. package/esm/ChartsTooltip/ChartsTooltipContainer.js +6 -3
  48. package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
  49. package/esm/ChartsTooltip/utils.js +18 -29
  50. package/esm/LineChart/AreaPlot.js +5 -115
  51. package/esm/LineChart/LinePlot.js +5 -99
  52. package/esm/LineChart/useAreaPlotData.d.ts +12 -0
  53. package/esm/LineChart/useAreaPlotData.js +118 -0
  54. package/esm/LineChart/useLinePlotData.d.ts +11 -0
  55. package/esm/LineChart/useLinePlotData.js +101 -0
  56. package/esm/ScatterChart/Scatter.js +23 -49
  57. package/esm/ScatterChart/useScatterPlotData.d.ts +8 -0
  58. package/esm/ScatterChart/useScatterPlotData.js +26 -0
  59. package/esm/context/ChartApi.d.ts +22 -0
  60. package/esm/context/ChartApi.js +1 -0
  61. package/esm/context/ChartProvider/ChartContext.js +2 -0
  62. package/esm/context/index.d.ts +2 -1
  63. package/esm/context/useChartApiContext.d.ts +1 -1
  64. package/esm/hooks/useInteractionItemProps.d.ts +14 -9
  65. package/esm/hooks/useInteractionItemProps.js +28 -28
  66. package/esm/index.d.ts +2 -1
  67. package/esm/index.js +2 -2
  68. package/esm/internals/index.d.ts +5 -0
  69. package/esm/internals/index.js +5 -0
  70. package/esm/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
  71. package/esm/internals/plugins/corePlugins/corePlugins.js +2 -1
  72. package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
  73. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -29
  74. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
  75. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +0 -6
  76. package/esm/internals/plugins/corePlugins/useChartId/useChartId.js +2 -0
  77. package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  78. package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
  79. package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.js +1 -0
  80. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
  81. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +77 -0
  82. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
  83. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +1 -0
  84. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
  85. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
  86. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +44 -33
  87. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +5 -5
  88. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +7 -7
  89. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
  90. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
  91. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +34 -34
  92. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
  93. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +6 -6
  94. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +47 -30
  95. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
  96. package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
  97. package/esm/internals/store/useCharts.d.ts +1 -1
  98. package/esm/locales/elGR.d.ts +19 -0
  99. package/esm/locales/elGR.js +15 -0
  100. package/esm/locales/index.d.ts +1 -0
  101. package/esm/locales/index.js +1 -0
  102. package/hooks/useInteractionItemProps.d.ts +14 -9
  103. package/hooks/useInteractionItemProps.js +29 -28
  104. package/index.d.ts +2 -1
  105. package/index.js +37 -11
  106. package/internals/index.d.ts +5 -0
  107. package/internals/index.js +44 -0
  108. package/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
  109. package/internals/plugins/corePlugins/corePlugins.js +2 -1
  110. package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
  111. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -29
  112. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
  113. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +0 -6
  114. package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -0
  115. package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
  116. package/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
  117. package/internals/plugins/corePlugins/useChartInteractionListener/index.js +12 -0
  118. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
  119. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +84 -0
  120. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
  121. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +5 -0
  122. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
  123. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
  124. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +44 -33
  125. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +5 -5
  126. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +7 -7
  127. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
  128. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
  129. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +34 -34
  130. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
  131. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +6 -6
  132. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +46 -30
  133. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
  134. package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
  135. package/internals/store/useCharts.d.ts +1 -1
  136. package/locales/elGR.d.ts +19 -0
  137. package/locales/elGR.js +21 -0
  138. package/locales/index.d.ts +1 -0
  139. package/locales/index.js +11 -0
  140. package/package.json +3 -2
@@ -6,14 +6,6 @@ import PropTypes from 'prop-types';
6
6
  import { ChartDataProvider } from "../ChartDataProvider/index.js";
7
7
  import { useChartContainerProps } from "./useChartContainerProps.js";
8
8
  import { ChartsSurface } from "../ChartsSurface/index.js";
9
-
10
- /**
11
- * The API of the chart `apiRef` object.
12
- * The chart type can be passed as the first generic parameter to narrow down the API to the specific chart type.
13
- * @example ChartApi<'bar'>
14
- * If the chart is being created using composition, the `composition` value can be used.
15
- * @example ChartApi<'composition'>
16
- */
17
9
  import { jsx as _jsx } from "react/jsx-runtime";
18
10
  /**
19
11
  * It sets up the data providers as well as the `<svg>` for the chart.
@@ -1 +1,8 @@
1
- export * from "./ChartContainer.js";
1
+ import type { ChartApi as ChartApiOriginal, PluginsPerSeriesType } from "../context/ChartApi.js";
2
+ import type { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
3
+ import type { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
4
+ export * from "./ChartContainer.js";
5
+ /**
6
+ * @deprecated Use `ChartApi` from `@mui/x-charts/context` instead.
7
+ */
8
+ export type ChartApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartApiOriginal<TSeries, TSignatures>;
@@ -1 +1,6 @@
1
- export * from "./ChartContainer.js";
1
+ export * from "./ChartContainer.js";
2
+
3
+ /**
4
+ * @deprecated Use `ChartApi` from `@mui/x-charts/context` instead.
5
+ */
6
+ export {};
@@ -7,4 +7,4 @@ declare function ChartsReferenceLine(props: ChartsReferenceLineProps): React.JSX
7
7
  declare namespace ChartsReferenceLine {
8
8
  var propTypes: any;
9
9
  }
10
- export { ChartsReferenceLine };
10
+ export { ChartsReferenceLine, type ChartsReferenceLineProps };
@@ -10,4 +10,7 @@ export type ChartsXReferenceLineProps<TValue extends string | number | Date = st
10
10
  };
11
11
  export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
12
12
  declare function ChartsXReferenceLine(props: ChartsXReferenceLineProps): React.JSX.Element | null;
13
+ declare namespace ChartsXReferenceLine {
14
+ var propTypes: any;
15
+ }
13
16
  export { ChartsXReferenceLine };
@@ -2,6 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
5
6
  import composeClasses from '@mui/utils/composeClasses';
6
7
  import { warnOnce } from '@mui/x-internals/warning';
7
8
  import { useDrawingArea, useXScale } from "../hooks/index.js";
@@ -99,4 +100,50 @@ function ChartsXReferenceLine(props) {
99
100
  }))]
100
101
  });
101
102
  }
103
+ process.env.NODE_ENV !== "production" ? ChartsXReferenceLine.propTypes = {
104
+ // ----------------------------- Warning --------------------------------
105
+ // | These PropTypes are generated from the TypeScript type definitions |
106
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
107
+ // ----------------------------------------------------------------------
108
+ /**
109
+ * The id of the axis used for the reference value.
110
+ * @default The `id` of the first defined axis.
111
+ */
112
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
113
+ /**
114
+ * Override or extend the styles applied to the component.
115
+ */
116
+ classes: PropTypes.object,
117
+ /**
118
+ * The label to display along the reference line.
119
+ */
120
+ label: PropTypes.string,
121
+ /**
122
+ * The alignment if the label is in the chart drawing area.
123
+ * @default 'middle'
124
+ */
125
+ labelAlign: PropTypes.oneOf(['end', 'middle', 'start']),
126
+ /**
127
+ * The style applied to the label.
128
+ */
129
+ labelStyle: PropTypes.object,
130
+ /**
131
+ * The style applied to the line.
132
+ */
133
+ lineStyle: PropTypes.object,
134
+ /**
135
+ * Additional space around the label in px.
136
+ * Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
137
+ * @default 5
138
+ */
139
+ spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
140
+ x: PropTypes.number,
141
+ y: PropTypes.number
142
+ })]),
143
+ /**
144
+ * The x value associated with the reference line.
145
+ * If defined the reference line will be vertical.
146
+ */
147
+ x: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
148
+ } : void 0;
102
149
  export { ChartsXReferenceLine };
@@ -10,4 +10,7 @@ export type ChartsYReferenceLineProps<TValue extends string | number | Date = st
10
10
  };
11
11
  export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
12
12
  declare function ChartsYReferenceLine(props: ChartsYReferenceLineProps): React.JSX.Element | null;
13
+ declare namespace ChartsYReferenceLine {
14
+ var propTypes: any;
15
+ }
13
16
  export { ChartsYReferenceLine };
@@ -2,6 +2,7 @@
2
2
 
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
+ import PropTypes from 'prop-types';
5
6
  import composeClasses from '@mui/utils/composeClasses';
6
7
  import { warnOnce } from '@mui/x-internals/warning';
7
8
  import { useDrawingArea, useYScale } from "../hooks/index.js";
@@ -99,4 +100,50 @@ function ChartsYReferenceLine(props) {
99
100
  }))]
100
101
  });
101
102
  }
103
+ process.env.NODE_ENV !== "production" ? ChartsYReferenceLine.propTypes = {
104
+ // ----------------------------- Warning --------------------------------
105
+ // | These PropTypes are generated from the TypeScript type definitions |
106
+ // | To update them edit the TypeScript types and run "pnpm proptypes" |
107
+ // ----------------------------------------------------------------------
108
+ /**
109
+ * The id of the axis used for the reference value.
110
+ * @default The `id` of the first defined axis.
111
+ */
112
+ axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
113
+ /**
114
+ * Override or extend the styles applied to the component.
115
+ */
116
+ classes: PropTypes.object,
117
+ /**
118
+ * The label to display along the reference line.
119
+ */
120
+ label: PropTypes.string,
121
+ /**
122
+ * The alignment if the label is in the chart drawing area.
123
+ * @default 'middle'
124
+ */
125
+ labelAlign: PropTypes.oneOf(['end', 'middle', 'start']),
126
+ /**
127
+ * The style applied to the label.
128
+ */
129
+ labelStyle: PropTypes.object,
130
+ /**
131
+ * The style applied to the line.
132
+ */
133
+ lineStyle: PropTypes.object,
134
+ /**
135
+ * Additional space around the label in px.
136
+ * Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
137
+ * @default 5
138
+ */
139
+ spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
140
+ x: PropTypes.number,
141
+ y: PropTypes.number
142
+ })]),
143
+ /**
144
+ * The y value associated with the reference line.
145
+ * If defined the reference line will be horizontal.
146
+ */
147
+ y: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
148
+ } : void 0;
102
149
  export { ChartsYReferenceLine };
@@ -1,2 +1,4 @@
1
1
  export * from "./ChartsReferenceLine.js";
2
- export * from "./chartsReferenceLineClasses.js";
2
+ export * from "./chartsReferenceLineClasses.js";
3
+ export type { ChartsXReferenceLineProps } from "./ChartsXReferenceLine.js";
4
+ export type { ChartsYReferenceLineProps } from "./ChartsYReferenceLine.js";
@@ -1,2 +1,3 @@
1
1
  export * from "./ChartsReferenceLine.js";
2
- export * from "./chartsReferenceLineClasses.js";
2
+ export * from "./chartsReferenceLineClasses.js";
3
+ export {};
@@ -29,7 +29,8 @@ const ChartsSurfaceStyles = styled('svg', {
29
29
  overflow: 'hidden',
30
30
  // This prevents default touch actions when using the svg on mobile devices.
31
31
  // For example, prevent page scroll & zoom.
32
- touchAction: 'none'
32
+ touchAction: 'pan-y',
33
+ userSelect: 'none'
33
34
  }));
34
35
 
35
36
  /**
@@ -10,7 +10,7 @@ import useLazyRef from '@mui/utils/useLazyRef';
10
10
  import { styled, useThemeProps } from '@mui/material/styles';
11
11
  import Popper from '@mui/material/Popper';
12
12
  import NoSsr from '@mui/material/NoSsr';
13
- import { useSvgRef } from "../hooks/useSvgRef.js";
13
+ import { rafThrottle } from '@mui/x-internals/rafThrottle';
14
14
  import { useIsFineMainPointer, usePointerType } from "./utils.js";
15
15
  import { useUtilityClasses } from "./chartsTooltipClasses.js";
16
16
  import { useSelector } from "../internals/store/useSelector.js";
@@ -19,6 +19,7 @@ import { selectorChartsInteractionItemIsDefined } from "../internals/plugins/fea
19
19
  import { selectorChartsInteractionAxisTooltip } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
20
20
  import { selectorChartsInteractionPolarAxisTooltip } from "../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js";
21
21
  import { useAxisSystem } from "../hooks/useAxisSystem.js";
22
+ import { useSvgRef } from "../hooks/index.js";
22
23
  import { jsx as _jsx } from "react/jsx-runtime";
23
24
  const noAxis = () => false;
24
25
  const ChartsTooltipRoot = styled(Popper, {
@@ -51,8 +52,8 @@ function ChartsTooltipContainer(inProps) {
51
52
  children
52
53
  } = props,
53
54
  other = _objectWithoutPropertiesLoose(props, _excluded);
54
- const classes = useUtilityClasses(propClasses);
55
55
  const svgRef = useSvgRef();
56
+ const classes = useUtilityClasses(propClasses);
56
57
  const pointerType = usePointerType();
57
58
  const isFineMainPointer = useIsFineMainPointer();
58
59
  const popperRef = React.useRef(null);
@@ -68,19 +69,21 @@ function ChartsTooltipContainer(inProps) {
68
69
  if (element === null) {
69
70
  return () => {};
70
71
  }
72
+ const update = rafThrottle(() => popperRef.current?.update());
71
73
  const handlePointerEvent = event => {
72
74
  // eslint-disable-next-line react-compiler/react-compiler
73
75
  positionRef.current = {
74
76
  x: event.clientX,
75
77
  y: event.clientY
76
78
  };
77
- popperRef.current?.update();
79
+ update();
78
80
  };
79
81
  element.addEventListener('pointerdown', handlePointerEvent);
80
82
  element.addEventListener('pointermove', handlePointerEvent);
81
83
  return () => {
82
84
  element.removeEventListener('pointerdown', handlePointerEvent);
83
85
  element.removeEventListener('pointermove', handlePointerEvent);
86
+ update.clear();
84
87
  };
85
88
  }, [svgRef, positionRef]);
86
89
  const anchorEl = React.useMemo(() => ({
@@ -13,6 +13,6 @@ export declare const ChartsTooltipRow: import("@emotion/styled").StyledComponent
13
13
  /**
14
14
  * @ignore - internal component.
15
15
  */
16
- export declare const ChartsTooltipCell: import("@emotion/styled").StyledComponent<Pick<import("@mui/material/Typography").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "p" | "style" | "typography" | "zIndex" | "classes" | "border" | "boxShadow" | "fontWeight" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "color" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "className" | "children" | "sx" | "align" | "variant" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping">, "p" | "slot" | "style" | "title" | "ref" | "typography" | "zIndex" | "classes" | "border" | "boxShadow" | "fontWeight" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "color" | "columnGap" | "content" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "translate" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onResize" | "onResizeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "sx" | "align" | "variant" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
16
+ export declare const ChartsTooltipCell: import("@emotion/styled").StyledComponent<Pick<import("@mui/material/Typography").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "p" | "style" | "typography" | "zIndex" | "classes" | "border" | "boxShadow" | "fontWeight" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "color" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "className" | "children" | "sx" | "align" | "variant" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping">, "p" | "slot" | "style" | "title" | "ref" | "typography" | "zIndex" | "classes" | "border" | "boxShadow" | "fontWeight" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "color" | "columnGap" | "content" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "translate" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "sx" | "align" | "variant" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
17
17
  component?: React.ElementType;
18
18
  }, {}, {}>;
@@ -2,55 +2,44 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import useMediaQuery from '@mui/material/useMediaQuery';
5
+ import { useChartContext } from "../context/ChartProvider/index.js";
5
6
  import { useSvgRef } from "../hooks/index.js";
6
7
  /**
7
8
  * @deprecated We recommend using vanilla JS to let popper track mouse position.
8
9
  */
9
10
  export function useMouseTracker() {
10
- const svgRef = useSvgRef();
11
+ const {
12
+ instance
13
+ } = useChartContext();
11
14
 
12
15
  // Use a ref to avoid rerendering on every mousemove event.
13
16
  const [mousePosition, setMousePosition] = React.useState(null);
14
17
  React.useEffect(() => {
15
- const element = svgRef.current;
16
- if (element === null) {
17
- return () => {};
18
- }
19
- const controller = new AbortController();
20
- const handleOut = event => {
21
- if (event.pointerType !== 'mouse') {
18
+ const moveEndHandler = instance.addInteractionListener('moveEnd', event => {
19
+ if (!event.detail.activeGestures.pan) {
22
20
  setMousePosition(null);
23
21
  }
24
- };
25
- const handleMove = event => {
22
+ });
23
+ const gestureHandler = event => {
26
24
  setMousePosition({
27
- x: event.clientX,
28
- y: event.clientY,
29
- height: event.height,
30
- pointerType: event.pointerType
25
+ x: event.detail.centroid.x,
26
+ y: event.detail.centroid.y,
27
+ height: event.detail.srcEvent.height,
28
+ pointerType: event.detail.srcEvent.pointerType
31
29
  });
32
30
  };
33
- element.addEventListener('pointerdown', handleMove, {
34
- signal: controller.signal
35
- });
36
- element.addEventListener('pointermove', handleMove, {
37
- signal: controller.signal
38
- });
39
- element.addEventListener('pointerup', handleOut, {
40
- signal: controller.signal
41
- });
31
+ const moveHandler = instance.addInteractionListener('move', gestureHandler);
32
+ const panHandler = instance.addInteractionListener('pan', gestureHandler);
42
33
  return () => {
43
- // Calling `.abort()` removes ALL event listeners
44
- // For more info, see https://kettanaito.com/blog/dont-sleep-on-abort-controller
45
- controller.abort();
34
+ moveHandler.cleanup();
35
+ panHandler.cleanup();
36
+ moveEndHandler.cleanup();
46
37
  };
47
- }, [svgRef]);
38
+ }, [instance]);
48
39
  return mousePosition;
49
40
  }
50
41
  export function usePointerType() {
51
42
  const svgRef = useSvgRef();
52
-
53
- // Use a ref to avoid rerendering on every mousemove event.
54
43
  const [pointerType, setPointerType] = React.useState(null);
55
44
  React.useEffect(() => {
56
45
  const element = svgRef.current;
@@ -1,22 +1,16 @@
1
1
  'use client';
2
2
 
3
- import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
5
  const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import { styled } from '@mui/material/styles';
9
- import { area as d3Area } from '@mui/x-charts-vendor/d3-shape';
10
9
  import { AreaElement, areaElementClasses } from "./AreaElement.js";
11
- import { getValueToPositionMapper } from "../hooks/useScale.js";
12
- import { getCurveFactory } from "../internals/getCurve.js";
13
- import { isBandScale } from "../internals/isBandScale.js";
14
- import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
15
- import { useLineSeriesContext } from "../hooks/useLineSeries.js";
16
10
  import { useSkipAnimation } from "../hooks/useSkipAnimation.js";
17
- import { useChartGradientIdBuilder } from "../hooks/useChartGradientId.js";
18
11
  import { useXAxes, useYAxes } from "../hooks/useAxis.js";
19
12
  import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js";
13
+ import { useAreaPlotData } from "./useAreaPlotData.js";
20
14
  import { jsx as _jsx } from "react/jsx-runtime";
21
15
  const AreaPlotRoot = styled('g', {
22
16
  name: 'MuiAreaPlot',
@@ -27,117 +21,13 @@ const AreaPlotRoot = styled('g', {
27
21
  }
28
22
  });
29
23
  const useAggregatedData = () => {
30
- const seriesData = useLineSeriesContext();
31
24
  const {
32
- xAxis,
33
- xAxisIds
25
+ xAxis: xAxes
34
26
  } = useXAxes();
35
27
  const {
36
- yAxis,
37
- yAxisIds
28
+ yAxis: yAxes
38
29
  } = useYAxes();
39
- const getGradientId = useChartGradientIdBuilder();
40
-
41
- // This memo prevents odd line chart behavior when hydrating.
42
- const allData = React.useMemo(() => {
43
- if (seriesData === undefined) {
44
- return [];
45
- }
46
- const {
47
- series,
48
- stackingGroups
49
- } = seriesData;
50
- const defaultXAxisId = xAxisIds[0];
51
- const defaultYAxisId = yAxisIds[0];
52
- return stackingGroups.flatMap(({
53
- ids: groupIds
54
- }) => {
55
- return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
56
- .map(seriesId => {
57
- const {
58
- xAxisId = defaultXAxisId,
59
- yAxisId = defaultYAxisId,
60
- stackedData,
61
- data,
62
- connectNulls,
63
- baseline,
64
- curve,
65
- strictStepCurve
66
- } = series[seriesId];
67
- const xScale = xAxis[xAxisId].scale;
68
- const xPosition = getValueToPositionMapper(xScale);
69
- const yScale = yAxis[yAxisId].scale;
70
- const xData = xAxis[xAxisId].data;
71
- const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
72
- if (process.env.NODE_ENV !== 'production') {
73
- if (xData === undefined) {
74
- throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
75
- }
76
- if (xData.length < stackedData.length) {
77
- throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
78
- }
79
- }
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 => {
116
- if (typeof baseline === 'number') {
117
- return yScale(baseline);
118
- }
119
- if (baseline === 'max') {
120
- return yScale.range()[1];
121
- }
122
- if (baseline === 'min') {
123
- return yScale.range()[0];
124
- }
125
- const value = d.y && yScale(d.y[0]);
126
- if (Number.isNaN(value)) {
127
- return yScale.range()[0];
128
- }
129
- return value;
130
- }).y1(d => d.y && yScale(d.y[1]));
131
- const d = areaPath.curve(getCurveFactory(curve))(d3Data) || '';
132
- return _extends({}, series[seriesId], {
133
- gradientId,
134
- d,
135
- seriesId
136
- });
137
- });
138
- });
139
- }, [seriesData, xAxisIds, yAxisIds, xAxis, yAxis, getGradientId]);
140
- return allData;
30
+ return useAreaPlotData(xAxes, yAxes);
141
31
  };
142
32
 
143
33
  /**