@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.
- package/BarChart/BarChart.d.ts +3 -2
- package/BarChart/BarChart.js +95 -2
- package/BarChart/BarClipPath.d.ts +17 -12
- package/BarChart/BarClipPath.js +70 -57
- package/BarChart/BarPlot.js +4 -0
- package/BarChart/barClasses.d.ts +1 -1
- package/BarChart/seriesConfig/extremums.js +2 -3
- package/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/BarChart/useBarChartProps.d.ts +1 -1
- package/BarChart/useBarPlotData.js +32 -5
- package/CHANGELOG.md +225 -24
- package/ChartContainer/ChartContainer.js +141 -0
- package/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/ChartsLabel/index.d.ts +1 -0
- package/ChartsLabel/index.js +18 -0
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
- package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +33 -7
- package/LineChart/LineChart.d.ts +3 -2
- package/LineChart/LineChart.js +95 -2
- package/LineChart/seriesConfig/extremums.js +2 -3
- package/LineChart/useLineChartProps.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +3 -0
- package/PieChart/PieArcPlot.js +3 -0
- package/PieChart/PieChart.d.ts +3 -2
- package/PieChart/PieChart.js +2 -2
- package/PieChart/pieClasses.d.ts +1 -1
- package/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/RadarChart/RadarChart.d.ts +3 -2
- package/RadarChart/RadarChart.js +24 -3
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
- package/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +38 -0
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/RadarChart/index.d.ts +1 -1
- package/RadarChart/useRadarChartProps.d.ts +4 -1
- package/RadarChart/useRadarChartProps.js +15 -3
- package/ScatterChart/ScatterChart.d.ts +3 -2
- package/ScatterChart/ScatterChart.js +95 -2
- package/ScatterChart/seriesConfig/extremums.js +50 -23
- package/ScatterChart/useScatterChartProps.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +93 -0
- package/esm/BarChart/BarChart.d.ts +3 -2
- package/esm/BarChart/BarChart.js +95 -2
- package/esm/BarChart/BarClipPath.d.ts +17 -12
- package/esm/BarChart/BarClipPath.js +69 -55
- package/esm/BarChart/BarPlot.js +4 -0
- package/esm/BarChart/barClasses.d.ts +1 -1
- package/esm/BarChart/seriesConfig/extremums.js +2 -3
- package/esm/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/esm/BarChart/useBarChartProps.d.ts +1 -1
- package/esm/BarChart/useBarPlotData.js +32 -5
- package/esm/ChartContainer/ChartContainer.js +141 -0
- package/esm/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/esm/ChartsLabel/index.d.ts +1 -0
- package/esm/ChartsLabel/index.js +1 -0
- package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
- package/esm/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +31 -6
- package/esm/LineChart/LineChart.d.ts +3 -2
- package/esm/LineChart/LineChart.js +95 -2
- package/esm/LineChart/seriesConfig/extremums.js +2 -3
- package/esm/LineChart/useLineChartProps.d.ts +1 -1
- package/esm/PieChart/PieArcLabelPlot.js +3 -0
- package/esm/PieChart/PieArcPlot.js +3 -0
- package/esm/PieChart/PieChart.d.ts +3 -2
- package/esm/PieChart/PieChart.js +2 -2
- package/esm/PieChart/pieClasses.d.ts +1 -1
- package/esm/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/esm/RadarChart/RadarChart.d.ts +3 -2
- package/esm/RadarChart/RadarChart.js +24 -3
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -2
- package/esm/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +32 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/esm/RadarChart/index.d.ts +1 -1
- package/esm/RadarChart/useRadarChartProps.d.ts +4 -1
- package/esm/RadarChart/useRadarChartProps.js +15 -3
- package/esm/ScatterChart/ScatterChart.d.ts +3 -2
- package/esm/ScatterChart/ScatterChart.js +95 -2
- package/esm/ScatterChart/seriesConfig/extremums.js +50 -23
- package/esm/ScatterChart/useScatterChartProps.d.ts +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +93 -0
- package/esm/hooks/useTicks.d.ts +6 -1
- package/esm/hooks/useTicks.js +94 -58
- package/esm/index.d.ts +2 -1
- package/esm/index.js +6 -2
- package/esm/internals/findMinMax.d.ts +1 -0
- package/esm/internals/findMinMax.js +13 -0
- package/esm/internals/getScale.js +3 -0
- package/esm/internals/index.d.ts +1 -1
- package/esm/internals/index.js +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
- package/esm/internals/symlogScale.d.ts +2 -0
- package/esm/internals/symlogScale.js +94 -0
- package/esm/models/axis.d.ts +47 -5
- package/esm/models/axis.js +3 -0
- package/esm/models/seriesType/bar.d.ts +11 -1
- package/esm/models/seriesType/common.d.ts +9 -3
- package/esm/models/seriesType/line.d.ts +3 -1
- package/esm/models/seriesType/scatter.d.ts +4 -1
- package/esm/tests/web-components.js +49 -0
- package/hooks/useTicks.d.ts +6 -1
- package/hooks/useTicks.js +95 -58
- package/index.d.ts +2 -1
- package/index.js +13 -1
- package/internals/findMinMax.d.ts +1 -0
- package/internals/findMinMax.js +19 -0
- package/internals/getScale.js +3 -0
- package/internals/index.d.ts +1 -1
- package/internals/index.js +12 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +3 -0
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +17 -12
- package/internals/symlogScale.d.ts +2 -0
- package/internals/symlogScale.js +100 -0
- package/models/axis.d.ts +47 -5
- package/models/axis.js +4 -0
- package/models/seriesType/bar.d.ts +11 -1
- package/models/seriesType/common.d.ts +9 -3
- package/models/seriesType/line.d.ts +3 -1
- package/models/seriesType/scatter.d.ts +4 -1
- package/package.json +6 -7
- package/tests/web-components.js +55 -0
- package/BarChart/getRadius.d.ts +0 -20
- package/BarChart/getRadius.js +0 -37
- package/esm/BarChart/getRadius.d.ts +0 -20
- package/esm/BarChart/getRadius.js +0 -30
- /package/{esm/internals/components/ChartsWrapper → ChartsWrapper}/index.d.ts +0 -0
- /package/{internals/components/ChartsWrapper → ChartsWrapper}/index.js +0 -0
- /package/{internals/components → esm}/ChartsWrapper/index.d.ts +0 -0
- /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
|
|
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
|
-
|
|
28
|
+
isInside
|
|
28
29
|
} = options;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
50
|
+
};
|
|
51
|
+
}), ...(tickPlacement === 'extremities' ? [{
|
|
52
|
+
formattedValue: undefined,
|
|
53
|
+
offset: scale.range()[1],
|
|
54
|
+
labelOffset: 0
|
|
55
|
+
}] : [])];
|
|
56
|
+
}
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
66
|
+
scale,
|
|
67
|
+
tickNumber,
|
|
68
|
+
defaultTickLabel
|
|
69
|
+
}) ?? defaultTickLabel,
|
|
63
70
|
offset: scale(value),
|
|
64
71
|
labelOffset: 0
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
97
|
-
|
|
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.
|
|
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
|
+
}
|
package/internals/getScale.js
CHANGED
|
@@ -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
|
}
|
package/internals/index.d.ts
CHANGED
|
@@ -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";
|
package/internals/index.js
CHANGED
|
@@ -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
|
|
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 =
|
|
7
|
-
|
|
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
|
-
|
|
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
|
|
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 =
|
|
7
|
-
|
|
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
|
-
|
|
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],
|
|
24
|
-
|
|
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)
|
|
37
|
-
|
|
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 =
|
|
78
|
-
|
|
79
|
-
|
|
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 (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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];
|