@mui/x-charts 7.10.0 → 7.11.1

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 (299) hide show
  1. package/BarChart/BarChart.js +2 -2
  2. package/BarChart/BarElement.d.ts +2 -1
  3. package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
  4. package/BarChart/BarPlot.js +8 -8
  5. package/BarChart/checkScaleErrors.d.ts +4 -4
  6. package/BarChart/checkScaleErrors.js +11 -11
  7. package/BarChart/extremums.js +4 -1
  8. package/BarChart/formatter.js +2 -2
  9. package/BarChart/useBarChartProps.js +38 -33
  10. package/CHANGELOG.md +169 -0
  11. package/ChartContainer/ChartContainer.d.ts +28 -2
  12. package/ChartContainer/ChartContainer.js +25 -66
  13. package/ChartContainer/useChartContainerHooks.d.ts +1 -1
  14. package/ChartContainer/useChartContainerHooks.js +2 -2
  15. package/ChartContainer/useChartContainerProps.d.ts +86 -0
  16. package/ChartContainer/useChartContainerProps.js +95 -0
  17. package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
  18. package/ChartContainer/useDefaultizeAxis.js +29 -0
  19. package/ChartsAxis/ChartsAxis.js +4 -4
  20. package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  21. package/ChartsLegend/ChartsLegend.d.ts +3 -12
  22. package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
  23. package/ChartsLegend/ContinuousColorLegend.js +398 -0
  24. package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
  25. package/ChartsLegend/DefaultChartsLegend.js +13 -198
  26. package/ChartsLegend/LegendPerItem.d.ts +61 -0
  27. package/ChartsLegend/LegendPerItem.js +151 -0
  28. package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
  29. package/ChartsLegend/PiecewiseColorLegend.js +169 -0
  30. package/ChartsLegend/chartsLegend.types.d.ts +31 -0
  31. package/ChartsLegend/chartsLegend.types.js +5 -0
  32. package/ChartsLegend/index.d.ts +2 -0
  33. package/ChartsLegend/index.js +22 -0
  34. package/ChartsLegend/legend.types.d.ts +62 -0
  35. package/ChartsLegend/legend.types.js +5 -0
  36. package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
  37. package/ChartsLegend/legendItemsPlacement.js +79 -0
  38. package/ChartsLegend/useAxis.d.ts +7 -0
  39. package/ChartsLegend/useAxis.js +47 -0
  40. package/ChartsLegend/utils.d.ts +1 -8
  41. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  42. package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
  43. package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
  44. package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  45. package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
  46. package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
  47. package/ChartsSurface.js +3 -1
  48. package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  49. package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  50. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  51. package/ChartsXAxis/ChartsXAxis.js +1 -1
  52. package/ChartsYAxis/ChartsYAxis.js +15 -3
  53. package/Gauge/Gauge.d.ts +1 -4
  54. package/Gauge/Gauge.js +9 -6
  55. package/Gauge/GaugeContainer.js +8 -4
  56. package/Gauge/GaugeProvider.js +9 -9
  57. package/LineChart/AnimatedArea.js +2 -2
  58. package/LineChart/AnimatedLine.js +2 -2
  59. package/LineChart/AreaElement.d.ts +2 -1
  60. package/LineChart/AreaPlot.js +10 -6
  61. package/LineChart/LineChart.js +5 -2
  62. package/LineChart/LineElement.d.ts +2 -1
  63. package/LineChart/LineHighlightPlot.d.ts +2 -1
  64. package/LineChart/LineHighlightPlot.js +17 -5
  65. package/LineChart/LinePlot.js +10 -6
  66. package/LineChart/MarkElement.js +2 -2
  67. package/LineChart/MarkPlot.js +13 -25
  68. package/LineChart/extremums.js +4 -1
  69. package/LineChart/formatter.js +2 -2
  70. package/LineChart/useLineChartProps.js +38 -33
  71. package/PieChart/PieArc.js +1 -0
  72. package/PieChart/PieChart.d.ts +1 -4
  73. package/PieChart/PieChart.js +40 -34
  74. package/PieChart/PiePlot.js +6 -6
  75. package/PieChart/getPieCoordinates.js +3 -3
  76. package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  77. package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
  78. package/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  79. package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
  80. package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
  81. package/ScatterChart/Scatter.js +6 -9
  82. package/ScatterChart/ScatterChart.js +4 -1
  83. package/ScatterChart/ScatterPlot.js +6 -3
  84. package/ScatterChart/extremums.js +8 -2
  85. package/ScatterChart/useScatterChartProps.js +35 -30
  86. package/SparkLineChart/SparkLineChart.js +27 -22
  87. package/context/CartesianProvider/CartesianContext.d.ts +1 -1
  88. package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
  89. package/context/CartesianProvider/CartesianProvider.js +18 -7
  90. package/context/CartesianProvider/computeValue.d.ts +32 -9
  91. package/context/CartesianProvider/computeValue.js +20 -16
  92. package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
  93. package/context/CartesianProvider/defaultizeAxis.js +21 -0
  94. package/context/CartesianProvider/index.d.ts +0 -1
  95. package/context/CartesianProvider/index.js +1 -3
  96. package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
  97. package/context/CartesianProvider/normalizeAxis.js +2 -2
  98. package/context/DrawingProvider.d.ts +12 -0
  99. package/context/DrawingProvider.js +15 -2
  100. package/context/HighlightedProvider/HighlightedProvider.js +2 -2
  101. package/context/SeriesContextProvider.js +1 -1
  102. package/context/ZAxisContextProvider.d.ts +1 -1
  103. package/context/ZAxisContextProvider.js +1 -1
  104. package/esm/BarChart/BarChart.js +2 -2
  105. package/esm/BarChart/BarPlot.js +8 -8
  106. package/esm/BarChart/checkScaleErrors.js +11 -11
  107. package/esm/BarChart/extremums.js +4 -1
  108. package/esm/BarChart/formatter.js +2 -2
  109. package/esm/BarChart/useBarChartProps.js +38 -33
  110. package/esm/ChartContainer/ChartContainer.js +25 -66
  111. package/esm/ChartContainer/useChartContainerHooks.js +2 -2
  112. package/esm/ChartContainer/useChartContainerProps.js +87 -0
  113. package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
  114. package/esm/ChartsAxis/ChartsAxis.js +4 -4
  115. package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  116. package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
  117. package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
  118. package/esm/ChartsLegend/LegendPerItem.js +141 -0
  119. package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
  120. package/esm/ChartsLegend/chartsLegend.types.js +1 -0
  121. package/esm/ChartsLegend/index.js +2 -0
  122. package/esm/ChartsLegend/legend.types.js +1 -0
  123. package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
  124. package/esm/ChartsLegend/useAxis.js +39 -0
  125. package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  126. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  127. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  128. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  129. package/esm/ChartsSurface.js +3 -1
  130. package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  131. package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  132. package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  133. package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
  134. package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
  135. package/esm/Gauge/Gauge.js +8 -5
  136. package/esm/Gauge/GaugeContainer.js +8 -4
  137. package/esm/Gauge/GaugeProvider.js +1 -1
  138. package/esm/LineChart/AnimatedArea.js +1 -1
  139. package/esm/LineChart/AnimatedLine.js +1 -1
  140. package/esm/LineChart/AreaPlot.js +10 -6
  141. package/esm/LineChart/LineChart.js +5 -2
  142. package/esm/LineChart/LineHighlightPlot.js +17 -5
  143. package/esm/LineChart/LinePlot.js +10 -6
  144. package/esm/LineChart/MarkElement.js +1 -1
  145. package/esm/LineChart/MarkPlot.js +12 -24
  146. package/esm/LineChart/extremums.js +4 -1
  147. package/esm/LineChart/formatter.js +2 -2
  148. package/esm/LineChart/useLineChartProps.js +38 -33
  149. package/esm/PieChart/PieArc.js +1 -0
  150. package/esm/PieChart/PieChart.js +39 -33
  151. package/esm/PieChart/PiePlot.js +1 -1
  152. package/esm/PieChart/getPieCoordinates.js +1 -1
  153. package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  154. package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  155. package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  156. package/esm/ScatterChart/Scatter.js +6 -9
  157. package/esm/ScatterChart/ScatterChart.js +4 -1
  158. package/esm/ScatterChart/ScatterPlot.js +6 -3
  159. package/esm/ScatterChart/extremums.js +8 -2
  160. package/esm/ScatterChart/useScatterChartProps.js +35 -30
  161. package/esm/SparkLineChart/SparkLineChart.js +27 -22
  162. package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
  163. package/esm/context/CartesianProvider/computeValue.js +20 -16
  164. package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
  165. package/esm/context/CartesianProvider/index.js +1 -3
  166. package/esm/context/CartesianProvider/normalizeAxis.js +2 -2
  167. package/esm/context/DrawingProvider.js +15 -2
  168. package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
  169. package/esm/context/SeriesContextProvider.js +1 -1
  170. package/esm/context/ZAxisContextProvider.js +1 -1
  171. package/esm/hooks/useAxisEvents.js +14 -17
  172. package/esm/hooks/useDrawingArea.js +5 -3
  173. package/esm/hooks/useReducedMotion.js +4 -2
  174. package/esm/internals/SlotComponentPropsFromProps.js +1 -0
  175. package/esm/internals/cleanId.js +6 -0
  176. package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  177. package/esm/internals/geometry.js +1 -1
  178. package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
  179. package/esm/internals/getSymbol.js +5 -0
  180. package/esm/internals/index.js +3 -1
  181. package/esm/internals/isDefined.js +3 -0
  182. package/esm/internals/notNull.js +3 -0
  183. package/esm/internals/ts-generic.js +1 -0
  184. package/esm/internals/warning.js +19 -11
  185. package/hooks/useAxisEvents.js +14 -17
  186. package/hooks/useDrawingArea.js +5 -3
  187. package/hooks/useReducedMotion.js +4 -2
  188. package/index.js +1 -1
  189. package/internals/SlotComponentPropsFromProps.d.ts +1 -0
  190. package/internals/SlotComponentPropsFromProps.js +5 -0
  191. package/internals/cleanId.d.ts +4 -0
  192. package/internals/cleanId.js +12 -0
  193. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
  194. package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  195. package/internals/defaultizeColor.d.ts +7 -0
  196. package/internals/geometry.js +1 -1
  197. package/internals/getPercentageValue.d.ts +7 -0
  198. package/internals/{utils.js → getPercentageValue.js} +1 -15
  199. package/internals/getSymbol.d.ts +2 -0
  200. package/internals/getSymbol.js +11 -0
  201. package/internals/index.d.ts +3 -1
  202. package/internals/index.js +25 -5
  203. package/internals/isDefined.d.ts +1 -0
  204. package/internals/isDefined.js +9 -0
  205. package/internals/notNull.d.ts +1 -0
  206. package/internals/notNull.js +9 -0
  207. package/internals/ts-generic.d.ts +5 -0
  208. package/internals/ts-generic.js +5 -0
  209. package/internals/warning.d.ts +2 -1
  210. package/internals/warning.js +21 -12
  211. package/models/axis.d.ts +5 -2
  212. package/models/helpers.d.ts +1 -0
  213. package/models/seriesType/common.d.ts +10 -0
  214. package/models/seriesType/config.d.ts +2 -16
  215. package/models/seriesType/scatter.d.ts +5 -0
  216. package/modern/BarChart/BarChart.js +2 -2
  217. package/modern/BarChart/BarPlot.js +8 -8
  218. package/modern/BarChart/checkScaleErrors.js +11 -11
  219. package/modern/BarChart/extremums.js +4 -1
  220. package/modern/BarChart/formatter.js +2 -2
  221. package/modern/BarChart/useBarChartProps.js +38 -33
  222. package/modern/ChartContainer/ChartContainer.js +25 -66
  223. package/modern/ChartContainer/useChartContainerHooks.js +2 -2
  224. package/modern/ChartContainer/useChartContainerProps.js +87 -0
  225. package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
  226. package/modern/ChartsAxis/ChartsAxis.js +4 -4
  227. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
  228. package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
  229. package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
  230. package/modern/ChartsLegend/LegendPerItem.js +141 -0
  231. package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
  232. package/modern/ChartsLegend/chartsLegend.types.js +1 -0
  233. package/modern/ChartsLegend/index.js +2 -0
  234. package/modern/ChartsLegend/legend.types.js +1 -0
  235. package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
  236. package/modern/ChartsLegend/useAxis.js +39 -0
  237. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
  238. package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
  239. package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
  240. package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
  241. package/modern/ChartsSurface.js +3 -1
  242. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
  243. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
  244. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
  245. package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
  246. package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
  247. package/modern/Gauge/Gauge.js +8 -5
  248. package/modern/Gauge/GaugeContainer.js +8 -4
  249. package/modern/Gauge/GaugeProvider.js +1 -1
  250. package/modern/LineChart/AnimatedArea.js +1 -1
  251. package/modern/LineChart/AnimatedLine.js +1 -1
  252. package/modern/LineChart/AreaPlot.js +10 -6
  253. package/modern/LineChart/LineChart.js +5 -2
  254. package/modern/LineChart/LineHighlightPlot.js +17 -5
  255. package/modern/LineChart/LinePlot.js +10 -6
  256. package/modern/LineChart/MarkElement.js +1 -1
  257. package/modern/LineChart/MarkPlot.js +12 -24
  258. package/modern/LineChart/extremums.js +4 -1
  259. package/modern/LineChart/formatter.js +2 -2
  260. package/modern/LineChart/useLineChartProps.js +38 -33
  261. package/modern/PieChart/PieArc.js +1 -0
  262. package/modern/PieChart/PieChart.js +39 -33
  263. package/modern/PieChart/PiePlot.js +1 -1
  264. package/modern/PieChart/getPieCoordinates.js +1 -1
  265. package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
  266. package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
  267. package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
  268. package/modern/ScatterChart/Scatter.js +6 -9
  269. package/modern/ScatterChart/ScatterChart.js +4 -1
  270. package/modern/ScatterChart/ScatterPlot.js +6 -3
  271. package/modern/ScatterChart/extremums.js +8 -2
  272. package/modern/ScatterChart/useScatterChartProps.js +35 -30
  273. package/modern/SparkLineChart/SparkLineChart.js +27 -22
  274. package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
  275. package/modern/context/CartesianProvider/computeValue.js +20 -16
  276. package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
  277. package/modern/context/CartesianProvider/index.js +1 -3
  278. package/modern/context/CartesianProvider/normalizeAxis.js +2 -2
  279. package/modern/context/DrawingProvider.js +15 -2
  280. package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
  281. package/modern/context/SeriesContextProvider.js +1 -1
  282. package/modern/context/ZAxisContextProvider.js +1 -1
  283. package/modern/hooks/useAxisEvents.js +14 -17
  284. package/modern/hooks/useDrawingArea.js +5 -3
  285. package/modern/hooks/useReducedMotion.js +4 -2
  286. package/modern/index.js +1 -1
  287. package/modern/internals/SlotComponentPropsFromProps.js +1 -0
  288. package/modern/internals/cleanId.js +6 -0
  289. package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
  290. package/modern/internals/geometry.js +1 -1
  291. package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
  292. package/modern/internals/getSymbol.js +5 -0
  293. package/modern/internals/index.js +3 -1
  294. package/modern/internals/isDefined.js +3 -0
  295. package/modern/internals/notNull.js +3 -0
  296. package/modern/internals/ts-generic.js +1 -0
  297. package/modern/internals/warning.js +19 -11
  298. package/package.json +4 -4
  299. package/internals/utils.d.ts +0 -18
@@ -2,13 +2,12 @@ import * as React from 'react';
2
2
  import { useDrawingArea } from '../../hooks/useDrawingArea';
3
3
  import { useSeries } from '../../hooks/useSeries';
4
4
  import { CartesianContext } from './CartesianContext';
5
- import { normalizeAxis } from './normalizeAxis';
6
5
  import { computeValue } from './computeValue';
7
6
  import { jsx as _jsx } from "react/jsx-runtime";
8
7
  function CartesianContextProvider(props) {
9
8
  const {
10
- xAxis: inXAxis,
11
- yAxis: inYAxis,
9
+ xAxis,
10
+ yAxis,
12
11
  dataset,
13
12
  xExtremumGetters,
14
13
  yExtremumGetters,
@@ -16,10 +15,22 @@ function CartesianContextProvider(props) {
16
15
  } = props;
17
16
  const formattedSeries = useSeries();
18
17
  const drawingArea = useDrawingArea();
19
- const xAxis = React.useMemo(() => normalizeAxis(inXAxis, dataset, 'x'), [inXAxis, dataset]);
20
- const yAxis = React.useMemo(() => normalizeAxis(inYAxis, dataset, 'y'), [inYAxis, dataset]);
21
- const xValues = React.useMemo(() => computeValue(drawingArea, formattedSeries, xAxis, xExtremumGetters, 'x'), [drawingArea, formattedSeries, xAxis, xExtremumGetters]);
22
- const yValues = React.useMemo(() => computeValue(drawingArea, formattedSeries, yAxis, yExtremumGetters, 'y'), [drawingArea, formattedSeries, yAxis, yExtremumGetters]);
18
+ const xValues = React.useMemo(() => computeValue({
19
+ drawingArea,
20
+ formattedSeries,
21
+ axis: xAxis,
22
+ extremumGetters: xExtremumGetters,
23
+ dataset,
24
+ axisDirection: 'x'
25
+ }), [drawingArea, formattedSeries, xAxis, xExtremumGetters, dataset]);
26
+ const yValues = React.useMemo(() => computeValue({
27
+ drawingArea,
28
+ formattedSeries,
29
+ axis: yAxis,
30
+ extremumGetters: yExtremumGetters,
31
+ dataset,
32
+ axisDirection: 'y'
33
+ }), [drawingArea, formattedSeries, yAxis, yExtremumGetters, dataset]);
23
34
  const value = React.useMemo(() => ({
24
35
  isInitialized: true,
25
36
  data: {
@@ -1,13 +1,13 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { scaleBand, scalePoint, scaleTime } from 'd3-scale';
3
- import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../../constants';
4
3
  import { isBandScaleConfig, isPointScaleConfig } from '../../models/axis';
5
4
  import { getColorScale, getOrdinalColorScale } from '../../internals/colorScale';
6
5
  import { getTickNumber } from '../../hooks/useTicks';
7
6
  import { getScale } from '../../internals/getScale';
8
7
  import { getAxisExtremum } from './getAxisExtremum';
9
- const getRange = (drawingArea, axisName, isReverse) => {
10
- const range = axisName === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
8
+ import { normalizeAxis } from './normalizeAxis';
9
+ const getRange = (drawingArea, axisDirection, isReverse) => {
10
+ const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
11
11
  return isReverse ? range.reverse() : range;
12
12
  };
13
13
  const zoomedScaleRange = (scaleRange, zoomRange) => {
@@ -29,26 +29,30 @@ function createDateFormatter(axis, range) {
29
29
  }
30
30
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
31
31
  const DEFAULT_BAR_GAP_RATIO = 0.1;
32
- export function computeValue(drawingArea, formattedSeries, inAxis, extremumGetters, axisName, zoomRange = [0, 100]) {
33
- const DEFAULT_AXIS_KEY = axisName === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
34
- const allAxis = [...(inAxis?.map((axis, index) => _extends({
35
- id: `defaultized-${axisName}-axis-${index}`
36
- }, axis)) ?? []), ...(inAxis === undefined || inAxis.findIndex(({
37
- id
38
- }) => id === DEFAULT_AXIS_KEY) === -1 ? [{
39
- id: DEFAULT_AXIS_KEY,
40
- scaleType: 'linear'
41
- }] : [])];
32
+ export function computeValue({
33
+ drawingArea,
34
+ formattedSeries,
35
+ axis: inAxis,
36
+ extremumGetters,
37
+ dataset,
38
+ axisDirection,
39
+ zoomData
40
+ }) {
41
+ const allAxis = normalizeAxis(inAxis, dataset, axisDirection);
42
42
  const completeAxis = {};
43
43
  allAxis.forEach((axis, axisIndex) => {
44
44
  const isDefaultAxis = axisIndex === 0;
45
45
  const [minData, maxData] = getAxisExtremum(axis, extremumGetters, isDefaultAxis, formattedSeries);
46
- const range = getRange(drawingArea, axisName, axis.reverse);
46
+ const zoom = zoomData?.find(({
47
+ axisId
48
+ }) => axisId === axis.id);
49
+ const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
50
+ const range = getRange(drawingArea, axisDirection, axis.reverse);
47
51
  if (isBandScaleConfig(axis)) {
48
52
  const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
49
53
  const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
50
54
  // Reverse range because ordinal scales are presented from top to bottom on y-axis
51
- const scaleRange = axisName === 'x' ? range : [range[1], range[0]];
55
+ const scaleRange = axisDirection === 'x' ? range : [range[1], range[0]];
52
56
  const zoomedRange = zoomedScaleRange(scaleRange, zoomRange);
53
57
  completeAxis[axis.id] = _extends({
54
58
  categoryGapRatio,
@@ -66,7 +70,7 @@ export function computeValue(drawingArea, formattedSeries, inAxis, extremumGette
66
70
  }
67
71
  }
68
72
  if (isPointScaleConfig(axis)) {
69
- const scaleRange = axisName === 'x' ? range : [...range].reverse();
73
+ const scaleRange = axisDirection === 'x' ? range : [...range].reverse();
70
74
  const zoomedRange = zoomedScaleRange(scaleRange, zoomRange);
71
75
  completeAxis[axis.id] = _extends({}, axis, {
72
76
  scale: scalePoint(axis.data, zoomedRange),
@@ -0,0 +1,13 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../../constants';
3
+ export const defaultizeAxis = (inAxis, axisName) => {
4
+ const DEFAULT_AXIS_KEY = axisName === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
5
+ return [...(inAxis?.map((axis, index) => _extends({
6
+ id: `defaultized-${axisName}-axis-${index}`
7
+ }, axis)) ?? []), ...(inAxis === undefined || inAxis.findIndex(({
8
+ id
9
+ }) => id === DEFAULT_AXIS_KEY) === -1 ? [{
10
+ id: DEFAULT_AXIS_KEY,
11
+ scaleType: 'linear'
12
+ }] : [])];
13
+ };
@@ -1,10 +1,8 @@
1
1
  import { computeValue } from './computeValue';
2
- import { normalizeAxis } from './normalizeAxis';
3
2
  export * from './CartesianProvider';
4
3
  export * from './CartesianContext';
5
4
  export * from './useCartesianContext';
6
5
  const cartesianProviderUtils = {
7
- computeValue,
8
- normalizeAxis
6
+ computeValue
9
7
  };
10
8
  export { cartesianProviderUtils };
@@ -6,10 +6,10 @@ export const normalizeAxis = (axis, dataset, axisName) => {
6
6
  return axisConfig;
7
7
  }
8
8
  if (dataset === undefined) {
9
- throw Error(`MUI X Charts: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
9
+ throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
10
10
  }
11
11
  return _extends({}, axisConfig, {
12
12
  data: dataset.map(d => d[dataKey])
13
13
  });
14
- });
14
+ }) ?? [];
15
15
  };
@@ -14,7 +14,8 @@ export const DrawingContext = /*#__PURE__*/React.createContext({
14
14
  right: 0,
15
15
  height: 300,
16
16
  width: 400,
17
- chartId: ''
17
+ chartId: '',
18
+ isPointInside: () => false
18
19
  });
19
20
  if (process.env.NODE_ENV !== 'production') {
20
21
  DrawingContext.displayName = 'DrawingContext';
@@ -38,9 +39,21 @@ export function DrawingProvider(props) {
38
39
  } = props;
39
40
  const drawingArea = useChartDimensions(width, height, margin);
40
41
  const chartId = useId();
42
+ const isPointInside = React.useCallback(({
43
+ x,
44
+ y
45
+ }, targetElement) => {
46
+ // For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
47
+ if (targetElement && targetElement.closest('[data-drawing-container]')) {
48
+ return true;
49
+ }
50
+ return x >= drawingArea.left && x <= drawingArea.left + drawingArea.width && y >= drawingArea.top && y <= drawingArea.top + drawingArea.height;
51
+ }, [drawingArea]);
41
52
  const value = React.useMemo(() => _extends({
42
53
  chartId: chartId ?? ''
43
- }, drawingArea), [chartId, drawingArea]);
54
+ }, drawingArea, {
55
+ isPointInside
56
+ }), [chartId, drawingArea, isPointInside]);
44
57
  const refValue = React.useMemo(() => ({
45
58
  isInitialized: true,
46
59
  data: svgRef
@@ -15,11 +15,11 @@ const mergeDeprecatedOptions = options => {
15
15
  highlighted,
16
16
  faded
17
17
  } = _ref,
18
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
18
+ other = _objectWithoutPropertiesLoose(_ref, _excluded);
19
19
  return _extends({
20
20
  highlight: highlighted,
21
21
  fade: faded
22
- }, rest);
22
+ }, other);
23
23
  };
24
24
  function HighlightedProvider({
25
25
  children,
@@ -34,7 +34,7 @@ const preprocessSeries = (series, colors, seriesFormatters, dataset) => {
34
34
  };
35
35
  }
36
36
  if (seriesGroups[type]?.series[id] !== undefined) {
37
- throw new Error(`MUI X Charts: series' id "${id}" is not unique.`);
37
+ throw new Error(`MUI X: series' id "${id}" is not unique.`);
38
38
  }
39
39
  seriesGroups[type].series[id] = _extends({
40
40
  id
@@ -22,7 +22,7 @@ function ZAxisContextProvider(props) {
22
22
  return axisConfig;
23
23
  }
24
24
  if (dataset === undefined) {
25
- throw Error('MUI X Charts: z-axis uses `dataKey` but no `dataset` is provided.');
25
+ throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
26
26
  }
27
27
  return _extends({}, axisConfig, {
28
28
  data: dataset.map(d => d[dataKey])
@@ -10,12 +10,7 @@ function getAsANumber(value) {
10
10
  }
11
11
  export const useAxisEvents = disableAxisListener => {
12
12
  const svgRef = useSvgRef();
13
- const {
14
- left,
15
- top,
16
- width,
17
- height
18
- } = useDrawingArea();
13
+ const drawingArea = useDrawingArea();
19
14
  const {
20
15
  xAxis,
21
16
  yAxis,
@@ -30,6 +25,7 @@ export const useAxisEvents = disableAxisListener => {
30
25
 
31
26
  // Use a ref to avoid rerendering on every mousemove event.
32
27
  const mousePosition = React.useRef({
28
+ isInChart: false,
33
29
  x: -1,
34
30
  y: -1
35
31
  });
@@ -89,6 +85,7 @@ export const useAxisEvents = disableAxisListener => {
89
85
  }
90
86
  const handleOut = () => {
91
87
  mousePosition.current = {
88
+ isInChart: false,
92
89
  x: -1,
93
90
  y: -1
94
91
  };
@@ -99,18 +96,18 @@ export const useAxisEvents = disableAxisListener => {
99
96
  const handleMove = event => {
100
97
  const target = 'targetTouches' in event ? event.targetTouches[0] : event;
101
98
  const svgPoint = getSVGPoint(element, target);
102
- mousePosition.current = {
103
- x: svgPoint.x,
104
- y: svgPoint.y
105
- };
106
- const outsideX = svgPoint.x < left || svgPoint.x > left + width;
107
- const outsideY = svgPoint.y < top || svgPoint.y > top + height;
108
- if (outsideX || outsideY) {
109
- dispatch({
110
- type: 'exitChart'
111
- });
99
+ mousePosition.current.x = svgPoint.x;
100
+ mousePosition.current.y = svgPoint.y;
101
+ if (!drawingArea.isPointInside(svgPoint, event.target)) {
102
+ if (mousePosition.current.isInChart) {
103
+ dispatch({
104
+ type: 'exitChart'
105
+ });
106
+ mousePosition.current.isInChart = false;
107
+ }
112
108
  return;
113
109
  }
110
+ mousePosition.current.isInChart = true;
114
111
  const newStateX = getNewAxisState(xAxis[usedXAxis], svgPoint.x);
115
112
  const newStateY = getNewAxisState(yAxis[usedYAxis], svgPoint.y);
116
113
  dispatch({
@@ -142,5 +139,5 @@ export const useAxisEvents = disableAxisListener => {
142
139
  element.removeEventListener('pointercancel', handleOut);
143
140
  element.removeEventListener('pointerleave', handleOut);
144
141
  };
145
- }, [svgRef, dispatch, left, width, top, height, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener]);
142
+ }, [svgRef, dispatch, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, drawingArea]);
146
143
  };
@@ -7,7 +7,8 @@ export function useDrawingArea() {
7
7
  width,
8
8
  height,
9
9
  bottom,
10
- right
10
+ right,
11
+ isPointInside
11
12
  } = React.useContext(DrawingContext);
12
13
  return React.useMemo(() => ({
13
14
  left,
@@ -15,6 +16,7 @@ export function useDrawingArea() {
15
16
  width,
16
17
  height,
17
18
  bottom,
18
- right
19
- }), [height, left, top, width, bottom, right]);
19
+ right,
20
+ isPointInside
21
+ }), [height, left, top, width, bottom, right, isPointInside]);
20
22
  }
@@ -26,9 +26,11 @@ export const useReducedMotion = () => {
26
26
  });
27
27
  };
28
28
  handleMediaChange(mql);
29
- mql.addEventListener('change', handleMediaChange);
29
+
30
+ // MatchMedia is not fully supported in all environments, so we need to check if it exists before calling addEventListener
31
+ mql.addEventListener?.('change', handleMediaChange);
30
32
  return () => {
31
- mql.removeEventListener('change', handleMediaChange);
33
+ mql.removeEventListener?.('change', handleMediaChange);
32
34
  };
33
35
  }, []);
34
36
  };
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v7.10.0
2
+ * @mui/x-charts v7.11.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Remove spaces to have viable ids
3
+ */
4
+ export function cleanId(id) {
5
+ return id.replace(' ', '_');
6
+ }
@@ -4,6 +4,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
4
4
  const PX_PRECISION = 10;
5
5
  export default function ChartsContinuousGradient(props) {
6
6
  const {
7
+ gradientUnits,
7
8
  isReversed,
8
9
  gradientId,
9
10
  size,
@@ -26,8 +27,8 @@ export default function ChartsContinuousGradient(props) {
26
27
  x2: "0",
27
28
  y1: "0",
28
29
  y2: "0",
29
- [`${direction}${isReversed ? 1 : 2}`]: `${size}px`,
30
- gradientUnits: "userSpaceOnUse" // Use the SVG coordinate instead of the component ones.
30
+ [`${direction}${isReversed ? 1 : 2}`]: gradientUnits === 'objectBoundingBox' ? 1 : `${size}px`,
31
+ gradientUnits: gradientUnits ?? 'userSpaceOnUse' // Use the SVG coordinate instead of the component ones.
31
32
  ,
32
33
  children: Array.from({
33
34
  length: numberOfPoints + 1
@@ -14,7 +14,7 @@ export function getMinXTranslation(width, height, angle = 0) {
14
14
  if (process.env.NODE_ENV !== 'production') {
15
15
  if (!warnedOnce && angle > 90 && angle < -90) {
16
16
  warnedOnce = true;
17
- console.warn([`MUI X Charts: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
17
+ console.warn([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
18
18
  }
19
19
  }
20
20
  const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
@@ -1,8 +1,3 @@
1
- // Returns the index of a defined shape
2
- export function getSymbol(shape) {
3
- const symbolNames = 'circle cross diamond square star triangle wye'.split(/ /);
4
- return symbolNames.indexOf(shape) || 0;
5
- }
6
1
  /**
7
2
  * Helper that converts values and percentages into values.
8
3
  * @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
@@ -29,12 +24,5 @@ export function getPercentageValue(value, refValue) {
29
24
  return val;
30
25
  }
31
26
  }
32
- throw Error(`MUI-Charts: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
33
- }
34
-
35
- /**
36
- * Remove spaces to have viable ids
37
- */
38
- export function cleanId(id) {
39
- return id.replace(' ', '_');
27
+ throw Error(`MUI X: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
40
28
  }
@@ -0,0 +1,5 @@
1
+ // Returns the index of a defined shape
2
+ export function getSymbol(shape) {
3
+ const symbolNames = 'circle cross diamond square star triangle wye'.split(/ /);
4
+ return symbolNames.indexOf(shape) || 0;
5
+ }
@@ -8,16 +8,18 @@ export { useReducedMotion } from '../hooks/useReducedMotion';
8
8
  export { useSeries } from '../hooks/useSeries';
9
9
  export { useInteractionItemProps } from '../hooks/useInteractionItemProps';
10
10
  export { useDrawingArea } from '../hooks/useDrawingArea';
11
- export { useChartContainerHooks } from '../ChartContainer/useChartContainerHooks';
12
11
  export { useScatterChartProps } from '../ScatterChart/useScatterChartProps';
13
12
  export { useLineChartProps } from '../LineChart/useLineChartProps';
14
13
  export { useBarChartProps } from '../BarChart/useBarChartProps';
14
+ export { useResponsiveChartContainerProps } from '../ResponsiveChartContainer/useResponsiveChartContainerProps';
15
+ export { useChartContainerProps } from '../ChartContainer/useChartContainerProps';
15
16
 
16
17
  // utils
17
18
  export * from './defaultizeValueFormatter';
18
19
  export * from './configInit';
19
20
  export * from './getLabel';
20
21
  export * from './getSVGPoint';
22
+ export * from './isDefined';
21
23
 
22
24
  // contexts
23
25
 
@@ -0,0 +1,3 @@
1
+ export function isDefined(value) {
2
+ return value !== null && value !== undefined;
3
+ }
@@ -0,0 +1,3 @@
1
+ export function notNull(value) {
2
+ return value !== null;
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,13 +1,21 @@
1
- export function buildWarning(message, gravity = 'warning') {
2
- let alreadyWarned = false;
3
- return (...args) => {
4
- if (!alreadyWarned) {
5
- alreadyWarned = true;
6
- if (gravity === 'error') {
7
- console.error(message(...args));
8
- } else {
9
- console.warn(message(...args));
10
- }
1
+ const warnedOnceCache = new Set();
2
+
3
+ // TODO move to @mui/x-internals
4
+ // TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
5
+ export function warnOnce(message, gravity = 'warning') {
6
+ if (process.env.NODE_ENV === 'production') {
7
+ return;
8
+ }
9
+ const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
10
+ if (!warnedOnceCache.has(cleanMessage)) {
11
+ warnedOnceCache.add(cleanMessage);
12
+ if (gravity === 'error') {
13
+ console.error(cleanMessage);
14
+ } else {
15
+ console.warn(cleanMessage);
11
16
  }
12
- };
17
+ }
18
+ }
19
+ export function clearWarningsCache() {
20
+ warnedOnceCache.clear();
13
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-charts",
3
- "version": "7.10.0",
3
+ "version": "7.11.1",
4
4
  "description": "The community edition of the Charts components (MUI X).",
5
5
  "author": "MUI Team",
6
6
  "main": "./index.js",
@@ -29,10 +29,10 @@
29
29
  "directory": "packages/x-charts"
30
30
  },
31
31
  "dependencies": {
32
- "@babel/runtime": "^7.24.7",
32
+ "@babel/runtime": "^7.24.8",
33
33
  "@mui/base": "^5.0.0-beta.40",
34
- "@mui/system": "^5.16.0",
35
- "@mui/utils": "^5.16.0",
34
+ "@mui/system": "^5.16.5",
35
+ "@mui/utils": "^5.16.5",
36
36
  "@react-spring/rafz": "^9.7.3",
37
37
  "@react-spring/web": "^9.7.3",
38
38
  "clsx": "^2.1.1",
@@ -1,18 +0,0 @@
1
- export type SymbolsTypes = 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
2
- export declare function getSymbol(shape: SymbolsTypes): number;
3
- type Without<T, U> = {
4
- [P in Exclude<keyof T, keyof U>]?: never;
5
- };
6
- export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
7
- /**
8
- * Helper that converts values and percentages into values.
9
- * @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
10
- * @param refValue The numerical value associated to 100%.
11
- * @returns The numerical value associated to the provided value.
12
- */
13
- export declare function getPercentageValue(value: number | string, refValue: number): number;
14
- /**
15
- * Remove spaces to have viable ids
16
- */
17
- export declare function cleanId(id: string): string;
18
- export {};