@mui/x-charts 7.0.0-alpha.9 → 7.0.0-beta.1
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 +2 -1
- package/BarChart/BarChart.js +24 -23
- package/BarChart/BarElement.d.ts +1 -1
- package/BarChart/BarElement.js +6 -3
- package/BarChart/BarPlot.d.ts +8 -1
- package/BarChart/BarPlot.js +19 -5
- package/BarChart/formatter.js +1 -1
- package/CHANGELOG.md +386 -38
- package/ChartContainer/ChartContainer.d.ts +12 -0
- package/ChartContainer/ChartContainer.js +197 -0
- package/ChartContainer/index.d.ts +1 -11
- package/ChartContainer/index.js +9 -63
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.d.ts +20 -0
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +83 -0
- package/ChartsOnAxisClickHandler/index.d.ts +1 -0
- package/ChartsOnAxisClickHandler/index.js +16 -0
- package/ChartsOnAxisClickHandler/package.json +6 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +8 -59
- package/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -58
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
- package/ChartsTooltip/utils.d.ts +3 -1
- package/ChartsTooltip/utils.js +8 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +7 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/LineChart/AnimatedArea.d.ts +1361 -0
- package/LineChart/AnimatedArea.js +111 -0
- package/LineChart/AnimatedLine.d.ts +1361 -0
- package/LineChart/AnimatedLine.js +113 -0
- package/LineChart/AreaElement.d.ts +17 -17
- package/LineChart/AreaElement.js +17 -34
- package/LineChart/AreaPlot.d.ts +12 -7
- package/LineChart/AreaPlot.js +91 -58
- package/LineChart/LineChart.d.ts +13 -4
- package/LineChart/LineChart.js +36 -29
- package/LineChart/LineElement.d.ts +17 -17
- package/LineChart/LineElement.js +16 -36
- package/LineChart/LineHighlightElement.js +3 -2
- package/LineChart/LinePlot.d.ts +12 -7
- package/LineChart/LinePlot.js +89 -56
- package/LineChart/MarkElement.d.ts +5 -2
- package/LineChart/MarkElement.js +26 -13
- package/LineChart/MarkPlot.d.ts +8 -1
- package/LineChart/MarkPlot.js +80 -51
- package/LineChart/formatter.js +1 -1
- package/LineChart/index.d.ts +2 -0
- package/LineChart/index.js +22 -0
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +1 -1
- package/PieChart/PieArcPlot.d.ts +2 -2
- package/PieChart/PieArcPlot.js +6 -6
- package/PieChart/PieChart.d.ts +1 -1
- package/PieChart/PieChart.js +5 -50
- package/PieChart/PiePlot.d.ts +1 -1
- package/PieChart/PiePlot.js +4 -4
- package/README.md +2 -2
- package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +16 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +250 -0
- package/ResponsiveChartContainer/index.d.ts +1 -15
- package/ResponsiveChartContainer/index.js +8 -113
- package/ScatterChart/Scatter.d.ts +7 -1
- package/ScatterChart/Scatter.js +18 -23
- package/ScatterChart/ScatterChart.d.ts +8 -2
- package/ScatterChart/ScatterChart.js +12 -22
- package/ScatterChart/ScatterPlot.d.ts +1 -1
- package/ScatterChart/ScatterPlot.js +10 -2
- package/SparkLineChart/SparkLineChart.js +2 -0
- package/context/DrawingProvider.d.ts +6 -1
- package/context/DrawingProvider.js +9 -2
- package/context/InteractionProvider.d.ts +3 -3
- package/esm/BarChart/BarChart.js +24 -23
- package/esm/BarChart/BarElement.js +6 -3
- package/esm/BarChart/BarPlot.js +19 -5
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/ChartContainer.js +189 -0
- package/esm/ChartContainer/index.js +1 -61
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +77 -0
- package/esm/ChartsOnAxisClickHandler/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +8 -59
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +9 -58
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
- package/esm/ChartsTooltip/utils.js +6 -0
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/esm/LineChart/AnimatedArea.js +103 -0
- package/esm/LineChart/AnimatedLine.js +105 -0
- package/esm/LineChart/AreaElement.js +16 -33
- package/esm/LineChart/AreaPlot.js +92 -59
- package/esm/LineChart/LineChart.js +36 -29
- package/esm/LineChart/LineElement.js +16 -35
- package/esm/LineChart/LineHighlightElement.js +3 -2
- package/esm/LineChart/LinePlot.js +90 -57
- package/esm/LineChart/MarkElement.js +26 -13
- package/esm/LineChart/MarkPlot.js +80 -51
- package/esm/LineChart/formatter.js +1 -1
- package/esm/LineChart/index.js +2 -0
- package/esm/PieChart/PieArcLabelPlot.js +1 -1
- package/esm/PieChart/PieArcPlot.js +6 -6
- package/esm/PieChart/PieChart.js +5 -50
- package/esm/PieChart/PiePlot.js +4 -4
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +245 -0
- package/esm/ResponsiveChartContainer/index.js +1 -115
- package/esm/ScatterChart/Scatter.js +18 -23
- package/esm/ScatterChart/ScatterChart.js +12 -22
- package/esm/ScatterChart/ScatterPlot.js +10 -2
- package/esm/SparkLineChart/SparkLineChart.js +2 -0
- package/esm/context/DrawingProvider.js +9 -2
- package/esm/hooks/useDrawingArea.js +7 -3
- package/esm/index.js +1 -0
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/useAnimatedPath.js +29 -0
- package/esm/internals/utils.js +7 -0
- package/hooks/useDrawingArea.d.ts +2 -0
- package/hooks/useDrawingArea.js +7 -3
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/geometry.js +1 -1
- package/internals/useAnimatedPath.d.ts +1 -0
- package/internals/useAnimatedPath.js +38 -0
- package/internals/utils.d.ts +4 -0
- package/internals/utils.js +8 -0
- package/legacy/BarChart/BarChart.js +24 -23
- package/legacy/BarChart/BarElement.js +5 -2
- package/legacy/BarChart/BarPlot.js +18 -4
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/ChartContainer.js +187 -0
- package/legacy/ChartContainer/index.js +1 -59
- package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/legacy/ChartsOnAxisClickHandler/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +8 -61
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +9 -58
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
- package/legacy/ChartsTooltip/utils.js +6 -0
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +88 -44
- package/legacy/LineChart/AnimatedArea.js +102 -0
- package/legacy/LineChart/AnimatedLine.js +104 -0
- package/legacy/LineChart/AreaElement.js +15 -35
- package/legacy/LineChart/AreaPlot.js +102 -66
- package/legacy/LineChart/LineChart.js +36 -29
- package/legacy/LineChart/LineElement.js +15 -37
- package/legacy/LineChart/LineHighlightElement.js +3 -2
- package/legacy/LineChart/LinePlot.js +97 -63
- package/legacy/LineChart/MarkElement.js +29 -12
- package/legacy/LineChart/MarkPlot.js +83 -53
- package/legacy/LineChart/formatter.js +1 -1
- package/legacy/LineChart/index.js +2 -0
- package/legacy/PieChart/PieArcLabelPlot.js +1 -1
- package/legacy/PieChart/PieArcPlot.js +6 -6
- package/legacy/PieChart/PieChart.js +5 -50
- package/legacy/PieChart/PiePlot.js +4 -4
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +253 -0
- package/legacy/ResponsiveChartContainer/index.js +1 -123
- package/legacy/ScatterChart/Scatter.js +20 -23
- package/legacy/ScatterChart/ScatterChart.js +12 -22
- package/legacy/ScatterChart/ScatterPlot.js +10 -2
- package/legacy/SparkLineChart/SparkLineChart.js +2 -0
- package/legacy/context/DrawingProvider.js +11 -2
- package/legacy/hooks/useDrawingArea.js +7 -3
- package/legacy/index.js +2 -1
- package/legacy/internals/geometry.js +1 -1
- package/legacy/internals/useAnimatedPath.js +32 -0
- package/legacy/internals/utils.js +7 -0
- package/modern/BarChart/BarChart.js +24 -23
- package/modern/BarChart/BarElement.js +6 -3
- package/modern/BarChart/BarPlot.js +19 -5
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/ChartContainer.js +189 -0
- package/modern/ChartContainer/index.js +1 -61
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/modern/ChartsOnAxisClickHandler/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +8 -59
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -58
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
- package/modern/ChartsTooltip/utils.js +6 -0
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/modern/LineChart/AnimatedArea.js +103 -0
- package/modern/LineChart/AnimatedLine.js +105 -0
- package/modern/LineChart/AreaElement.js +16 -33
- package/modern/LineChart/AreaPlot.js +91 -58
- package/modern/LineChart/LineChart.js +36 -29
- package/modern/LineChart/LineElement.js +16 -35
- package/modern/LineChart/LineHighlightElement.js +3 -2
- package/modern/LineChart/LinePlot.js +89 -56
- package/modern/LineChart/MarkElement.js +26 -13
- package/modern/LineChart/MarkPlot.js +80 -51
- package/modern/LineChart/formatter.js +1 -1
- package/modern/LineChart/index.js +2 -0
- package/modern/PieChart/PieArcLabelPlot.js +1 -1
- package/modern/PieChart/PieArcPlot.js +6 -6
- package/modern/PieChart/PieChart.js +5 -50
- package/modern/PieChart/PiePlot.js +4 -4
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +242 -0
- package/modern/ResponsiveChartContainer/index.js +1 -112
- package/modern/ScatterChart/Scatter.js +18 -23
- package/modern/ScatterChart/ScatterChart.js +12 -22
- package/modern/ScatterChart/ScatterPlot.js +10 -2
- package/modern/SparkLineChart/SparkLineChart.js +2 -0
- package/modern/context/DrawingProvider.js +9 -2
- package/modern/hooks/useDrawingArea.js +7 -3
- package/modern/index.js +2 -1
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/useAnimatedPath.js +29 -0
- package/modern/internals/utils.js +7 -0
- package/package.json +6 -5
|
@@ -5,6 +5,7 @@ import { useSlotProps } from '@mui/base/utils';
|
|
|
5
5
|
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
6
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
7
|
import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
|
|
8
|
+
import { isCartesianSeriesType } from './utils';
|
|
8
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
10
|
function ChartsAxisTooltipContent(props) {
|
|
10
11
|
var content = props.content,
|
|
@@ -24,9 +25,7 @@ function ChartsAxisTooltipContent(props) {
|
|
|
24
25
|
var USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
|
|
25
26
|
var relevantSeries = React.useMemo(function () {
|
|
26
27
|
var rep = [];
|
|
27
|
-
Object.keys(series).filter(function (seriesType) {
|
|
28
|
-
return ['bar', 'line', 'scatter'].includes(seriesType);
|
|
29
|
-
}).forEach(function (seriesType) {
|
|
28
|
+
Object.keys(series).filter(isCartesianSeriesType).forEach(function (seriesType) {
|
|
30
29
|
series[seriesType].seriesOrder.forEach(function (seriesId) {
|
|
31
30
|
var item = series[seriesType].series[seriesId];
|
|
32
31
|
var axisKey = isXaxis ? item.xAxisKey : item.yAxisKey;
|
|
@@ -65,83 +64,31 @@ process.env.NODE_ENV !== "production" ? ChartsAxisTooltipContent.propTypes = {
|
|
|
65
64
|
axisData: PropTypes.shape({
|
|
66
65
|
x: PropTypes.shape({
|
|
67
66
|
index: PropTypes.number,
|
|
68
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
67
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
69
68
|
}),
|
|
70
69
|
y: PropTypes.shape({
|
|
71
70
|
index: PropTypes.number,
|
|
72
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
71
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
73
72
|
})
|
|
74
73
|
}).isRequired,
|
|
75
74
|
classes: PropTypes.object.isRequired,
|
|
76
75
|
content: PropTypes.elementType,
|
|
77
76
|
contentProps: PropTypes.shape({
|
|
78
|
-
axis: PropTypes.
|
|
79
|
-
axisId: PropTypes.string,
|
|
80
|
-
classes: PropTypes.object,
|
|
81
|
-
data: PropTypes.array,
|
|
82
|
-
dataKey: PropTypes.string,
|
|
83
|
-
disableLine: PropTypes.bool,
|
|
84
|
-
disableTicks: PropTypes.bool,
|
|
85
|
-
fill: PropTypes.string,
|
|
86
|
-
hideTooltip: PropTypes.bool,
|
|
87
|
-
id: PropTypes.string.isRequired,
|
|
88
|
-
label: PropTypes.string,
|
|
89
|
-
labelFontSize: PropTypes.number,
|
|
90
|
-
labelStyle: PropTypes.object,
|
|
91
|
-
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
92
|
-
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
93
|
-
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
94
|
-
scale: PropTypes.func.isRequired,
|
|
95
|
-
scaleType: PropTypes.oneOf(['time']).isRequired,
|
|
96
|
-
slotProps: PropTypes.object,
|
|
97
|
-
slots: PropTypes.object,
|
|
98
|
-
stroke: PropTypes.string,
|
|
99
|
-
tickFontSize: PropTypes.number,
|
|
100
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
101
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
102
|
-
tickLabelStyle: PropTypes.object,
|
|
103
|
-
tickMaxStep: PropTypes.number,
|
|
104
|
-
tickMinStep: PropTypes.number,
|
|
105
|
-
tickNumber: PropTypes.number.isRequired,
|
|
106
|
-
tickSize: PropTypes.number,
|
|
107
|
-
valueFormatter: PropTypes.func
|
|
108
|
-
}),
|
|
77
|
+
axis: PropTypes.object,
|
|
109
78
|
axisData: PropTypes.shape({
|
|
110
79
|
x: PropTypes.shape({
|
|
111
80
|
index: PropTypes.number,
|
|
112
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
81
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
113
82
|
}),
|
|
114
83
|
y: PropTypes.shape({
|
|
115
84
|
index: PropTypes.number,
|
|
116
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
85
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
117
86
|
})
|
|
118
87
|
}),
|
|
119
88
|
axisValue: PropTypes.any,
|
|
120
89
|
classes: PropTypes.object,
|
|
121
90
|
dataIndex: PropTypes.number,
|
|
122
|
-
series: PropTypes.arrayOf(PropTypes.
|
|
123
|
-
area: PropTypes.bool,
|
|
124
|
-
color: PropTypes.string.isRequired,
|
|
125
|
-
connectNulls: PropTypes.bool,
|
|
126
|
-
curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
|
|
127
|
-
data: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
128
|
-
dataKey: PropTypes.string,
|
|
129
|
-
disableHighlight: PropTypes.bool,
|
|
130
|
-
highlightScope: PropTypes.shape({
|
|
131
|
-
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
132
|
-
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
133
|
-
}),
|
|
134
|
-
id: PropTypes.string.isRequired,
|
|
135
|
-
label: PropTypes.string,
|
|
136
|
-
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
137
|
-
stack: PropTypes.string,
|
|
138
|
-
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
|
|
139
|
-
stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
|
|
140
|
-
type: PropTypes.oneOf(['line']).isRequired,
|
|
141
|
-
valueFormatter: PropTypes.func.isRequired,
|
|
142
|
-
xAxisKey: PropTypes.string,
|
|
143
|
-
yAxisKey: PropTypes.string
|
|
144
|
-
})),
|
|
91
|
+
series: PropTypes.arrayOf(PropTypes.object),
|
|
145
92
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
146
93
|
}),
|
|
147
94
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
@@ -40,17 +40,7 @@ process.env.NODE_ENV !== "production" ? ChartsItemTooltipContent.propTypes = {
|
|
|
40
40
|
seriesId: PropTypes.string.isRequired,
|
|
41
41
|
type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired
|
|
42
42
|
}),
|
|
43
|
-
series: PropTypes.
|
|
44
|
-
color: PropTypes.string,
|
|
45
|
-
data: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
46
|
-
highlightScope: PropTypes.shape({
|
|
47
|
-
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
48
|
-
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
49
|
-
}),
|
|
50
|
-
id: PropTypes.string.isRequired,
|
|
51
|
-
type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired,
|
|
52
|
-
valueFormatter: PropTypes.func.isRequired
|
|
53
|
-
}),
|
|
43
|
+
series: PropTypes.object,
|
|
54
44
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
55
45
|
}),
|
|
56
46
|
itemData: PropTypes.shape({
|
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
5
5
|
import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
6
|
+
import { isCartesianSeries } from './utils';
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
9
|
function DefaultChartsAxisTooltipContent(props) {
|
|
@@ -34,13 +35,15 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
34
35
|
})
|
|
35
36
|
})
|
|
36
37
|
}), /*#__PURE__*/_jsx("tbody", {
|
|
37
|
-
children: series.map(function (_ref) {
|
|
38
|
+
children: series.filter(isCartesianSeries).map(function (_ref) {
|
|
39
|
+
var _data$dataIndex;
|
|
38
40
|
var color = _ref.color,
|
|
39
41
|
id = _ref.id,
|
|
40
42
|
label = _ref.label,
|
|
41
43
|
valueFormatter = _ref.valueFormatter,
|
|
42
44
|
data = _ref.data;
|
|
43
|
-
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
var formattedValue = valueFormatter((_data$dataIndex = data[dataIndex]) != null ? _data$dataIndex : null);
|
|
44
47
|
if (formattedValue == null) {
|
|
45
48
|
return null;
|
|
46
49
|
}
|
|
@@ -80,48 +83,18 @@ process.env.NODE_ENV !== "production" ? DefaultChartsAxisTooltipContent.propType
|
|
|
80
83
|
/**
|
|
81
84
|
* The properties of the triggered axis.
|
|
82
85
|
*/
|
|
83
|
-
axis: PropTypes.
|
|
84
|
-
axisId: PropTypes.string,
|
|
85
|
-
classes: PropTypes.object,
|
|
86
|
-
data: PropTypes.array,
|
|
87
|
-
dataKey: PropTypes.string,
|
|
88
|
-
disableLine: PropTypes.bool,
|
|
89
|
-
disableTicks: PropTypes.bool,
|
|
90
|
-
fill: PropTypes.string,
|
|
91
|
-
hideTooltip: PropTypes.bool,
|
|
92
|
-
id: PropTypes.string.isRequired,
|
|
93
|
-
label: PropTypes.string,
|
|
94
|
-
labelFontSize: PropTypes.number,
|
|
95
|
-
labelStyle: PropTypes.object,
|
|
96
|
-
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
97
|
-
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
98
|
-
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
99
|
-
scale: PropTypes.func.isRequired,
|
|
100
|
-
scaleType: PropTypes.oneOf(['time']).isRequired,
|
|
101
|
-
slotProps: PropTypes.object,
|
|
102
|
-
slots: PropTypes.object,
|
|
103
|
-
stroke: PropTypes.string,
|
|
104
|
-
tickFontSize: PropTypes.number,
|
|
105
|
-
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
106
|
-
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
107
|
-
tickLabelStyle: PropTypes.object,
|
|
108
|
-
tickMaxStep: PropTypes.number,
|
|
109
|
-
tickMinStep: PropTypes.number,
|
|
110
|
-
tickNumber: PropTypes.number.isRequired,
|
|
111
|
-
tickSize: PropTypes.number,
|
|
112
|
-
valueFormatter: PropTypes.func
|
|
113
|
-
}).isRequired,
|
|
86
|
+
axis: PropTypes.object.isRequired,
|
|
114
87
|
/**
|
|
115
88
|
* Data identifying the triggered axis.
|
|
116
89
|
*/
|
|
117
90
|
axisData: PropTypes.shape({
|
|
118
91
|
x: PropTypes.shape({
|
|
119
92
|
index: PropTypes.number,
|
|
120
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
93
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
121
94
|
}),
|
|
122
95
|
y: PropTypes.shape({
|
|
123
96
|
index: PropTypes.number,
|
|
124
|
-
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]).isRequired
|
|
97
|
+
value: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
125
98
|
})
|
|
126
99
|
}).isRequired,
|
|
127
100
|
/**
|
|
@@ -139,29 +112,7 @@ process.env.NODE_ENV !== "production" ? DefaultChartsAxisTooltipContent.propType
|
|
|
139
112
|
/**
|
|
140
113
|
* The series linked to the triggered axis.
|
|
141
114
|
*/
|
|
142
|
-
series: PropTypes.arrayOf(PropTypes.
|
|
143
|
-
area: PropTypes.bool,
|
|
144
|
-
color: PropTypes.string.isRequired,
|
|
145
|
-
connectNulls: PropTypes.bool,
|
|
146
|
-
curve: PropTypes.oneOf(['catmullRom', 'linear', 'monotoneX', 'monotoneY', 'natural', 'step', 'stepAfter', 'stepBefore']),
|
|
147
|
-
data: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
148
|
-
dataKey: PropTypes.string,
|
|
149
|
-
disableHighlight: PropTypes.bool,
|
|
150
|
-
highlightScope: PropTypes.shape({
|
|
151
|
-
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
152
|
-
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
153
|
-
}),
|
|
154
|
-
id: PropTypes.string.isRequired,
|
|
155
|
-
label: PropTypes.string,
|
|
156
|
-
showMark: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
157
|
-
stack: PropTypes.string,
|
|
158
|
-
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
|
|
159
|
-
stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
|
|
160
|
-
type: PropTypes.oneOf(['line']).isRequired,
|
|
161
|
-
valueFormatter: PropTypes.func.isRequired,
|
|
162
|
-
xAxisKey: PropTypes.string,
|
|
163
|
-
yAxisKey: PropTypes.string
|
|
164
|
-
})).isRequired,
|
|
115
|
+
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
165
116
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
166
117
|
} : void 0;
|
|
167
118
|
export { DefaultChartsAxisTooltipContent };
|
|
@@ -72,17 +72,7 @@ process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propType
|
|
|
72
72
|
/**
|
|
73
73
|
* The series linked to the triggered axis.
|
|
74
74
|
*/
|
|
75
|
-
series: PropTypes.
|
|
76
|
-
color: PropTypes.string,
|
|
77
|
-
data: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
78
|
-
highlightScope: PropTypes.shape({
|
|
79
|
-
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
80
|
-
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
81
|
-
}),
|
|
82
|
-
id: PropTypes.string.isRequired,
|
|
83
|
-
type: PropTypes.oneOf(['bar', 'line', 'pie', 'scatter']).isRequired,
|
|
84
|
-
valueFormatter: PropTypes.func.isRequired
|
|
85
|
-
}).isRequired,
|
|
75
|
+
series: PropTypes.object.isRequired,
|
|
86
76
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
87
77
|
} : void 0;
|
|
88
78
|
export { DefaultChartsItemTooltipContent };
|
|
@@ -88,4 +88,10 @@ export function getTooltipHasData(trigger, displayedData) {
|
|
|
88
88
|
var hasAxisXData = displayedData.x !== null;
|
|
89
89
|
var hasAxisYData = displayedData.y !== null;
|
|
90
90
|
return hasAxisXData || hasAxisYData;
|
|
91
|
+
}
|
|
92
|
+
export function isCartesianSeriesType(seriesType) {
|
|
93
|
+
return ['bar', 'line', 'scatter'].includes(seriesType);
|
|
94
|
+
}
|
|
95
|
+
export function isCartesianSeries(series) {
|
|
96
|
+
return isCartesianSeriesType(series.type);
|
|
91
97
|
}
|
|
@@ -11,7 +11,8 @@ import { getSVGPoint } from '../internals/utils';
|
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
function ChartsVoronoiHandler(props) {
|
|
13
13
|
var _React$useContext$sca;
|
|
14
|
-
var voronoiMaxRadius = props.voronoiMaxRadius
|
|
14
|
+
var voronoiMaxRadius = props.voronoiMaxRadius,
|
|
15
|
+
onItemClick = props.onItemClick;
|
|
15
16
|
var svgRef = React.useContext(SVGContext);
|
|
16
17
|
var _React$useContext = React.useContext(DrawingContext),
|
|
17
18
|
width = _React$useContext.width,
|
|
@@ -44,6 +45,8 @@ function ChartsVoronoiHandler(props) {
|
|
|
44
45
|
};
|
|
45
46
|
}, [dispatch]);
|
|
46
47
|
useEnhancedEffect(function () {
|
|
48
|
+
// This effect generate and store the Delaunay object that's used to map coordinate to closest point.
|
|
49
|
+
|
|
47
50
|
if (seriesOrder === undefined || series === undefined) {
|
|
48
51
|
// If there is no scatter chart series
|
|
49
52
|
return;
|
|
@@ -77,81 +80,122 @@ function ChartsVoronoiHandler(props) {
|
|
|
77
80
|
if (element === null) {
|
|
78
81
|
return undefined;
|
|
79
82
|
}
|
|
80
|
-
var handleMouseOut = function handleMouseOut() {
|
|
81
|
-
dispatch({
|
|
82
|
-
type: 'exitChart'
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
83
|
|
|
86
84
|
// TODO: A perf optimisation of voronoi could be to use the last point as the intial point for the next search.
|
|
87
|
-
|
|
85
|
+
function getClosestPoint(event) {
|
|
88
86
|
var _voronoiRef$current$d;
|
|
89
87
|
// Get mouse coordinate in global SVG space
|
|
90
88
|
var svgPoint = getSVGPoint(svgRef.current, event);
|
|
91
89
|
var outsideX = svgPoint.x < left || svgPoint.x > left + width;
|
|
92
90
|
var outsideY = svgPoint.y < top || svgPoint.y > top + height;
|
|
93
91
|
if (outsideX || outsideY) {
|
|
94
|
-
|
|
95
|
-
type: 'exitChart'
|
|
96
|
-
});
|
|
97
|
-
return;
|
|
92
|
+
return 'outside-chart';
|
|
98
93
|
}
|
|
99
94
|
if (!voronoiRef.current.delauney) {
|
|
100
|
-
return;
|
|
95
|
+
return 'no-point-found';
|
|
101
96
|
}
|
|
102
97
|
var closestPointIndex = (_voronoiRef$current$d = voronoiRef.current.delauney) == null ? void 0 : _voronoiRef$current$d.find(svgPoint.x, svgPoint.y);
|
|
103
|
-
if (closestPointIndex
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return
|
|
109
|
-
});
|
|
110
|
-
if (seriesId === undefined) {
|
|
111
|
-
return;
|
|
98
|
+
if (closestPointIndex === undefined) {
|
|
99
|
+
return 'no-point-found';
|
|
100
|
+
}
|
|
101
|
+
var seriesId = Object.keys(voronoiRef.current).find(function (id) {
|
|
102
|
+
if (id === 'delauney') {
|
|
103
|
+
return false;
|
|
112
104
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
105
|
+
return 2 * closestPointIndex >= voronoiRef.current[id].startIndex && 2 * closestPointIndex < voronoiRef.current[id].endIndex;
|
|
106
|
+
});
|
|
107
|
+
if (seriesId === undefined) {
|
|
108
|
+
return 'no-point-found';
|
|
109
|
+
}
|
|
110
|
+
var dataIndex = (2 * closestPointIndex - voronoiRef.current[seriesId].startIndex) / 2;
|
|
111
|
+
if (voronoiMaxRadius !== undefined) {
|
|
112
|
+
var pointX = voronoiRef.current.delauney.points[2 * closestPointIndex];
|
|
113
|
+
var pointY = voronoiRef.current.delauney.points[2 * closestPointIndex + 1];
|
|
114
|
+
var dist2 = Math.pow(pointX - svgPoint.x, 2) + Math.pow(pointY - svgPoint.y, 2);
|
|
115
|
+
if (dist2 > Math.pow(voronoiMaxRadius, 2)) {
|
|
116
|
+
// The closest point is too far to be considered.
|
|
117
|
+
return 'outside-voronoi-max-radius';
|
|
130
118
|
}
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
seriesId: seriesId,
|
|
122
|
+
dataIndex: dataIndex
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
var handleMouseOut = function handleMouseOut() {
|
|
126
|
+
dispatch({
|
|
127
|
+
type: 'exitChart'
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
var handleMouseMove = function handleMouseMove(event) {
|
|
131
|
+
var closestPoint = getClosestPoint(event);
|
|
132
|
+
if (closestPoint === 'outside-chart') {
|
|
131
133
|
dispatch({
|
|
132
|
-
type: '
|
|
134
|
+
type: 'exitChart'
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (closestPoint === 'outside-voronoi-max-radius' || closestPoint === 'no-point-found') {
|
|
139
|
+
dispatch({
|
|
140
|
+
type: 'leaveItem',
|
|
133
141
|
data: {
|
|
134
|
-
type: 'scatter'
|
|
135
|
-
seriesId: seriesId,
|
|
136
|
-
dataIndex: dataIndex
|
|
142
|
+
type: 'scatter'
|
|
137
143
|
}
|
|
138
144
|
});
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
var seriesId = closestPoint.seriesId,
|
|
148
|
+
dataIndex = closestPoint.dataIndex;
|
|
149
|
+
dispatch({
|
|
150
|
+
type: 'enterItem',
|
|
151
|
+
data: {
|
|
152
|
+
type: 'scatter',
|
|
153
|
+
seriesId: seriesId,
|
|
154
|
+
dataIndex: dataIndex
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
var handleMouseClick = function handleMouseClick(event) {
|
|
159
|
+
if (!onItemClick) {
|
|
160
|
+
return;
|
|
139
161
|
}
|
|
162
|
+
var closestPoint = getClosestPoint(event);
|
|
163
|
+
if (typeof closestPoint === 'string') {
|
|
164
|
+
// No point fond for any reason
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
var seriesId = closestPoint.seriesId,
|
|
168
|
+
dataIndex = closestPoint.dataIndex;
|
|
169
|
+
onItemClick(event, {
|
|
170
|
+
type: 'scatter',
|
|
171
|
+
seriesId: seriesId,
|
|
172
|
+
dataIndex: dataIndex
|
|
173
|
+
});
|
|
140
174
|
};
|
|
141
175
|
element.addEventListener('mouseout', handleMouseOut);
|
|
142
176
|
element.addEventListener('mousemove', handleMouseMove);
|
|
177
|
+
element.addEventListener('click', handleMouseClick);
|
|
143
178
|
return function () {
|
|
144
179
|
element.removeEventListener('mouseout', handleMouseOut);
|
|
145
180
|
element.removeEventListener('mousemove', handleMouseMove);
|
|
181
|
+
element.removeEventListener('click', handleMouseClick);
|
|
146
182
|
};
|
|
147
|
-
}, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius]);
|
|
148
|
-
|
|
183
|
+
}, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius, onItemClick]);
|
|
184
|
+
|
|
185
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
186
|
+
return /*#__PURE__*/_jsx(React.Fragment, {});
|
|
149
187
|
}
|
|
150
188
|
process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
|
|
151
189
|
// ----------------------------- Warning --------------------------------
|
|
152
190
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
153
191
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
154
192
|
// ----------------------------------------------------------------------
|
|
193
|
+
/**
|
|
194
|
+
* Callback fired when clicking on a scatter item.
|
|
195
|
+
* @param {MouseEvent} event Mouse event catched at the svg level
|
|
196
|
+
* @param {ScatterItemIdentifier} scatterItemIdentifier Identify whihc item got clicked
|
|
197
|
+
*/
|
|
198
|
+
onItemClick: PropTypes.func,
|
|
155
199
|
/**
|
|
156
200
|
* Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
|
|
157
201
|
* If `undefined`, the radius is assumed to be infinite.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["d", "skipAnimation", "ownerState"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
|
+
import { color as d3Color } from 'd3-color';
|
|
8
|
+
import { animated, useSpring } from '@react-spring/web';
|
|
9
|
+
import { useAnimatedPath } from '../internals/useAnimatedPath';
|
|
10
|
+
import { DrawingContext } from '../context/DrawingProvider';
|
|
11
|
+
import { cleanId } from '../internals/utils';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
export var AreaElementPath = styled(animated.path, {
|
|
15
|
+
name: 'MuiAreaElement',
|
|
16
|
+
slot: 'Root',
|
|
17
|
+
overridesResolver: function overridesResolver(_, styles) {
|
|
18
|
+
return styles.root;
|
|
19
|
+
}
|
|
20
|
+
})(function (_ref) {
|
|
21
|
+
var ownerState = _ref.ownerState;
|
|
22
|
+
return {
|
|
23
|
+
stroke: 'none',
|
|
24
|
+
fill: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(1).formatHex() : d3Color(ownerState.color).brighter(0.5).formatHex(),
|
|
25
|
+
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
26
|
+
opacity: ownerState.isFaded ? 0.3 : 1
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Demos:
|
|
31
|
+
*
|
|
32
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
33
|
+
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
34
|
+
*
|
|
35
|
+
* API:
|
|
36
|
+
*
|
|
37
|
+
* - [AreaElement API](https://mui.com/x/api/charts/animated-area/)
|
|
38
|
+
*/
|
|
39
|
+
function AnimatedArea(props) {
|
|
40
|
+
var d = props.d,
|
|
41
|
+
skipAnimation = props.skipAnimation,
|
|
42
|
+
ownerState = props.ownerState,
|
|
43
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
44
|
+
var _React$useContext = React.useContext(DrawingContext),
|
|
45
|
+
left = _React$useContext.left,
|
|
46
|
+
top = _React$useContext.top,
|
|
47
|
+
right = _React$useContext.right,
|
|
48
|
+
bottom = _React$useContext.bottom,
|
|
49
|
+
width = _React$useContext.width,
|
|
50
|
+
height = _React$useContext.height,
|
|
51
|
+
chartId = _React$useContext.chartId;
|
|
52
|
+
var path = useAnimatedPath(d, skipAnimation);
|
|
53
|
+
var _useSpring = useSpring({
|
|
54
|
+
from: {
|
|
55
|
+
animatedWidth: left
|
|
56
|
+
},
|
|
57
|
+
to: {
|
|
58
|
+
animatedWidth: width + left + right
|
|
59
|
+
},
|
|
60
|
+
reset: false,
|
|
61
|
+
immediate: skipAnimation
|
|
62
|
+
}),
|
|
63
|
+
animatedWidth = _useSpring.animatedWidth;
|
|
64
|
+
var clipId = cleanId("".concat(chartId, "-").concat(ownerState.id, "-area-clip"));
|
|
65
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
66
|
+
children: [/*#__PURE__*/_jsx("clipPath", {
|
|
67
|
+
id: clipId,
|
|
68
|
+
children: /*#__PURE__*/_jsx(animated.rect, {
|
|
69
|
+
x: 0,
|
|
70
|
+
y: 0,
|
|
71
|
+
width: animatedWidth,
|
|
72
|
+
height: top + height + bottom
|
|
73
|
+
})
|
|
74
|
+
}), /*#__PURE__*/_jsx("g", {
|
|
75
|
+
clipPath: "url(#".concat(clipId, ")"),
|
|
76
|
+
children: /*#__PURE__*/_jsx(AreaElementPath, _extends({}, other, {
|
|
77
|
+
ownerState: ownerState,
|
|
78
|
+
d: path
|
|
79
|
+
}))
|
|
80
|
+
})]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
process.env.NODE_ENV !== "production" ? AnimatedArea.propTypes = {
|
|
84
|
+
// ----------------------------- Warning --------------------------------
|
|
85
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
86
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
87
|
+
// ----------------------------------------------------------------------
|
|
88
|
+
d: PropTypes.string.isRequired,
|
|
89
|
+
ownerState: PropTypes.shape({
|
|
90
|
+
classes: PropTypes.object,
|
|
91
|
+
color: PropTypes.string.isRequired,
|
|
92
|
+
id: PropTypes.string.isRequired,
|
|
93
|
+
isFaded: PropTypes.bool.isRequired,
|
|
94
|
+
isHighlighted: PropTypes.bool.isRequired
|
|
95
|
+
}).isRequired,
|
|
96
|
+
/**
|
|
97
|
+
* If `true`, animations are skipped.
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
skipAnimation: PropTypes.bool
|
|
101
|
+
} : void 0;
|
|
102
|
+
export { AnimatedArea };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["d", "skipAnimation", "ownerState"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { animated, useSpring } from '@react-spring/web';
|
|
7
|
+
import { color as d3Color } from 'd3-color';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import { useAnimatedPath } from '../internals/useAnimatedPath';
|
|
10
|
+
import { DrawingContext } from '../context/DrawingProvider';
|
|
11
|
+
import { cleanId } from '../internals/utils';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
export var LineElementPath = styled(animated.path, {
|
|
15
|
+
name: 'MuiLineElement',
|
|
16
|
+
slot: 'Root',
|
|
17
|
+
overridesResolver: function overridesResolver(_, styles) {
|
|
18
|
+
return styles.root;
|
|
19
|
+
}
|
|
20
|
+
})(function (_ref) {
|
|
21
|
+
var ownerState = _ref.ownerState;
|
|
22
|
+
return {
|
|
23
|
+
strokeWidth: 2,
|
|
24
|
+
strokeLinejoin: 'round',
|
|
25
|
+
fill: 'none',
|
|
26
|
+
stroke: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(0.5).formatHex() : ownerState.color,
|
|
27
|
+
transition: 'opacity 0.2s ease-in, stroke 0.2s ease-in',
|
|
28
|
+
opacity: ownerState.isFaded ? 0.3 : 1
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Demos:
|
|
33
|
+
*
|
|
34
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
35
|
+
* - [Line demonstration](https://mui.com/x/react-charts/line-demo/)
|
|
36
|
+
*
|
|
37
|
+
* API:
|
|
38
|
+
*
|
|
39
|
+
* - [AnimatedLine API](https://mui.com/x/api/charts/animated-line/)
|
|
40
|
+
*/
|
|
41
|
+
function AnimatedLine(props) {
|
|
42
|
+
var d = props.d,
|
|
43
|
+
skipAnimation = props.skipAnimation,
|
|
44
|
+
ownerState = props.ownerState,
|
|
45
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
46
|
+
var _React$useContext = React.useContext(DrawingContext),
|
|
47
|
+
left = _React$useContext.left,
|
|
48
|
+
top = _React$useContext.top,
|
|
49
|
+
bottom = _React$useContext.bottom,
|
|
50
|
+
width = _React$useContext.width,
|
|
51
|
+
height = _React$useContext.height,
|
|
52
|
+
right = _React$useContext.right,
|
|
53
|
+
chartId = _React$useContext.chartId;
|
|
54
|
+
var path = useAnimatedPath(d, skipAnimation);
|
|
55
|
+
var _useSpring = useSpring({
|
|
56
|
+
from: {
|
|
57
|
+
animatedWidth: left
|
|
58
|
+
},
|
|
59
|
+
to: {
|
|
60
|
+
animatedWidth: width + left + right
|
|
61
|
+
},
|
|
62
|
+
reset: false,
|
|
63
|
+
immediate: skipAnimation
|
|
64
|
+
}),
|
|
65
|
+
animatedWidth = _useSpring.animatedWidth;
|
|
66
|
+
var clipId = cleanId("".concat(chartId, "-").concat(ownerState.id, "-line-clip"));
|
|
67
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
68
|
+
children: [/*#__PURE__*/_jsx("clipPath", {
|
|
69
|
+
id: clipId,
|
|
70
|
+
children: /*#__PURE__*/_jsx(animated.rect, {
|
|
71
|
+
x: 0,
|
|
72
|
+
y: 0,
|
|
73
|
+
width: animatedWidth,
|
|
74
|
+
height: top + height + bottom
|
|
75
|
+
})
|
|
76
|
+
}), /*#__PURE__*/_jsx("g", {
|
|
77
|
+
clipPath: "url(#".concat(clipId, ")"),
|
|
78
|
+
children: /*#__PURE__*/_jsx(LineElementPath, _extends({}, other, {
|
|
79
|
+
ownerState: ownerState,
|
|
80
|
+
d: path
|
|
81
|
+
}))
|
|
82
|
+
})]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
|
|
86
|
+
// ----------------------------- Warning --------------------------------
|
|
87
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
88
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
89
|
+
// ----------------------------------------------------------------------
|
|
90
|
+
d: PropTypes.string.isRequired,
|
|
91
|
+
ownerState: PropTypes.shape({
|
|
92
|
+
classes: PropTypes.object,
|
|
93
|
+
color: PropTypes.string.isRequired,
|
|
94
|
+
id: PropTypes.string.isRequired,
|
|
95
|
+
isFaded: PropTypes.bool.isRequired,
|
|
96
|
+
isHighlighted: PropTypes.bool.isRequired
|
|
97
|
+
}).isRequired,
|
|
98
|
+
/**
|
|
99
|
+
* If `true`, animations are skipped.
|
|
100
|
+
* @default false
|
|
101
|
+
*/
|
|
102
|
+
skipAnimation: PropTypes.bool
|
|
103
|
+
} : void 0;
|
|
104
|
+
export { AnimatedLine };
|