@mui/x-charts 8.9.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.js +94 -1
- package/BarChart/BarClipPath.d.ts +17 -12
- package/BarChart/BarClipPath.js +70 -57
- package/BarChart/BarPlot.js +4 -0
- package/BarChart/seriesConfig/extremums.js +2 -3
- package/BarChart/useBarChartProps.d.ts +1 -1
- package/CHANGELOG.md +124 -0
- package/ChartContainer/ChartContainer.js +141 -0
- package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.d.ts +13 -4
- package/{internals/components/ChartsWrapper → ChartsWrapper}/ChartsWrapper.js +33 -7
- package/LineChart/LineChart.js +94 -1
- package/LineChart/seriesConfig/extremums.js +2 -3
- package/LineChart/useLineChartProps.d.ts +1 -1
- package/PieChart/PieChart.js +1 -1
- package/RadarChart/RadarChart.d.ts +1 -1
- package/RadarChart/RadarChart.js +1 -1
- package/RadarChart/useRadarChartProps.d.ts +1 -1
- package/ScatterChart/ScatterChart.js +94 -1
- package/ScatterChart/seriesConfig/extremums.js +50 -23
- package/ScatterChart/useScatterChartProps.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +93 -0
- package/esm/BarChart/BarChart.js +94 -1
- 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/seriesConfig/extremums.js +2 -3
- package/esm/BarChart/useBarChartProps.d.ts +1 -1
- package/esm/ChartContainer/ChartContainer.js +141 -0
- 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.js +94 -1
- package/esm/LineChart/seriesConfig/extremums.js +2 -3
- package/esm/LineChart/useLineChartProps.d.ts +1 -1
- package/esm/PieChart/PieChart.js +1 -1
- package/esm/RadarChart/RadarChart.d.ts +1 -1
- package/esm/RadarChart/RadarChart.js +1 -1
- package/esm/RadarChart/useRadarChartProps.d.ts +1 -1
- package/esm/ScatterChart/ScatterChart.js +94 -1
- 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/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/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 +20 -4
- package/esm/models/axis.js +3 -0
- 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/useChartVoronoi/useChartVoronoi.js +17 -12
- package/internals/symlogScale.d.ts +2 -0
- package/internals/symlogScale.js +100 -0
- package/models/axis.d.ts +20 -4
- package/models/axis.js +4 -0
- package/package.json +5 -6
- 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
|
@@ -4,9 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getExtremumY = exports.getExtremumX = void 0;
|
|
7
|
-
const mergeMinMax = (acc, val) => {
|
|
8
|
-
return [val[0] === null ? acc[0] : Math.min(acc[0], val[0]), val[1] === null ? acc[1] : Math.max(acc[1], val[1])];
|
|
9
|
-
};
|
|
10
7
|
const getExtremumX = params => {
|
|
11
8
|
const {
|
|
12
9
|
series,
|
|
@@ -14,24 +11,39 @@ const getExtremumX = params => {
|
|
|
14
11
|
isDefaultAxis,
|
|
15
12
|
getFilters
|
|
16
13
|
} = params;
|
|
17
|
-
|
|
14
|
+
let min = Infinity;
|
|
15
|
+
let max = -Infinity;
|
|
16
|
+
for (const seriesId in series) {
|
|
17
|
+
if (!Object.hasOwn(series, seriesId)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
18
20
|
const axisId = series[seriesId].xAxisId;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
if (!(axisId === axis.id || axisId === undefined && isDefaultAxis)) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
21
24
|
const filter = getFilters?.({
|
|
22
25
|
currentAxisId: axis.id,
|
|
23
26
|
isDefaultAxis,
|
|
24
27
|
seriesXAxisId: series[seriesId].xAxisId,
|
|
25
28
|
seriesYAxisId: series[seriesId].yAxisId
|
|
26
29
|
});
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
const seriesData = series[seriesId].data ?? [];
|
|
31
|
+
for (let i = 0; i < seriesData.length; i += 1) {
|
|
32
|
+
const d = seriesData[i];
|
|
33
|
+
if (filter && !filter(d, i)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (d.x !== null) {
|
|
37
|
+
if (d.x < min) {
|
|
38
|
+
min = d.x;
|
|
39
|
+
}
|
|
40
|
+
if (d.x > max) {
|
|
41
|
+
max = d.x;
|
|
42
|
+
}
|
|
30
43
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, [Infinity, -Infinity]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return [min, max];
|
|
35
47
|
};
|
|
36
48
|
exports.getExtremumX = getExtremumX;
|
|
37
49
|
const getExtremumY = params => {
|
|
@@ -41,23 +53,38 @@ const getExtremumY = params => {
|
|
|
41
53
|
isDefaultAxis,
|
|
42
54
|
getFilters
|
|
43
55
|
} = params;
|
|
44
|
-
|
|
56
|
+
let min = Infinity;
|
|
57
|
+
let max = -Infinity;
|
|
58
|
+
for (const seriesId in series) {
|
|
59
|
+
if (!Object.hasOwn(series, seriesId)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
45
62
|
const axisId = series[seriesId].yAxisId;
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
if (!(axisId === axis.id || axisId === undefined && isDefaultAxis)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
48
66
|
const filter = getFilters?.({
|
|
49
67
|
currentAxisId: axis.id,
|
|
50
68
|
isDefaultAxis,
|
|
51
69
|
seriesXAxisId: series[seriesId].xAxisId,
|
|
52
70
|
seriesYAxisId: series[seriesId].yAxisId
|
|
53
71
|
});
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
const seriesData = series[seriesId].data ?? [];
|
|
73
|
+
for (let i = 0; i < seriesData.length; i += 1) {
|
|
74
|
+
const d = seriesData[i];
|
|
75
|
+
if (filter && !filter(d, i)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (d.y !== null) {
|
|
79
|
+
if (d.y < min) {
|
|
80
|
+
min = d.y;
|
|
81
|
+
}
|
|
82
|
+
if (d.y > max) {
|
|
83
|
+
max = d.y;
|
|
84
|
+
}
|
|
57
85
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}, [Infinity, -Infinity]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return [min, max];
|
|
62
89
|
};
|
|
63
90
|
exports.getExtremumY = getExtremumY;
|
|
@@ -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
|
|
@@ -484,6 +484,53 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
484
484
|
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
485
485
|
tickSize: _propTypes.default.number,
|
|
486
486
|
valueFormatter: _propTypes.default.func
|
|
487
|
+
}), _propTypes.default.shape({
|
|
488
|
+
axis: _propTypes.default.oneOf(['x']),
|
|
489
|
+
classes: _propTypes.default.object,
|
|
490
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
491
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
492
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
493
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
494
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
495
|
+
}), _propTypes.default.shape({
|
|
496
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
497
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
498
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
499
|
+
})]),
|
|
500
|
+
constant: _propTypes.default.number,
|
|
501
|
+
data: _propTypes.default.array,
|
|
502
|
+
dataKey: _propTypes.default.string,
|
|
503
|
+
disableLine: _propTypes.default.bool,
|
|
504
|
+
disableTicks: _propTypes.default.bool,
|
|
505
|
+
domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
|
|
506
|
+
fill: _propTypes.default.string,
|
|
507
|
+
height: _propTypes.default.number,
|
|
508
|
+
hideTooltip: _propTypes.default.bool,
|
|
509
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
510
|
+
ignoreTooltip: _propTypes.default.bool,
|
|
511
|
+
label: _propTypes.default.string,
|
|
512
|
+
labelStyle: _propTypes.default.object,
|
|
513
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
514
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
515
|
+
offset: _propTypes.default.number,
|
|
516
|
+
position: _propTypes.default.oneOf(['bottom', 'none', 'top']),
|
|
517
|
+
reverse: _propTypes.default.bool,
|
|
518
|
+
scaleType: _propTypes.default.oneOf(['symlog']),
|
|
519
|
+
slotProps: _propTypes.default.object,
|
|
520
|
+
slots: _propTypes.default.object,
|
|
521
|
+
stroke: _propTypes.default.string,
|
|
522
|
+
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
523
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
524
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
525
|
+
tickLabelMinGap: _propTypes.default.number,
|
|
526
|
+
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
527
|
+
tickLabelStyle: _propTypes.default.object,
|
|
528
|
+
tickMaxStep: _propTypes.default.number,
|
|
529
|
+
tickMinStep: _propTypes.default.number,
|
|
530
|
+
tickNumber: _propTypes.default.number,
|
|
531
|
+
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
532
|
+
tickSize: _propTypes.default.number,
|
|
533
|
+
valueFormatter: _propTypes.default.func
|
|
487
534
|
}), _propTypes.default.shape({
|
|
488
535
|
axis: _propTypes.default.oneOf(['x']),
|
|
489
536
|
classes: _propTypes.default.object,
|
|
@@ -866,6 +913,52 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
866
913
|
tickSize: _propTypes.default.number,
|
|
867
914
|
valueFormatter: _propTypes.default.func,
|
|
868
915
|
width: _propTypes.default.number
|
|
916
|
+
}), _propTypes.default.shape({
|
|
917
|
+
axis: _propTypes.default.oneOf(['y']),
|
|
918
|
+
classes: _propTypes.default.object,
|
|
919
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
920
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
921
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
922
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
923
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
924
|
+
}), _propTypes.default.shape({
|
|
925
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
926
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
927
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
928
|
+
})]),
|
|
929
|
+
constant: _propTypes.default.number,
|
|
930
|
+
data: _propTypes.default.array,
|
|
931
|
+
dataKey: _propTypes.default.string,
|
|
932
|
+
disableLine: _propTypes.default.bool,
|
|
933
|
+
disableTicks: _propTypes.default.bool,
|
|
934
|
+
domainLimit: _propTypes.default.oneOfType([_propTypes.default.oneOf(['nice', 'strict']), _propTypes.default.func]),
|
|
935
|
+
fill: _propTypes.default.string,
|
|
936
|
+
hideTooltip: _propTypes.default.bool,
|
|
937
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
938
|
+
ignoreTooltip: _propTypes.default.bool,
|
|
939
|
+
label: _propTypes.default.string,
|
|
940
|
+
labelStyle: _propTypes.default.object,
|
|
941
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
942
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
943
|
+
offset: _propTypes.default.number,
|
|
944
|
+
position: _propTypes.default.oneOf(['left', 'none', 'right']),
|
|
945
|
+
reverse: _propTypes.default.bool,
|
|
946
|
+
scaleType: _propTypes.default.oneOf(['symlog']),
|
|
947
|
+
slotProps: _propTypes.default.object,
|
|
948
|
+
slots: _propTypes.default.object,
|
|
949
|
+
stroke: _propTypes.default.string,
|
|
950
|
+
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
951
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
952
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
953
|
+
tickLabelPlacement: _propTypes.default.oneOf(['middle', 'tick']),
|
|
954
|
+
tickLabelStyle: _propTypes.default.object,
|
|
955
|
+
tickMaxStep: _propTypes.default.number,
|
|
956
|
+
tickMinStep: _propTypes.default.number,
|
|
957
|
+
tickNumber: _propTypes.default.number,
|
|
958
|
+
tickPlacement: _propTypes.default.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
959
|
+
tickSize: _propTypes.default.number,
|
|
960
|
+
valueFormatter: _propTypes.default.func,
|
|
961
|
+
width: _propTypes.default.number
|
|
869
962
|
}), _propTypes.default.shape({
|
|
870
963
|
axis: _propTypes.default.oneOf(['y']),
|
|
871
964
|
classes: _propTypes.default.object,
|
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -16,7 +16,7 @@ import { useBarChartProps } from "./useBarChartProps.js";
|
|
|
16
16
|
import { ChartDataProvider } from "../ChartDataProvider/index.js";
|
|
17
17
|
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
18
18
|
import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
|
|
19
|
-
import { ChartsWrapper } from "../
|
|
19
|
+
import { ChartsWrapper } from "../ChartsWrapper/index.js";
|
|
20
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
21
|
/**
|
|
22
22
|
* Demos:
|
|
@@ -388,6 +388,53 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
388
388
|
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
389
389
|
tickSize: PropTypes.number,
|
|
390
390
|
valueFormatter: PropTypes.func
|
|
391
|
+
}), PropTypes.shape({
|
|
392
|
+
axis: PropTypes.oneOf(['x']),
|
|
393
|
+
classes: PropTypes.object,
|
|
394
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
395
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
396
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
397
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
398
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
399
|
+
}), PropTypes.shape({
|
|
400
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
401
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
402
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
403
|
+
})]),
|
|
404
|
+
constant: PropTypes.number,
|
|
405
|
+
data: PropTypes.array,
|
|
406
|
+
dataKey: PropTypes.string,
|
|
407
|
+
disableLine: PropTypes.bool,
|
|
408
|
+
disableTicks: PropTypes.bool,
|
|
409
|
+
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
410
|
+
fill: PropTypes.string,
|
|
411
|
+
height: PropTypes.number,
|
|
412
|
+
hideTooltip: PropTypes.bool,
|
|
413
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
414
|
+
ignoreTooltip: PropTypes.bool,
|
|
415
|
+
label: PropTypes.string,
|
|
416
|
+
labelStyle: PropTypes.object,
|
|
417
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
418
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
419
|
+
offset: PropTypes.number,
|
|
420
|
+
position: PropTypes.oneOf(['bottom', 'none', 'top']),
|
|
421
|
+
reverse: PropTypes.bool,
|
|
422
|
+
scaleType: PropTypes.oneOf(['symlog']),
|
|
423
|
+
slotProps: PropTypes.object,
|
|
424
|
+
slots: PropTypes.object,
|
|
425
|
+
stroke: PropTypes.string,
|
|
426
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
427
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
428
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
429
|
+
tickLabelMinGap: PropTypes.number,
|
|
430
|
+
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
431
|
+
tickLabelStyle: PropTypes.object,
|
|
432
|
+
tickMaxStep: PropTypes.number,
|
|
433
|
+
tickMinStep: PropTypes.number,
|
|
434
|
+
tickNumber: PropTypes.number,
|
|
435
|
+
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
436
|
+
tickSize: PropTypes.number,
|
|
437
|
+
valueFormatter: PropTypes.func
|
|
391
438
|
}), PropTypes.shape({
|
|
392
439
|
axis: PropTypes.oneOf(['x']),
|
|
393
440
|
classes: PropTypes.object,
|
|
@@ -771,6 +818,52 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
771
818
|
tickSize: PropTypes.number,
|
|
772
819
|
valueFormatter: PropTypes.func,
|
|
773
820
|
width: PropTypes.number
|
|
821
|
+
}), PropTypes.shape({
|
|
822
|
+
axis: PropTypes.oneOf(['y']),
|
|
823
|
+
classes: PropTypes.object,
|
|
824
|
+
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
825
|
+
color: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string.isRequired), PropTypes.func]).isRequired,
|
|
826
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
827
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
828
|
+
type: PropTypes.oneOf(['continuous']).isRequired
|
|
829
|
+
}), PropTypes.shape({
|
|
830
|
+
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
831
|
+
thresholds: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired).isRequired,
|
|
832
|
+
type: PropTypes.oneOf(['piecewise']).isRequired
|
|
833
|
+
})]),
|
|
834
|
+
constant: PropTypes.number,
|
|
835
|
+
data: PropTypes.array,
|
|
836
|
+
dataKey: PropTypes.string,
|
|
837
|
+
disableLine: PropTypes.bool,
|
|
838
|
+
disableTicks: PropTypes.bool,
|
|
839
|
+
domainLimit: PropTypes.oneOfType([PropTypes.oneOf(['nice', 'strict']), PropTypes.func]),
|
|
840
|
+
fill: PropTypes.string,
|
|
841
|
+
hideTooltip: PropTypes.bool,
|
|
842
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
843
|
+
ignoreTooltip: PropTypes.bool,
|
|
844
|
+
label: PropTypes.string,
|
|
845
|
+
labelStyle: PropTypes.object,
|
|
846
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
847
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
848
|
+
offset: PropTypes.number,
|
|
849
|
+
position: PropTypes.oneOf(['left', 'none', 'right']),
|
|
850
|
+
reverse: PropTypes.bool,
|
|
851
|
+
scaleType: PropTypes.oneOf(['symlog']),
|
|
852
|
+
slotProps: PropTypes.object,
|
|
853
|
+
slots: PropTypes.object,
|
|
854
|
+
stroke: PropTypes.string,
|
|
855
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
856
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
857
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
858
|
+
tickLabelPlacement: PropTypes.oneOf(['middle', 'tick']),
|
|
859
|
+
tickLabelStyle: PropTypes.object,
|
|
860
|
+
tickMaxStep: PropTypes.number,
|
|
861
|
+
tickMinStep: PropTypes.number,
|
|
862
|
+
tickNumber: PropTypes.number,
|
|
863
|
+
tickPlacement: PropTypes.oneOf(['end', 'extremities', 'middle', 'start']),
|
|
864
|
+
tickSize: PropTypes.number,
|
|
865
|
+
valueFormatter: PropTypes.func,
|
|
866
|
+
width: PropTypes.number
|
|
774
867
|
}), PropTypes.shape({
|
|
775
868
|
axis: PropTypes.oneOf(['y']),
|
|
776
869
|
classes: PropTypes.object,
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
interface UseAnimateBarClipPathParams {
|
|
3
|
+
ref?: React.Ref<SVGPathElement>;
|
|
4
|
+
layout: 'vertical' | 'horizontal';
|
|
5
|
+
hasNegative: boolean;
|
|
6
|
+
hasPositive: boolean;
|
|
7
|
+
xOrigin: number;
|
|
8
|
+
yOrigin: number;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
5
13
|
borderRadius: number;
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
type UseAnimateBarClipRectReturn = {
|
|
9
|
-
ref: React.Ref<SVGRectElement>;
|
|
10
|
-
style: React.CSSProperties;
|
|
11
|
-
} & Pick<BarClipRectProps, 'x' | 'y' | 'width' | 'height'>;
|
|
12
|
-
export declare function useAnimateBarClipRect(props: UseAnimateBarClipRectParams): UseAnimateBarClipRectReturn;
|
|
13
|
-
interface BarClipRectProps extends Pick<BarClipPathProps, 'x' | 'y' | 'width' | 'height' | 'skipAnimation'> {
|
|
14
|
-
ownerState: GetRadiusData;
|
|
14
|
+
skipAnimation: boolean;
|
|
15
15
|
}
|
|
16
|
+
export declare function useAnimateBarClipPath(props: UseAnimateBarClipPathParams): import("../index.js").UseAnimateReturn<SVGPathElement, {
|
|
17
|
+
d: string | undefined;
|
|
18
|
+
}>;
|
|
16
19
|
export interface BarClipPathProps {
|
|
17
20
|
maskId: string;
|
|
18
21
|
borderRadius?: number;
|
|
@@ -21,6 +24,8 @@ export interface BarClipPathProps {
|
|
|
21
24
|
layout?: 'vertical' | 'horizontal';
|
|
22
25
|
x: number;
|
|
23
26
|
y: number;
|
|
27
|
+
xOrigin: number;
|
|
28
|
+
yOrigin: number;
|
|
24
29
|
width: number;
|
|
25
30
|
height: number;
|
|
26
31
|
skipAnimation: boolean;
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
-
const _excluded = ["maskId", "x", "y", "width", "height", "skipAnimation"];
|
|
6
3
|
import * as React from 'react';
|
|
7
4
|
import { interpolateNumber } from '@mui/x-charts-vendor/d3-interpolate';
|
|
8
5
|
import { useAnimate } from "../hooks/animation/index.js";
|
|
9
|
-
import { getRadius } from "./getRadius.js";
|
|
10
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
function
|
|
12
|
-
const radiusData = _extends({}, ownerState, {
|
|
13
|
-
borderRadius
|
|
14
|
-
});
|
|
15
|
-
const topLeft = Math.min(size, getRadius('top-left', radiusData));
|
|
16
|
-
const topRight = Math.min(size, getRadius('top-right', radiusData));
|
|
17
|
-
const bottomRight = Math.min(size, getRadius('bottom-right', radiusData));
|
|
18
|
-
const bottomLeft = Math.min(size, getRadius('bottom-left', radiusData));
|
|
19
|
-
return `inset(0px round ${topLeft}px ${topRight}px ${bottomRight}px ${bottomLeft}px)`;
|
|
20
|
-
}
|
|
21
|
-
function barClipRectPropsInterpolator(from, to) {
|
|
7
|
+
function barClipPathPropsInterpolator(from, to) {
|
|
22
8
|
const interpolateX = interpolateNumber(from.x, to.x);
|
|
23
9
|
const interpolateY = interpolateNumber(from.y, to.y);
|
|
24
10
|
const interpolateWidth = interpolateNumber(from.width, to.width);
|
|
@@ -34,12 +20,12 @@ function barClipRectPropsInterpolator(from, to) {
|
|
|
34
20
|
};
|
|
35
21
|
};
|
|
36
22
|
}
|
|
37
|
-
export function
|
|
23
|
+
export function useAnimateBarClipPath(props) {
|
|
38
24
|
const initialProps = {
|
|
39
|
-
x: props.x,
|
|
40
|
-
y: props.
|
|
41
|
-
width: props.
|
|
42
|
-
height: props.
|
|
25
|
+
x: props.layout === 'vertical' ? props.x : props.xOrigin,
|
|
26
|
+
y: props.layout === 'vertical' ? props.yOrigin : props.y,
|
|
27
|
+
width: props.layout === 'vertical' ? props.width : 0,
|
|
28
|
+
height: props.layout === 'vertical' ? 0 : props.height,
|
|
43
29
|
borderRadius: props.borderRadius
|
|
44
30
|
};
|
|
45
31
|
return useAnimate({
|
|
@@ -49,60 +35,88 @@ export function useAnimateBarClipRect(props) {
|
|
|
49
35
|
height: props.height,
|
|
50
36
|
borderRadius: props.borderRadius
|
|
51
37
|
}, {
|
|
52
|
-
createInterpolator:
|
|
38
|
+
createInterpolator: barClipPathPropsInterpolator,
|
|
53
39
|
transformProps: p => ({
|
|
54
|
-
|
|
55
|
-
y: p.y,
|
|
56
|
-
width: p.width,
|
|
57
|
-
height: p.height,
|
|
58
|
-
style: {
|
|
59
|
-
clipPath: buildClipPath(props.ownerState.layout === 'vertical' ? p.height : p.width, p.borderRadius, props.ownerState)
|
|
60
|
-
}
|
|
40
|
+
d: generateClipPath(props.hasNegative, props.hasPositive, props.layout, p.x, p.y, p.width, p.height, props.xOrigin, props.yOrigin, p.borderRadius)
|
|
61
41
|
}),
|
|
62
|
-
applyProps(element,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
42
|
+
applyProps(element, {
|
|
43
|
+
d
|
|
44
|
+
}) {
|
|
45
|
+
if (d) {
|
|
46
|
+
element.setAttribute('d', d);
|
|
47
|
+
}
|
|
68
48
|
},
|
|
69
49
|
initialProps,
|
|
70
50
|
skip: props.skipAnimation,
|
|
71
51
|
ref: props.ref
|
|
72
52
|
});
|
|
73
53
|
}
|
|
74
|
-
function BarClipRect(props) {
|
|
75
|
-
const animatedProps = useAnimateBarClipRect(_extends({}, props, {
|
|
76
|
-
borderRadius: props.ownerState.borderRadius ?? 0
|
|
77
|
-
}));
|
|
78
|
-
return /*#__PURE__*/_jsx("rect", _extends({}, animatedProps));
|
|
79
|
-
}
|
|
80
54
|
/**
|
|
81
55
|
* @ignore - internal component.
|
|
82
56
|
*/
|
|
83
57
|
function BarClipPath(props) {
|
|
84
58
|
const {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
59
|
+
maskId,
|
|
60
|
+
x,
|
|
61
|
+
y,
|
|
62
|
+
width,
|
|
63
|
+
height,
|
|
64
|
+
skipAnimation
|
|
65
|
+
} = props;
|
|
66
|
+
const {
|
|
67
|
+
ref,
|
|
68
|
+
d
|
|
69
|
+
} = useAnimateBarClipPath({
|
|
70
|
+
layout: props.layout ?? 'vertical',
|
|
71
|
+
hasNegative: props.hasNegative,
|
|
72
|
+
hasPositive: props.hasPositive,
|
|
73
|
+
xOrigin: props.xOrigin,
|
|
74
|
+
yOrigin: props.yOrigin,
|
|
75
|
+
x,
|
|
76
|
+
y,
|
|
77
|
+
width,
|
|
78
|
+
height,
|
|
79
|
+
borderRadius: props.borderRadius ?? 0,
|
|
80
|
+
skipAnimation
|
|
81
|
+
});
|
|
93
82
|
if (!props.borderRadius || props.borderRadius <= 0) {
|
|
94
83
|
return null;
|
|
95
84
|
}
|
|
96
85
|
return /*#__PURE__*/_jsx("clipPath", {
|
|
97
86
|
id: maskId,
|
|
98
|
-
children: /*#__PURE__*/_jsx(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
y: y,
|
|
102
|
-
width: width,
|
|
103
|
-
height: height,
|
|
104
|
-
skipAnimation: skipAnimation
|
|
87
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
88
|
+
ref: ref,
|
|
89
|
+
d: d
|
|
105
90
|
})
|
|
106
91
|
});
|
|
107
92
|
}
|
|
93
|
+
function generateClipPath(hasNegative, hasPositive, layout, x, y, width, height, xOrigin, yOrigin, borderRadius) {
|
|
94
|
+
if (layout === 'vertical') {
|
|
95
|
+
if (hasPositive && hasNegative) {
|
|
96
|
+
const bR = Math.min(borderRadius, width / 2, height / 2);
|
|
97
|
+
return `M${x},${y + height / 2} v${-(height / 2 - bR)} a${bR},${bR} 0 0 1 ${bR},${-bR} h${width - bR * 2} a${bR},${bR} 0 0 1 ${bR},${bR} v${height - 2 * bR} a${bR},${bR} 0 0 1 ${-bR},${bR} h${-(width - bR * 2)} a${bR},${bR} 0 0 1 ${-bR},${-bR} v${-(height / 2 - bR)}`;
|
|
98
|
+
}
|
|
99
|
+
const bR = Math.min(borderRadius, width / 2);
|
|
100
|
+
if (hasPositive) {
|
|
101
|
+
return `M${x},${Math.max(yOrigin, y + bR)} v${Math.min(0, -(yOrigin - y - bR))} a${bR},${bR} 0 0 1 ${bR},${-bR} h${width - bR * 2} a${bR},${bR} 0 0 1 ${bR},${bR} v${Math.max(0, yOrigin - y - bR)} Z`;
|
|
102
|
+
}
|
|
103
|
+
if (hasNegative) {
|
|
104
|
+
return `M${x},${Math.min(yOrigin, y + height - bR)} v${Math.max(0, height - bR)} a${bR},${bR} 0 0 0 ${bR},${bR} h${width - bR * 2} a${bR},${bR} 0 0 0 ${bR},${-bR} v${-Math.max(0, height - bR)} Z`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (layout === 'horizontal') {
|
|
108
|
+
if (hasPositive && hasNegative) {
|
|
109
|
+
const bR = Math.min(borderRadius, width / 2, height / 2);
|
|
110
|
+
return `M${x + width / 2},${y} h${width / 2 - bR} a${bR},${bR} 0 0 1 ${bR},${bR} v${height - bR * 2} a${bR},${bR} 0 0 1 ${-bR},${bR} h${-(width - 2 * bR)} a${bR},${bR} 0 0 1 ${-bR},${-bR} v${-(height - bR * 2)} a${bR},${bR} 0 0 1 ${bR},${-bR} h${width / 2 - bR}`;
|
|
111
|
+
}
|
|
112
|
+
const bR = Math.min(borderRadius, height / 2);
|
|
113
|
+
if (hasPositive) {
|
|
114
|
+
return `M${Math.min(xOrigin, x - bR)},${y} h${width} a${bR},${bR} 0 0 1 ${bR},${bR} v${height - bR * 2} a${bR},${bR} 0 0 1 ${-bR},${bR} h${-width} Z`;
|
|
115
|
+
}
|
|
116
|
+
if (hasNegative) {
|
|
117
|
+
return `M${Math.max(xOrigin, x + width + bR)},${y} h${-width} a${bR},${bR} 0 0 0 ${-bR},${bR} v${height - bR * 2} a${bR},${bR} 0 0 0 ${bR},${bR} h${width} Z`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
108
122
|
export { BarClipPath };
|
package/esm/BarChart/BarPlot.js
CHANGED
|
@@ -64,6 +64,8 @@ function BarPlot(props) {
|
|
|
64
64
|
id,
|
|
65
65
|
x,
|
|
66
66
|
y,
|
|
67
|
+
xOrigin,
|
|
68
|
+
yOrigin,
|
|
67
69
|
width,
|
|
68
70
|
height,
|
|
69
71
|
hasPositive,
|
|
@@ -78,6 +80,8 @@ function BarPlot(props) {
|
|
|
78
80
|
layout: layout,
|
|
79
81
|
x: x,
|
|
80
82
|
y: y,
|
|
83
|
+
xOrigin: xOrigin,
|
|
84
|
+
yOrigin: yOrigin,
|
|
81
85
|
width: width,
|
|
82
86
|
height: height,
|
|
83
87
|
skipAnimation: skipAnimation ?? false
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findMinMax } from "../../internals/findMinMax.js";
|
|
1
2
|
const createResult = (data, direction) => {
|
|
2
3
|
if (direction === 'x') {
|
|
3
4
|
return {
|
|
@@ -24,9 +25,7 @@ const getBaseExtremum = params => {
|
|
|
24
25
|
x: null,
|
|
25
26
|
y: null
|
|
26
27
|
}, i)) : axis.data;
|
|
27
|
-
|
|
28
|
-
const maxX = Math.max(...(data ?? []));
|
|
29
|
-
return [minX, maxX];
|
|
28
|
+
return findMinMax(data ?? []);
|
|
30
29
|
};
|
|
31
30
|
const getValueExtremum = direction => params => {
|
|
32
31
|
const {
|
|
@@ -8,7 +8,7 @@ import { ChartsOverlayProps } from "../ChartsOverlay/index.js";
|
|
|
8
8
|
import { ChartsAxisProps } from "../ChartsAxis/index.js";
|
|
9
9
|
import { ChartsAxisHighlightProps } from "../ChartsAxisHighlight/index.js";
|
|
10
10
|
import { ChartsLegendSlotExtension } from "../ChartsLegend/index.js";
|
|
11
|
-
import type { ChartsWrapperProps } from "../
|
|
11
|
+
import type { ChartsWrapperProps } from "../ChartsWrapper/index.js";
|
|
12
12
|
import { BarChartPluginsSignatures } from "./BarChart.plugins.js";
|
|
13
13
|
/**
|
|
14
14
|
* A helper function that extracts BarChartProps from the input props
|