@mui/x-charts 8.0.0-beta.1 → 8.0.0-beta.2

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 (132) hide show
  1. package/BarChart/useBarChartProps.d.ts +2 -1
  2. package/BarChart/useBarChartProps.js +20 -13
  3. package/CHANGELOG.md +94 -0
  4. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +8 -8
  5. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +8 -8
  6. package/ChartsOverlay/ChartsLoadingOverlay.js +1 -1
  7. package/ChartsOverlay/ChartsNoDataOverlay.js +1 -1
  8. package/ChartsTooltip/ChartsTooltipContainer.js +2 -1
  9. package/ChartsTooltip/useAxisTooltip.js +2 -2
  10. package/LineChart/CircleMarkElement.js +2 -2
  11. package/LineChart/LineHighlightPlot.js +2 -2
  12. package/LineChart/MarkElement.js +2 -2
  13. package/LineChart/useLineChartProps.d.ts +2 -1
  14. package/LineChart/useLineChartProps.js +7 -4
  15. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +9 -5
  16. package/RadarChart/RadarGrid/RadarGrid.d.ts +1 -1
  17. package/RadarChart/RadarGrid/RadarGrid.js +5 -1
  18. package/RadarChart/RadarGrid/useRadarGridData.d.ts +1 -1
  19. package/RadarChart/RadarGrid/useRadarGridData.js +3 -0
  20. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.js +2 -2
  21. package/ScatterChart/useScatterChartProps.d.ts +2 -1
  22. package/ScatterChart/useScatterChartProps.js +6 -3
  23. package/esm/BarChart/useBarChartProps.d.ts +2 -1
  24. package/esm/BarChart/useBarChartProps.js +19 -13
  25. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +8 -8
  26. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +8 -8
  27. package/esm/ChartsOverlay/ChartsLoadingOverlay.js +1 -1
  28. package/esm/ChartsOverlay/ChartsNoDataOverlay.js +1 -1
  29. package/esm/ChartsTooltip/ChartsTooltipContainer.js +2 -1
  30. package/esm/ChartsTooltip/useAxisTooltip.js +1 -1
  31. package/esm/LineChart/CircleMarkElement.js +1 -1
  32. package/esm/LineChart/LineHighlightPlot.js +1 -1
  33. package/esm/LineChart/MarkElement.js +1 -1
  34. package/esm/LineChart/useLineChartProps.d.ts +2 -1
  35. package/esm/LineChart/useLineChartProps.js +6 -4
  36. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +9 -5
  37. package/esm/RadarChart/RadarGrid/RadarGrid.d.ts +1 -1
  38. package/esm/RadarChart/RadarGrid/RadarGrid.js +5 -1
  39. package/esm/RadarChart/RadarGrid/useRadarGridData.d.ts +1 -1
  40. package/esm/RadarChart/RadarGrid/useRadarGridData.js +3 -0
  41. package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.js +2 -2
  42. package/esm/ScatterChart/useScatterChartProps.d.ts +2 -1
  43. package/esm/ScatterChart/useScatterChartProps.js +5 -3
  44. package/esm/hooks/useAxis.d.ts +5 -5
  45. package/esm/hooks/useScale.d.ts +2 -2
  46. package/esm/hooks/useScale.js +2 -2
  47. package/esm/index.js +1 -1
  48. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +8 -6
  49. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +28 -22
  50. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
  51. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +1 -0
  52. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +9 -42
  53. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +1 -0
  54. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +41 -0
  55. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +7 -20
  56. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +36 -242
  57. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +4 -10
  58. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +9 -15
  59. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +12 -0
  60. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +8 -0
  61. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.d.ts +6 -4
  62. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.js +18 -13
  63. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +16 -32
  64. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +3669 -0
  65. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +22 -0
  66. package/hooks/useAxis.d.ts +5 -5
  67. package/hooks/useScale.d.ts +2 -2
  68. package/hooks/useScale.js +2 -2
  69. package/index.js +1 -1
  70. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +8 -6
  71. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +29 -22
  72. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
  73. package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +12 -0
  74. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +7 -40
  75. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +1 -0
  76. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +47 -0
  77. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +7 -20
  78. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +36 -242
  79. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +5 -11
  80. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +9 -15
  81. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +12 -0
  82. package/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +17 -0
  83. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.d.ts +6 -4
  84. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.js +19 -13
  85. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +16 -32
  86. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +3669 -0
  87. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +28 -0
  88. package/modern/BarChart/useBarChartProps.d.ts +2 -1
  89. package/modern/BarChart/useBarChartProps.js +19 -13
  90. package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +8 -8
  91. package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +8 -8
  92. package/modern/ChartsOverlay/ChartsLoadingOverlay.js +1 -1
  93. package/modern/ChartsOverlay/ChartsNoDataOverlay.js +1 -1
  94. package/modern/ChartsTooltip/ChartsTooltipContainer.js +2 -1
  95. package/modern/ChartsTooltip/useAxisTooltip.js +1 -1
  96. package/modern/LineChart/CircleMarkElement.js +1 -1
  97. package/modern/LineChart/LineHighlightPlot.js +1 -1
  98. package/modern/LineChart/MarkElement.js +1 -1
  99. package/modern/LineChart/useLineChartProps.d.ts +2 -1
  100. package/modern/LineChart/useLineChartProps.js +6 -4
  101. package/modern/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +9 -5
  102. package/modern/RadarChart/RadarGrid/RadarGrid.d.ts +1 -1
  103. package/modern/RadarChart/RadarGrid/RadarGrid.js +5 -1
  104. package/modern/RadarChart/RadarGrid/useRadarGridData.d.ts +1 -1
  105. package/modern/RadarChart/RadarGrid/useRadarGridData.js +3 -0
  106. package/modern/RadarChart/RadarSeriesPlot/useRadarSeriesData.js +2 -2
  107. package/modern/ScatterChart/useScatterChartProps.d.ts +2 -1
  108. package/modern/ScatterChart/useScatterChartProps.js +5 -3
  109. package/modern/hooks/useAxis.d.ts +5 -5
  110. package/modern/hooks/useScale.d.ts +2 -2
  111. package/modern/hooks/useScale.js +2 -2
  112. package/modern/index.js +1 -1
  113. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +8 -6
  114. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +28 -22
  115. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +1 -0
  116. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +1 -0
  117. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +9 -42
  118. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +1 -0
  119. package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +41 -0
  120. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +7 -20
  121. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +36 -242
  122. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +4 -10
  123. package/modern/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +9 -15
  124. package/modern/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.d.ts +12 -0
  125. package/modern/internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js +8 -0
  126. package/modern/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.d.ts +6 -4
  127. package/modern/internals/plugins/featurePlugins/useChartPolarAxis/getAxisValue.js +18 -13
  128. package/modern/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +16 -32
  129. package/modern/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +3669 -0
  130. package/modern/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +22 -0
  131. package/package.json +2 -2
  132. package/tsconfig.build.tsbuildinfo +1 -1
@@ -5,7 +5,7 @@ import { getValueToPositionMapper, useXScale } from "../hooks/useScale.js";
5
5
  import { isBandScale } from "../internals/isBandScale.js";
6
6
  import { useSelector } from "../internals/store/useSelector.js";
7
7
  import { useStore } from "../internals/store/useStore.js";
8
- import { selectorChartsInteractionXAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
8
+ import { selectorChartsInteractionXAxisValue } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
9
9
  import { useDrawingArea } from "../hooks/index.js";
10
10
  import { ChartsAxisHighlightPath } from "./ChartsAxisHighlightPath.js";
11
11
 
@@ -24,26 +24,26 @@ export default function ChartsXHighlight(props) {
24
24
  } = useDrawingArea();
25
25
  const xScale = useXScale();
26
26
  const store = useStore();
27
- const axisX = useSelector(store, selectorChartsInteractionXAxis);
27
+ const axisXValue = useSelector(store, selectorChartsInteractionXAxisValue);
28
28
  const getXPosition = getValueToPositionMapper(xScale);
29
- const isBandScaleX = type === 'band' && axisX !== null && isBandScale(xScale);
29
+ const isBandScaleX = type === 'band' && axisXValue !== null && isBandScale(xScale);
30
30
  if (process.env.NODE_ENV !== 'production') {
31
- const isError = isBandScaleX && xScale(axisX.value) === undefined;
31
+ const isError = isBandScaleX && xScale(axisXValue) === undefined;
32
32
  if (isError) {
33
33
  console.error([`MUI X: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
34
34
  }
35
35
  }
36
36
  return /*#__PURE__*/_jsxs(React.Fragment, {
37
- children: [isBandScaleX && xScale(axisX.value) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath
37
+ children: [isBandScaleX && xScale(axisXValue) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath
38
38
  // @ts-expect-error, xScale value is checked in the statement above
39
39
  , {
40
- d: `M ${xScale(axisX.value) - (xScale.step() - xScale.bandwidth()) / 2} ${top} l ${xScale.step()} 0 l 0 ${height} l ${-xScale.step()} 0 Z`,
40
+ d: `M ${xScale(axisXValue) - (xScale.step() - xScale.bandwidth()) / 2} ${top} l ${xScale.step()} 0 l 0 ${height} l ${-xScale.step()} 0 Z`,
41
41
  className: classes.root,
42
42
  ownerState: {
43
43
  axisHighlight: 'band'
44
44
  }
45
- }), type === 'line' && axisX !== null && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
46
- d: `M ${getXPosition(axisX.value)} ${top} L ${getXPosition(axisX.value)} ${top + height}`,
45
+ }), type === 'line' && axisXValue !== null && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
46
+ d: `M ${getXPosition(axisXValue)} ${top} L ${getXPosition(axisXValue)} ${top + height}`,
47
47
  className: classes.root,
48
48
  ownerState: {
49
49
  axisHighlight: 'line'
@@ -5,7 +5,7 @@ import { getValueToPositionMapper, useYScale } from "../hooks/useScale.js";
5
5
  import { isBandScale } from "../internals/isBandScale.js";
6
6
  import { useSelector } from "../internals/store/useSelector.js";
7
7
  import { useStore } from "../internals/store/useStore.js";
8
- import { selectorChartsInteractionYAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
8
+ import { selectorChartsInteractionYAxisValue } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
9
9
  import { useDrawingArea } from "../hooks/index.js";
10
10
  import { ChartsAxisHighlightPath } from "./ChartsAxisHighlightPath.js";
11
11
 
@@ -24,26 +24,26 @@ export default function ChartsYHighlight(props) {
24
24
  } = useDrawingArea();
25
25
  const yScale = useYScale();
26
26
  const store = useStore();
27
- const axisY = useSelector(store, selectorChartsInteractionYAxis);
27
+ const axisYValue = useSelector(store, selectorChartsInteractionYAxisValue);
28
28
  const getYPosition = getValueToPositionMapper(yScale);
29
- const isBandScaleY = type === 'band' && axisY !== null && isBandScale(yScale);
29
+ const isBandScaleY = type === 'band' && axisYValue !== null && isBandScale(yScale);
30
30
  if (process.env.NODE_ENV !== 'production') {
31
- const isError = isBandScaleY && yScale(axisY.value) === undefined;
31
+ const isError = isBandScaleY && yScale(axisYValue) === undefined;
32
32
  if (isError) {
33
33
  console.error([`MUI X: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
34
34
  }
35
35
  }
36
36
  return /*#__PURE__*/_jsxs(React.Fragment, {
37
- children: [isBandScaleY && yScale(axisY.value) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
37
+ children: [isBandScaleY && yScale(axisYValue) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
38
38
  d: `M ${left} ${
39
39
  // @ts-expect-error, yScale value is checked in the statement above
40
- yScale(axisY.value) - (yScale.step() - yScale.bandwidth()) / 2} l 0 ${yScale.step()} l ${width} 0 l 0 ${-yScale.step()} Z`,
40
+ yScale(axisYValue) - (yScale.step() - yScale.bandwidth()) / 2} l 0 ${yScale.step()} l ${width} 0 l 0 ${-yScale.step()} Z`,
41
41
  className: classes.root,
42
42
  ownerState: {
43
43
  axisHighlight: 'band'
44
44
  }
45
- }), type === 'line' && axisY !== null && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
46
- d: `M ${left} ${getYPosition(axisY.value)} L ${left + width} ${getYPosition(axisY.value)}`,
45
+ }), type === 'line' && axisYValue !== null && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
46
+ d: `M ${left} ${getYPosition(axisYValue)} L ${left + width} ${getYPosition(axisYValue)}`,
47
47
  className: classes.root,
48
48
  ownerState: {
49
49
  axisHighlight: 'line'
@@ -11,7 +11,7 @@ const StyledText = styled('text')(({
11
11
  theme
12
12
  }) => _extends({}, theme.typography.body2, {
13
13
  stroke: 'none',
14
- fill: theme.palette.text.primary,
14
+ fill: (theme.vars || theme).palette.text.primary,
15
15
  shapeRendering: 'crispEdges',
16
16
  textAnchor: 'middle',
17
17
  dominantBaseline: 'middle'
@@ -11,7 +11,7 @@ const StyledText = styled('text')(({
11
11
  theme
12
12
  }) => _extends({}, theme.typography.body2, {
13
13
  stroke: 'none',
14
- fill: theme.palette.text.primary,
14
+ fill: (theme.vars || theme).palette.text.primary,
15
15
  shapeRendering: 'crispEdges',
16
16
  textAnchor: 'middle',
17
17
  dominantBaseline: 'middle'
@@ -15,7 +15,8 @@ import { usePointerType } from "./utils.js";
15
15
  import { useSelector } from "../internals/store/useSelector.js";
16
16
  import { useStore } from "../internals/store/useStore.js";
17
17
  import { useXAxis } from "../hooks/index.js";
18
- import { selectorChartsInteractionItemIsDefined, selectorChartsInteractionXAxisIsDefined, selectorChartsInteractionYAxisIsDefined } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
18
+ import { selectorChartsInteractionItemIsDefined } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
19
+ import { selectorChartsInteractionXAxisIsDefined, selectorChartsInteractionYAxisIsDefined } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
19
20
  import { jsx as _jsx } from "react/jsx-runtime";
20
21
  const ChartsTooltipRoot = styled(Popper, {
21
22
  name: 'MuiChartsTooltip',
@@ -9,7 +9,7 @@ import { isCartesianSeriesType } from "../internals/isCartesian.js";
9
9
  import { utcFormatter } from "./utils.js";
10
10
  import { useXAxes, useXAxis, useYAxes, useYAxis } from "../hooks/useAxis.js";
11
11
  import { useZAxes } from "../hooks/useZAxis.js";
12
- import { selectorChartsInteractionXAxis, selectorChartsInteractionYAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
12
+ import { selectorChartsInteractionXAxis, selectorChartsInteractionYAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
13
13
  export function useAxisTooltip() {
14
14
  const defaultXAxis = useXAxis();
15
15
  const defaultYAxis = useYAxis();
@@ -11,7 +11,7 @@ import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
11
11
  import { useItemHighlighted } from "../hooks/useItemHighlighted.js";
12
12
  import { useUtilityClasses } from "./markElementClasses.js";
13
13
  import { useSelector } from "../internals/store/useSelector.js";
14
- import { selectorChartsInteractionXAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
14
+ import { selectorChartsInteractionXAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
15
15
  import { useStore } from "../internals/store/useStore.js";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  /**
@@ -13,7 +13,7 @@ import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
13
13
  import { useLineSeriesContext } from "../hooks/useLineSeries.js";
14
14
  import getColor from "./seriesConfig/getColor.js";
15
15
  import { useChartContext } from "../context/ChartProvider/index.js";
16
- import { selectorChartsInteractionXAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
16
+ import { selectorChartsInteractionXAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
17
17
  import { useXAxes, useYAxes } from "../hooks/useAxis.js";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  /**
@@ -12,7 +12,7 @@ import { getSymbol } from "../internals/getSymbol.js";
12
12
  import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
13
13
  import { useItemHighlighted } from "../hooks/useItemHighlighted.js";
14
14
  import { useUtilityClasses } from "./markElementClasses.js";
15
- import { selectorChartsInteractionXAxis } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
15
+ import { selectorChartsInteractionXAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
16
16
  import { useSelector } from "../internals/store/useSelector.js";
17
17
  import { useStore } from "../internals/store/useStore.js";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import { ChartsAxisProps } from "../ChartsAxis/index.js";
2
3
  import { ChartsAxisHighlightProps } from "../ChartsAxisHighlight/index.js";
3
4
  import { ChartsClipPathProps } from "../ChartsClipPath/index.js";
@@ -35,5 +36,5 @@ export declare const useLineChartProps: (props: LineChartProps) => {
35
36
  axisHighlightProps: ChartsAxisHighlightProps;
36
37
  lineHighlightPlotProps: LineHighlightPlotProps;
37
38
  legendProps: ChartsLegendSlotExtension;
38
- children: import("react").ReactNode;
39
+ children: React.ReactNode;
39
40
  };
@@ -3,6 +3,7 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
5
  const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className"];
6
+ import * as React from 'react';
6
7
  import useId from '@mui/utils/useId';
7
8
  import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
8
9
  import { LINE_CHART_PLUGINS } from "./LineChart.plugins.js";
@@ -43,11 +44,12 @@ export const useLineChartProps = props => {
43
44
  other = _objectWithoutPropertiesLoose(props, _excluded);
44
45
  const id = useId();
45
46
  const clipPathId = `${id}-clip-path`;
47
+ const seriesWithDefault = React.useMemo(() => series.map(s => _extends({
48
+ disableHighlight: !!disableLineItemHighlight,
49
+ type: 'line'
50
+ }, s)), [disableLineItemHighlight, series]);
46
51
  const chartContainerProps = _extends({}, other, {
47
- series: series.map(s => _extends({
48
- disableHighlight: !!disableLineItemHighlight,
49
- type: 'line'
50
- }, s)),
52
+ series: seriesWithDefault,
51
53
  width,
52
54
  height,
53
55
  margin,
@@ -5,7 +5,7 @@ import { useSelector } from "../../internals/store/useSelector.js";
5
5
  import { useStore } from "../../internals/store/useStore.js";
6
6
  import { useChartContext } from "../../context/ChartProvider/useChartContext.js";
7
7
  import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
8
- import { selectorChartsInteractionXAxis } from "../../internals/plugins/featurePlugins/useChartInteraction/index.js";
8
+ import { selectorChartsInteractionRotationAxisIndex, selectorChartsInteractionRotationAxisValue } from "../../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js";
9
9
  export function useRadarAxisHighlight(params) {
10
10
  const {
11
11
  includesNeighbors = false
@@ -20,10 +20,14 @@ export function useRadarAxisHighlight(params) {
20
20
  instance
21
21
  } = useChartContext();
22
22
  const store = useStore();
23
- const xAxisIdentifier = useSelector(store, selectorChartsInteractionXAxis);
23
+ const rotationAxisIndex = useSelector(store, selectorChartsInteractionRotationAxisIndex);
24
+ const rotationAxisValue = useSelector(store, selectorChartsInteractionRotationAxisValue);
24
25
  const center = useSelector(store, selectorChartPolarCenter);
25
- const highlightedIndex = xAxisIdentifier?.index;
26
- if (highlightedIndex === undefined) {
26
+ const highlightedIndex = rotationAxisIndex;
27
+ if (!rotationScale) {
28
+ return null;
29
+ }
30
+ if (highlightedIndex === null || highlightedIndex === -1) {
27
31
  return null;
28
32
  }
29
33
  if (radarSeries === undefined || radarSeries.length === 0) {
@@ -31,7 +35,7 @@ export function useRadarAxisHighlight(params) {
31
35
  }
32
36
  const metric = radiusAxisIds[highlightedIndex];
33
37
  const radiusScale = radiusAxis[metric].scale;
34
- const angle = rotationScale(xAxisIdentifier?.value);
38
+ const angle = rotationScale(rotationAxisValue);
35
39
  const radius = radiusScale.range()[1];
36
40
  return {
37
41
  center,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { RadarGridProps } from "./RadarGrid.types.js";
3
- declare function RadarGrid(props: RadarGridProps): React.JSX.Element;
3
+ declare function RadarGrid(props: RadarGridProps): React.JSX.Element | null;
4
4
  declare namespace RadarGrid {
5
5
  var propTypes: any;
6
6
  }
@@ -9,11 +9,15 @@ function RadarGrid(props) {
9
9
  divisions = 5,
10
10
  shape = 'sharp'
11
11
  } = props;
12
+ const gridData = useRadarGridData();
13
+ if (gridData === null) {
14
+ return null;
15
+ }
12
16
  const {
13
17
  center,
14
18
  corners,
15
19
  radius
16
- } = useRadarGridData();
20
+ } = gridData;
17
21
  return shape === 'sharp' ? /*#__PURE__*/_jsx(SharpRadarGrid, {
18
22
  divisions: divisions,
19
23
  corners: corners,
@@ -8,4 +8,4 @@ export declare function useRadarGridData(): {
8
8
  y: number;
9
9
  }[];
10
10
  radius: number;
11
- };
11
+ } | null;
@@ -13,6 +13,9 @@ export function useRadarGridData() {
13
13
  const drawingArea = useDrawingArea();
14
14
  const cx = drawingArea.left + drawingArea.width / 2;
15
15
  const cy = drawingArea.top + drawingArea.height / 2;
16
+ if (!rotationScale || rotationScale.domain().length === 0) {
17
+ return null;
18
+ }
16
19
  const metrics = rotationScale.domain();
17
20
  const angles = metrics.map(key => rotationScale(key));
18
21
  return {
@@ -23,8 +23,8 @@ export function useRadarSeriesData(querySeriesId) {
23
23
  isFaded: isItemFaded,
24
24
  isHighlighted: isItemHighlighted
25
25
  } = useItemHighlightedGetter();
26
- const metrics = rotationScale.domain();
27
- const angles = metrics.map(key => rotationScale(key));
26
+ const metrics = rotationScale?.domain() ?? [];
27
+ const angles = metrics.map(key => rotationScale?.(key));
28
28
  return radarSeries.map(series => {
29
29
  const seriesId = series.id;
30
30
  const isSeriesHighlighted = isItemHighlighted({
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import { ChartsAxisProps } from "../ChartsAxis/index.js";
2
3
  import { ChartsAxisHighlightProps } from "../ChartsAxisHighlight/index.js";
3
4
  import { ChartsGridProps } from "../ChartsGrid/index.js";
@@ -24,5 +25,5 @@ export declare const useScatterChartProps: (props: ScatterChartProps) => {
24
25
  overlayProps: ChartsOverlayProps;
25
26
  legendProps: ChartsLegendSlotExtension;
26
27
  axisHighlightProps: ChartsAxisHighlightProps;
27
- children: import("react").ReactNode;
28
+ children: React.ReactNode;
28
29
  };
@@ -3,6 +3,7 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
5
  const _excluded = ["xAxis", "yAxis", "zAxis", "series", "axisHighlight", "voronoiMaxRadius", "disableVoronoi", "hideLegend", "width", "height", "margin", "colors", "sx", "grid", "onItemClick", "children", "slots", "slotProps", "loading", "highlightedItem", "onHighlightChange", "className"];
6
+ import * as React from 'react';
6
7
  import { SCATTER_CHART_PLUGINS } from "./ScatterChart.plugins.js";
7
8
  /**
8
9
  * A helper function that extracts ScatterChartProps from the input props
@@ -36,10 +37,11 @@ export const useScatterChartProps = props => {
36
37
  className
37
38
  } = props,
38
39
  other = _objectWithoutPropertiesLoose(props, _excluded);
40
+ const seriesWithDefault = React.useMemo(() => series.map(s => _extends({
41
+ type: 'scatter'
42
+ }, s)), [series]);
39
43
  const chartContainerProps = _extends({}, other, {
40
- series: series.map(s => _extends({
41
- type: 'scatter'
42
- }, s)),
44
+ series: seriesWithDefault,
43
45
  width,
44
46
  height,
45
47
  margin,
@@ -1,4 +1,4 @@
1
- import { AxisId } from "../models/axis.js";
1
+ import { AxisId, ChartsRadiusAxisProps, ChartsRotationAxisProps, PolarAxisDefaultized, ScaleName } from "../models/axis.js";
2
2
  /**
3
3
  * Get all the x-axes.
4
4
  *
@@ -40,12 +40,12 @@ export declare function useXAxis(axisId?: AxisId): import("../internals").AxisDe
40
40
  */
41
41
  export declare function useYAxis(axisId?: AxisId): import("../internals").AxisDefaultized<keyof import("../internals").AxisScaleConfig, any, import("..").ChartsYAxisProps>;
42
42
  export declare function useRotationAxes(): {
43
- rotationAxis: import("../internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue").DefaultizedAxisConfig<import("../internals").ChartsRotationAxisProps>;
43
+ rotationAxis: import("../internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue").DefaultizedAxisConfig<ChartsRotationAxisProps>;
44
44
  rotationAxisIds: string[];
45
45
  };
46
46
  export declare function useRadiusAxes(): {
47
- radiusAxis: import("../internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue").DefaultizedAxisConfig<import("../internals").ChartsRadiusAxisProps>;
47
+ radiusAxis: import("../internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue").DefaultizedAxisConfig<ChartsRadiusAxisProps>;
48
48
  radiusAxisIds: string[];
49
49
  };
50
- export declare function useRotationAxis(identifier?: number | string): import("../internals").PolarAxisDefaultized<keyof import("../internals").AxisScaleConfig, any, import("../internals").ChartsRotationAxisProps>;
51
- export declare function useRadiusAxis(identifier?: number | string): import("../internals").PolarAxisDefaultized<keyof import("../internals").AxisScaleConfig, any, import("../internals").ChartsRadiusAxisProps>;
50
+ export declare function useRotationAxis(identifier?: number | string): PolarAxisDefaultized<ScaleName, any, ChartsRotationAxisProps> | undefined;
51
+ export declare function useRadiusAxis(identifier?: number | string): PolarAxisDefaultized<ScaleName, any, ChartsRadiusAxisProps> | undefined;
@@ -20,5 +20,5 @@ export declare function useXScale<S extends ScaleName>(axisId?: AxisId): AxisSca
20
20
  * @returns {AxisScaleConfig[S]['scale']} The scale for the specified Y axis.
21
21
  */
22
22
  export declare function useYScale<S extends ScaleName>(axisId?: AxisId): AxisScaleConfig[S]['scale'];
23
- export declare function useRotationScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'];
24
- export declare function useRadiusScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'];
23
+ export declare function useRotationScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'] | undefined;
24
+ export declare function useRadiusScale<S extends ScaleName>(identifier?: number | string): AxisScaleConfig[S]['scale'] | undefined;
@@ -39,9 +39,9 @@ export function useYScale(axisId) {
39
39
  }
40
40
  export function useRotationScale(identifier) {
41
41
  const axis = useRotationAxis(identifier);
42
- return axis.scale;
42
+ return axis?.scale;
43
43
  }
44
44
  export function useRadiusScale(identifier) {
45
45
  const axis = useRadiusAxis(identifier);
46
- return axis.scale;
46
+ return axis?.scale;
47
47
  }
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.0.0-beta.1
2
+ * @mui/x-charts v8.0.0-beta.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,9 +1,11 @@
1
1
  import { AxisDefaultized } from "../../../../models/axis.js";
2
2
  /**
3
- * For a pointer coordinate, this function returns the value and dataIndex associated.
4
- * Returns `null` if the coordinate is outside of values.
3
+ * For a pointer coordinate, this function returns the dataIndex associated.
4
+ * Returns `-1` if no dataIndex matches.
5
5
  */
6
- export declare function getAxisValue(axisConfig: AxisDefaultized, pointerValue: number): {
7
- value: any;
8
- index: number;
9
- } | null;
6
+ export declare function getAxisIndex(axisConfig: AxisDefaultized, pointerValue: number): number;
7
+ /**
8
+ * For a pointer coordinate, this function returns the value associated.
9
+ * Returns `null` if the coordinate has no value associated.
10
+ */
11
+ export declare function getAxisValue(axisConfig: AxisDefaultized, pointerValue: number, dataIndex: number): number | Date | null;
@@ -4,10 +4,10 @@ function getAsANumber(value) {
4
4
  }
5
5
 
6
6
  /**
7
- * For a pointer coordinate, this function returns the value and dataIndex associated.
8
- * Returns `null` if the coordinate is outside of values.
7
+ * For a pointer coordinate, this function returns the dataIndex associated.
8
+ * Returns `-1` if no dataIndex matches.
9
9
  */
10
- export function getAxisValue(axisConfig, pointerValue) {
10
+ export function getAxisIndex(axisConfig, pointerValue) {
11
11
  const {
12
12
  scale,
13
13
  data: axisData,
@@ -16,10 +16,7 @@ export function getAxisValue(axisConfig, pointerValue) {
16
16
  if (!isBandScale(scale)) {
17
17
  const value = scale.invert(pointerValue);
18
18
  if (axisData === undefined) {
19
- return {
20
- value,
21
- index: -1
22
- };
19
+ return -1;
23
20
  }
24
21
  const valueAsNumber = getAsANumber(value);
25
22
  const closestIndex = axisData?.findIndex((pointValue, index) => {
@@ -36,24 +33,33 @@ export function getAxisValue(axisConfig, pointerValue) {
36
33
  }
37
34
  return false;
38
35
  });
39
- return {
40
- value: closestIndex !== undefined && closestIndex >= 0 ? axisData[closestIndex] : value,
41
- index: closestIndex
42
- };
36
+ return closestIndex;
43
37
  }
44
38
  const dataIndex = scale.bandwidth() === 0 ? Math.floor((pointerValue - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((pointerValue - Math.min(...scale.range())) / scale.step());
45
39
  if (dataIndex < 0 || dataIndex >= axisData.length) {
46
- return null;
40
+ return -1;
41
+ }
42
+ return reverse ? axisData.length - 1 - dataIndex : dataIndex;
43
+ }
44
+
45
+ /**
46
+ * For a pointer coordinate, this function returns the value associated.
47
+ * Returns `null` if the coordinate has no value associated.
48
+ */
49
+ export function getAxisValue(axisConfig, pointerValue, dataIndex) {
50
+ const {
51
+ scale,
52
+ data: axisData
53
+ } = axisConfig;
54
+ if (!isBandScale(scale)) {
55
+ const value = scale.invert(pointerValue);
56
+ if (dataIndex < 0) {
57
+ return value;
58
+ }
59
+ return axisData[dataIndex];
47
60
  }
48
- if (reverse) {
49
- const reverseIndex = axisData.length - 1 - dataIndex;
50
- return {
51
- index: reverseIndex,
52
- value: axisData[reverseIndex]
53
- };
61
+ if (dataIndex < 0 || dataIndex >= axisData.length) {
62
+ return null;
54
63
  }
55
- return {
56
- index: dataIndex,
57
- value: axisData[dataIndex]
58
- };
64
+ return axisData[dataIndex];
59
65
  }
@@ -1,6 +1,7 @@
1
1
  export { useChartCartesianAxis } from "./useChartCartesianAxis.js";
2
2
  export type * from './useChartCartesianAxis.types';
3
3
  export * from "./useChartCartesianAxisRendering.selectors.js";
4
+ export * from "./useChartCartesianInteraction.selectors.js";
4
5
  export { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.js";
5
6
  export * from "./computeAxisValue.js";
6
7
  export * from "./createZoomLookup.js";
@@ -1,5 +1,6 @@
1
1
  export { useChartCartesianAxis } from "./useChartCartesianAxis.js";
2
2
  export * from "./useChartCartesianAxisRendering.selectors.js";
3
+ export * from "./useChartCartesianInteraction.selectors.js";
3
4
  export { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.js";
4
5
  export * from "./computeAxisValue.js";
5
6
  export * from "./createZoomLookup.js";
@@ -9,9 +9,9 @@ import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/u
9
9
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
10
10
  import { defaultizeXAxis, defaultizeYAxis } from "./defaultizeAxis.js";
11
11
  import { selectorChartXAxis, selectorChartYAxis } from "./useChartCartesianAxisRendering.selectors.js";
12
- import { getAxisValue } from "./getAxisValue.js";
12
+ import { getAxisIndex } from "./getAxisValue.js";
13
13
  import { getSVGPoint } from "../../../getSVGPoint.js";
14
- import { selectorChartsInteractionAxis, selectorChartsInteractionIsInitialized } from "../useChartInteraction/index.js";
14
+ import { selectorChartsInteractionIsInitialized } from "../useChartInteraction/index.js";
15
15
  export const useChartCartesianAxis = ({
16
16
  params,
17
17
  store,
@@ -33,7 +33,6 @@ export const useChartCartesianAxis = ({
33
33
  }
34
34
  const drawingArea = useSelector(store, selectorChartDrawingArea);
35
35
  const processedSeries = useSelector(store, selectorChartSeriesProcessed);
36
- const interactionAxis = useSelector(store, selectorChartsInteractionAxis);
37
36
  const isInteractionEnabled = useSelector(store, selectorChartsInteractionIsInitialized);
38
37
  const {
39
38
  axis: xAxisWithScale,
@@ -75,21 +74,10 @@ export const useChartCartesianAxis = ({
75
74
  if (!instance.isPointInside(svgPoint, {
76
75
  targetElement: event.target
77
76
  })) {
78
- store.update(prev => _extends({}, prev, {
79
- interaction: {
80
- item: null,
81
- axis: {
82
- x: null,
83
- y: null
84
- }
85
- }
86
- }));
77
+ instance.cleanInteraction?.();
87
78
  return;
88
79
  }
89
- instance.setAxisInteraction?.({
90
- x: getAxisValue(xAxisWithScale[usedXAxis], svgPoint.x),
91
- y: getAxisValue(yAxisWithScale[usedYAxis], svgPoint.y)
92
- });
80
+ instance.setPointerCoordinate?.(svgPoint);
93
81
  };
94
82
  const handleDown = event => {
95
83
  const target = event.currentTarget;
@@ -102,31 +90,15 @@ export const useChartCartesianAxis = ({
102
90
  };
103
91
  element.addEventListener('pointerdown', handleDown);
104
92
  element.addEventListener('pointermove', handleMove);
105
- element.addEventListener('pointerout', handleOut);
106
93
  element.addEventListener('pointercancel', handleOut);
107
94
  element.addEventListener('pointerleave', handleOut);
108
95
  return () => {
109
96
  element.removeEventListener('pointerdown', handleDown);
110
97
  element.removeEventListener('pointermove', handleMove);
111
- element.removeEventListener('pointerout', handleOut);
112
98
  element.removeEventListener('pointercancel', handleOut);
113
99
  element.removeEventListener('pointerleave', handleOut);
114
100
  };
115
101
  }, [svgRef, store, xAxisWithScale, usedXAxis, yAxisWithScale, usedYAxis, instance, params.disableAxisListener, isInteractionEnabled]);
116
- const axisInteractionRef = React.useRef({
117
- x: null,
118
- y: null
119
- });
120
-
121
- // This avoids re-attaching the event listener on mouse move.
122
- React.useEffect(() => {
123
- const {
124
- x,
125
- y
126
- } = interactionAxis;
127
- axisInteractionRef.current.x = x;
128
- axisInteractionRef.current.y = y;
129
- }, [interactionAxis]);
130
102
  React.useEffect(() => {
131
103
  const element = svgRef.current;
132
104
  const onAxisClick = params.onAxisClick;
@@ -137,15 +109,10 @@ export const useChartCartesianAxis = ({
137
109
  event.preventDefault();
138
110
  let dataIndex = null;
139
111
  let isXAxis = false;
140
- if (axisInteractionRef.current.x === null && axisInteractionRef.current.y === null) {
141
- const svgPoint = getSVGPoint(element, event);
142
- const xIndex = getAxisValue(xAxisWithScale[usedXAxis], svgPoint.x)?.index ?? null;
143
- isXAxis = xIndex !== null && xIndex !== -1;
144
- dataIndex = isXAxis ? xIndex : getAxisValue(yAxisWithScale[usedYAxis], svgPoint.y)?.index ?? null;
145
- } else {
146
- isXAxis = axisInteractionRef.current.x !== null && axisInteractionRef.current.x.index !== -1;
147
- dataIndex = isXAxis ? axisInteractionRef.current.x && axisInteractionRef.current.x.index : axisInteractionRef.current.y && axisInteractionRef.current.y.index;
148
- }
112
+ const svgPoint = getSVGPoint(element, event);
113
+ const xIndex = getAxisIndex(xAxisWithScale[usedXAxis], svgPoint.x);
114
+ isXAxis = xIndex !== -1;
115
+ dataIndex = isXAxis ? xIndex : getAxisIndex(yAxisWithScale[usedYAxis], svgPoint.y);
149
116
  const USED_AXIS_ID = isXAxis ? xAxisIds[0] : yAxisIds[0];
150
117
  if (dataIndex == null || dataIndex === -1) {
151
118
  return;
@@ -175,7 +142,7 @@ export const useChartCartesianAxis = ({
175
142
  return () => {
176
143
  element.removeEventListener('click', handleMouseClick);
177
144
  };
178
- }, [params.onAxisClick, processedSeries, svgRef, xAxisWithScale, xAxisIds, yAxisWithScale, yAxisIds, axisInteractionRef, usedXAxis, usedYAxis]);
145
+ }, [params.onAxisClick, processedSeries, svgRef, xAxisWithScale, xAxisIds, yAxisWithScale, yAxisIds, usedXAxis, usedYAxis]);
179
146
  return {};
180
147
  };
181
148
  useChartCartesianAxis.params = {