@mui/x-charts 9.0.3 → 9.1.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 (191) hide show
  1. package/BarChart/BarChart.d.mts +1 -2
  2. package/BarChart/BarChart.d.ts +1 -2
  3. package/BarChart/BarChart.js +2 -913
  4. package/BarChart/BarChart.mjs +2 -913
  5. package/BarChart/FocusedBar.js +3 -0
  6. package/BarChart/FocusedBar.mjs +3 -0
  7. package/BarChart/seriesConfig/bar/seriesProcessor.js +2 -0
  8. package/BarChart/seriesConfig/bar/seriesProcessor.mjs +2 -0
  9. package/CHANGELOG.md +220 -0
  10. package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.d.mts +55 -0
  11. package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.d.ts +55 -0
  12. package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.js +94 -0
  13. package/ChartsAxisHighlightValue/ChartsAxisHighlightValue.mjs +88 -0
  14. package/ChartsAxisHighlightValue/ChartsAxisHighlightValueItem.d.mts +13 -0
  15. package/ChartsAxisHighlightValue/ChartsAxisHighlightValueItem.d.ts +13 -0
  16. package/ChartsAxisHighlightValue/ChartsAxisHighlightValueItem.js +86 -0
  17. package/ChartsAxisHighlightValue/ChartsAxisHighlightValueItem.mjs +80 -0
  18. package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.d.mts +18 -0
  19. package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.d.ts +18 -0
  20. package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.js +26 -0
  21. package/ChartsAxisHighlightValue/chartsAxisHighlightValueClasses.mjs +16 -0
  22. package/ChartsAxisHighlightValue/index.d.mts +1 -0
  23. package/ChartsAxisHighlightValue/index.d.ts +1 -0
  24. package/ChartsAxisHighlightValue/index.js +16 -0
  25. package/ChartsAxisHighlightValue/index.mjs +1 -0
  26. package/ChartsAxisHighlightValue/useAxisHighlightValue.d.mts +14 -0
  27. package/ChartsAxisHighlightValue/useAxisHighlightValue.d.ts +14 -0
  28. package/ChartsAxisHighlightValue/useAxisHighlightValue.js +130 -0
  29. package/ChartsAxisHighlightValue/useAxisHighlightValue.mjs +124 -0
  30. package/ChartsContainer/ChartsContainer.js +4 -1431
  31. package/ChartsContainer/ChartsContainer.mjs +4 -1431
  32. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.d.mts +15 -0
  33. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.d.ts +15 -0
  34. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.js +56 -0
  35. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.mjs +50 -0
  36. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.d.mts +6 -0
  37. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.d.ts +6 -0
  38. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.js +5 -0
  39. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlight.types.mjs +1 -0
  40. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlightPath.d.mts +11 -0
  41. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlightPath.d.ts +11 -0
  42. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlightPath.js +70 -0
  43. package/ChartsRadialAxisHighlight/ChartsRadialAxisHighlightPath.mjs +64 -0
  44. package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.d.mts +9 -0
  45. package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.d.ts +9 -0
  46. package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.js +87 -0
  47. package/ChartsRadialAxisHighlight/ChartsRadiusAxisHighlight.mjs +81 -0
  48. package/ChartsRadialAxisHighlight/ChartsRotationAxisHighlight.d.mts +9 -0
  49. package/ChartsRadialAxisHighlight/ChartsRotationAxisHighlight.d.ts +9 -0
  50. package/ChartsRadialAxisHighlight/ChartsRotationAxisHighlight.js +98 -0
  51. package/ChartsRadialAxisHighlight/ChartsRotationAxisHighlight.mjs +92 -0
  52. package/ChartsRadialAxisHighlight/chartsRadialAxisHighlightClasses.d.mts +7 -0
  53. package/ChartsRadialAxisHighlight/chartsRadialAxisHighlightClasses.d.ts +7 -0
  54. package/ChartsRadialAxisHighlight/chartsRadialAxisHighlightClasses.js +14 -0
  55. package/ChartsRadialAxisHighlight/chartsRadialAxisHighlightClasses.mjs +6 -0
  56. package/ChartsRadialAxisHighlight/index.d.mts +5 -0
  57. package/ChartsRadialAxisHighlight/index.d.ts +5 -0
  58. package/ChartsRadialAxisHighlight/index.js +47 -0
  59. package/ChartsRadialAxisHighlight/index.mjs +4 -0
  60. package/ChartsRadiusAxis/index.d.mts +3 -2
  61. package/ChartsRadiusAxis/index.d.ts +3 -2
  62. package/ChartsRadiusAxis/index.mjs +3 -1
  63. package/ChartsRotationAxis/index.d.mts +3 -2
  64. package/ChartsRotationAxis/index.d.ts +3 -2
  65. package/ChartsRotationAxis/index.mjs +3 -1
  66. package/ChartsTooltip/useAxesTooltip.js +11 -3
  67. package/ChartsTooltip/useAxesTooltip.mjs +11 -3
  68. package/ChartsXAxis/useAxisTicksProps.d.mts +162 -81
  69. package/ChartsXAxis/useAxisTicksProps.d.ts +162 -81
  70. package/ChartsYAxis/useAxisTicksProps.d.mts +162 -81
  71. package/ChartsYAxis/useAxisTicksProps.d.ts +162 -81
  72. package/LICENSE +2 -0
  73. package/LineChart/FocusedLineMark.js +3 -0
  74. package/LineChart/FocusedLineMark.mjs +3 -0
  75. package/LineChart/LineChart.js +2 -913
  76. package/LineChart/LineChart.mjs +2 -913
  77. package/LineChart/seriesConfig/curveEvaluation.d.mts +19 -1
  78. package/LineChart/seriesConfig/curveEvaluation.d.ts +19 -1
  79. package/LineChart/seriesConfig/curveEvaluation.js +132 -0
  80. package/LineChart/seriesConfig/curveEvaluation.mjs +131 -0
  81. package/LineChart/seriesConfig/getItemAtPosition.js +12 -35
  82. package/LineChart/seriesConfig/getItemAtPosition.mjs +10 -33
  83. package/LineChart/seriesConfig/getSeriesWithDefaultValues.js +2 -1
  84. package/LineChart/seriesConfig/getSeriesWithDefaultValues.mjs +2 -1
  85. package/LineChart/seriesConfig/seriesProcessor.js +4 -0
  86. package/LineChart/seriesConfig/seriesProcessor.mjs +4 -0
  87. package/LineChart/useAreaPlotData.js +4 -0
  88. package/LineChart/useAreaPlotData.mjs +4 -0
  89. package/LineChart/useLinePlotData.js +2 -0
  90. package/LineChart/useLinePlotData.mjs +2 -0
  91. package/LineChart/useMarkPlotData.js +2 -0
  92. package/LineChart/useMarkPlotData.mjs +2 -0
  93. package/PieChart/FocusedPieArc.js +3 -0
  94. package/PieChart/FocusedPieArc.mjs +3 -0
  95. package/RadarChart/FocusedRadarMark.js +3 -0
  96. package/RadarChart/FocusedRadarMark.mjs +3 -0
  97. package/ScatterChart/FocusedScatterMark.js +10 -21
  98. package/ScatterChart/FocusedScatterMark.mjs +10 -21
  99. package/ScatterChart/HighlightedScatterMark.d.mts +11 -0
  100. package/ScatterChart/HighlightedScatterMark.d.ts +11 -0
  101. package/ScatterChart/HighlightedScatterMark.js +68 -0
  102. package/ScatterChart/HighlightedScatterMark.mjs +62 -0
  103. package/ScatterChart/ScatterChart.d.mts +1 -2
  104. package/ScatterChart/ScatterChart.d.ts +1 -2
  105. package/ScatterChart/ScatterChart.js +2 -913
  106. package/ScatterChart/ScatterChart.mjs +2 -913
  107. package/ScatterChart/index.d.mts +1 -0
  108. package/ScatterChart/index.d.ts +1 -0
  109. package/ScatterChart/index.js +12 -0
  110. package/ScatterChart/index.mjs +1 -0
  111. package/ScatterChart/scatterClasses.d.mts +3 -1
  112. package/ScatterChart/scatterClasses.d.ts +3 -1
  113. package/ScatterChart/scatterClasses.js +3 -2
  114. package/ScatterChart/scatterClasses.mjs +3 -2
  115. package/ScatterChart/useScatterChartProps.js +3 -1
  116. package/ScatterChart/useScatterChartProps.mjs +3 -1
  117. package/ScatterChart/useScatterItemPosition.d.mts +16 -0
  118. package/ScatterChart/useScatterItemPosition.d.ts +16 -0
  119. package/ScatterChart/useScatterItemPosition.js +47 -0
  120. package/ScatterChart/useScatterItemPosition.mjs +41 -0
  121. package/SparkLineChart/SparkLineChart.js +2 -913
  122. package/SparkLineChart/SparkLineChart.mjs +2 -913
  123. package/hooks/useAxis.d.mts +3 -3
  124. package/hooks/useAxis.d.ts +3 -3
  125. package/hooks/useAxisSystem.d.mts +1 -1
  126. package/hooks/useAxisSystem.d.ts +1 -1
  127. package/hooks/useAxisSystem.js +1 -1
  128. package/hooks/useAxisSystem.mjs +1 -1
  129. package/index.d.mts +2 -0
  130. package/index.d.ts +2 -0
  131. package/index.js +25 -1
  132. package/index.mjs +3 -1
  133. package/internals/commonNextFocusItem.js +62 -8
  134. package/internals/commonNextFocusItem.mjs +62 -8
  135. package/internals/findClosestIndex.d.mts +5 -0
  136. package/internals/findClosestIndex.d.ts +5 -0
  137. package/internals/findClosestIndex.js +27 -0
  138. package/internals/findClosestIndex.mjs +22 -0
  139. package/internals/getAsNumber.d.mts +1 -0
  140. package/internals/getAsNumber.d.ts +1 -0
  141. package/internals/getAsNumber.js +9 -0
  142. package/internals/getAsNumber.mjs +3 -0
  143. package/internals/index.d.mts +6 -0
  144. package/internals/index.d.ts +6 -0
  145. package/internals/index.js +60 -0
  146. package/internals/index.mjs +6 -0
  147. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +4 -2
  148. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.mjs +4 -2
  149. package/internals/plugins/corePlugins/useChartSeriesConfig/types/polarExtremumGetter.types.d.mts +2 -2
  150. package/internals/plugins/corePlugins/useChartSeriesConfig/types/polarExtremumGetter.types.d.ts +2 -2
  151. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +4 -21
  152. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.mjs +4 -21
  153. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +3 -2
  154. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3 -2
  155. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.d.mts +30 -0
  156. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.d.ts +30 -0
  157. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.js +57 -0
  158. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.mjs +51 -0
  159. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +7 -1
  160. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.mjs +7 -1
  161. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +7 -1
  162. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.mjs +7 -1
  163. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.mts +4 -7
  164. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.ts +4 -7
  165. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -1
  166. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.mjs +2 -1
  167. package/internals/plugins/featurePlugins/useChartPolarAxis/defaultizeAxis.d.mts +3 -2
  168. package/internals/plugins/featurePlugins/useChartPolarAxis/defaultizeAxis.d.ts +3 -2
  169. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisExtremum.d.mts +2 -2
  170. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisExtremum.d.ts +2 -2
  171. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.d.mts +2 -2
  172. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.d.ts +2 -2
  173. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +27 -6
  174. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs +27 -5
  175. package/internals/plugins/featurePlugins/useChartPolarAxis/index.d.mts +2 -1
  176. package/internals/plugins/featurePlugins/useChartPolarAxis/index.d.ts +2 -1
  177. package/internals/plugins/featurePlugins/useChartPolarAxis/index.js +12 -0
  178. package/internals/plugins/featurePlugins/useChartPolarAxis/index.mjs +2 -1
  179. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.mts +4 -4
  180. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +4 -4
  181. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.mts +3 -3
  182. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +3 -3
  183. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.mts +1 -1
  184. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +1 -1
  185. package/models/axis.d.mts +28 -28
  186. package/models/axis.d.ts +28 -28
  187. package/models/axis.js +5 -1
  188. package/models/axis.mjs +5 -1
  189. package/models/seriesType/line.d.mts +6 -6
  190. package/models/seriesType/line.d.ts +6 -6
  191. package/package.json +170 -142
@@ -45,6 +45,8 @@ export function useLinePlotData(xAxes, yAxes) {
45
45
  const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
46
46
  if (process.env.NODE_ENV !== 'production') {
47
47
  if (xData === undefined) {
48
+ // TODO: fix mui/no-guarded-throw
49
+ // eslint-disable-next-line mui/no-guarded-throw
48
50
  throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
49
51
  }
50
52
  if (xData.length < stackedData.length) {
@@ -53,6 +53,8 @@ function useMarkPlotData(xAxes, yAxes) {
53
53
  const xData = xAxes[xAxisId].data;
54
54
  if (process.env.NODE_ENV !== 'production') {
55
55
  if (xData === undefined) {
56
+ // TODO: fix mui/no-guarded-throw
57
+ // eslint-disable-next-line mui/no-guarded-throw
56
58
  throw new Error(`MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
57
59
  }
58
60
  }
@@ -45,6 +45,8 @@ export function useMarkPlotData(xAxes, yAxes) {
45
45
  const xData = xAxes[xAxisId].data;
46
46
  if (process.env.NODE_ENV !== 'production') {
47
47
  if (xData === undefined) {
48
+ // TODO: fix mui/no-guarded-throw
49
+ // eslint-disable-next-line mui/no-guarded-throw
48
50
  throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have a data property to be able to display a line plot. ` + 'The x-axis data defines the positions for each point in the line. ' + 'Provide a data array to the x-axis configuration.');
49
51
  }
50
52
  }
@@ -38,6 +38,9 @@ function FocusedPieArc(props) {
38
38
  return null;
39
39
  }
40
40
  const item = series.data[focusedItem.dataIndex];
41
+ if (!item || item.hidden) {
42
+ return null;
43
+ }
41
44
  const _getModifiedArcProper = (0, _getModifiedArcProperties.getModifiedArcProperties)(series, pieSeriesLayout[focusedItem.seriesId], isHighlighted, isFaded),
42
45
  arcSizes = (0, _objectWithoutPropertiesLoose2.default)(_getModifiedArcProper, _excluded);
43
46
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PieArc.PieArc, (0, _extends2.default)({
@@ -32,6 +32,9 @@ export function FocusedPieArc(props) {
32
32
  return null;
33
33
  }
34
34
  const item = series.data[focusedItem.dataIndex];
35
+ if (!item || item.hidden) {
36
+ return null;
37
+ }
35
38
  const _getModifiedArcProper = getModifiedArcProperties(series, pieSeriesLayout[focusedItem.seriesId], isHighlighted, isFaded),
36
39
  arcSizes = _objectWithoutPropertiesLoose(_getModifiedArcProper, _excluded);
37
40
  return /*#__PURE__*/_jsx(PieArc, _extends({
@@ -20,6 +20,9 @@ function FocusedRadarMark(props) {
20
20
  if (!focusedItem || focusedItem.type !== 'radar' || seriesCoordinates.length === 0) {
21
21
  return null;
22
22
  }
23
+ if (seriesCoordinates[0].hidden) {
24
+ return null;
25
+ }
23
26
  const point = seriesCoordinates[0].points[focusedItem.dataIndex];
24
27
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _extends2.default)({
25
28
  fill: "none",
@@ -13,6 +13,9 @@ export function FocusedRadarMark(props) {
13
13
  if (!focusedItem || focusedItem.type !== 'radar' || seriesCoordinates.length === 0) {
14
14
  return null;
15
15
  }
16
+ if (seriesCoordinates[0].hidden) {
17
+ return null;
18
+ }
16
19
  const point = seriesCoordinates[0].points[focusedItem.dataIndex];
17
20
  return /*#__PURE__*/_jsx("rect", _extends({
18
21
  fill: "none",
@@ -13,8 +13,8 @@ var React = _interopRequireWildcard(require("react"));
13
13
  var _clsx = _interopRequireDefault(require("clsx"));
14
14
  var _styles = require("@mui/material/styles");
15
15
  var _useFocusedItem = require("../hooks/useFocusedItem");
16
- var _hooks = require("../hooks");
17
16
  var _scatterClasses = require("./scatterClasses");
17
+ var _useScatterItemPosition = require("./useScatterItemPosition");
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
  const _excluded = ["className"];
20
20
  function FocusedScatterMark(_ref) {
@@ -24,35 +24,24 @@ function FocusedScatterMark(_ref) {
24
24
  props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
25
25
  const theme = (0, _styles.useTheme)();
26
26
  const focusedItem = (0, _useFocusedItem.useFocusedItem)();
27
- const scatterSeries = (0, _hooks.useScatterSeriesContext)();
28
- const {
29
- xAxis,
30
- xAxisIds
31
- } = (0, _hooks.useXAxes)();
32
- const {
33
- yAxis,
34
- yAxisIds
35
- } = (0, _hooks.useYAxes)();
36
27
  const classes = (0, _scatterClasses.useUtilityClasses)();
37
- if (focusedItem === null || focusedItem.type !== 'scatter' || !scatterSeries) {
28
+ const resolved = (0, _useScatterItemPosition.useScatterItemPosition)(focusedItem?.type === 'scatter' ? focusedItem : null);
29
+ if (!resolved) {
38
30
  return null;
39
31
  }
40
- const series = scatterSeries?.series[focusedItem.seriesId];
41
- const xAxisId = series.xAxisId ?? xAxisIds[0];
42
- const yAxisId = series.yAxisId ?? yAxisIds[0];
43
- const getXPosition = (0, _hooks.getValueToPositionMapper)(xAxis[xAxisId].scale);
44
- const getYPosition = (0, _hooks.getValueToPositionMapper)(yAxis[yAxisId].scale);
45
- const scatterPoint = series.data[focusedItem.dataIndex];
46
- const x = getXPosition(scatterPoint.x);
47
- const y = getYPosition(scatterPoint.y);
32
+ const {
33
+ cx,
34
+ cy,
35
+ series
36
+ } = resolved;
48
37
  const size = series.markerSize + 3;
49
38
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", (0, _extends2.default)({
50
39
  className: (0, _clsx.default)(classes.focusedMark, className),
51
40
  fill: "none",
52
41
  stroke: (theme.vars ?? theme).palette.text.primary,
53
42
  strokeWidth: 2,
54
- x: x - size,
55
- y: y - size,
43
+ x: cx - size,
44
+ y: cy - size,
56
45
  width: 2 * size,
57
46
  height: 2 * size,
58
47
  rx: 3,
@@ -7,8 +7,8 @@ import * as React from 'react';
7
7
  import clsx from 'clsx';
8
8
  import { useTheme } from '@mui/material/styles';
9
9
  import { useFocusedItem } from "../hooks/useFocusedItem.mjs";
10
- import { getValueToPositionMapper, useScatterSeriesContext, useXAxes, useYAxes } from "../hooks/index.mjs";
11
10
  import { useUtilityClasses } from "./scatterClasses.mjs";
11
+ import { useScatterItemPosition } from "./useScatterItemPosition.mjs";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  export function FocusedScatterMark(_ref) {
14
14
  let {
@@ -17,35 +17,24 @@ export function FocusedScatterMark(_ref) {
17
17
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
18
18
  const theme = useTheme();
19
19
  const focusedItem = useFocusedItem();
20
- const scatterSeries = useScatterSeriesContext();
21
- const {
22
- xAxis,
23
- xAxisIds
24
- } = useXAxes();
25
- const {
26
- yAxis,
27
- yAxisIds
28
- } = useYAxes();
29
20
  const classes = useUtilityClasses();
30
- if (focusedItem === null || focusedItem.type !== 'scatter' || !scatterSeries) {
21
+ const resolved = useScatterItemPosition(focusedItem?.type === 'scatter' ? focusedItem : null);
22
+ if (!resolved) {
31
23
  return null;
32
24
  }
33
- const series = scatterSeries?.series[focusedItem.seriesId];
34
- const xAxisId = series.xAxisId ?? xAxisIds[0];
35
- const yAxisId = series.yAxisId ?? yAxisIds[0];
36
- const getXPosition = getValueToPositionMapper(xAxis[xAxisId].scale);
37
- const getYPosition = getValueToPositionMapper(yAxis[yAxisId].scale);
38
- const scatterPoint = series.data[focusedItem.dataIndex];
39
- const x = getXPosition(scatterPoint.x);
40
- const y = getYPosition(scatterPoint.y);
25
+ const {
26
+ cx,
27
+ cy,
28
+ series
29
+ } = resolved;
41
30
  const size = series.markerSize + 3;
42
31
  return /*#__PURE__*/_jsx("rect", _extends({
43
32
  className: clsx(classes.focusedMark, className),
44
33
  fill: "none",
45
34
  stroke: (theme.vars ?? theme).palette.text.primary,
46
35
  strokeWidth: 2,
47
- x: x - size,
48
- y: y - size,
36
+ x: cx - size,
37
+ y: cy - size,
49
38
  width: 2 * size,
50
39
  height: 2 * size,
51
40
  rx: 3,
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Draws an SVG ring around the currently highlighted scatter point.
4
+ * Used by renderers where the point itself is rasterized off the SVG tree
5
+ * (for example WebGL or `svg-batch`), so the highlight has to be drawn in SVG
6
+ * and positioned via the same axis scales the underlying renderer uses.
7
+ */
8
+ export declare function HighlightedScatterMark({
9
+ className,
10
+ ...props
11
+ }: React.SVGAttributes<SVGCircleElement>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Draws an SVG ring around the currently highlighted scatter point.
4
+ * Used by renderers where the point itself is rasterized off the SVG tree
5
+ * (for example WebGL or `svg-batch`), so the highlight has to be drawn in SVG
6
+ * and positioned via the same axis scales the underlying renderer uses.
7
+ */
8
+ export declare function HighlightedScatterMark({
9
+ className,
10
+ ...props
11
+ }: React.SVGAttributes<SVGCircleElement>): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.HighlightedScatterMark = HighlightedScatterMark;
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
12
+ var React = _interopRequireWildcard(require("react"));
13
+ var _clsx = _interopRequireDefault(require("clsx"));
14
+ var _styles = require("@mui/material/styles");
15
+ var _useChartHighlight = require("../internals/plugins/featurePlugins/useChartHighlight");
16
+ var _useChartDimensions = require("../internals/plugins/corePlugins/useChartDimensions");
17
+ var _useStore = require("../internals/store/useStore");
18
+ var _scatterClasses = require("./scatterClasses");
19
+ var _useScatterItemPosition = require("./useScatterItemPosition");
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+ const _excluded = ["className"];
22
+ /**
23
+ * Draws an SVG ring around the currently highlighted scatter point.
24
+ * Used by renderers where the point itself is rasterized off the SVG tree
25
+ * (for example WebGL or `svg-batch`), so the highlight has to be drawn in SVG
26
+ * and positioned via the same axis scales the underlying renderer uses.
27
+ */
28
+ function HighlightedScatterMark(_ref) {
29
+ let {
30
+ className
31
+ } = _ref,
32
+ props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
33
+ const theme = (0, _styles.useTheme)();
34
+ const store = (0, _useStore.useStore)();
35
+ const highlightedItem = store.use(_useChartHighlight.selectorChartsHighlightedItem);
36
+ const drawingArea = store.use(_useChartDimensions.selectorChartDrawingArea);
37
+ const classes = (0, _scatterClasses.useUtilityClasses)();
38
+ const isHighlightedScatter = highlightedItem?.type === 'scatter' && highlightedItem.dataIndex !== undefined;
39
+ const resolved = (0, _useScatterItemPosition.useScatterItemPosition)(isHighlightedScatter ? {
40
+ seriesId: highlightedItem.seriesId,
41
+ dataIndex: highlightedItem.dataIndex
42
+ } : null);
43
+ if (!resolved) {
44
+ return null;
45
+ }
46
+ const {
47
+ cx,
48
+ cy,
49
+ series
50
+ } = resolved;
51
+
52
+ // Allow a markerSize margin around the drawing area so the highlight ring stays
53
+ // visible at the edges (e.g. during keyboard navigation) without needing a clip-path.
54
+ const margin = series.markerSize;
55
+ if (cx < drawingArea.left - margin || cx > drawingArea.left + drawingArea.width + margin || cy < drawingArea.top - margin || cy > drawingArea.top + drawingArea.height + margin) {
56
+ return null;
57
+ }
58
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", (0, _extends2.default)({
59
+ className: (0, _clsx.default)(classes.highlightedMark, className),
60
+ fill: "none",
61
+ stroke: (theme.vars ?? theme).palette.text.primary,
62
+ strokeWidth: 1,
63
+ cx: cx,
64
+ cy: cy,
65
+ r: series.markerSize,
66
+ pointerEvents: "none"
67
+ }, props));
68
+ }
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
+ const _excluded = ["className"];
6
+ import * as React from 'react';
7
+ import clsx from 'clsx';
8
+ import { useTheme } from '@mui/material/styles';
9
+ import { selectorChartsHighlightedItem } from "../internals/plugins/featurePlugins/useChartHighlight/index.mjs";
10
+ import { selectorChartDrawingArea } from "../internals/plugins/corePlugins/useChartDimensions/index.mjs";
11
+ import { useStore } from "../internals/store/useStore.mjs";
12
+ import { useUtilityClasses } from "./scatterClasses.mjs";
13
+ import { useScatterItemPosition } from "./useScatterItemPosition.mjs";
14
+
15
+ /**
16
+ * Draws an SVG ring around the currently highlighted scatter point.
17
+ * Used by renderers where the point itself is rasterized off the SVG tree
18
+ * (for example WebGL or `svg-batch`), so the highlight has to be drawn in SVG
19
+ * and positioned via the same axis scales the underlying renderer uses.
20
+ */
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ export function HighlightedScatterMark(_ref) {
23
+ let {
24
+ className
25
+ } = _ref,
26
+ props = _objectWithoutPropertiesLoose(_ref, _excluded);
27
+ const theme = useTheme();
28
+ const store = useStore();
29
+ const highlightedItem = store.use(selectorChartsHighlightedItem);
30
+ const drawingArea = store.use(selectorChartDrawingArea);
31
+ const classes = useUtilityClasses();
32
+ const isHighlightedScatter = highlightedItem?.type === 'scatter' && highlightedItem.dataIndex !== undefined;
33
+ const resolved = useScatterItemPosition(isHighlightedScatter ? {
34
+ seriesId: highlightedItem.seriesId,
35
+ dataIndex: highlightedItem.dataIndex
36
+ } : null);
37
+ if (!resolved) {
38
+ return null;
39
+ }
40
+ const {
41
+ cx,
42
+ cy,
43
+ series
44
+ } = resolved;
45
+
46
+ // Allow a markerSize margin around the drawing area so the highlight ring stays
47
+ // visible at the edges (e.g. during keyboard navigation) without needing a clip-path.
48
+ const margin = series.markerSize;
49
+ if (cx < drawingArea.left - margin || cx > drawingArea.left + drawingArea.width + margin || cy < drawingArea.top - margin || cy > drawingArea.top + drawingArea.height + margin) {
50
+ return null;
51
+ }
52
+ return /*#__PURE__*/_jsx("circle", _extends({
53
+ className: clsx(classes.highlightedMark, className),
54
+ fill: "none",
55
+ stroke: (theme.vars ?? theme).palette.text.primary,
56
+ strokeWidth: 1,
57
+ cx: cx,
58
+ cy: cy,
59
+ r: series.markerSize,
60
+ pointerEvents: "none"
61
+ }, props));
62
+ }
@@ -4,7 +4,6 @@ import { type ChartsToolbarSlotProps, type ChartsToolbarSlots } from "../Toolbar
4
4
  import { type ChartsSlots, type ChartsSlotProps } from "../internals/material/index.mjs";
5
5
  import { type ScatterPlotProps, type ScatterPlotSlotProps, type ScatterPlotSlots } from "./ScatterPlot.mjs";
6
6
  import { type ChartsContainerProps } from "../ChartsContainer/index.mjs";
7
- import { type ChartsAxisProps } from "../ChartsAxis/index.mjs";
8
7
  import { type ScatterSeriesType } from "../models/seriesType/scatter.mjs";
9
8
  import { type ChartsTooltipProps } from "../ChartsTooltip/index.mjs";
10
9
  import { type ChartsTooltipSlots, type ChartsTooltipSlotProps } from "../ChartsTooltip/ChartTooltip.types.mjs";
@@ -24,7 +23,7 @@ export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotS
24
23
  tooltip?: Partial<ChartsTooltipProps<'item' | 'none'>>;
25
24
  }
26
25
  export type ScatterSeries = MakeOptional<ScatterSeriesType, 'type'>;
27
- export interface ScatterChartProps extends Omit<ChartsContainerProps<'scatter', ScatterChartPluginSignatures>, 'series' | 'plugins' | 'onItemClick' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<ScatterPlotProps, 'renderer'> {
26
+ export interface ScatterChartProps extends Omit<ChartsContainerProps<'scatter', ScatterChartPluginSignatures>, 'series' | 'plugins' | 'onItemClick' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<ScatterPlotProps, 'renderer'> {
28
27
  /**
29
28
  * The series to display in the scatter chart.
30
29
  * An array of [[ScatterSeries]] objects.
@@ -4,7 +4,6 @@ import { type ChartsToolbarSlotProps, type ChartsToolbarSlots } from "../Toolbar
4
4
  import { type ChartsSlots, type ChartsSlotProps } from "../internals/material/index.js";
5
5
  import { type ScatterPlotProps, type ScatterPlotSlotProps, type ScatterPlotSlots } from "./ScatterPlot.js";
6
6
  import { type ChartsContainerProps } from "../ChartsContainer/index.js";
7
- import { type ChartsAxisProps } from "../ChartsAxis/index.js";
8
7
  import { type ScatterSeriesType } from "../models/seriesType/scatter.js";
9
8
  import { type ChartsTooltipProps } from "../ChartsTooltip/index.js";
10
9
  import { type ChartsTooltipSlots, type ChartsTooltipSlotProps } from "../ChartsTooltip/ChartTooltip.types.js";
@@ -24,7 +23,7 @@ export interface ScatterChartSlotProps extends ChartsAxisSlotProps, ScatterPlotS
24
23
  tooltip?: Partial<ChartsTooltipProps<'item' | 'none'>>;
25
24
  }
26
25
  export type ScatterSeries = MakeOptional<ScatterSeriesType, 'type'>;
27
- export interface ScatterChartProps extends Omit<ChartsContainerProps<'scatter', ScatterChartPluginSignatures>, 'series' | 'plugins' | 'onItemClick' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<ScatterPlotProps, 'renderer'> {
26
+ export interface ScatterChartProps extends Omit<ChartsContainerProps<'scatter', ScatterChartPluginSignatures>, 'series' | 'plugins' | 'onItemClick' | 'highlightedAxis' | 'onHighlightedAxisChange'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<ScatterPlotProps, 'renderer'> {
28
27
  /**
29
28
  * The series to display in the scatter chart.
30
29
  * An array of [[ScatterSeries]] objects.