@mui/x-charts 9.0.2 → 9.0.4

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 (150) hide show
  1. package/BarChart/BarChart.js +2 -1
  2. package/BarChart/BarChart.mjs +2 -1
  3. package/BarChart/BarPlot.js +2 -1
  4. package/BarChart/BarPlot.mjs +2 -1
  5. package/BarChart/FocusedBar.js +3 -0
  6. package/BarChart/FocusedBar.mjs +3 -0
  7. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +8 -8
  8. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +8 -8
  9. package/CHANGELOG.md +223 -0
  10. package/ChartsRadialGrid/ChartsRadialGrid.js +2 -0
  11. package/ChartsRadialGrid/ChartsRadialGrid.mjs +2 -0
  12. package/ChartsRadialGrid/ChartsRadiusGrid.d.mts +1 -0
  13. package/ChartsRadialGrid/ChartsRadiusGrid.d.ts +1 -0
  14. package/ChartsRadialGrid/ChartsRadiusGrid.js +1 -2
  15. package/ChartsRadialGrid/ChartsRadiusGrid.mjs +1 -2
  16. package/ChartsRadiusAxis/ChartsRadiusAxis.d.mts +48 -0
  17. package/ChartsRadiusAxis/ChartsRadiusAxis.d.ts +48 -0
  18. package/ChartsRadiusAxis/ChartsRadiusAxis.js +147 -0
  19. package/ChartsRadiusAxis/ChartsRadiusAxis.mjs +141 -0
  20. package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.mts +6 -0
  21. package/ChartsRadiusAxis/chartsRadiusAxisClasses.d.ts +6 -0
  22. package/ChartsRadiusAxis/chartsRadiusAxisClasses.js +30 -0
  23. package/ChartsRadiusAxis/chartsRadiusAxisClasses.mjs +17 -0
  24. package/ChartsRadiusAxis/createGetLabelTextAnchors.d.mts +10 -0
  25. package/ChartsRadiusAxis/createGetLabelTextAnchors.d.ts +10 -0
  26. package/ChartsRadiusAxis/createGetLabelTextAnchors.js +46 -0
  27. package/ChartsRadiusAxis/createGetLabelTextAnchors.mjs +39 -0
  28. package/ChartsRadiusAxis/getLabelTransform.d.mts +11 -0
  29. package/ChartsRadiusAxis/getLabelTransform.d.ts +11 -0
  30. package/ChartsRadiusAxis/getLabelTransform.js +37 -0
  31. package/ChartsRadiusAxis/getLabelTransform.mjs +31 -0
  32. package/ChartsRadiusAxis/index.d.mts +3 -0
  33. package/ChartsRadiusAxis/index.d.ts +3 -0
  34. package/ChartsRadiusAxis/index.js +19 -0
  35. package/ChartsRadiusAxis/index.mjs +2 -0
  36. package/ChartsRadiusAxis/sharedRadialAxisClasses.d.mts +21 -0
  37. package/ChartsRadiusAxis/sharedRadialAxisClasses.d.ts +21 -0
  38. package/ChartsRadiusAxis/sharedRadialAxisClasses.js +14 -0
  39. package/ChartsRadiusAxis/sharedRadialAxisClasses.mjs +6 -0
  40. package/ChartsRotationAxis/ChartsRotationAxis.d.mts +48 -0
  41. package/ChartsRotationAxis/ChartsRotationAxis.d.ts +48 -0
  42. package/ChartsRotationAxis/ChartsRotationAxis.js +141 -0
  43. package/ChartsRotationAxis/ChartsRotationAxis.mjs +135 -0
  44. package/ChartsRotationAxis/chartsRotationAxisClasses.d.mts +5 -0
  45. package/ChartsRotationAxis/chartsRotationAxisClasses.d.ts +5 -0
  46. package/ChartsRotationAxis/chartsRotationAxisClasses.js +29 -0
  47. package/ChartsRotationAxis/chartsRotationAxisClasses.mjs +16 -0
  48. package/ChartsRotationAxis/getLabelTransform.d.mts +11 -0
  49. package/ChartsRotationAxis/getLabelTransform.d.ts +11 -0
  50. package/ChartsRotationAxis/getLabelTransform.js +37 -0
  51. package/ChartsRotationAxis/getLabelTransform.mjs +31 -0
  52. package/ChartsRotationAxis/index.d.mts +2 -0
  53. package/ChartsRotationAxis/index.d.ts +2 -0
  54. package/ChartsRotationAxis/index.js +19 -0
  55. package/ChartsRotationAxis/index.mjs +2 -0
  56. package/ChartsTooltip/useAxesTooltip.js +18 -7
  57. package/ChartsTooltip/useAxesTooltip.mjs +19 -8
  58. package/ChartsTooltip/useItemTooltip.d.mts +1 -1
  59. package/ChartsTooltip/useItemTooltip.d.ts +1 -1
  60. package/ChartsTooltip/useItemTooltip.js +17 -2
  61. package/ChartsTooltip/useItemTooltip.mjs +18 -3
  62. package/ChartsXAxis/useAxisTicksProps.d.mts +245 -164
  63. package/ChartsXAxis/useAxisTicksProps.d.ts +245 -164
  64. package/ChartsYAxis/useAxisTicksProps.d.mts +245 -164
  65. package/ChartsYAxis/useAxisTicksProps.d.ts +245 -164
  66. package/LineChart/FocusedLineMark.js +3 -0
  67. package/LineChart/FocusedLineMark.mjs +3 -0
  68. package/LineChart/seriesConfig/curveEvaluation.js +24 -19
  69. package/LineChart/seriesConfig/curveEvaluation.mjs +24 -19
  70. package/LineChart/seriesConfig/getItemAtPosition.js +25 -37
  71. package/LineChart/seriesConfig/getItemAtPosition.mjs +24 -36
  72. package/LineChart/seriesConfig/getSeriesWithDefaultValues.js +4 -6
  73. package/LineChart/seriesConfig/getSeriesWithDefaultValues.mjs +4 -6
  74. package/LineChart/seriesConfig/seriesProcessor.d.mts +4 -2
  75. package/LineChart/seriesConfig/seriesProcessor.d.ts +4 -2
  76. package/LineChart/seriesConfig/seriesProcessor.js +2 -2
  77. package/LineChart/seriesConfig/seriesProcessor.mjs +2 -2
  78. package/PieChart/FocusedPieArc.js +3 -0
  79. package/PieChart/FocusedPieArc.mjs +3 -0
  80. package/RadarChart/FocusedRadarMark.js +3 -0
  81. package/RadarChart/FocusedRadarMark.mjs +3 -0
  82. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.mts +2 -2
  83. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
  84. package/ScatterChart/FocusedScatterMark.js +3 -0
  85. package/ScatterChart/FocusedScatterMark.mjs +3 -0
  86. package/hooks/useAxis.d.mts +2 -2
  87. package/hooks/useAxis.d.ts +2 -2
  88. package/index.d.mts +2 -0
  89. package/index.d.ts +2 -0
  90. package/index.js +22 -2
  91. package/index.mjs +3 -1
  92. package/internals/commonNextFocusItem.js +62 -8
  93. package/internals/commonNextFocusItem.mjs +62 -8
  94. package/internals/cubiqSolver.d.mts +5 -0
  95. package/internals/cubiqSolver.d.ts +5 -0
  96. package/internals/cubiqSolver.js +62 -0
  97. package/internals/cubiqSolver.mjs +56 -0
  98. package/internals/findClosestIndex.d.mts +5 -0
  99. package/internals/findClosestIndex.d.ts +5 -0
  100. package/internals/findClosestIndex.js +27 -0
  101. package/internals/findClosestIndex.mjs +22 -0
  102. package/internals/getAsNumber.d.mts +1 -0
  103. package/internals/getAsNumber.d.ts +1 -0
  104. package/internals/getAsNumber.js +9 -0
  105. package/internals/getAsNumber.mjs +3 -0
  106. package/internals/index.d.mts +6 -1
  107. package/internals/index.d.ts +6 -1
  108. package/internals/index.js +59 -2
  109. package/internals/index.mjs +6 -1
  110. package/internals/isPolar.d.mts +3 -2
  111. package/internals/isPolar.d.ts +3 -2
  112. package/internals/isPolar.js +4 -0
  113. package/internals/isPolar.mjs +3 -0
  114. package/internals/plugins/corePlugins/useChartSeriesConfig/types/colorProcessor.types.d.mts +8 -9
  115. package/internals/plugins/corePlugins/useChartSeriesConfig/types/colorProcessor.types.d.ts +8 -9
  116. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +4 -21
  117. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.mjs +4 -21
  118. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.d.mts +30 -0
  119. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.d.ts +30 -0
  120. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.js +57 -0
  121. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/findVisibleDataIndex.mjs +51 -0
  122. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +7 -1
  123. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.mjs +7 -1
  124. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +7 -1
  125. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.mjs +7 -1
  126. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.mts +3 -2
  127. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.d.ts +3 -2
  128. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +25 -14
  129. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.mjs +25 -14
  130. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +9 -4
  131. package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.mjs +9 -3
  132. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +2 -2
  133. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
  134. package/models/axis.d.mts +2 -0
  135. package/models/axis.d.ts +2 -0
  136. package/models/seriesType/bar.d.mts +12 -7
  137. package/models/seriesType/bar.d.ts +12 -7
  138. package/models/seriesType/common.d.mts +10 -0
  139. package/models/seriesType/common.d.ts +10 -0
  140. package/models/seriesType/composition.d.mts +3 -1
  141. package/models/seriesType/composition.d.ts +3 -1
  142. package/models/seriesType/composition.js +6 -2
  143. package/models/seriesType/composition.mjs +5 -1
  144. package/models/seriesType/index.d.mts +3 -3
  145. package/models/seriesType/index.d.ts +3 -3
  146. package/models/seriesType/index.js +0 -22
  147. package/models/seriesType/index.mjs +0 -2
  148. package/models/seriesType/line.d.mts +13 -8
  149. package/models/seriesType/line.d.ts +13 -8
  150. package/package.json +32 -4
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -25,7 +26,8 @@ var _exportNames = {
25
26
  getBandSize: true,
26
27
  useChartsTooltipUtilityClasses: true,
27
28
  getChartsTooltipUtilityClass: true,
28
- getAxisExtrema: true
29
+ getAxisExtrema: true,
30
+ getLineItemAtPosition: true
29
31
  };
30
32
  Object.defineProperty(exports, "checkBarChartScaleErrors", {
31
33
  enumerable: true,
@@ -69,6 +71,12 @@ Object.defineProperty(exports, "getChartsTooltipUtilityClass", {
69
71
  return _chartsTooltipClasses.getChartsTooltipUtilityClass;
70
72
  }
71
73
  });
74
+ Object.defineProperty(exports, "getLineItemAtPosition", {
75
+ enumerable: true,
76
+ get: function () {
77
+ return _getItemAtPosition.default;
78
+ }
79
+ });
72
80
  Object.defineProperty(exports, "getSeriesColorFn", {
73
81
  enumerable: true,
74
82
  get: function () {
@@ -266,6 +274,18 @@ Object.keys(_useChartsDataProviderProps).forEach(function (key) {
266
274
  }
267
275
  });
268
276
  });
277
+ var _useChartsRadialDataProviderProps = require("../ChartsRadialDataProvider/useChartsRadialDataProviderProps");
278
+ Object.keys(_useChartsRadialDataProviderProps).forEach(function (key) {
279
+ if (key === "default" || key === "__esModule") return;
280
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
281
+ if (key in exports && exports[key] === _useChartsRadialDataProviderProps[key]) return;
282
+ Object.defineProperty(exports, key, {
283
+ enumerable: true,
284
+ get: function () {
285
+ return _useChartsRadialDataProviderProps[key];
286
+ }
287
+ });
288
+ });
269
289
  var _seriesSelectorOfType = require("./seriesSelectorOfType");
270
290
  Object.keys(_seriesSelectorOfType).forEach(function (key) {
271
291
  if (key === "default" || key === "__esModule") return;
@@ -666,6 +686,18 @@ Object.keys(_getCurve).forEach(function (key) {
666
686
  }
667
687
  });
668
688
  });
689
+ var _getSymbol = require("./getSymbol");
690
+ Object.keys(_getSymbol).forEach(function (key) {
691
+ if (key === "default" || key === "__esModule") return;
692
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
693
+ if (key in exports && exports[key] === _getSymbol[key]) return;
694
+ Object.defineProperty(exports, key, {
695
+ enumerable: true,
696
+ get: function () {
697
+ return _getSymbol[key];
698
+ }
699
+ });
700
+ });
669
701
  var _consumeSlots = require("./consumeSlots");
670
702
  Object.keys(_consumeSlots).forEach(function (key) {
671
703
  if (key === "default" || key === "__esModule") return;
@@ -852,6 +884,30 @@ Object.keys(_common).forEach(function (key) {
852
884
  }
853
885
  });
854
886
  });
887
+ var _line = require("../models/seriesType/line");
888
+ Object.keys(_line).forEach(function (key) {
889
+ if (key === "default" || key === "__esModule") return;
890
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
891
+ if (key in exports && exports[key] === _line[key]) return;
892
+ Object.defineProperty(exports, key, {
893
+ enumerable: true,
894
+ get: function () {
895
+ return _line[key];
896
+ }
897
+ });
898
+ });
899
+ var _bar = require("../models/seriesType/bar");
900
+ Object.keys(_bar).forEach(function (key) {
901
+ if (key === "default" || key === "__esModule") return;
902
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
903
+ if (key in exports && exports[key] === _bar[key]) return;
904
+ Object.defineProperty(exports, key, {
905
+ enumerable: true,
906
+ get: function () {
907
+ return _bar[key];
908
+ }
909
+ });
910
+ });
855
911
  var _zAxis = require("../models/z-axis");
856
912
  Object.keys(_zAxis).forEach(function (key) {
857
913
  if (key === "default" || key === "__esModule") return;
@@ -971,4 +1027,5 @@ Object.keys(_identifierCleaner).forEach(function (key) {
971
1027
  return _identifierCleaner[key];
972
1028
  }
973
1029
  });
974
- });
1030
+ });
1031
+ var _getItemAtPosition = _interopRequireDefault(require("../LineChart/seriesConfig/getItemAtPosition"));
@@ -20,6 +20,7 @@ export { processBarDataForPlot } from "../BarChart/useBarPlotData.mjs";
20
20
  export { useRadarChartProps } from "../RadarChart/useRadarChartProps.mjs";
21
21
  export * from "../ChartsContainer/useChartsContainerProps.mjs";
22
22
  export * from "../ChartsDataProvider/useChartsDataProviderProps.mjs";
23
+ export * from "../ChartsRadialDataProvider/useChartsRadialDataProviderProps.mjs";
23
24
  export * from "./seriesSelectorOfType.mjs";
24
25
  export { useSkipAnimation } from "../hooks/useSkipAnimation.mjs";
25
26
  export { useRegisterPointerInteractions } from "./plugins/featurePlugins/shared/useRegisterPointerInteractions.mjs";
@@ -63,6 +64,7 @@ export * from "./isDefined.mjs";
63
64
  export * from "./getScale.mjs";
64
65
  export * from "./stacking/index.mjs";
65
66
  export * from "./getCurve.mjs";
67
+ export * from "./getSymbol.mjs";
66
68
  export * from "./consumeSlots.mjs";
67
69
  export * from "./consumeThemeProps.mjs";
68
70
  export * from "./defaultizeMargin.mjs";
@@ -88,6 +90,8 @@ export * from "../context/ChartsSlotsContext.mjs";
88
90
  // series configuration
89
91
  export * from "../models/seriesType/config.mjs";
90
92
  export * from "../models/seriesType/common.mjs";
93
+ export * from "../models/seriesType/line.mjs";
94
+ export * from "../models/seriesType/bar.mjs";
91
95
  export * from "../models/z-axis.mjs";
92
96
  export * from "../models/axis.mjs";
93
97
  export * from "../models/seriesType/composition.mjs";
@@ -97,4 +101,5 @@ export * from "./createSvgIcon.mjs";
97
101
  export * from "./constants.mjs";
98
102
  export * from "./scales/index.mjs";
99
103
  export * from "./identifierSerializer.mjs";
100
- export * from "./identifierCleaner.mjs";
104
+ export * from "./identifierCleaner.mjs";
105
+ export { default as getLineItemAtPosition } from "../LineChart/seriesConfig/getItemAtPosition.mjs";
@@ -1,2 +1,3 @@
1
- import { type PolarChartSeriesType } from "../models/seriesType/config.mjs";
2
- export declare function isPolarSeriesType(seriesType: string): seriesType is PolarChartSeriesType;
1
+ import { type ChartSeriesType, type ChartSeriesDefaultized, type PolarChartSeriesType } from "../models/seriesType/config.mjs";
2
+ export declare function isPolarSeriesType(seriesType: string): seriesType is PolarChartSeriesType;
3
+ export declare function isPolarSeries(series: ChartSeriesDefaultized<ChartSeriesType>): series is ChartSeriesDefaultized<PolarChartSeriesType>;
@@ -1,2 +1,3 @@
1
- import { type PolarChartSeriesType } from "../models/seriesType/config.js";
2
- export declare function isPolarSeriesType(seriesType: string): seriesType is PolarChartSeriesType;
1
+ import { type ChartSeriesType, type ChartSeriesDefaultized, type PolarChartSeriesType } from "../models/seriesType/config.js";
2
+ export declare function isPolarSeriesType(seriesType: string): seriesType is PolarChartSeriesType;
3
+ export declare function isPolarSeries(series: ChartSeriesDefaultized<ChartSeriesType>): series is ChartSeriesDefaultized<PolarChartSeriesType>;
@@ -3,8 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.isPolarSeries = isPolarSeries;
6
7
  exports.isPolarSeriesType = isPolarSeriesType;
7
8
  var _configInit = require("./configInit");
8
9
  function isPolarSeriesType(seriesType) {
9
10
  return _configInit.polarSeriesTypes.getTypes().has(seriesType);
11
+ }
12
+ function isPolarSeries(series) {
13
+ return isPolarSeriesType(series.type);
10
14
  }
@@ -1,4 +1,7 @@
1
1
  import { polarSeriesTypes } from "./configInit.mjs";
2
2
  export function isPolarSeriesType(seriesType) {
3
3
  return polarSeriesTypes.getTypes().has(seriesType);
4
+ }
5
+ export function isPolarSeries(series) {
6
+ return isPolarSeriesType(series.type);
4
7
  }
@@ -1,4 +1,4 @@
1
- import type { ComputedXAxis, ComputedYAxis } from "../../../../../models/axis.mjs";
1
+ import type { ChartsRadiusAxisProps, ChartsRotationAxisProps, ComputedAxis, ComputedXAxis, ComputedYAxis, ScaleName } from "../../../../../models/axis.mjs";
2
2
  import type { DefaultizedSeriesType } from "../../../../../models/seriesType/index.mjs";
3
3
  import type { ZAxisDefaultized } from "../../../../../models/z-axis.mjs";
4
4
  import type { ChartSeriesType } from "../../../../../models/seriesType/config.mjs";
@@ -7,13 +7,12 @@ import type { ChartSeriesType } from "../../../../../models/seriesType/config.mj
7
7
  * If dataIndex is not defined, it falls back to the series color when defined.
8
8
  */
9
9
  export type ColorGetter<SeriesType extends ChartSeriesType> = SeriesType extends 'pie' | 'funnel' ? (dataIndex: number) => string : SeriesType extends 'heatmap' ? (value: number | null) => string : (dataIndex?: number) => string;
10
+ export type ColorProcessor<SeriesType extends ChartSeriesType> = (series: DefaultizedSeriesType<SeriesType>,
10
11
  /**
11
- * Transforms charts config to a color getter.
12
- * If dataIndex is not defined, it falls back to the series color.
13
- * @param {DefaultizedSeriesType<SeriesType>} series - The series configuration.
14
- * @param {ComputedXAxis | undefined} xAxis - The computed x-axis configuration.
15
- * @param {ComputedYAxis | undefined} yAxis - The computed y-axis configuration.
16
- * @param {ZAxisDefaultized | undefined} zAxis - The defaulted z-axis configuration.
17
- * @returns {ColorGetter<SeriesType>} A function that takes a data index and returns a color string.
12
+ * Either the x-axis or rotation-axis, depending on the coordinate system.
18
13
  */
19
- export type ColorProcessor<SeriesType extends ChartSeriesType> = (series: DefaultizedSeriesType<SeriesType>, xAxis?: ComputedXAxis, yAxis?: ComputedYAxis, zAxis?: ZAxisDefaultized) => ColorGetter<SeriesType>;
14
+ mainAxis?: ComputedXAxis | ComputedAxis<ScaleName, any, ChartsRotationAxisProps>,
15
+ /**
16
+ * Either the y-axis or radius-axis, depending on the coordinate system.
17
+ */
18
+ secondaryAxis?: ComputedYAxis | ComputedAxis<ScaleName, any, ChartsRadiusAxisProps>, zAxis?: ZAxisDefaultized) => ColorGetter<SeriesType>;
@@ -1,4 +1,4 @@
1
- import type { ComputedXAxis, ComputedYAxis } from "../../../../../models/axis.js";
1
+ import type { ChartsRadiusAxisProps, ChartsRotationAxisProps, ComputedAxis, ComputedXAxis, ComputedYAxis, ScaleName } from "../../../../../models/axis.js";
2
2
  import type { DefaultizedSeriesType } from "../../../../../models/seriesType/index.js";
3
3
  import type { ZAxisDefaultized } from "../../../../../models/z-axis.js";
4
4
  import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
@@ -7,13 +7,12 @@ import type { ChartSeriesType } from "../../../../../models/seriesType/config.js
7
7
  * If dataIndex is not defined, it falls back to the series color when defined.
8
8
  */
9
9
  export type ColorGetter<SeriesType extends ChartSeriesType> = SeriesType extends 'pie' | 'funnel' ? (dataIndex: number) => string : SeriesType extends 'heatmap' ? (value: number | null) => string : (dataIndex?: number) => string;
10
+ export type ColorProcessor<SeriesType extends ChartSeriesType> = (series: DefaultizedSeriesType<SeriesType>,
10
11
  /**
11
- * Transforms charts config to a color getter.
12
- * If dataIndex is not defined, it falls back to the series color.
13
- * @param {DefaultizedSeriesType<SeriesType>} series - The series configuration.
14
- * @param {ComputedXAxis | undefined} xAxis - The computed x-axis configuration.
15
- * @param {ComputedYAxis | undefined} yAxis - The computed y-axis configuration.
16
- * @param {ZAxisDefaultized | undefined} zAxis - The defaulted z-axis configuration.
17
- * @returns {ColorGetter<SeriesType>} A function that takes a data index and returns a color string.
12
+ * Either the x-axis or rotation-axis, depending on the coordinate system.
18
13
  */
19
- export type ColorProcessor<SeriesType extends ChartSeriesType> = (series: DefaultizedSeriesType<SeriesType>, xAxis?: ComputedXAxis, yAxis?: ComputedYAxis, zAxis?: ZAxisDefaultized) => ColorGetter<SeriesType>;
14
+ mainAxis?: ComputedXAxis | ComputedAxis<ScaleName, any, ChartsRotationAxisProps>,
15
+ /**
16
+ * Either the y-axis or radius-axis, depending on the coordinate system.
17
+ */
18
+ secondaryAxis?: ComputedYAxis | ComputedAxis<ScaleName, any, ChartsRadiusAxisProps>, zAxis?: ZAxisDefaultized) => ColorGetter<SeriesType>;
@@ -6,10 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getAxisIndex = getAxisIndex;
7
7
  exports.getAxisValue = getAxisValue;
8
8
  var _scaleGuards = require("../../../scaleGuards");
9
- function getAsANumber(value) {
10
- return value instanceof Date ? value.getTime() : value;
11
- }
12
-
9
+ var _getAsNumber = require("../../../getAsNumber");
10
+ var _findClosestIndex = require("../../../findClosestIndex");
13
11
  /**
14
12
  * For a pointer coordinate, this function returns the dataIndex associated.
15
13
  * Returns `-1` if no dataIndex matches.
@@ -21,26 +19,11 @@ function getAxisIndex(axisConfig, pointerValue) {
21
19
  reverse
22
20
  } = axisConfig;
23
21
  if (!(0, _scaleGuards.isOrdinalScale)(scale)) {
24
- const value = scale.invert(pointerValue);
25
22
  if (axisData === undefined) {
26
23
  return -1;
27
24
  }
28
- const valueAsNumber = getAsANumber(value);
29
- const closestIndex = axisData?.findIndex((pointValue, index) => {
30
- const v = getAsANumber(pointValue);
31
- if (v > valueAsNumber) {
32
- if (index === 0 || Math.abs(valueAsNumber - v) <= Math.abs(valueAsNumber - getAsANumber(axisData[index - 1]))) {
33
- return true;
34
- }
35
- }
36
- if (v <= valueAsNumber) {
37
- if (index === axisData.length - 1 || Math.abs(getAsANumber(value) - v) < Math.abs(getAsANumber(value) - getAsANumber(axisData[index + 1]))) {
38
- return true;
39
- }
40
- }
41
- return false;
42
- });
43
- return closestIndex;
25
+ const valueAsNumber = (0, _getAsNumber.getAsNumber)(scale.invert(pointerValue));
26
+ return (0, _findClosestIndex.findClosestIndex)(axisData, valueAsNumber);
44
27
  }
45
28
  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());
46
29
  if (dataIndex < 0 || dataIndex >= axisData.length) {
@@ -1,8 +1,6 @@
1
1
  import { isOrdinalScale } from "../../../scaleGuards.mjs";
2
- function getAsANumber(value) {
3
- return value instanceof Date ? value.getTime() : value;
4
- }
5
-
2
+ import { getAsNumber } from "../../../getAsNumber.mjs";
3
+ import { findClosestIndex } from "../../../findClosestIndex.mjs";
6
4
  /**
7
5
  * For a pointer coordinate, this function returns the dataIndex associated.
8
6
  * Returns `-1` if no dataIndex matches.
@@ -14,26 +12,11 @@ export function getAxisIndex(axisConfig, pointerValue) {
14
12
  reverse
15
13
  } = axisConfig;
16
14
  if (!isOrdinalScale(scale)) {
17
- const value = scale.invert(pointerValue);
18
15
  if (axisData === undefined) {
19
16
  return -1;
20
17
  }
21
- const valueAsNumber = getAsANumber(value);
22
- const closestIndex = axisData?.findIndex((pointValue, index) => {
23
- const v = getAsANumber(pointValue);
24
- if (v > valueAsNumber) {
25
- if (index === 0 || Math.abs(valueAsNumber - v) <= Math.abs(valueAsNumber - getAsANumber(axisData[index - 1]))) {
26
- return true;
27
- }
28
- }
29
- if (v <= valueAsNumber) {
30
- if (index === axisData.length - 1 || Math.abs(getAsANumber(value) - v) < Math.abs(getAsANumber(value) - getAsANumber(axisData[index + 1]))) {
31
- return true;
32
- }
33
- }
34
- return false;
35
- });
36
- return closestIndex;
18
+ const valueAsNumber = getAsNumber(scale.invert(pointerValue));
19
+ return findClosestIndex(axisData, valueAsNumber);
37
20
  }
38
21
  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());
39
22
  if (dataIndex < 0 || dataIndex >= axisData.length) {
@@ -0,0 +1,30 @@
1
+ import type { SeriesId } from "../../../../../models/seriesType/common.mjs";
2
+ import type { ChartSeriesType } from "../../../../../models/seriesType/config.mjs";
3
+ import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/useChartSeries.types.mjs";
4
+ /**
5
+ * Walk forward (or backward) from `startIndex` and return the first dataIndex
6
+ * whose data point is visible. Returns `null` if every traversed index is hidden.
7
+ *
8
+ * Series-level hidden flags are filtered upstream (see `getNonEmptySeriesArray`),
9
+ * so only per-data-point hidden flags are relevant here. Today only Pie sets a
10
+ * `hidden` flag on individual data items; for other series types the data
11
+ * elements are scalars or objects without that field, and this helper returns
12
+ * the proposed index unchanged.
13
+ */
14
+ export declare function findVisibleDataIndex({
15
+ processedSeries,
16
+ type,
17
+ seriesId,
18
+ startIndex,
19
+ dataLength,
20
+ direction,
21
+ allowCycles
22
+ }: {
23
+ processedSeries: ProcessedSeries<ChartSeriesType>;
24
+ type: ChartSeriesType;
25
+ seriesId: SeriesId;
26
+ startIndex: number;
27
+ dataLength: number;
28
+ direction: 1 | -1;
29
+ allowCycles: boolean;
30
+ }): number | null;
@@ -0,0 +1,30 @@
1
+ import type { SeriesId } from "../../../../../models/seriesType/common.js";
2
+ import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
3
+ import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/useChartSeries.types.js";
4
+ /**
5
+ * Walk forward (or backward) from `startIndex` and return the first dataIndex
6
+ * whose data point is visible. Returns `null` if every traversed index is hidden.
7
+ *
8
+ * Series-level hidden flags are filtered upstream (see `getNonEmptySeriesArray`),
9
+ * so only per-data-point hidden flags are relevant here. Today only Pie sets a
10
+ * `hidden` flag on individual data items; for other series types the data
11
+ * elements are scalars or objects without that field, and this helper returns
12
+ * the proposed index unchanged.
13
+ */
14
+ export declare function findVisibleDataIndex({
15
+ processedSeries,
16
+ type,
17
+ seriesId,
18
+ startIndex,
19
+ dataLength,
20
+ direction,
21
+ allowCycles
22
+ }: {
23
+ processedSeries: ProcessedSeries<ChartSeriesType>;
24
+ type: ChartSeriesType;
25
+ seriesId: SeriesId;
26
+ startIndex: number;
27
+ dataLength: number;
28
+ direction: 1 | -1;
29
+ allowCycles: boolean;
30
+ }): number | null;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findVisibleDataIndex = findVisibleDataIndex;
7
+ /**
8
+ * Walk forward (or backward) from `startIndex` and return the first dataIndex
9
+ * whose data point is visible. Returns `null` if every traversed index is hidden.
10
+ *
11
+ * Series-level hidden flags are filtered upstream (see `getNonEmptySeriesArray`),
12
+ * so only per-data-point hidden flags are relevant here. Today only Pie sets a
13
+ * `hidden` flag on individual data items; for other series types the data
14
+ * elements are scalars or objects without that field, and this helper returns
15
+ * the proposed index unchanged.
16
+ */
17
+ function findVisibleDataIndex({
18
+ processedSeries,
19
+ type,
20
+ seriesId,
21
+ startIndex,
22
+ dataLength,
23
+ direction,
24
+ allowCycles
25
+ }) {
26
+ if (dataLength <= 0) {
27
+ return null;
28
+ }
29
+ const seriesItem = processedSeries[type]?.series[seriesId];
30
+ if (seriesItem && 'hidden' in seriesItem && seriesItem.hidden) {
31
+ return null;
32
+ }
33
+ const seriesData = seriesItem?.data;
34
+ const isIndexHidden = idx => {
35
+ if (!seriesData) {
36
+ return false;
37
+ }
38
+ const item = seriesData[idx];
39
+ return typeof item === 'object' && item !== null && 'hidden' in item && Boolean(item.hidden);
40
+ };
41
+ let dataIndex = startIndex;
42
+ for (let attempt = 0; attempt < dataLength; attempt += 1) {
43
+ if (dataIndex >= 0 && dataIndex < dataLength && !isIndexHidden(dataIndex)) {
44
+ return dataIndex;
45
+ }
46
+ if (allowCycles) {
47
+ dataIndex = (dataIndex + direction + dataLength) % dataLength;
48
+ } else {
49
+ const next = dataIndex + direction;
50
+ if (next < 0 || next >= dataLength) {
51
+ return null;
52
+ }
53
+ dataIndex = next;
54
+ }
55
+ }
56
+ return null;
57
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Walk forward (or backward) from `startIndex` and return the first dataIndex
3
+ * whose data point is visible. Returns `null` if every traversed index is hidden.
4
+ *
5
+ * Series-level hidden flags are filtered upstream (see `getNonEmptySeriesArray`),
6
+ * so only per-data-point hidden flags are relevant here. Today only Pie sets a
7
+ * `hidden` flag on individual data items; for other series types the data
8
+ * elements are scalars or objects without that field, and this helper returns
9
+ * the proposed index unchanged.
10
+ */
11
+ export function findVisibleDataIndex({
12
+ processedSeries,
13
+ type,
14
+ seriesId,
15
+ startIndex,
16
+ dataLength,
17
+ direction,
18
+ allowCycles
19
+ }) {
20
+ if (dataLength <= 0) {
21
+ return null;
22
+ }
23
+ const seriesItem = processedSeries[type]?.series[seriesId];
24
+ if (seriesItem && 'hidden' in seriesItem && seriesItem.hidden) {
25
+ return null;
26
+ }
27
+ const seriesData = seriesItem?.data;
28
+ const isIndexHidden = idx => {
29
+ if (!seriesData) {
30
+ return false;
31
+ }
32
+ const item = seriesData[idx];
33
+ return typeof item === 'object' && item !== null && 'hidden' in item && Boolean(item.hidden);
34
+ };
35
+ let dataIndex = startIndex;
36
+ for (let attempt = 0; attempt < dataLength; attempt += 1) {
37
+ if (dataIndex >= 0 && dataIndex < dataLength && !isIndexHidden(dataIndex)) {
38
+ return dataIndex;
39
+ }
40
+ if (allowCycles) {
41
+ dataIndex = (dataIndex + direction + dataLength) % dataLength;
42
+ } else {
43
+ const next = dataIndex + direction;
44
+ if (next < 0 || next >= dataLength) {
45
+ return null;
46
+ }
47
+ dataIndex = next;
48
+ }
49
+ }
50
+ return null;
51
+ }
@@ -7,6 +7,12 @@ exports.getMaxSeriesLength = getMaxSeriesLength;
7
7
  function getMaxSeriesLength(series, availableSeriesTypes) {
8
8
  return Object.keys(series).filter(type => availableSeriesTypes.has(type)).flatMap(type => {
9
9
  const seriesOfType = series[type];
10
- return seriesOfType.seriesOrder.filter(seriesId => seriesOfType.series[seriesId].data.length > 0 && seriesOfType.series[seriesId].data.some(value => value != null)).map(seriesId => seriesOfType.series[seriesId].data.length);
10
+ return seriesOfType.seriesOrder.filter(seriesId => {
11
+ const seriesItem = seriesOfType.series[seriesId];
12
+ if ('hidden' in seriesItem && seriesItem.hidden) {
13
+ return false;
14
+ }
15
+ return seriesItem.data.length > 0 && seriesItem.data.some(value => value != null && !(typeof value === 'object' && 'hidden' in value && value.hidden));
16
+ }).map(seriesId => seriesOfType.series[seriesId].data.length);
11
17
  }).reduce((maxLengths, length) => Math.max(maxLengths, length), 0);
12
18
  }
@@ -1,6 +1,12 @@
1
1
  export function getMaxSeriesLength(series, availableSeriesTypes) {
2
2
  return Object.keys(series).filter(type => availableSeriesTypes.has(type)).flatMap(type => {
3
3
  const seriesOfType = series[type];
4
- return seriesOfType.seriesOrder.filter(seriesId => seriesOfType.series[seriesId].data.length > 0 && seriesOfType.series[seriesId].data.some(value => value != null)).map(seriesId => seriesOfType.series[seriesId].data.length);
4
+ return seriesOfType.seriesOrder.filter(seriesId => {
5
+ const seriesItem = seriesOfType.series[seriesId];
6
+ if ('hidden' in seriesItem && seriesItem.hidden) {
7
+ return false;
8
+ }
9
+ return seriesItem.data.length > 0 && seriesItem.data.some(value => value != null && !(typeof value === 'object' && 'hidden' in value && value.hidden));
10
+ }).map(seriesId => seriesOfType.series[seriesId].data.length);
5
11
  }).reduce((maxLengths, length) => Math.max(maxLengths, length), 0);
6
12
  }
@@ -7,7 +7,13 @@ exports.getNonEmptySeriesArray = getNonEmptySeriesArray;
7
7
  function getNonEmptySeriesArray(series, availableSeriesTypes) {
8
8
  return Object.keys(series).filter(type => availableSeriesTypes.has(type)).flatMap(type => {
9
9
  const seriesOfType = series[type];
10
- return seriesOfType.seriesOrder.filter(seriesId => seriesOfType.series[seriesId].data.length > 0 && seriesOfType.series[seriesId].data.some(value => value != null)).map(seriesId => ({
10
+ return seriesOfType.seriesOrder.filter(seriesId => {
11
+ const seriesItem = seriesOfType.series[seriesId];
12
+ if ('hidden' in seriesItem && seriesItem.hidden) {
13
+ return false;
14
+ }
15
+ return seriesItem.data.length > 0 && seriesItem.data.some(value => value != null);
16
+ }).map(seriesId => ({
11
17
  type,
12
18
  seriesId
13
19
  }));
@@ -1,7 +1,13 @@
1
1
  export function getNonEmptySeriesArray(series, availableSeriesTypes) {
2
2
  return Object.keys(series).filter(type => availableSeriesTypes.has(type)).flatMap(type => {
3
3
  const seriesOfType = series[type];
4
- return seriesOfType.seriesOrder.filter(seriesId => seriesOfType.series[seriesId].data.length > 0 && seriesOfType.series[seriesId].data.some(value => value != null)).map(seriesId => ({
4
+ return seriesOfType.seriesOrder.filter(seriesId => {
5
+ const seriesItem = seriesOfType.series[seriesId];
6
+ if ('hidden' in seriesItem && seriesItem.hidden) {
7
+ return false;
8
+ }
9
+ return seriesItem.data.length > 0 && seriesItem.data.some(value => value != null);
10
+ }).map(seriesId => ({
5
11
  type,
6
12
  seriesId
7
13
  }));
@@ -1,14 +1,15 @@
1
- import { type AxisConfig, type ScaleName } from "../../../../models/index.mjs";
1
+ import type { AxisConfig, ScaleName } from "../../../../models/index.mjs";
2
2
  import { type ChartsAxisProps, type ChartsRotationAxisProps, type ChartsRadiusAxisProps, type PolarAxisDefaultized, type AxisId } from "../../../../models/axis.mjs";
3
3
  import { type ChartSeriesType } from "../../../../models/seriesType/config.mjs";
4
4
  import type { ChartDrawingArea } from "../../../../hooks/index.mjs";
5
5
  import { type ChartSeriesConfig } from "../../corePlugins/useChartSeriesConfig/index.mjs";
6
6
  import { type ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.mjs";
7
+ import { type ComputedAxisConfig } from "../useChartCartesianAxis/index.mjs";
7
8
  export type DefaultizedAxisConfig<AxisProps extends ChartsRotationAxisProps | ChartsRadiusAxisProps> = {
8
9
  [axisId: AxisId]: PolarAxisDefaultized<ScaleName, any, AxisProps>;
9
10
  };
10
11
  export type ComputeResult<T extends ChartsAxisProps> = {
11
- axis: DefaultizedAxisConfig<T>;
12
+ axis: ComputedAxisConfig<T>;
12
13
  axisIds: string[];
13
14
  };
14
15
  type ComputeCommonParams<SeriesType extends ChartSeriesType = ChartSeriesType> = {
@@ -1,14 +1,15 @@
1
- import { type AxisConfig, type ScaleName } from "../../../../models/index.js";
1
+ import type { AxisConfig, ScaleName } from "../../../../models/index.js";
2
2
  import { type ChartsAxisProps, type ChartsRotationAxisProps, type ChartsRadiusAxisProps, type PolarAxisDefaultized, type AxisId } from "../../../../models/axis.js";
3
3
  import { type ChartSeriesType } from "../../../../models/seriesType/config.js";
4
4
  import type { ChartDrawingArea } from "../../../../hooks/index.js";
5
5
  import { type ChartSeriesConfig } from "../../corePlugins/useChartSeriesConfig/index.js";
6
6
  import { type ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.js";
7
+ import { type ComputedAxisConfig } from "../useChartCartesianAxis/index.js";
7
8
  export type DefaultizedAxisConfig<AxisProps extends ChartsRotationAxisProps | ChartsRadiusAxisProps> = {
8
9
  [axisId: AxisId]: PolarAxisDefaultized<ScaleName, any, AxisProps>;
9
10
  };
10
11
  export type ComputeResult<T extends ChartsAxisProps> = {
11
- axis: DefaultizedAxisConfig<T>;
12
+ axis: ComputedAxisConfig<T>;
12
13
  axisIds: string[];
13
14
  };
14
15
  type ComputeCommonParams<SeriesType extends ChartSeriesType = ChartSeriesType> = {