@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
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
const mergeMinMax = (acc, val) => {
|
|
2
|
-
return [val[0] === null ? acc[0] : Math.min(acc[0], val[0]), val[1] === null ? acc[1] : Math.max(acc[1], val[1])];
|
|
3
|
-
};
|
|
4
1
|
export const getExtremumX = params => {
|
|
5
2
|
const {
|
|
6
3
|
series,
|
|
@@ -8,24 +5,39 @@ export const getExtremumX = params => {
|
|
|
8
5
|
isDefaultAxis,
|
|
9
6
|
getFilters
|
|
10
7
|
} = params;
|
|
11
|
-
|
|
8
|
+
let min = Infinity;
|
|
9
|
+
let max = -Infinity;
|
|
10
|
+
for (const seriesId in series) {
|
|
11
|
+
if (!Object.hasOwn(series, seriesId)) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
12
14
|
const axisId = series[seriesId].xAxisId;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
if (!(axisId === axis.id || axisId === undefined && isDefaultAxis)) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
15
18
|
const filter = getFilters?.({
|
|
16
19
|
currentAxisId: axis.id,
|
|
17
20
|
isDefaultAxis,
|
|
18
21
|
seriesXAxisId: series[seriesId].xAxisId,
|
|
19
22
|
seriesYAxisId: series[seriesId].yAxisId
|
|
20
23
|
});
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
const seriesData = series[seriesId].data ?? [];
|
|
25
|
+
for (let i = 0; i < seriesData.length; i += 1) {
|
|
26
|
+
const d = seriesData[i];
|
|
27
|
+
if (filter && !filter(d, i)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (d.x !== null) {
|
|
31
|
+
if (d.x < min) {
|
|
32
|
+
min = d.x;
|
|
33
|
+
}
|
|
34
|
+
if (d.x > max) {
|
|
35
|
+
max = d.x;
|
|
36
|
+
}
|
|
24
37
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, [Infinity, -Infinity]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return [min, max];
|
|
29
41
|
};
|
|
30
42
|
export const getExtremumY = params => {
|
|
31
43
|
const {
|
|
@@ -34,22 +46,37 @@ export const getExtremumY = params => {
|
|
|
34
46
|
isDefaultAxis,
|
|
35
47
|
getFilters
|
|
36
48
|
} = params;
|
|
37
|
-
|
|
49
|
+
let min = Infinity;
|
|
50
|
+
let max = -Infinity;
|
|
51
|
+
for (const seriesId in series) {
|
|
52
|
+
if (!Object.hasOwn(series, seriesId)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
38
55
|
const axisId = series[seriesId].yAxisId;
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
if (!(axisId === axis.id || axisId === undefined && isDefaultAxis)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
41
59
|
const filter = getFilters?.({
|
|
42
60
|
currentAxisId: axis.id,
|
|
43
61
|
isDefaultAxis,
|
|
44
62
|
seriesXAxisId: series[seriesId].xAxisId,
|
|
45
63
|
seriesYAxisId: series[seriesId].yAxisId
|
|
46
64
|
});
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
const seriesData = series[seriesId].data ?? [];
|
|
66
|
+
for (let i = 0; i < seriesData.length; i += 1) {
|
|
67
|
+
const d = seriesData[i];
|
|
68
|
+
if (filter && !filter(d, i)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (d.y !== null) {
|
|
72
|
+
if (d.y < min) {
|
|
73
|
+
min = d.y;
|
|
74
|
+
}
|
|
75
|
+
if (d.y > max) {
|
|
76
|
+
max = d.y;
|
|
77
|
+
}
|
|
50
78
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, [Infinity, -Infinity]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return [min, max];
|
|
55
82
|
};
|
|
@@ -7,7 +7,7 @@ import { ChartsOverlayProps } from "../ChartsOverlay/index.js";
|
|
|
7
7
|
import { ChartContainerProps } from "../ChartContainer/index.js";
|
|
8
8
|
import type { ScatterChartProps } from "./ScatterChart.js";
|
|
9
9
|
import type { ScatterPlotProps } from "./ScatterPlot.js";
|
|
10
|
-
import type { ChartsWrapperProps } from "../
|
|
10
|
+
import type { ChartsWrapperProps } from "../ChartsWrapper/index.js";
|
|
11
11
|
import { ScatterChartPluginsSignatures } from "./ScatterChart.plugins.js";
|
|
12
12
|
/**
|
|
13
13
|
* A helper function that extracts ScatterChartProps from the input props
|
|
@@ -477,6 +477,53 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
477
477
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
478
478
|
tickSize: PropTypes.number,
|
|
479
479
|
valueFormatter: PropTypes.func
|
|
480
|
+
}), PropTypes.shape({
|
|
481
|
+
axis: PropTypes.oneOf(['x']),
|
|
482
|
+
classes: PropTypes.object,
|
|
483
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
484
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
485
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
486
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
487
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
488
|
+
}), PropTypes.shape({
|
|
489
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
490
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
491
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
492
|
+
})]),
|
|
493
|
+
constant: PropTypes.number,
|
|
494
|
+
data: PropTypes.array,
|
|
495
|
+
dataKey: PropTypes.string,
|
|
496
|
+
disableLine: PropTypes.bool,
|
|
497
|
+
disableTicks: PropTypes.bool,
|
|
498
|
+
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
499
|
+
fill: PropTypes.string,
|
|
500
|
+
height: PropTypes.number,
|
|
501
|
+
hideTooltip: PropTypes.bool,
|
|
502
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
503
|
+
ignoreTooltip: PropTypes.bool,
|
|
504
|
+
label: PropTypes.string,
|
|
505
|
+
labelStyle: PropTypes.object,
|
|
506
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
507
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
508
|
+
offset: PropTypes.number,
|
|
509
|
+
position: PropTypes.oneOf(['bottom', 'none', 'top']),
|
|
510
|
+
reverse: PropTypes.bool,
|
|
511
|
+
scaleType: PropTypes.oneOf(['symlog']),
|
|
512
|
+
slotProps: PropTypes.object,
|
|
513
|
+
slots: PropTypes.object,
|
|
514
|
+
stroke: PropTypes.string,
|
|
515
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
516
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
517
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
518
|
+
tickLabelMinGap: PropTypes.number,
|
|
519
|
+
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
520
|
+
tickLabelStyle: PropTypes.object,
|
|
521
|
+
tickMaxStep: PropTypes.number,
|
|
522
|
+
tickMinStep: PropTypes.number,
|
|
523
|
+
tickNumber: PropTypes.number,
|
|
524
|
+
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
525
|
+
tickSize: PropTypes.number,
|
|
526
|
+
valueFormatter: PropTypes.func
|
|
480
527
|
}), PropTypes.shape({
|
|
481
528
|
axis: PropTypes.oneOf(['x']),
|
|
482
529
|
classes: PropTypes.object,
|
|
@@ -859,6 +906,52 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
859
906
|
tickSize: PropTypes.number,
|
|
860
907
|
valueFormatter: PropTypes.func,
|
|
861
908
|
width: PropTypes.number
|
|
909
|
+
}), PropTypes.shape({
|
|
910
|
+
axis: PropTypes.oneOf(['y']),
|
|
911
|
+
classes: PropTypes.object,
|
|
912
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
913
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
914
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
915
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
916
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
917
|
+
}), PropTypes.shape({
|
|
918
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
919
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
920
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
921
|
+
})]),
|
|
922
|
+
constant: PropTypes.number,
|
|
923
|
+
data: PropTypes.array,
|
|
924
|
+
dataKey: PropTypes.string,
|
|
925
|
+
disableLine: PropTypes.bool,
|
|
926
|
+
disableTicks: PropTypes.bool,
|
|
927
|
+
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
928
|
+
fill: PropTypes.string,
|
|
929
|
+
hideTooltip: PropTypes.bool,
|
|
930
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
931
|
+
ignoreTooltip: PropTypes.bool,
|
|
932
|
+
label: PropTypes.string,
|
|
933
|
+
labelStyle: PropTypes.object,
|
|
934
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
935
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
936
|
+
offset: PropTypes.number,
|
|
937
|
+
position: PropTypes.oneOf(['left', 'none', 'right']),
|
|
938
|
+
reverse: PropTypes.bool,
|
|
939
|
+
scaleType: PropTypes.oneOf(['symlog']),
|
|
940
|
+
slotProps: PropTypes.object,
|
|
941
|
+
slots: PropTypes.object,
|
|
942
|
+
stroke: PropTypes.string,
|
|
943
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
944
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
945
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
946
|
+
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
947
|
+
tickLabelStyle: PropTypes.object,
|
|
948
|
+
tickMaxStep: PropTypes.number,
|
|
949
|
+
tickMinStep: PropTypes.number,
|
|
950
|
+
tickNumber: PropTypes.number,
|
|
951
|
+
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
952
|
+
tickSize: PropTypes.number,
|
|
953
|
+
valueFormatter: PropTypes.func,
|
|
954
|
+
width: PropTypes.number
|
|
862
955
|
}), PropTypes.shape({
|
|
863
956
|
axis: PropTypes.oneOf(['y']),
|
|
864
957
|
classes: PropTypes.object,
|
package/esm/hooks/useTicks.d.ts
CHANGED
|
@@ -49,8 +49,13 @@ export type TickItemType = {
|
|
|
49
49
|
offset: number;
|
|
50
50
|
labelOffset: number;
|
|
51
51
|
};
|
|
52
|
+
export declare function getTicks(options: {
|
|
53
|
+
scale: D3Scale;
|
|
54
|
+
valueFormatter?: AxisConfig['valueFormatter'];
|
|
55
|
+
isInside: (offset: number) => boolean;
|
|
56
|
+
} & Pick<TickParams, 'tickInterval' | 'tickPlacement' | 'tickLabelPlacement'> & Required<Pick<TickParams, 'tickNumber'>>): TickItemType[];
|
|
52
57
|
export declare function useTicks(options: {
|
|
53
58
|
scale: D3Scale;
|
|
54
59
|
valueFormatter?: AxisConfig['valueFormatter'];
|
|
55
60
|
direction: 'x' | 'y';
|
|
56
|
-
} & Pick<TickParams, '
|
|
61
|
+
} & Pick<TickParams, 'tickInterval' | 'tickPlacement' | 'tickLabelPlacement'> & Required<Pick<TickParams, 'tickNumber'>>): TickItemType[];
|
package/esm/hooks/useTicks.js
CHANGED
|
@@ -10,7 +10,7 @@ const offsetRatio = {
|
|
|
10
10
|
end: 1,
|
|
11
11
|
middle: 0.5
|
|
12
12
|
};
|
|
13
|
-
export function
|
|
13
|
+
export function getTicks(options) {
|
|
14
14
|
const {
|
|
15
15
|
scale,
|
|
16
16
|
tickNumber,
|
|
@@ -18,75 +18,111 @@ export function useTicks(options) {
|
|
|
18
18
|
tickInterval,
|
|
19
19
|
tickPlacement = 'extremities',
|
|
20
20
|
tickLabelPlacement: tickLabelPlacementProp,
|
|
21
|
-
|
|
21
|
+
isInside
|
|
22
22
|
} = options;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return [...filteredDomain.map(value => ({
|
|
23
|
+
|
|
24
|
+
// band scale
|
|
25
|
+
if (isBandScale(scale)) {
|
|
26
|
+
const domain = scale.domain();
|
|
27
|
+
const tickLabelPlacement = tickLabelPlacementProp ?? 'middle';
|
|
28
|
+
if (scale.bandwidth() > 0) {
|
|
29
|
+
// scale type = 'band'
|
|
30
|
+
const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
|
|
31
|
+
return [...filteredDomain.map(value => {
|
|
32
|
+
const defaultTickLabel = `${value}`;
|
|
33
|
+
return {
|
|
35
34
|
value,
|
|
36
35
|
formattedValue: valueFormatter?.(value, {
|
|
37
36
|
location: 'tick',
|
|
38
|
-
scale
|
|
39
|
-
|
|
37
|
+
scale,
|
|
38
|
+
tickNumber,
|
|
39
|
+
defaultTickLabel
|
|
40
|
+
}) ?? defaultTickLabel,
|
|
40
41
|
offset: scale(value) - (scale.step() - scale.bandwidth()) / 2 + offsetRatio[tickPlacement] * scale.step(),
|
|
41
42
|
labelOffset: tickLabelPlacement === 'tick' ? 0 : scale.step() * (offsetRatio[tickLabelPlacement] - offsetRatio[tickPlacement])
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
43
|
+
};
|
|
44
|
+
}), ...(tickPlacement === 'extremities' ? [{
|
|
45
|
+
formattedValue: undefined,
|
|
46
|
+
offset: scale.range()[1],
|
|
47
|
+
labelOffset: 0
|
|
48
|
+
}] : [])];
|
|
49
|
+
}
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
// scale type = 'point'
|
|
52
|
+
const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
|
|
53
|
+
return filteredDomain.map(value => {
|
|
54
|
+
const defaultTickLabel = `${value}`;
|
|
55
|
+
return {
|
|
52
56
|
value,
|
|
53
57
|
formattedValue: valueFormatter?.(value, {
|
|
54
58
|
location: 'tick',
|
|
55
|
-
scale
|
|
56
|
-
|
|
59
|
+
scale,
|
|
60
|
+
tickNumber,
|
|
61
|
+
defaultTickLabel
|
|
62
|
+
}) ?? defaultTickLabel,
|
|
57
63
|
offset: scale(value),
|
|
58
64
|
labelOffset: 0
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const domain = scale.domain();
|
|
69
|
+
// Skip axis rendering if no data is available
|
|
70
|
+
// - The domains contains Infinity for continuous scales.
|
|
71
|
+
if (domain.some(isInfinity)) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
const tickLabelPlacement = tickLabelPlacementProp;
|
|
75
|
+
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
69
76
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
// Ticks inside the drawing area
|
|
78
|
+
const visibleTicks = [];
|
|
79
|
+
for (let i = 0; i < ticks.length; i += 1) {
|
|
80
|
+
const value = ticks[i];
|
|
81
|
+
const offset = scale(value);
|
|
82
|
+
if (isInside(offset)) {
|
|
83
|
+
/* If d3 returns an empty string, it means that a tick should be shown, but its label shouldn't.
|
|
84
|
+
* This is especially useful in a log scale where we want to show ticks to demonstrate it's a log
|
|
85
|
+
* scale, but don't want to show labels because they would overlap.
|
|
86
|
+
* https://github.com/mui/mui-x/issues/18239 */
|
|
87
|
+
const defaultTickLabel = scale.tickFormat(tickNumber)(value);
|
|
88
|
+
visibleTicks.push({
|
|
89
|
+
value,
|
|
90
|
+
formattedValue: valueFormatter?.(value, {
|
|
91
|
+
location: 'tick',
|
|
92
|
+
scale,
|
|
93
|
+
tickNumber,
|
|
94
|
+
defaultTickLabel
|
|
95
|
+
}) ?? defaultTickLabel,
|
|
96
|
+
offset,
|
|
97
|
+
// Allowing the label to be placed in the middle of a continuous scale is weird.
|
|
98
|
+
// But it is useful in some cases, like funnel categories with a linear scale.
|
|
99
|
+
labelOffset: tickLabelPlacement === 'middle' ? scale(ticks[i - 1] ?? 0) - (offset + scale(ticks[i - 1] ?? 0)) / 2 : 0
|
|
100
|
+
});
|
|
89
101
|
}
|
|
90
|
-
|
|
91
|
-
|
|
102
|
+
}
|
|
103
|
+
return visibleTicks;
|
|
104
|
+
}
|
|
105
|
+
export function useTicks(options) {
|
|
106
|
+
const {
|
|
107
|
+
scale,
|
|
108
|
+
tickNumber,
|
|
109
|
+
valueFormatter,
|
|
110
|
+
tickInterval,
|
|
111
|
+
tickPlacement = 'extremities',
|
|
112
|
+
tickLabelPlacement,
|
|
113
|
+
direction
|
|
114
|
+
} = options;
|
|
115
|
+
const {
|
|
116
|
+
instance
|
|
117
|
+
} = useChartContext();
|
|
118
|
+
const isInside = direction === 'x' ? instance.isXInside : instance.isYInside;
|
|
119
|
+
return React.useMemo(() => getTicks({
|
|
120
|
+
scale,
|
|
121
|
+
tickNumber,
|
|
122
|
+
tickPlacement,
|
|
123
|
+
tickInterval,
|
|
124
|
+
tickLabelPlacement,
|
|
125
|
+
valueFormatter,
|
|
126
|
+
isInside
|
|
127
|
+
}), [scale, tickNumber, tickPlacement, tickInterval, tickLabelPlacement, valueFormatter, isInside]);
|
|
92
128
|
}
|
package/esm/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/esm/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
|
|
@@ -32,4 +32,8 @@ export * from "./RadarChart/index.js";
|
|
|
32
32
|
export * from "./ChartsSurface/index.js";
|
|
33
33
|
export { ChartContainer } from "./ChartContainer/index.js";
|
|
34
34
|
export * from "./ChartDataProvider/index.js";
|
|
35
|
-
export * from "./Toolbar/index.js";
|
|
35
|
+
export * from "./Toolbar/index.js";
|
|
36
|
+
export * from "./ChartsWrapper/index.js";
|
|
37
|
+
|
|
38
|
+
// Locales should be imported from `@mui/x-charts/locales`
|
|
39
|
+
// export * from './locales';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findMinMax(data: readonly number[]): [number, number];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { scaleLog, scalePow, scaleSqrt, scaleTime, scaleUtc, scaleLinear } from '@mui/x-charts-vendor/d3-scale';
|
|
2
|
+
import { scaleSymlog } from "./symlogScale.js";
|
|
2
3
|
export function getScale(scaleType, domain, range) {
|
|
3
4
|
switch (scaleType) {
|
|
4
5
|
case 'log':
|
|
@@ -11,6 +12,8 @@ export function getScale(scaleType, domain, range) {
|
|
|
11
12
|
return scaleTime(domain, range);
|
|
12
13
|
case 'utc':
|
|
13
14
|
return scaleUtc(domain, range);
|
|
15
|
+
case 'symlog':
|
|
16
|
+
return scaleSymlog(domain, range);
|
|
14
17
|
default:
|
|
15
18
|
return scaleLinear(domain, range);
|
|
16
19
|
}
|
package/esm/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/esm/internals/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Components
|
|
2
2
|
export * from "./components/ChartsAxesGradients/index.js";
|
|
3
|
-
export * from "./components/ChartsWrapper/index.js";
|
|
4
3
|
export * from "../ChartsLabel/ChartsLabelMark.js";
|
|
5
4
|
export * from "./components/NotRendered.js";
|
|
6
5
|
|
|
@@ -64,6 +63,7 @@ export * from "./ticks.js";
|
|
|
64
63
|
export * from "./dateHelpers.js";
|
|
65
64
|
export * from "./invertScale.js";
|
|
66
65
|
export * from "./isBandScale.js";
|
|
66
|
+
export * from "./findMinMax.js";
|
|
67
67
|
|
|
68
68
|
// contexts
|
|
69
69
|
export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
|
|
3
3
|
import { createScalarFormatter } from "../../../defaultValueFormatters.js";
|
|
4
|
-
import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.js";
|
|
4
|
+
import { isBandScaleConfig, isPointScaleConfig, isSymlogScaleConfig } from "../../../../models/axis.js";
|
|
5
5
|
import { getColorScale, getOrdinalColorScale } from "../../../colorScale.js";
|
|
6
6
|
import { getTickNumber, scaleTickNumberByRange } from "../../../ticks.js";
|
|
7
7
|
import { getScale } from "../../../getScale.js";
|
|
@@ -114,6 +114,9 @@ export function computeAxisValue({
|
|
|
114
114
|
const tickNumber = scaleTickNumberByRange(rawTickNumber, zoomRange);
|
|
115
115
|
const zoomedRange = zoomScaleRange(range, zoomRange);
|
|
116
116
|
const scale = getScale(scaleType, axisExtremums, zoomedRange);
|
|
117
|
+
if (isSymlogScaleConfig(axis) && axis.constant != null) {
|
|
118
|
+
scale.constant(axis.constant);
|
|
119
|
+
}
|
|
117
120
|
const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
|
|
118
121
|
const [minDomain, maxDomain] = finalScale.domain();
|
|
119
122
|
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;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
if (!highlightScope || !highlightedItem || !item) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
if (highlightScope.fade === 'series') {
|
|
6
|
-
return item.seriesId === highlightedItem.seriesId && item.dataIndex !== highlightedItem.dataIndex;
|
|
7
|
-
}
|
|
8
|
-
if (highlightScope.fade === 'global') {
|
|
9
|
-
return item.seriesId !== highlightedItem.seriesId || item.dataIndex !== highlightedItem.dataIndex;
|
|
10
|
-
}
|
|
1
|
+
function alwaysFalse() {
|
|
11
2
|
return false;
|
|
12
|
-
}
|
|
3
|
+
}
|
|
4
|
+
export function createIsFaded(highlightScope, highlightedItem) {
|
|
5
|
+
if (!highlightScope || !highlightedItem) {
|
|
6
|
+
return alwaysFalse;
|
|
7
|
+
}
|
|
8
|
+
return function isFaded(item) {
|
|
9
|
+
if (!item) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (highlightScope.fade === 'series') {
|
|
13
|
+
return item.seriesId === highlightedItem.seriesId && item.dataIndex !== highlightedItem.dataIndex;
|
|
14
|
+
}
|
|
15
|
+
if (highlightScope.fade === 'global') {
|
|
16
|
+
return item.seriesId !== highlightedItem.seriesId || item.dataIndex !== highlightedItem.dataIndex;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -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;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
if (!highlightScope || !highlightedItem || !item) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
if (highlightScope.highlight === 'series') {
|
|
6
|
-
return item.seriesId === highlightedItem.seriesId;
|
|
7
|
-
}
|
|
8
|
-
if (highlightScope.highlight === 'item') {
|
|
9
|
-
return item.dataIndex === highlightedItem.dataIndex && item.seriesId === highlightedItem.seriesId;
|
|
10
|
-
}
|
|
1
|
+
function alwaysFalse() {
|
|
11
2
|
return false;
|
|
12
|
-
}
|
|
3
|
+
}
|
|
4
|
+
export function createIsHighlighted(highlightScope, highlightedItem) {
|
|
5
|
+
if (!highlightScope || !highlightedItem) {
|
|
6
|
+
return alwaysFalse;
|
|
7
|
+
}
|
|
8
|
+
return function isHighlighted(item) {
|
|
9
|
+
if (!item) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (highlightScope.highlight === 'series') {
|
|
13
|
+
return item.seriesId === highlightedItem.seriesId;
|
|
14
|
+
}
|
|
15
|
+
if (highlightScope.highlight === 'item') {
|
|
16
|
+
return item.dataIndex === highlightedItem.dataIndex && item.seriesId === highlightedItem.seriesId;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
}
|
package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js
CHANGED
|
@@ -14,8 +14,10 @@ export const selectorChartsHighlightScopePerSeriesId = createSelector([selectSer
|
|
|
14
14
|
});
|
|
15
15
|
return map;
|
|
16
16
|
});
|
|
17
|
-
export const selectorChartsHighlightedItem = createSelector([selectHighlight],
|
|
18
|
-
|
|
17
|
+
export const selectorChartsHighlightedItem = createSelector([selectHighlight], function selectorChartsHighlightedItem(highlight) {
|
|
18
|
+
return highlight.item;
|
|
19
|
+
});
|
|
20
|
+
export const selectorChartsHighlightScope = createSelector([selectorChartsHighlightScopePerSeriesId, selectorChartsHighlightedItem], function selectorChartsHighlightScope(seriesIdToHighlightScope, highlightedItem) {
|
|
19
21
|
if (!highlightedItem) {
|
|
20
22
|
return null;
|
|
21
23
|
}
|
|
@@ -27,5 +29,9 @@ export const selectorChartsHighlightScope = createSelector([selectorChartsHighli
|
|
|
27
29
|
});
|
|
28
30
|
export const selectorChartsIsHighlightedCallback = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], createIsHighlighted);
|
|
29
31
|
export const selectorChartsIsFadedCallback = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem], createIsFaded);
|
|
30
|
-
export const selectorChartsIsHighlighted = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], (highlightScope, highlightedItem, item)
|
|
31
|
-
|
|
32
|
+
export const selectorChartsIsHighlighted = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
|
|
33
|
+
return createIsHighlighted(highlightScope, highlightedItem)(item);
|
|
34
|
+
});
|
|
35
|
+
export const selectorChartsIsFaded = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
|
|
36
|
+
return createIsFaded(highlightScope, highlightedItem)(item);
|
|
37
|
+
});
|