@mui/x-charts 7.0.0-beta.0 → 7.0.0-beta.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 +2 -1
- package/BarChart/BarChart.js +33 -12
- package/BarChart/BarElement.d.ts +20 -13
- package/BarChart/BarElement.js +7 -3
- package/BarChart/BarPlot.d.ts +11 -6
- package/BarChart/BarPlot.js +28 -15
- package/BarChart/formatter.js +1 -1
- package/CHANGELOG.md +406 -1
- package/ChartContainer/ChartContainer.js +6 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsLegend/ChartsLegend.d.ts +5 -54
- package/ChartsLegend/ChartsLegend.js +2 -307
- package/ChartsLegend/DefaultChartsLegend.d.ts +60 -0
- package/ChartsLegend/DefaultChartsLegend.js +294 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- 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/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsReferenceLine/common.d.ts +2 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -5
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/ChartsTooltip/utils.d.ts +4 -1
- package/ChartsTooltip/utils.js +15 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +7 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/ChartsXAxis/ChartsXAxis.js +13 -9
- package/ChartsYAxis/ChartsYAxis.js +1 -1
- 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 +19 -18
- 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 +45 -14
- package/LineChart/LineElement.d.ts +19 -18
- package/LineChart/LineElement.js +16 -36
- package/LineChart/LineHighlightElement.d.ts +3 -2
- package/LineChart/LineHighlightElement.js +5 -3
- package/LineChart/LinePlot.d.ts +12 -7
- package/LineChart/LinePlot.js +89 -56
- package/LineChart/MarkElement.d.ts +8 -4
- package/LineChart/MarkElement.js +27 -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/PieArc.d.ts +3 -2
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieArcLabel.d.ts +3 -2
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +2 -2
- package/PieChart/PieArcPlot.d.ts +2 -2
- package/PieChart/PieArcPlot.js +7 -7
- package/PieChart/PieChart.d.ts +1 -1
- package/PieChart/PieChart.js +14 -12
- package/PieChart/PiePlot.d.ts +1 -1
- package/PieChart/PiePlot.js +4 -4
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/ScatterChart/Scatter.d.ts +7 -1
- package/ScatterChart/Scatter.js +17 -3
- package/ScatterChart/ScatterChart.d.ts +8 -2
- package/ScatterChart/ScatterChart.js +21 -10
- package/ScatterChart/ScatterPlot.d.ts +1 -1
- package/ScatterChart/ScatterPlot.js +10 -2
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +7 -4
- package/context/CartesianContextProvider.js +8 -6
- 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 +33 -12
- package/esm/BarChart/BarElement.js +7 -3
- package/esm/BarChart/BarPlot.js +27 -15
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/ChartContainer.js +6 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -307
- package/esm/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/esm/ChartsLegend/index.js +1 -0
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +77 -0
- package/esm/ChartsOnAxisClickHandler/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -5
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/esm/ChartsTooltip/utils.js +12 -0
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/esm/ChartsXAxis/ChartsXAxis.js +13 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -1
- 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 +45 -14
- package/esm/LineChart/LineElement.js +16 -35
- package/esm/LineChart/LineHighlightElement.js +5 -3
- package/esm/LineChart/LinePlot.js +90 -57
- package/esm/LineChart/MarkElement.js +27 -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/PieArc.js +1 -0
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieArcLabelPlot.js +2 -2
- package/esm/PieChart/PieArcPlot.js +7 -7
- package/esm/PieChart/PieChart.js +14 -12
- package/esm/PieChart/PiePlot.js +4 -4
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/esm/ScatterChart/Scatter.js +17 -3
- package/esm/ScatterChart/ScatterChart.js +21 -10
- package/esm/ScatterChart/ScatterPlot.js +10 -2
- package/esm/SparkLineChart/SparkLineChart.js +7 -4
- package/esm/context/CartesianContextProvider.js +8 -6
- 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/defaultizeColor.d.ts +16 -16
- package/internals/defaultizeValueFormatter.d.ts +4 -7
- package/internals/geometry.js +1 -1
- package/internals/stackSeries.d.ts +4 -7
- 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 +33 -12
- package/legacy/BarChart/BarElement.js +6 -2
- package/legacy/BarChart/BarPlot.js +28 -14
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/ChartContainer.js +6 -4
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/ChartsLegend/ChartsLegend.js +2 -323
- package/legacy/ChartsLegend/DefaultChartsLegend.js +302 -0
- package/legacy/ChartsLegend/index.js +1 -0
- package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/legacy/ChartsOnAxisClickHandler/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +6 -7
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -5
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/legacy/ChartsTooltip/utils.js +12 -0
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +88 -44
- package/legacy/ChartsXAxis/ChartsXAxis.js +12 -8
- package/legacy/ChartsYAxis/ChartsYAxis.js +1 -1
- 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 +45 -14
- package/legacy/LineChart/LineElement.js +15 -37
- package/legacy/LineChart/LineHighlightElement.js +5 -3
- package/legacy/LineChart/LinePlot.js +97 -63
- package/legacy/LineChart/MarkElement.js +30 -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/PieArc.js +1 -0
- package/legacy/PieChart/PieArcLabel.js +1 -0
- package/legacy/PieChart/PieArcLabelPlot.js +2 -2
- package/legacy/PieChart/PieArcPlot.js +7 -7
- package/legacy/PieChart/PieChart.js +14 -12
- package/legacy/PieChart/PiePlot.js +4 -4
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/legacy/ScatterChart/Scatter.js +19 -3
- package/legacy/ScatterChart/ScatterChart.js +21 -10
- package/legacy/ScatterChart/ScatterPlot.js +10 -2
- package/legacy/SparkLineChart/SparkLineChart.js +8 -5
- package/legacy/context/CartesianContextProvider.js +8 -6
- 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/models/axis.d.ts +7 -2
- package/models/seriesType/common.d.ts +2 -1
- package/models/seriesType/config.d.ts +7 -12
- package/models/seriesType/line.d.ts +2 -2
- package/models/seriesType/pie.d.ts +7 -3
- package/models/seriesType/scatter.d.ts +5 -2
- package/modern/BarChart/BarChart.js +33 -12
- package/modern/BarChart/BarElement.js +7 -3
- package/modern/BarChart/BarPlot.js +27 -15
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/ChartContainer.js +6 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsLegend/ChartsLegend.js +2 -307
- package/modern/ChartsLegend/DefaultChartsLegend.js +286 -0
- package/modern/ChartsLegend/index.js +1 -0
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/modern/ChartsOnAxisClickHandler/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -5
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -1
- package/modern/ChartsTooltip/utils.js +12 -0
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/modern/ChartsXAxis/ChartsXAxis.js +13 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +1 -1
- 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 +45 -14
- package/modern/LineChart/LineElement.js +16 -35
- package/modern/LineChart/LineHighlightElement.js +5 -3
- package/modern/LineChart/LinePlot.js +89 -56
- package/modern/LineChart/MarkElement.js +27 -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/PieArc.js +1 -0
- package/modern/PieChart/PieArcLabel.js +1 -0
- package/modern/PieChart/PieArcLabelPlot.js +2 -2
- package/modern/PieChart/PieArcPlot.js +7 -7
- package/modern/PieChart/PieChart.js +14 -12
- package/modern/PieChart/PiePlot.js +4 -4
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +6 -4
- package/modern/ScatterChart/Scatter.js +17 -3
- package/modern/ScatterChart/ScatterChart.js +21 -10
- package/modern/ScatterChart/ScatterPlot.js +10 -2
- package/modern/SparkLineChart/SparkLineChart.js +7 -4
- package/modern/context/CartesianContextProvider.js +8 -6
- 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
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
3
|
+
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps", "onClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
7
|
import { useSlotProps } from '@mui/base/utils';
|
|
8
8
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
9
|
-
import { styled } from '@mui/material/styles';
|
|
10
9
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
11
|
-
import { color as d3Color } from 'd3-color';
|
|
12
10
|
import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
13
11
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
12
|
+
import { AnimatedArea } from './AnimatedArea';
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
export function getAreaElementUtilityClass(slot) {
|
|
16
15
|
return generateUtilityClass('MuiAreaElement', slot);
|
|
@@ -28,33 +27,6 @@ const useUtilityClasses = ownerState => {
|
|
|
28
27
|
};
|
|
29
28
|
return composeClasses(slots, getAreaElementUtilityClass, classes);
|
|
30
29
|
};
|
|
31
|
-
export const AreaElementPath = styled('path', {
|
|
32
|
-
name: 'MuiAreaElement',
|
|
33
|
-
slot: 'Root',
|
|
34
|
-
overridesResolver: (_, styles) => styles.root
|
|
35
|
-
})(({
|
|
36
|
-
ownerState
|
|
37
|
-
}) => ({
|
|
38
|
-
stroke: 'none',
|
|
39
|
-
fill: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(1).formatHex() : d3Color(ownerState.color).brighter(0.5).formatHex(),
|
|
40
|
-
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
41
|
-
opacity: ownerState.isFaded ? 0.3 : 1
|
|
42
|
-
}));
|
|
43
|
-
AreaElementPath.propTypes = {
|
|
44
|
-
// ----------------------------- Warning --------------------------------
|
|
45
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
46
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
47
|
-
// ----------------------------------------------------------------------
|
|
48
|
-
as: PropTypes.elementType,
|
|
49
|
-
ownerState: PropTypes.shape({
|
|
50
|
-
classes: PropTypes.object,
|
|
51
|
-
color: PropTypes.string.isRequired,
|
|
52
|
-
id: PropTypes.string.isRequired,
|
|
53
|
-
isFaded: PropTypes.bool.isRequired,
|
|
54
|
-
isHighlighted: PropTypes.bool.isRequired
|
|
55
|
-
}).isRequired,
|
|
56
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
57
|
-
};
|
|
58
30
|
/**
|
|
59
31
|
* Demos:
|
|
60
32
|
*
|
|
@@ -72,7 +44,8 @@ function AreaElement(props) {
|
|
|
72
44
|
color,
|
|
73
45
|
highlightScope,
|
|
74
46
|
slots,
|
|
75
|
-
slotProps
|
|
47
|
+
slotProps,
|
|
48
|
+
onClick
|
|
76
49
|
} = props,
|
|
77
50
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
78
51
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -95,7 +68,7 @@ function AreaElement(props) {
|
|
|
95
68
|
isHighlighted
|
|
96
69
|
};
|
|
97
70
|
const classes = useUtilityClasses(ownerState);
|
|
98
|
-
const Area = slots?.area ??
|
|
71
|
+
const Area = slots?.area ?? AnimatedArea;
|
|
99
72
|
const areaProps = useSlotProps({
|
|
100
73
|
elementType: Area,
|
|
101
74
|
externalSlotProps: slotProps?.area,
|
|
@@ -103,7 +76,9 @@ function AreaElement(props) {
|
|
|
103
76
|
type: 'line',
|
|
104
77
|
seriesId: id
|
|
105
78
|
}), {
|
|
106
|
-
className: classes.root
|
|
79
|
+
className: classes.root,
|
|
80
|
+
onClick,
|
|
81
|
+
cursor: onClick ? 'pointer' : 'unset'
|
|
107
82
|
}),
|
|
108
83
|
ownerState
|
|
109
84
|
});
|
|
@@ -115,10 +90,18 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
|
115
90
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
116
91
|
// ----------------------------------------------------------------------
|
|
117
92
|
classes: PropTypes.object,
|
|
93
|
+
color: PropTypes.string.isRequired,
|
|
94
|
+
d: PropTypes.string.isRequired,
|
|
118
95
|
highlightScope: PropTypes.shape({
|
|
119
96
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
120
97
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
121
98
|
}),
|
|
99
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
100
|
+
/**
|
|
101
|
+
* If `true`, animations are skipped.
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
skipAnimation: PropTypes.bool,
|
|
122
105
|
/**
|
|
123
106
|
* The props used for each component slot.
|
|
124
107
|
* @default {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { area as d3Area } from 'd3-shape';
|
|
@@ -11,27 +11,11 @@ import { getValueToPositionMapper } from '../hooks/useScale';
|
|
|
11
11
|
import getCurveFactory from '../internals/getCurve';
|
|
12
12
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
|
|
15
|
-
* Demos:
|
|
16
|
-
*
|
|
17
|
-
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
18
|
-
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
19
|
-
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
20
|
-
*
|
|
21
|
-
* API:
|
|
22
|
-
*
|
|
23
|
-
* - [AreaPlot API](https://mui.com/x/api/charts/area-plot/)
|
|
24
|
-
*/
|
|
25
|
-
function AreaPlot(props) {
|
|
26
|
-
const {
|
|
27
|
-
slots,
|
|
28
|
-
slotProps
|
|
29
|
-
} = props,
|
|
30
|
-
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
14
|
+
const useAggregatedData = () => {
|
|
31
15
|
const seriesData = React.useContext(SeriesContext).line;
|
|
32
16
|
const axisData = React.useContext(CartesianContext);
|
|
33
17
|
if (seriesData === undefined) {
|
|
34
|
-
return
|
|
18
|
+
return [];
|
|
35
19
|
}
|
|
36
20
|
const {
|
|
37
21
|
series,
|
|
@@ -45,46 +29,84 @@ function AreaPlot(props) {
|
|
|
45
29
|
} = axisData;
|
|
46
30
|
const defaultXAxisId = xAxisIds[0];
|
|
47
31
|
const defaultYAxisId = yAxisIds[0];
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
66
|
-
}
|
|
67
|
-
if (xData.length < stackedData.length) {
|
|
68
|
-
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
69
|
-
}
|
|
32
|
+
return stackingGroups.flatMap(({
|
|
33
|
+
ids: groupIds
|
|
34
|
+
}) => {
|
|
35
|
+
return groupIds.flatMap(seriesId => {
|
|
36
|
+
const {
|
|
37
|
+
xAxisKey = defaultXAxisId,
|
|
38
|
+
yAxisKey = defaultYAxisId,
|
|
39
|
+
stackedData,
|
|
40
|
+
data,
|
|
41
|
+
connectNulls
|
|
42
|
+
} = series[seriesId];
|
|
43
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
44
|
+
const yScale = yAxis[yAxisKey].scale;
|
|
45
|
+
const xData = xAxis[xAxisKey].data;
|
|
46
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
47
|
+
if (xData === undefined) {
|
|
48
|
+
throw new Error(`MUI X Charts: ${xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisKey}"`} should have data property to be able to display a line plot.`);
|
|
70
49
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
50
|
+
if (xData.length < stackedData.length) {
|
|
51
|
+
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => d.y && yScale(d.y[0])).y1(d => d.y && yScale(d.y[1]));
|
|
55
|
+
const curve = getCurveFactory(series[seriesId].curve);
|
|
56
|
+
const formattedData = xData?.map((x, index) => ({
|
|
57
|
+
x,
|
|
58
|
+
y: stackedData[index]
|
|
59
|
+
})) ?? [];
|
|
60
|
+
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
61
|
+
const d = areaPath.curve(curve)(d3Data) || '';
|
|
62
|
+
return _extends({}, series[seriesId], {
|
|
63
|
+
d,
|
|
64
|
+
seriesId
|
|
86
65
|
});
|
|
87
|
-
})
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Demos:
|
|
72
|
+
*
|
|
73
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
74
|
+
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
75
|
+
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
76
|
+
*
|
|
77
|
+
* API:
|
|
78
|
+
*
|
|
79
|
+
* - [AreaPlot API](https://mui.com/x/api/charts/area-plot/)
|
|
80
|
+
*/
|
|
81
|
+
function AreaPlot(props) {
|
|
82
|
+
const {
|
|
83
|
+
slots,
|
|
84
|
+
slotProps,
|
|
85
|
+
onItemClick,
|
|
86
|
+
skipAnimation
|
|
87
|
+
} = props,
|
|
88
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
89
|
+
const completedData = useAggregatedData();
|
|
90
|
+
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
91
|
+
children: completedData.reverse().map(({
|
|
92
|
+
d,
|
|
93
|
+
seriesId,
|
|
94
|
+
color,
|
|
95
|
+
highlightScope,
|
|
96
|
+
area
|
|
97
|
+
}) => !!area && /*#__PURE__*/_jsx(AreaElement, {
|
|
98
|
+
id: seriesId,
|
|
99
|
+
d: d,
|
|
100
|
+
color: color,
|
|
101
|
+
highlightScope: highlightScope,
|
|
102
|
+
slots: slots,
|
|
103
|
+
slotProps: slotProps,
|
|
104
|
+
onClick: onItemClick && (event => onItemClick(event, {
|
|
105
|
+
type: 'line',
|
|
106
|
+
seriesId
|
|
107
|
+
})),
|
|
108
|
+
skipAnimation: skipAnimation
|
|
109
|
+
}, seriesId))
|
|
88
110
|
}));
|
|
89
111
|
}
|
|
90
112
|
process.env.NODE_ENV !== "production" ? AreaPlot.propTypes = {
|
|
@@ -92,6 +114,17 @@ process.env.NODE_ENV !== "production" ? AreaPlot.propTypes = {
|
|
|
92
114
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
93
115
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
94
116
|
// ----------------------------------------------------------------------
|
|
117
|
+
/**
|
|
118
|
+
* Callback fired when a line area item is clicked.
|
|
119
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
120
|
+
* @param {LineItemIdentifier} lineItemIdentifier The line item identifier.
|
|
121
|
+
*/
|
|
122
|
+
onItemClick: PropTypes.func,
|
|
123
|
+
/**
|
|
124
|
+
* If `true`, animations are skipped.
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
skipAnimation: PropTypes.bool,
|
|
95
128
|
/**
|
|
96
129
|
* The props used for each component slot.
|
|
97
130
|
* @default {}
|
|
@@ -13,6 +13,7 @@ import { ChartsLegend } from '../ChartsLegend';
|
|
|
13
13
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
14
14
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
15
15
|
import { LineHighlightPlot } from './LineHighlightPlot';
|
|
16
|
+
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
16
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
18
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
19
|
/**
|
|
@@ -37,6 +38,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
37
38
|
dataset,
|
|
38
39
|
sx,
|
|
39
40
|
tooltip,
|
|
41
|
+
onAxisClick,
|
|
42
|
+
onAreaClick,
|
|
43
|
+
onLineClick,
|
|
44
|
+
onMarkClick,
|
|
40
45
|
axisHighlight = {
|
|
41
46
|
x: 'line'
|
|
42
47
|
},
|
|
@@ -48,7 +53,8 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
48
53
|
bottomAxis,
|
|
49
54
|
children,
|
|
50
55
|
slots,
|
|
51
|
-
slotProps
|
|
56
|
+
slotProps,
|
|
57
|
+
skipAnimation
|
|
52
58
|
} = props;
|
|
53
59
|
const id = useId();
|
|
54
60
|
const clipPathId = `${id}-clip-path`;
|
|
@@ -72,15 +78,21 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
72
78
|
colors: colors,
|
|
73
79
|
dataset: dataset,
|
|
74
80
|
sx: sx,
|
|
75
|
-
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none',
|
|
76
|
-
children: [/*#__PURE__*/
|
|
81
|
+
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
82
|
+
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
83
|
+
onAxisClick: onAxisClick
|
|
84
|
+
}), /*#__PURE__*/_jsxs("g", {
|
|
77
85
|
clipPath: `url(#${clipPathId})`,
|
|
78
86
|
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
79
87
|
slots: slots,
|
|
80
|
-
slotProps: slotProps
|
|
88
|
+
slotProps: slotProps,
|
|
89
|
+
onItemClick: onAreaClick,
|
|
90
|
+
skipAnimation: skipAnimation
|
|
81
91
|
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
82
92
|
slots: slots,
|
|
83
|
-
slotProps: slotProps
|
|
93
|
+
slotProps: slotProps,
|
|
94
|
+
onItemClick: onLineClick,
|
|
95
|
+
skipAnimation: skipAnimation
|
|
84
96
|
})]
|
|
85
97
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
86
98
|
topAxis: topAxis,
|
|
@@ -91,7 +103,9 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
91
103
|
slotProps: slotProps
|
|
92
104
|
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(MarkPlot, {
|
|
93
105
|
slots: slots,
|
|
94
|
-
slotProps: slotProps
|
|
106
|
+
slotProps: slotProps,
|
|
107
|
+
onItemClick: onMarkClick,
|
|
108
|
+
skipAnimation: skipAnimation
|
|
95
109
|
}), /*#__PURE__*/_jsx(LineHighlightPlot, {
|
|
96
110
|
slots: slots,
|
|
97
111
|
slotProps: slotProps
|
|
@@ -129,7 +143,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
129
143
|
* @default xAxisIds[0] The id of the first provided axis
|
|
130
144
|
*/
|
|
131
145
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
132
|
-
axisId: PropTypes.string,
|
|
146
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
133
147
|
classes: PropTypes.object,
|
|
134
148
|
disableLine: PropTypes.bool,
|
|
135
149
|
disableTicks: PropTypes.bool,
|
|
@@ -183,7 +197,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
183
197
|
* @default yAxisIds[0] The id of the first provided axis
|
|
184
198
|
*/
|
|
185
199
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
186
|
-
axisId: PropTypes.string,
|
|
200
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
187
201
|
classes: PropTypes.object,
|
|
188
202
|
disableLine: PropTypes.bool,
|
|
189
203
|
disableTicks: PropTypes.bool,
|
|
@@ -230,13 +244,23 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
230
244
|
right: PropTypes.number,
|
|
231
245
|
top: PropTypes.number
|
|
232
246
|
}),
|
|
247
|
+
onAreaClick: PropTypes.func,
|
|
248
|
+
/**
|
|
249
|
+
* The function called for onClick events.
|
|
250
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
251
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
252
|
+
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
253
|
+
*/
|
|
254
|
+
onAxisClick: PropTypes.func,
|
|
255
|
+
onLineClick: PropTypes.func,
|
|
256
|
+
onMarkClick: PropTypes.func,
|
|
233
257
|
/**
|
|
234
258
|
* Indicate which axis to display the right of the charts.
|
|
235
259
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
236
260
|
* @default null
|
|
237
261
|
*/
|
|
238
262
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
239
|
-
axisId: PropTypes.string,
|
|
263
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
240
264
|
classes: PropTypes.object,
|
|
241
265
|
disableLine: PropTypes.bool,
|
|
242
266
|
disableTicks: PropTypes.bool,
|
|
@@ -258,6 +282,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
258
282
|
tickSize: PropTypes.number
|
|
259
283
|
}), PropTypes.string]),
|
|
260
284
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
285
|
+
/**
|
|
286
|
+
* If `true`, animations are skipped.
|
|
287
|
+
* @default false
|
|
288
|
+
*/
|
|
289
|
+
skipAnimation: PropTypes.bool,
|
|
261
290
|
/**
|
|
262
291
|
* The props used for each component slot.
|
|
263
292
|
* @default {}
|
|
@@ -284,7 +313,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
284
313
|
* @default null
|
|
285
314
|
*/
|
|
286
315
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
287
|
-
axisId: PropTypes.string,
|
|
316
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
288
317
|
classes: PropTypes.object,
|
|
289
318
|
disableLine: PropTypes.bool,
|
|
290
319
|
disableTicks: PropTypes.bool,
|
|
@@ -321,7 +350,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
321
350
|
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
322
351
|
*/
|
|
323
352
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
324
|
-
axisId: PropTypes.string,
|
|
353
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
325
354
|
classes: PropTypes.object,
|
|
326
355
|
data: PropTypes.array,
|
|
327
356
|
dataKey: PropTypes.string,
|
|
@@ -329,13 +358,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
329
358
|
disableTicks: PropTypes.bool,
|
|
330
359
|
fill: PropTypes.string,
|
|
331
360
|
hideTooltip: PropTypes.bool,
|
|
332
|
-
id: PropTypes.string,
|
|
361
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
333
362
|
label: PropTypes.string,
|
|
334
363
|
labelFontSize: PropTypes.number,
|
|
335
364
|
labelStyle: PropTypes.object,
|
|
336
365
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
337
366
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
338
367
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
368
|
+
reverse: PropTypes.bool,
|
|
339
369
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
340
370
|
slotProps: PropTypes.object,
|
|
341
371
|
slots: PropTypes.object,
|
|
@@ -355,7 +385,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
355
385
|
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
356
386
|
*/
|
|
357
387
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
358
|
-
axisId: PropTypes.string,
|
|
388
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
359
389
|
classes: PropTypes.object,
|
|
360
390
|
data: PropTypes.array,
|
|
361
391
|
dataKey: PropTypes.string,
|
|
@@ -363,13 +393,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
363
393
|
disableTicks: PropTypes.bool,
|
|
364
394
|
fill: PropTypes.string,
|
|
365
395
|
hideTooltip: PropTypes.bool,
|
|
366
|
-
id: PropTypes.string,
|
|
396
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
367
397
|
label: PropTypes.string,
|
|
368
398
|
labelFontSize: PropTypes.number,
|
|
369
399
|
labelStyle: PropTypes.object,
|
|
370
400
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
371
401
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
372
402
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
403
|
+
reverse: PropTypes.bool,
|
|
373
404
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
374
405
|
slotProps: PropTypes.object,
|
|
375
406
|
slots: PropTypes.object,
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
-
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
3
|
+
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps", "onClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { color as d3Color } from 'd3-color';
|
|
7
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
7
|
import { useSlotProps } from '@mui/base/utils';
|
|
9
8
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
10
|
-
import { styled } from '@mui/material/styles';
|
|
11
9
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
12
10
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
13
11
|
import { getIsFaded, getIsHighlighted, useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
12
|
+
import { AnimatedLine } from './AnimatedLine';
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
14
|
export function getLineElementUtilityClass(slot) {
|
|
16
15
|
return generateUtilityClass('MuiLineElement', slot);
|
|
@@ -28,35 +27,6 @@ const useUtilityClasses = ownerState => {
|
|
|
28
27
|
};
|
|
29
28
|
return composeClasses(slots, getLineElementUtilityClass, classes);
|
|
30
29
|
};
|
|
31
|
-
export const LineElementPath = styled('path', {
|
|
32
|
-
name: 'MuiLineElement',
|
|
33
|
-
slot: 'Root',
|
|
34
|
-
overridesResolver: (_, styles) => styles.root
|
|
35
|
-
})(({
|
|
36
|
-
ownerState
|
|
37
|
-
}) => ({
|
|
38
|
-
strokeWidth: 2,
|
|
39
|
-
strokeLinejoin: 'round',
|
|
40
|
-
fill: 'none',
|
|
41
|
-
stroke: ownerState.isHighlighted ? d3Color(ownerState.color).brighter(0.5).formatHex() : ownerState.color,
|
|
42
|
-
transition: 'opacity 0.2s ease-in, stroke 0.2s ease-in',
|
|
43
|
-
opacity: ownerState.isFaded ? 0.3 : 1
|
|
44
|
-
}));
|
|
45
|
-
LineElementPath.propTypes = {
|
|
46
|
-
// ----------------------------- Warning --------------------------------
|
|
47
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
48
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
49
|
-
// ----------------------------------------------------------------------
|
|
50
|
-
as: PropTypes.elementType,
|
|
51
|
-
ownerState: PropTypes.shape({
|
|
52
|
-
classes: PropTypes.object,
|
|
53
|
-
color: PropTypes.string.isRequired,
|
|
54
|
-
id: PropTypes.string.isRequired,
|
|
55
|
-
isFaded: PropTypes.bool.isRequired,
|
|
56
|
-
isHighlighted: PropTypes.bool.isRequired
|
|
57
|
-
}).isRequired,
|
|
58
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
59
|
-
};
|
|
60
30
|
/**
|
|
61
31
|
* Demos:
|
|
62
32
|
*
|
|
@@ -74,7 +44,8 @@ function LineElement(props) {
|
|
|
74
44
|
color,
|
|
75
45
|
highlightScope,
|
|
76
46
|
slots,
|
|
77
|
-
slotProps
|
|
47
|
+
slotProps,
|
|
48
|
+
onClick
|
|
78
49
|
} = props,
|
|
79
50
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
80
51
|
const getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
@@ -97,7 +68,7 @@ function LineElement(props) {
|
|
|
97
68
|
isHighlighted
|
|
98
69
|
};
|
|
99
70
|
const classes = useUtilityClasses(ownerState);
|
|
100
|
-
const Line = slots?.line ??
|
|
71
|
+
const Line = slots?.line ?? AnimatedLine;
|
|
101
72
|
const lineProps = useSlotProps({
|
|
102
73
|
elementType: Line,
|
|
103
74
|
externalSlotProps: slotProps?.line,
|
|
@@ -105,7 +76,9 @@ function LineElement(props) {
|
|
|
105
76
|
type: 'line',
|
|
106
77
|
seriesId: id
|
|
107
78
|
}), {
|
|
108
|
-
className: classes.root
|
|
79
|
+
className: classes.root,
|
|
80
|
+
onClick,
|
|
81
|
+
cursor: onClick ? 'pointer' : 'unset'
|
|
109
82
|
}),
|
|
110
83
|
ownerState
|
|
111
84
|
});
|
|
@@ -117,10 +90,18 @@ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
|
|
|
117
90
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
118
91
|
// ----------------------------------------------------------------------
|
|
119
92
|
classes: PropTypes.object,
|
|
93
|
+
color: PropTypes.string.isRequired,
|
|
94
|
+
d: PropTypes.string.isRequired,
|
|
120
95
|
highlightScope: PropTypes.shape({
|
|
121
96
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
122
97
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
123
98
|
}),
|
|
99
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
100
|
+
/**
|
|
101
|
+
* If `true`, animations are skipped.
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
skipAnimation: PropTypes.bool,
|
|
124
105
|
/**
|
|
125
106
|
* The props used for each component slot.
|
|
126
107
|
* @default {}
|
|
@@ -60,19 +60,21 @@ function LineHighlightElement(props) {
|
|
|
60
60
|
y
|
|
61
61
|
};
|
|
62
62
|
const classes = useUtilityClasses(ownerState);
|
|
63
|
-
return /*#__PURE__*/_jsx(HighlightElement, _extends({
|
|
63
|
+
return /*#__PURE__*/_jsx(HighlightElement, _extends({
|
|
64
|
+
pointerEvents: "none",
|
|
64
65
|
ownerState: ownerState,
|
|
65
66
|
className: classes.root,
|
|
66
67
|
cx: 0,
|
|
67
68
|
cy: 0,
|
|
68
69
|
r: other.r === undefined ? 5 : other.r
|
|
69
|
-
}));
|
|
70
|
+
}, other));
|
|
70
71
|
}
|
|
71
72
|
process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
|
|
72
73
|
// ----------------------------- Warning --------------------------------
|
|
73
74
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
74
75
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
75
76
|
// ----------------------------------------------------------------------
|
|
76
|
-
classes: PropTypes.object
|
|
77
|
+
classes: PropTypes.object,
|
|
78
|
+
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired
|
|
77
79
|
} : void 0;
|
|
78
80
|
export { LineHighlightElement };
|