@mui/x-charts 8.8.0 → 8.9.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 (164) hide show
  1. package/BarChart/BarChart.d.ts +3 -2
  2. package/BarChart/BarChart.js +95 -2
  3. package/BarChart/BarClipPath.d.ts +17 -12
  4. package/BarChart/BarClipPath.js +70 -57
  5. package/BarChart/BarPlot.js +4 -0
  6. package/BarChart/barClasses.d.ts +1 -1
  7. package/BarChart/seriesConfig/extremums.js +2 -3
  8. package/BarChart/seriesConfig/seriesProcessor.js +5 -3
  9. package/BarChart/useBarChartProps.d.ts +1 -1
  10. package/BarChart/useBarPlotData.js +32 -5
  11. package/CHANGELOG.md +225 -24
  12. package/ChartContainer/ChartContainer.js +141 -0
  13. package/ChartsLabel/ChartsLabelMark.d.ts +2 -1
  14. package/ChartsLabel/index.d.ts +1 -0
  15. package/ChartsLabel/index.js +18 -0
  16. package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  17. package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  18. package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
  19. package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +33 -7
  20. package/LineChart/LineChart.d.ts +3 -2
  21. package/LineChart/LineChart.js +95 -2
  22. package/LineChart/seriesConfig/extremums.js +2 -3
  23. package/LineChart/useLineChartProps.d.ts +1 -1
  24. package/PieChart/PieArcLabelPlot.js +3 -0
  25. package/PieChart/PieArcPlot.js +3 -0
  26. package/PieChart/PieChart.d.ts +3 -2
  27. package/PieChart/PieChart.js +2 -2
  28. package/PieChart/pieClasses.d.ts +1 -1
  29. package/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
  30. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
  31. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
  32. package/RadarChart/RadarChart.d.ts +3 -2
  33. package/RadarChart/RadarChart.js +24 -3
  34. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
  35. package/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
  36. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
  37. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
  38. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
  39. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
  40. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
  41. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +38 -0
  42. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
  43. package/RadarChart/index.d.ts +1 -1
  44. package/RadarChart/useRadarChartProps.d.ts +4 -1
  45. package/RadarChart/useRadarChartProps.js +15 -3
  46. package/ScatterChart/ScatterChart.d.ts +3 -2
  47. package/ScatterChart/ScatterChart.js +95 -2
  48. package/ScatterChart/seriesConfig/extremums.js +50 -23
  49. package/ScatterChart/useScatterChartProps.d.ts +1 -1
  50. package/SparkLineChart/SparkLineChart.js +93 -0
  51. package/esm/BarChart/BarChart.d.ts +3 -2
  52. package/esm/BarChart/BarChart.js +95 -2
  53. package/esm/BarChart/BarClipPath.d.ts +17 -12
  54. package/esm/BarChart/BarClipPath.js +69 -55
  55. package/esm/BarChart/BarPlot.js +4 -0
  56. package/esm/BarChart/barClasses.d.ts +1 -1
  57. package/esm/BarChart/seriesConfig/extremums.js +2 -3
  58. package/esm/BarChart/seriesConfig/seriesProcessor.js +5 -3
  59. package/esm/BarChart/useBarChartProps.d.ts +1 -1
  60. package/esm/BarChart/useBarPlotData.js +32 -5
  61. package/esm/ChartContainer/ChartContainer.js +141 -0
  62. package/esm/ChartsLabel/ChartsLabelMark.d.ts +2 -1
  63. package/esm/ChartsLabel/index.d.ts +1 -0
  64. package/esm/ChartsLabel/index.js +1 -0
  65. package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
  66. package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
  67. package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
  68. package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +31 -6
  69. package/esm/LineChart/LineChart.d.ts +3 -2
  70. package/esm/LineChart/LineChart.js +95 -2
  71. package/esm/LineChart/seriesConfig/extremums.js +2 -3
  72. package/esm/LineChart/useLineChartProps.d.ts +1 -1
  73. package/esm/PieChart/PieArcLabelPlot.js +3 -0
  74. package/esm/PieChart/PieArcPlot.js +3 -0
  75. package/esm/PieChart/PieChart.d.ts +3 -2
  76. package/esm/PieChart/PieChart.js +2 -2
  77. package/esm/PieChart/pieClasses.d.ts +1 -1
  78. package/esm/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
  79. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
  80. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
  81. package/esm/RadarChart/RadarChart.d.ts +3 -2
  82. package/esm/RadarChart/RadarChart.js +24 -3
  83. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
  84. package/esm/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
  85. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
  86. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
  87. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
  88. package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
  89. package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
  90. package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +32 -0
  91. package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
  92. package/esm/RadarChart/index.d.ts +1 -1
  93. package/esm/RadarChart/useRadarChartProps.d.ts +4 -1
  94. package/esm/RadarChart/useRadarChartProps.js +15 -3
  95. package/esm/ScatterChart/ScatterChart.d.ts +3 -2
  96. package/esm/ScatterChart/ScatterChart.js +95 -2
  97. package/esm/ScatterChart/seriesConfig/extremums.js +50 -23
  98. package/esm/ScatterChart/useScatterChartProps.d.ts +1 -1
  99. package/esm/SparkLineChart/SparkLineChart.js +93 -0
  100. package/esm/hooks/useTicks.d.ts +6 -1
  101. package/esm/hooks/useTicks.js +94 -58
  102. package/esm/index.d.ts +2 -1
  103. package/esm/index.js +6 -2
  104. package/esm/internals/findMinMax.d.ts +1 -0
  105. package/esm/internals/findMinMax.js +13 -0
  106. package/esm/internals/getScale.js +3 -0
  107. package/esm/internals/index.d.ts +1 -1
  108. package/esm/internals/index.js +1 -1
  109. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -1
  110. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
  111. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +19 -11
  112. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
  113. package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +19 -11
  114. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
  115. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
  116. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
  117. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
  118. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
  119. package/esm/internals/symlogScale.d.ts +2 -0
  120. package/esm/internals/symlogScale.js +94 -0
  121. package/esm/models/axis.d.ts +47 -5
  122. package/esm/models/axis.js +3 -0
  123. package/esm/models/seriesType/bar.d.ts +11 -1
  124. package/esm/models/seriesType/common.d.ts +9 -3
  125. package/esm/models/seriesType/line.d.ts +3 -1
  126. package/esm/models/seriesType/scatter.d.ts +4 -1
  127. package/esm/tests/web-components.js +49 -0
  128. package/hooks/useTicks.d.ts +6 -1
  129. package/hooks/useTicks.js +95 -58
  130. package/index.d.ts +2 -1
  131. package/index.js +13 -1
  132. package/internals/findMinMax.d.ts +1 -0
  133. package/internals/findMinMax.js +19 -0
  134. package/internals/getScale.js +3 -0
  135. package/internals/index.d.ts +1 -1
  136. package/internals/index.js +12 -12
  137. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +3 -0
  138. package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
  139. package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +20 -13
  140. package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
  141. package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +20 -13
  142. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
  143. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
  144. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
  145. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
  146. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
  147. package/internals/symlogScale.d.ts +2 -0
  148. package/internals/symlogScale.js +100 -0
  149. package/models/axis.d.ts +47 -5
  150. package/models/axis.js +4 -0
  151. package/models/seriesType/bar.d.ts +11 -1
  152. package/models/seriesType/common.d.ts +9 -3
  153. package/models/seriesType/line.d.ts +3 -1
  154. package/models/seriesType/scatter.d.ts +4 -1
  155. package/package.json +6 -7
  156. package/tests/web-components.js +55 -0
  157. package/BarChart/getRadius.d.ts +0 -20
  158. package/BarChart/getRadius.js +0 -37
  159. package/esm/BarChart/getRadius.d.ts +0 -20
  160. package/esm/BarChart/getRadius.js +0 -30
  161. /package/{esm/internals/components/ChartsWrapper → ChartsWrapper}/index.d.ts +0 -0
  162. /package/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
  163. /package/{internals/components → esm}/ChartsWrapper/index.d.ts +0 -0
  164. /package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
package/hooks/useTicks.js CHANGED
@@ -5,6 +5,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.getTicks = getTicks;
8
9
  exports.useTicks = useTicks;
9
10
  var React = _interopRequireWildcard(require("react"));
10
11
  var _ChartProvider = require("../context/ChartProvider");
@@ -16,7 +17,7 @@ const offsetRatio = {
16
17
  end: 1,
17
18
  middle: 0.5
18
19
  };
19
- function useTicks(options) {
20
+ function getTicks(options) {
20
21
  const {
21
22
  scale,
22
23
  tickNumber,
@@ -24,75 +25,111 @@ function useTicks(options) {
24
25
  tickInterval,
25
26
  tickPlacement = 'extremities',
26
27
  tickLabelPlacement: tickLabelPlacementProp,
27
- direction
28
+ isInside
28
29
  } = options;
29
- const {
30
- instance
31
- } = (0, _ChartProvider.useChartContext)();
32
- return React.useMemo(() => {
33
- // band scale
34
- if ((0, _isBandScale.isBandScale)(scale)) {
35
- const domain = scale.domain();
36
- const tickLabelPlacement = tickLabelPlacementProp ?? 'middle';
37
- if (scale.bandwidth() > 0) {
38
- // scale type = 'band'
39
- const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
40
- return [...filteredDomain.map(value => ({
30
+
31
+ // band scale
32
+ if ((0, _isBandScale.isBandScale)(scale)) {
33
+ const domain = scale.domain();
34
+ const tickLabelPlacement = tickLabelPlacementProp ?? 'middle';
35
+ if (scale.bandwidth() > 0) {
36
+ // scale type = 'band'
37
+ const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
38
+ return [...filteredDomain.map(value => {
39
+ const defaultTickLabel = `${value}`;
40
+ return {
41
41
  value,
42
42
  formattedValue: valueFormatter?.(value, {
43
43
  location: 'tick',
44
- scale
45
- }) ?? `${value}`,
44
+ scale,
45
+ tickNumber,
46
+ defaultTickLabel
47
+ }) ?? defaultTickLabel,
46
48
  offset: scale(value) - (scale.step() - scale.bandwidth()) / 2 + offsetRatio[tickPlacement] * scale.step(),
47
49
  labelOffset: tickLabelPlacement === 'tick' ? 0 : scale.step() * (offsetRatio[tickLabelPlacement] - offsetRatio[tickPlacement])
48
- })), ...(tickPlacement === 'extremities' ? [{
49
- formattedValue: undefined,
50
- offset: scale.range()[1],
51
- labelOffset: 0
52
- }] : [])];
53
- }
50
+ };
51
+ }), ...(tickPlacement === 'extremities' ? [{
52
+ formattedValue: undefined,
53
+ offset: scale.range()[1],
54
+ labelOffset: 0
55
+ }] : [])];
56
+ }
54
57
 
55
- // scale type = 'point'
56
- const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
57
- return filteredDomain.map(value => ({
58
+ // scale type = 'point'
59
+ const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
60
+ return filteredDomain.map(value => {
61
+ const defaultTickLabel = `${value}`;
62
+ return {
58
63
  value,
59
64
  formattedValue: valueFormatter?.(value, {
60
65
  location: 'tick',
61
- scale
62
- }) ?? `${value}`,
66
+ scale,
67
+ tickNumber,
68
+ defaultTickLabel
69
+ }) ?? defaultTickLabel,
63
70
  offset: scale(value),
64
71
  labelOffset: 0
65
- }));
66
- }
67
- const domain = scale.domain();
68
- // Skip axis rendering if no data is available
69
- // - The domains contains Infinity for continuous scales.
70
- if (domain.some(_isInfinity.isInfinity)) {
71
- return [];
72
- }
73
- const tickLabelPlacement = tickLabelPlacementProp;
74
- const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
72
+ };
73
+ });
74
+ }
75
+ const domain = scale.domain();
76
+ // Skip axis rendering if no data is available
77
+ // - The domains contains Infinity for continuous scales.
78
+ if (domain.some(_isInfinity.isInfinity)) {
79
+ return [];
80
+ }
81
+ const tickLabelPlacement = tickLabelPlacementProp;
82
+ const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
75
83
 
76
- // Ticks inside the drawing area
77
- const visibleTicks = [];
78
- for (let i = 0; i < ticks.length; i += 1) {
79
- const value = ticks[i];
80
- const offset = scale(value);
81
- const isInside = direction === 'x' ? instance.isXInside(offset) : instance.isYInside(offset);
82
- if (isInside) {
83
- visibleTicks.push({
84
- value,
85
- formattedValue: valueFormatter?.(value, {
86
- location: 'tick',
87
- scale
88
- }) ?? scale.tickFormat(tickNumber)(value),
89
- offset,
90
- // Allowing the label to be placed in the middle of a continuous scale is weird.
91
- // But it is useful in some cases, like funnel categories with a linear scale.
92
- labelOffset: tickLabelPlacement === 'middle' ? scale(ticks[i - 1] ?? 0) - (offset + scale(ticks[i - 1] ?? 0)) / 2 : 0
93
- });
94
- }
84
+ // Ticks inside the drawing area
85
+ const visibleTicks = [];
86
+ for (let i = 0; i < ticks.length; i += 1) {
87
+ const value = ticks[i];
88
+ const offset = scale(value);
89
+ if (isInside(offset)) {
90
+ /* If d3 returns an empty string, it means that a tick should be shown, but its label shouldn't.
91
+ * This is especially useful in a log scale where we want to show ticks to demonstrate it's a log
92
+ * scale, but don't want to show labels because they would overlap.
93
+ * https://github.com/mui/mui-x/issues/18239 */
94
+ const defaultTickLabel = scale.tickFormat(tickNumber)(value);
95
+ visibleTicks.push({
96
+ value,
97
+ formattedValue: valueFormatter?.(value, {
98
+ location: 'tick',
99
+ scale,
100
+ tickNumber,
101
+ defaultTickLabel
102
+ }) ?? defaultTickLabel,
103
+ offset,
104
+ // Allowing the label to be placed in the middle of a continuous scale is weird.
105
+ // But it is useful in some cases, like funnel categories with a linear scale.
106
+ labelOffset: tickLabelPlacement === 'middle' ? scale(ticks[i - 1] ?? 0) - (offset + scale(ticks[i - 1] ?? 0)) / 2 : 0
107
+ });
95
108
  }
96
- return visibleTicks;
97
- }, [scale, tickLabelPlacementProp, tickInterval, tickNumber, tickPlacement, valueFormatter, direction, instance]);
109
+ }
110
+ return visibleTicks;
111
+ }
112
+ function useTicks(options) {
113
+ const {
114
+ scale,
115
+ tickNumber,
116
+ valueFormatter,
117
+ tickInterval,
118
+ tickPlacement = 'extremities',
119
+ tickLabelPlacement,
120
+ direction
121
+ } = options;
122
+ const {
123
+ instance
124
+ } = (0, _ChartProvider.useChartContext)();
125
+ const isInside = direction === 'x' ? instance.isXInside : instance.isYInside;
126
+ return React.useMemo(() => getTicks({
127
+ scale,
128
+ tickNumber,
129
+ tickPlacement,
130
+ tickInterval,
131
+ tickLabelPlacement,
132
+ valueFormatter,
133
+ isInside
134
+ }), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, valueFormatter, isInside]);
98
135
  }
package/index.d.ts CHANGED
@@ -26,4 +26,5 @@ export * from "./ChartsSurface/index.js";
26
26
  export { ChartContainer } from "./ChartContainer/index.js";
27
27
  export type { ChartContainerProps } from "./ChartContainer/index.js";
28
28
  export * from "./ChartDataProvider/index.js";
29
- export * from "./Toolbar/index.js";
29
+ export * from "./Toolbar/index.js";
30
+ export * from "./ChartsWrapper/index.js";
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.8.0
2
+ * @mui/x-charts v8.9.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -343,4 +343,16 @@ Object.keys(_Toolbar).forEach(function (key) {
343
343
  return _Toolbar[key];
344
344
  }
345
345
  });
346
+ });
347
+ var _ChartsWrapper = require("./ChartsWrapper");
348
+ Object.keys(_ChartsWrapper).forEach(function (key) {
349
+ if (key === "default" || key === "__esModule") return;
350
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
351
+ if (key in exports && exports[key] === _ChartsWrapper[key]) return;
352
+ Object.defineProperty(exports, key, {
353
+ enumerable: true,
354
+ get: function () {
355
+ return _ChartsWrapper[key];
356
+ }
357
+ });
346
358
  });
@@ -0,0 +1 @@
1
+ export declare function findMinMax(data: readonly number[]): [number, number];
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findMinMax = findMinMax;
7
+ function findMinMax(data) {
8
+ let min = Infinity;
9
+ let max = -Infinity;
10
+ for (const value of data ?? []) {
11
+ if (value < min) {
12
+ min = value;
13
+ }
14
+ if (value > max) {
15
+ max = value;
16
+ }
17
+ }
18
+ return [min, max];
19
+ }
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getScale = getScale;
7
7
  var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
8
+ var _symlogScale = require("./symlogScale");
8
9
  function getScale(scaleType, domain, range) {
9
10
  switch (scaleType) {
10
11
  case 'log':
@@ -17,6 +18,8 @@ function getScale(scaleType, domain, range) {
17
18
  return (0, _d3Scale.scaleTime)(domain, range);
18
19
  case 'utc':
19
20
  return (0, _d3Scale.scaleUtc)(domain, range);
21
+ case 'symlog':
22
+ return (0, _symlogScale.scaleSymlog)(domain, range);
20
23
  default:
21
24
  return (0, _d3Scale.scaleLinear)(domain, range);
22
25
  }
@@ -1,5 +1,4 @@
1
1
  export * from "./components/ChartsAxesGradients/index.js";
2
- export * from "./components/ChartsWrapper/index.js";
3
2
  export * from "../ChartsLabel/ChartsLabelMark.js";
4
3
  export * from "./components/NotRendered.js";
5
4
  export { useSeries } from "../hooks/useSeries.js";
@@ -54,6 +53,7 @@ export * from "./ticks.js";
54
53
  export * from "./dateHelpers.js";
55
54
  export * from "./invertScale.js";
56
55
  export * from "./isBandScale.js";
56
+ export * from "./findMinMax.js";
57
57
  export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
58
58
  export * from "../context/ChartProvider/index.js";
59
59
  export * from "../context/ChartsSlotsContext.js";
@@ -122,18 +122,6 @@ Object.keys(_ChartsAxesGradients).forEach(function (key) {
122
122
  }
123
123
  });
124
124
  });
125
- var _ChartsWrapper = require("./components/ChartsWrapper");
126
- Object.keys(_ChartsWrapper).forEach(function (key) {
127
- if (key === "default" || key === "__esModule") return;
128
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
129
- if (key in exports && exports[key] === _ChartsWrapper[key]) return;
130
- Object.defineProperty(exports, key, {
131
- enumerable: true,
132
- get: function () {
133
- return _ChartsWrapper[key];
134
- }
135
- });
136
- });
137
125
  var _ChartsLabelMark = require("../ChartsLabel/ChartsLabelMark");
138
126
  Object.keys(_ChartsLabelMark).forEach(function (key) {
139
127
  if (key === "default" || key === "__esModule") return;
@@ -628,6 +616,18 @@ Object.keys(_isBandScale).forEach(function (key) {
628
616
  }
629
617
  });
630
618
  });
619
+ var _findMinMax = require("./findMinMax");
620
+ Object.keys(_findMinMax).forEach(function (key) {
621
+ if (key === "default" || key === "__esModule") return;
622
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
623
+ if (key in exports && exports[key] === _findMinMax[key]) return;
624
+ Object.defineProperty(exports, key, {
625
+ enumerable: true,
626
+ get: function () {
627
+ return _findMinMax[key];
628
+ }
629
+ });
630
+ });
631
631
  var _getAxisExtremum = require("./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum");
632
632
  var _ChartProvider = require("../context/ChartProvider");
633
633
  Object.keys(_ChartProvider).forEach(function (key) {
@@ -121,6 +121,9 @@ function computeAxisValue({
121
121
  const tickNumber = (0, _ticks.scaleTickNumberByRange)(rawTickNumber, zoomRange);
122
122
  const zoomedRange = (0, _zoom.zoomScaleRange)(range, zoomRange);
123
123
  const scale = (0, _getScale.getScale)(scaleType, axisExtremums, zoomedRange);
124
+ if ((0, _axis.isSymlogScaleConfig)(axis) && axis.constant != null) {
125
+ scale.constant(axis.constant);
126
+ }
124
127
  const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
125
128
  const [minDomain, maxDomain] = finalScale.domain();
126
129
  const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
@@ -1,3 +1,3 @@
1
1
  import { HighlightScope } from "./highlightConfig.types.js";
2
2
  import { HighlightItemData } from "./useChartHighlight.types.js";
3
- export declare const createIsFaded: (highlightScope: HighlightScope | null | undefined, highlightedItem: HighlightItemData | null) => (item: HighlightItemData | null) => boolean;
3
+ export declare function createIsFaded(highlightScope: HighlightScope | null | undefined, highlightedItem: HighlightItemData | null): (item: HighlightItemData | null) => boolean;
@@ -3,17 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createIsFaded = void 0;
7
- const createIsFaded = (highlightScope, highlightedItem) => item => {
8
- if (!highlightScope || !highlightedItem || !item) {
9
- return false;
10
- }
11
- if (highlightScope.fade === 'series') {
12
- return item.seriesId === highlightedItem.seriesId && item.dataIndex !== highlightedItem.dataIndex;
13
- }
14
- if (highlightScope.fade === 'global') {
15
- return item.seriesId !== highlightedItem.seriesId || item.dataIndex !== highlightedItem.dataIndex;
16
- }
6
+ exports.createIsFaded = createIsFaded;
7
+ function alwaysFalse() {
17
8
  return false;
18
- };
19
- exports.createIsFaded = createIsFaded;
9
+ }
10
+ function createIsFaded(highlightScope, highlightedItem) {
11
+ if (!highlightScope || !highlightedItem) {
12
+ return alwaysFalse;
13
+ }
14
+ return function isFaded(item) {
15
+ if (!item) {
16
+ return false;
17
+ }
18
+ if (highlightScope.fade === 'series') {
19
+ return item.seriesId === highlightedItem.seriesId && item.dataIndex !== highlightedItem.dataIndex;
20
+ }
21
+ if (highlightScope.fade === 'global') {
22
+ return item.seriesId !== highlightedItem.seriesId || item.dataIndex !== highlightedItem.dataIndex;
23
+ }
24
+ return false;
25
+ };
26
+ }
@@ -1,3 +1,3 @@
1
1
  import { HighlightScope } from "./highlightConfig.types.js";
2
2
  import { HighlightItemData } from "./useChartHighlight.types.js";
3
- export declare const createIsHighlighted: (highlightScope: HighlightScope | null | undefined, highlightedItem: HighlightItemData | null) => (item: HighlightItemData | null) => boolean;
3
+ export declare function createIsHighlighted(highlightScope: HighlightScope | null | undefined, highlightedItem: HighlightItemData | null): (item: HighlightItemData | null) => boolean;
@@ -3,17 +3,24 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createIsHighlighted = void 0;
7
- const createIsHighlighted = (highlightScope, highlightedItem) => item => {
8
- if (!highlightScope || !highlightedItem || !item) {
9
- return false;
10
- }
11
- if (highlightScope.highlight === 'series') {
12
- return item.seriesId === highlightedItem.seriesId;
13
- }
14
- if (highlightScope.highlight === 'item') {
15
- return item.dataIndex === highlightedItem.dataIndex && item.seriesId === highlightedItem.seriesId;
16
- }
6
+ exports.createIsHighlighted = createIsHighlighted;
7
+ function alwaysFalse() {
17
8
  return false;
18
- };
19
- exports.createIsHighlighted = createIsHighlighted;
9
+ }
10
+ function createIsHighlighted(highlightScope, highlightedItem) {
11
+ if (!highlightScope || !highlightedItem) {
12
+ return alwaysFalse;
13
+ }
14
+ return function isHighlighted(item) {
15
+ if (!item) {
16
+ return false;
17
+ }
18
+ if (highlightScope.highlight === 'series') {
19
+ return item.seriesId === highlightedItem.seriesId;
20
+ }
21
+ if (highlightScope.highlight === 'item') {
22
+ return item.dataIndex === highlightedItem.dataIndex && item.seriesId === highlightedItem.seriesId;
23
+ }
24
+ return false;
25
+ };
26
+ }
@@ -20,8 +20,10 @@ const selectorChartsHighlightScopePerSeriesId = exports.selectorChartsHighlightS
20
20
  });
21
21
  return map;
22
22
  });
23
- const selectorChartsHighlightedItem = exports.selectorChartsHighlightedItem = (0, _selectors.createSelector)([selectHighlight], highlight => highlight.item);
24
- const selectorChartsHighlightScope = exports.selectorChartsHighlightScope = (0, _selectors.createSelector)([selectorChartsHighlightScopePerSeriesId, selectorChartsHighlightedItem], (seriesIdToHighlightScope, highlightedItem) => {
23
+ const selectorChartsHighlightedItem = exports.selectorChartsHighlightedItem = (0, _selectors.createSelector)([selectHighlight], function selectorChartsHighlightedItem(highlight) {
24
+ return highlight.item;
25
+ });
26
+ const selectorChartsHighlightScope = exports.selectorChartsHighlightScope = (0, _selectors.createSelector)([selectorChartsHighlightScopePerSeriesId, selectorChartsHighlightedItem], function selectorChartsHighlightScope(seriesIdToHighlightScope, highlightedItem) {
25
27
  if (!highlightedItem) {
26
28
  return null;
27
29
  }
@@ -33,5 +35,9 @@ const selectorChartsHighlightScope = exports.selectorChartsHighlightScope = (0,
33
35
  });
34
36
  const selectorChartsIsHighlightedCallback = exports.selectorChartsIsHighlightedCallback = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem], _createIsHighlighted.createIsHighlighted);
35
37
  const selectorChartsIsFadedCallback = exports.selectorChartsIsFadedCallback = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem], _createIsFaded.createIsFaded);
36
- const selectorChartsIsHighlighted = exports.selectorChartsIsHighlighted = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], (highlightScope, highlightedItem, item) => (0, _createIsHighlighted.createIsHighlighted)(highlightScope, highlightedItem)(item));
37
- const selectorChartsIsFaded = exports.selectorChartsIsFaded = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], (highlightScope, highlightedItem, item) => (0, _createIsFaded.createIsFaded)(highlightScope, highlightedItem)(item));
38
+ const selectorChartsIsHighlighted = exports.selectorChartsIsHighlighted = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
39
+ return (0, _createIsHighlighted.createIsHighlighted)(highlightScope, highlightedItem)(item);
40
+ });
41
+ const selectorChartsIsFaded = exports.selectorChartsIsFaded = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
42
+ return (0, _createIsFaded.createIsFaded)(highlightScope, highlightedItem)(item);
43
+ });
@@ -11,7 +11,7 @@ var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompa
11
11
  const useChartInteraction = ({
12
12
  store
13
13
  }) => {
14
- const cleanInteraction = (0, _useEventCallback.default)(() => {
14
+ const cleanInteraction = (0, _useEventCallback.default)(function cleanInteraction() {
15
15
  store.update(prev => {
16
16
  return (0, _extends2.default)({}, prev, {
17
17
  interaction: {
@@ -21,7 +21,7 @@ const useChartInteraction = ({
21
21
  });
22
22
  });
23
23
  });
24
- const removeItemInteraction = (0, _useEventCallback.default)(itemToRemove => {
24
+ const removeItemInteraction = (0, _useEventCallback.default)(function removeItemInteraction(itemToRemove) {
25
25
  store.update(prev => {
26
26
  const prevItem = prev.interaction.item;
27
27
  if (!itemToRemove) {
@@ -43,7 +43,7 @@ const useChartInteraction = ({
43
43
  });
44
44
  });
45
45
  });
46
- const setItemInteraction = (0, _useEventCallback.default)(newItem => {
46
+ const setItemInteraction = (0, _useEventCallback.default)(function setItemInteraction(newItem) {
47
47
  store.update(prev => {
48
48
  if ((0, _fastObjectShallowCompare.fastObjectShallowCompare)(prev.interaction.item, newItem)) {
49
49
  return prev;
@@ -55,7 +55,7 @@ const useChartInteraction = ({
55
55
  });
56
56
  });
57
57
  });
58
- const setPointerCoordinate = (0, _useEventCallback.default)(coordinate => {
58
+ const setPointerCoordinate = (0, _useEventCallback.default)(function setPointerCoordinate(coordinate) {
59
59
  store.update(prev => (0, _extends2.default)({}, prev, {
60
60
  interaction: (0, _extends2.default)({}, prev.interaction, {
61
61
  pointer: coordinate
@@ -17,6 +17,8 @@ var _useChartInteraction = require("../useChartInteraction");
17
17
  var _useChartPolarAxis = require("./useChartPolarAxis.selectors");
18
18
  var _getSVGPoint = require("../../../getSVGPoint");
19
19
  var _coordinateTransformation = require("./coordinateTransformation");
20
+ var _getAxisIndex = require("./getAxisIndex");
21
+ var _useChartSeries = require("../../corePlugins/useChartSeries");
20
22
  const useChartPolarAxis = ({
21
23
  params,
22
24
  store,
@@ -37,6 +39,7 @@ const useChartPolarAxis = ({
37
39
  }
38
40
  }
39
41
  const drawingArea = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartDrawingArea);
42
+ const processedSeries = (0, _useSelector.useSelector)(store, _useChartSeries.selectorChartSeriesProcessed);
40
43
  const center = (0, _useSelector.useSelector)(store, _useChartPolarAxis.selectorChartPolarCenter);
41
44
  const isInteractionEnabled = (0, _useSelector.useSelector)(store, _useChartInteraction.selectorChartsInteractionIsInitialized);
42
45
  const {
@@ -163,6 +166,45 @@ const useChartPolarAxis = ({
163
166
  pressEndHandler.cleanup();
164
167
  };
165
168
  }, [svgRef, store, center, radiusAxisWithScale, usedRadiusAxisId, rotationAxisWithScale, usedRotationAxisId, instance, params.disableAxisListener, isInteractionEnabled, svg2rotation]);
169
+ React.useEffect(() => {
170
+ const element = svgRef.current;
171
+ const onAxisClick = params.onAxisClick;
172
+ if (element === null || !onAxisClick) {
173
+ return () => {};
174
+ }
175
+ const axisClickHandler = instance.addInteractionListener('tap', event => {
176
+ let dataIndex = null;
177
+ let isRotationAxis = false;
178
+ const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, event.detail.srcEvent);
179
+ const rotation = (0, _coordinateTransformation.generateSvg2rotation)(center)(svgPoint.x, svgPoint.y);
180
+ const rotationIndex = (0, _getAxisIndex.getAxisIndex)(rotationAxisWithScale[usedRotationAxisId], rotation);
181
+ isRotationAxis = rotationIndex !== -1;
182
+ dataIndex = isRotationAxis ? rotationIndex : null; // radius index is not yet implemented.
183
+
184
+ const USED_AXIS_ID = isRotationAxis ? usedRotationAxisId : usedRadiusAxisId;
185
+ if (dataIndex == null || dataIndex === -1) {
186
+ return;
187
+ }
188
+
189
+ // The .data exist because otherwise the dataIndex would be null or -1.
190
+ const axisValue = (isRotationAxis ? rotationAxisWithScale : radiusAxisWithScale)[USED_AXIS_ID].data[dataIndex];
191
+ const seriesValues = {};
192
+ Object.keys(processedSeries).filter(seriesType => seriesType === 'radar').forEach(seriesType => {
193
+ processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
194
+ const seriesItem = processedSeries[seriesType].series[seriesId];
195
+ seriesValues[seriesId] = seriesItem.data[dataIndex];
196
+ });
197
+ });
198
+ onAxisClick(event.detail.srcEvent, {
199
+ dataIndex,
200
+ axisValue,
201
+ seriesValues
202
+ });
203
+ });
204
+ return () => {
205
+ axisClickHandler.cleanup();
206
+ };
207
+ }, [center, instance, params.onAxisClick, processedSeries, radiusAxisWithScale, rotationAxisWithScale, svgRef, usedRadiusAxisId, usedRotationAxisId]);
166
208
  return {
167
209
  instance: {
168
210
  svg2polar,
@@ -176,7 +218,8 @@ useChartPolarAxis.params = {
176
218
  rotationAxis: true,
177
219
  radiusAxis: true,
178
220
  dataset: true,
179
- disableAxisListener: true
221
+ disableAxisListener: true,
222
+ onAxisClick: true
180
223
  };
181
224
  useChartPolarAxis.getInitialState = params => ({
182
225
  polarAxis: {
@@ -1,6 +1,6 @@
1
1
  import { ChartPluginSignature } from "../../models/index.js";
2
2
  import { ChartSeriesType, DatasetType } from "../../../../models/seriesType/config.js";
3
- import { ScaleName, AxisConfig, ChartsRotationAxisProps, ChartsRadiusAxisProps, RadiusAxis, RotationAxis } from "../../../../models/axis.js";
3
+ import { ScaleName, AxisConfig, ChartsRotationAxisProps, ChartsRadiusAxisProps, RadiusAxis, RotationAxis, ChartsAxisData } from "../../../../models/axis.js";
4
4
  import { UseChartSeriesSignature } from "../../corePlugins/useChartSeries/index.js";
5
5
  import { UseChartInteractionSignature } from "../useChartInteraction/index.js";
6
6
  export interface UseChartPolarAxisInstance {
@@ -49,6 +49,13 @@ export interface UseChartPolarAxisParameters {
49
49
  * @default false
50
50
  */
51
51
  disableAxisListener?: boolean;
52
+ /**
53
+ * The function called for onClick events.
54
+ * The second argument contains information about all line/bar elements at the current mouse position.
55
+ * @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
56
+ * @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
57
+ */
58
+ onAxisClick?: (event: MouseEvent, data: null | ChartsAxisData) => void;
52
59
  }
53
60
  export type UseChartPolarAxisDefaultizedParameters = UseChartPolarAxisParameters & {};
54
61
  export interface UseChartPolarAxisState {
@@ -74,22 +74,24 @@ const useChartVoronoi = ({
74
74
  const yScale = yAxis[yAxisId ?? defaultYAxisId].scale;
75
75
  const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
76
76
  const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
77
- const seriesPoints = data.flatMap(({
78
- x,
79
- y
80
- }) => {
77
+ const seriesPoints = [];
78
+ const seriesIndexes = [];
79
+ for (let dataIndex = 0; dataIndex < data.length; dataIndex += 1) {
80
+ const {
81
+ x,
82
+ y
83
+ } = data[dataIndex];
81
84
  const pointX = getXPosition(x);
82
85
  const pointY = getYPosition(y);
83
- if (!instance.isPointInside(pointX, pointY)) {
84
- // If the point is not displayed we move them to a trash coordinate.
85
- // This avoids managing index mapping before/after filtering.
86
- // The trash point is far enough such that any point in the drawing area will be closer to the mouse than the trash coordinate.
87
- return [-drawingArea.width, -drawingArea.height];
86
+ if (instance.isPointInside(pointX, pointY)) {
87
+ seriesPoints.push(pointX);
88
+ seriesPoints.push(pointY);
89
+ seriesIndexes.push(dataIndex);
88
90
  }
89
- return [pointX, pointY];
90
- });
91
+ }
91
92
  voronoiRef.current[seriesId] = {
92
93
  seriesId,
94
+ seriesIndexes,
93
95
  startIndex: points.length,
94
96
  endIndex: points.length + seriesPoints.length
95
97
  };
@@ -124,7 +126,10 @@ const useChartVoronoi = ({
124
126
  if (closestSeries === undefined) {
125
127
  return 'no-point-found';
126
128
  }
127
- const dataIndex = (2 * closestPointIndex - voronoiRef.current[closestSeries.seriesId].startIndex) / 2;
129
+
130
+ // The point index in the series with id=closestSeries.seriesId.
131
+ const seriesPointIndex = (2 * closestPointIndex - voronoiRef.current[closestSeries.seriesId].startIndex) / 2;
132
+ const dataIndex = voronoiRef.current[closestSeries.seriesId].seriesIndexes[seriesPointIndex];
128
133
  if (voronoiMaxRadius !== undefined) {
129
134
  const pointX = delauneyRef.current.points[2 * closestPointIndex];
130
135
  const pointY = delauneyRef.current.points[2 * closestPointIndex + 1];
@@ -0,0 +1,2 @@
1
+ import { NumberValue, ScaleSymLog } from '@mui/x-charts-vendor/d3-scale';
2
+ export declare function scaleSymlog<Range, Output = Range, Unknown = never>(_domain: Iterable<NumberValue>, _range: Iterable<Range>): ScaleSymLog<Range, Output, Unknown>;