@mui/x-charts 7.0.0-beta.0 → 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 +23 -4
- 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 +247 -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/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -5
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -4
- 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 +35 -6
- 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 +4 -4
- package/PieChart/PiePlot.d.ts +1 -1
- package/PieChart/PiePlot.js +4 -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 +11 -2
- 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 +23 -4
- package/esm/BarChart/BarElement.js +6 -3
- package/esm/BarChart/BarPlot.js +19 -5
- package/esm/BarChart/formatter.js +1 -1
- 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 +6 -5
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -4
- 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 +35 -6
- 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 +4 -4
- package/esm/PieChart/PiePlot.js +4 -4
- package/esm/ScatterChart/Scatter.js +17 -3
- package/esm/ScatterChart/ScatterChart.js +11 -2
- 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 +23 -4
- package/legacy/BarChart/BarElement.js +5 -2
- package/legacy/BarChart/BarPlot.js +18 -4
- package/legacy/BarChart/formatter.js +1 -1
- 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 +6 -7
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +7 -4
- 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 +35 -6
- 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 +4 -4
- package/legacy/PieChart/PiePlot.js +4 -4
- package/legacy/ScatterChart/Scatter.js +19 -3
- package/legacy/ScatterChart/ScatterChart.js +11 -2
- 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 +23 -4
- package/modern/BarChart/BarElement.js +6 -3
- package/modern/BarChart/BarPlot.js +19 -5
- package/modern/BarChart/formatter.js +1 -1
- 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 +6 -5
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -4
- 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 +35 -6
- 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 +4 -4
- package/modern/PieChart/PiePlot.js +4 -4
- package/modern/ScatterChart/Scatter.js +17 -3
- package/modern/ScatterChart/ScatterChart.js +11 -2
- 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
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
3
|
+
var _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);
|
|
@@ -26,36 +25,6 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
26
25
|
};
|
|
27
26
|
return composeClasses(slots, getAreaElementUtilityClass, classes);
|
|
28
27
|
};
|
|
29
|
-
export var AreaElementPath = styled('path', {
|
|
30
|
-
name: 'MuiAreaElement',
|
|
31
|
-
slot: 'Root',
|
|
32
|
-
overridesResolver: function overridesResolver(_, styles) {
|
|
33
|
-
return styles.root;
|
|
34
|
-
}
|
|
35
|
-
})(function (_ref) {
|
|
36
|
-
var ownerState = _ref.ownerState;
|
|
37
|
-
return {
|
|
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
|
-
});
|
|
44
|
-
AreaElementPath.propTypes = {
|
|
45
|
-
// ----------------------------- Warning --------------------------------
|
|
46
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
47
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
48
|
-
// ----------------------------------------------------------------------
|
|
49
|
-
as: PropTypes.elementType,
|
|
50
|
-
ownerState: PropTypes.shape({
|
|
51
|
-
classes: PropTypes.object,
|
|
52
|
-
color: PropTypes.string.isRequired,
|
|
53
|
-
id: PropTypes.string.isRequired,
|
|
54
|
-
isFaded: PropTypes.bool.isRequired,
|
|
55
|
-
isHighlighted: PropTypes.bool.isRequired
|
|
56
|
-
}).isRequired,
|
|
57
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
58
|
-
};
|
|
59
28
|
/**
|
|
60
29
|
* Demos:
|
|
61
30
|
*
|
|
@@ -74,6 +43,7 @@ function AreaElement(props) {
|
|
|
74
43
|
highlightScope = props.highlightScope,
|
|
75
44
|
slots = props.slots,
|
|
76
45
|
slotProps = props.slotProps,
|
|
46
|
+
onClick = props.onClick,
|
|
77
47
|
other = _objectWithoutProperties(props, _excluded);
|
|
78
48
|
var getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
79
49
|
var _React$useContext = React.useContext(InteractionContext),
|
|
@@ -94,7 +64,7 @@ function AreaElement(props) {
|
|
|
94
64
|
isHighlighted: isHighlighted
|
|
95
65
|
};
|
|
96
66
|
var classes = useUtilityClasses(ownerState);
|
|
97
|
-
var Area = (_slots$area = slots == null ? void 0 : slots.area) != null ? _slots$area :
|
|
67
|
+
var Area = (_slots$area = slots == null ? void 0 : slots.area) != null ? _slots$area : AnimatedArea;
|
|
98
68
|
var areaProps = useSlotProps({
|
|
99
69
|
elementType: Area,
|
|
100
70
|
externalSlotProps: slotProps == null ? void 0 : slotProps.area,
|
|
@@ -102,7 +72,9 @@ function AreaElement(props) {
|
|
|
102
72
|
type: 'line',
|
|
103
73
|
seriesId: id
|
|
104
74
|
}), {
|
|
105
|
-
className: classes.root
|
|
75
|
+
className: classes.root,
|
|
76
|
+
onClick: onClick,
|
|
77
|
+
cursor: onClick ? 'pointer' : 'unset'
|
|
106
78
|
}),
|
|
107
79
|
ownerState: ownerState
|
|
108
80
|
});
|
|
@@ -114,10 +86,18 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
|
114
86
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
115
87
|
// ----------------------------------------------------------------------
|
|
116
88
|
classes: PropTypes.object,
|
|
89
|
+
color: PropTypes.string.isRequired,
|
|
90
|
+
d: PropTypes.string.isRequired,
|
|
117
91
|
highlightScope: PropTypes.shape({
|
|
118
92
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
119
93
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
120
94
|
}),
|
|
95
|
+
id: PropTypes.string.isRequired,
|
|
96
|
+
/**
|
|
97
|
+
* If `true`, animations are skipped.
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
skipAnimation: PropTypes.bool,
|
|
121
101
|
/**
|
|
122
102
|
* The props used for each component slot.
|
|
123
103
|
* @default {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
var _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,6 +11,71 @@ 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
|
+
var useAggregatedData = function useAggregatedData() {
|
|
15
|
+
var seriesData = React.useContext(SeriesContext).line;
|
|
16
|
+
var axisData = React.useContext(CartesianContext);
|
|
17
|
+
if (seriesData === undefined) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
var series = seriesData.series,
|
|
21
|
+
stackingGroups = seriesData.stackingGroups;
|
|
22
|
+
var xAxis = axisData.xAxis,
|
|
23
|
+
yAxis = axisData.yAxis,
|
|
24
|
+
xAxisIds = axisData.xAxisIds,
|
|
25
|
+
yAxisIds = axisData.yAxisIds;
|
|
26
|
+
var defaultXAxisId = xAxisIds[0];
|
|
27
|
+
var defaultYAxisId = yAxisIds[0];
|
|
28
|
+
return stackingGroups.flatMap(function (_ref) {
|
|
29
|
+
var groupIds = _ref.ids;
|
|
30
|
+
return groupIds.flatMap(function (seriesId) {
|
|
31
|
+
var _xData$map;
|
|
32
|
+
var _series$seriesId = series[seriesId],
|
|
33
|
+
_series$seriesId$xAxi = _series$seriesId.xAxisKey,
|
|
34
|
+
xAxisKey = _series$seriesId$xAxi === void 0 ? defaultXAxisId : _series$seriesId$xAxi,
|
|
35
|
+
_series$seriesId$yAxi = _series$seriesId.yAxisKey,
|
|
36
|
+
yAxisKey = _series$seriesId$yAxi === void 0 ? defaultYAxisId : _series$seriesId$yAxi,
|
|
37
|
+
stackedData = _series$seriesId.stackedData,
|
|
38
|
+
data = _series$seriesId.data,
|
|
39
|
+
connectNulls = _series$seriesId.connectNulls;
|
|
40
|
+
var xScale = getValueToPositionMapper(xAxis[xAxisKey].scale);
|
|
41
|
+
var yScale = yAxis[yAxisKey].scale;
|
|
42
|
+
var xData = xAxis[xAxisKey].data;
|
|
43
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
44
|
+
if (xData === undefined) {
|
|
45
|
+
throw new Error("MUI X Charts: ".concat(xAxisKey === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : "The x-axis with id \"".concat(xAxisKey, "\""), " should have data property to be able to display a line plot."));
|
|
46
|
+
}
|
|
47
|
+
if (xData.length < stackedData.length) {
|
|
48
|
+
throw new Error("MUI X Charts: The data length of the x axis (".concat(xData.length, " items) is lower than the length of series (").concat(stackedData.length, " items)."));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
var areaPath = d3Area().x(function (d) {
|
|
52
|
+
return xScale(d.x);
|
|
53
|
+
}).defined(function (_, i) {
|
|
54
|
+
return connectNulls || data[i] != null;
|
|
55
|
+
}).y0(function (d) {
|
|
56
|
+
return d.y && yScale(d.y[0]);
|
|
57
|
+
}).y1(function (d) {
|
|
58
|
+
return d.y && yScale(d.y[1]);
|
|
59
|
+
});
|
|
60
|
+
var curve = getCurveFactory(series[seriesId].curve);
|
|
61
|
+
var formattedData = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
|
|
62
|
+
return {
|
|
63
|
+
x: x,
|
|
64
|
+
y: stackedData[index]
|
|
65
|
+
};
|
|
66
|
+
})) != null ? _xData$map : [];
|
|
67
|
+
var d3Data = connectNulls ? formattedData.filter(function (_, i) {
|
|
68
|
+
return data[i] != null;
|
|
69
|
+
}) : formattedData;
|
|
70
|
+
var d = areaPath.curve(curve)(d3Data) || '';
|
|
71
|
+
return _extends({}, series[seriesId], {
|
|
72
|
+
d: d,
|
|
73
|
+
seriesId: seriesId
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
14
79
|
/**
|
|
15
80
|
* Demos:
|
|
16
81
|
*
|
|
@@ -25,72 +90,32 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
25
90
|
function AreaPlot(props) {
|
|
26
91
|
var slots = props.slots,
|
|
27
92
|
slotProps = props.slotProps,
|
|
93
|
+
onItemClick = props.onItemClick,
|
|
94
|
+
skipAnimation = props.skipAnimation,
|
|
28
95
|
other = _objectWithoutProperties(props, _excluded);
|
|
29
|
-
var
|
|
30
|
-
var axisData = React.useContext(CartesianContext);
|
|
31
|
-
if (seriesData === undefined) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
var series = seriesData.series,
|
|
35
|
-
stackingGroups = seriesData.stackingGroups;
|
|
36
|
-
var xAxis = axisData.xAxis,
|
|
37
|
-
yAxis = axisData.yAxis,
|
|
38
|
-
xAxisIds = axisData.xAxisIds,
|
|
39
|
-
yAxisIds = axisData.yAxisIds;
|
|
40
|
-
var defaultXAxisId = xAxisIds[0];
|
|
41
|
-
var defaultYAxisId = yAxisIds[0];
|
|
96
|
+
var completedData = useAggregatedData();
|
|
42
97
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
43
|
-
children:
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
var areaPath = d3Area().x(function (d) {
|
|
67
|
-
return xScale(d.x);
|
|
68
|
-
}).defined(function (_, i) {
|
|
69
|
-
return connectNulls || data[i] != null;
|
|
70
|
-
}).y0(function (d) {
|
|
71
|
-
return d.y && yScale(d.y[0]);
|
|
72
|
-
}).y1(function (d) {
|
|
73
|
-
return d.y && yScale(d.y[1]);
|
|
74
|
-
});
|
|
75
|
-
var curve = getCurveFactory(series[seriesId].curve);
|
|
76
|
-
var formattedData = (_xData$map = xData == null ? void 0 : xData.map(function (x, index) {
|
|
77
|
-
return {
|
|
78
|
-
x: x,
|
|
79
|
-
y: stackedData[index]
|
|
80
|
-
};
|
|
81
|
-
})) != null ? _xData$map : [];
|
|
82
|
-
var d3Data = connectNulls ? formattedData.filter(function (_, i) {
|
|
83
|
-
return data[i] != null;
|
|
84
|
-
}) : formattedData;
|
|
85
|
-
return !!series[seriesId].area && /*#__PURE__*/_jsx(AreaElement, {
|
|
86
|
-
id: seriesId,
|
|
87
|
-
d: areaPath.curve(curve)(d3Data) || undefined,
|
|
88
|
-
color: series[seriesId].color,
|
|
89
|
-
highlightScope: series[seriesId].highlightScope,
|
|
90
|
-
slots: slots,
|
|
91
|
-
slotProps: slotProps
|
|
92
|
-
}, seriesId);
|
|
93
|
-
});
|
|
98
|
+
children: completedData.reverse().map(function (_ref2) {
|
|
99
|
+
var d = _ref2.d,
|
|
100
|
+
seriesId = _ref2.seriesId,
|
|
101
|
+
color = _ref2.color,
|
|
102
|
+
highlightScope = _ref2.highlightScope,
|
|
103
|
+
area = _ref2.area;
|
|
104
|
+
return !!area && /*#__PURE__*/_jsx(AreaElement, {
|
|
105
|
+
id: seriesId,
|
|
106
|
+
d: d,
|
|
107
|
+
color: color,
|
|
108
|
+
highlightScope: highlightScope,
|
|
109
|
+
slots: slots,
|
|
110
|
+
slotProps: slotProps,
|
|
111
|
+
onClick: onItemClick && function (event) {
|
|
112
|
+
return onItemClick(event, {
|
|
113
|
+
type: 'line',
|
|
114
|
+
seriesId: seriesId
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
skipAnimation: skipAnimation
|
|
118
|
+
}, seriesId);
|
|
94
119
|
})
|
|
95
120
|
}));
|
|
96
121
|
}
|
|
@@ -99,6 +124,17 @@ process.env.NODE_ENV !== "production" ? AreaPlot.propTypes = {
|
|
|
99
124
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
100
125
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
101
126
|
// ----------------------------------------------------------------------
|
|
127
|
+
/**
|
|
128
|
+
* Callback fired when a line area item is clicked.
|
|
129
|
+
* @param {React.MouseEvent<SVGPathElement, MouseEvent>} event The event source of the callback.
|
|
130
|
+
* @param {LineItemIdentifier} lineItemIdentifier The line item identifier.
|
|
131
|
+
*/
|
|
132
|
+
onItemClick: PropTypes.func,
|
|
133
|
+
/**
|
|
134
|
+
* If `true`, animations are skipped.
|
|
135
|
+
* @default false
|
|
136
|
+
*/
|
|
137
|
+
skipAnimation: PropTypes.bool,
|
|
102
138
|
/**
|
|
103
139
|
* The props used for each component slot.
|
|
104
140
|
* @default {}
|
|
@@ -14,6 +14,7 @@ import { ChartsLegend } from '../ChartsLegend';
|
|
|
14
14
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
15
15
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
16
16
|
import { LineHighlightPlot } from './LineHighlightPlot';
|
|
17
|
+
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
20
|
/**
|
|
@@ -37,6 +38,10 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
37
38
|
dataset = props.dataset,
|
|
38
39
|
sx = props.sx,
|
|
39
40
|
tooltip = props.tooltip,
|
|
41
|
+
onAxisClick = props.onAxisClick,
|
|
42
|
+
onAreaClick = props.onAreaClick,
|
|
43
|
+
onLineClick = props.onLineClick,
|
|
44
|
+
onMarkClick = props.onMarkClick,
|
|
40
45
|
_props$axisHighlight = props.axisHighlight,
|
|
41
46
|
axisHighlight = _props$axisHighlight === void 0 ? {
|
|
42
47
|
x: 'line'
|
|
@@ -49,7 +54,8 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
49
54
|
bottomAxis = props.bottomAxis,
|
|
50
55
|
children = props.children,
|
|
51
56
|
slots = props.slots,
|
|
52
|
-
slotProps = props.slotProps
|
|
57
|
+
slotProps = props.slotProps,
|
|
58
|
+
skipAnimation = props.skipAnimation;
|
|
53
59
|
var id = useId();
|
|
54
60
|
var clipPathId = "".concat(id, "-clip-path");
|
|
55
61
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, {
|
|
@@ -79,15 +85,21 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
79
85
|
colors: colors,
|
|
80
86
|
dataset: dataset,
|
|
81
87
|
sx: sx,
|
|
82
|
-
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
|
|
83
|
-
children: [/*#__PURE__*/
|
|
88
|
+
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
|
|
89
|
+
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
90
|
+
onAxisClick: onAxisClick
|
|
91
|
+
}), /*#__PURE__*/_jsxs("g", {
|
|
84
92
|
clipPath: "url(#".concat(clipPathId, ")"),
|
|
85
93
|
children: [/*#__PURE__*/_jsx(AreaPlot, {
|
|
86
94
|
slots: slots,
|
|
87
|
-
slotProps: slotProps
|
|
95
|
+
slotProps: slotProps,
|
|
96
|
+
onItemClick: onAreaClick,
|
|
97
|
+
skipAnimation: skipAnimation
|
|
88
98
|
}), /*#__PURE__*/_jsx(LinePlot, {
|
|
89
99
|
slots: slots,
|
|
90
|
-
slotProps: slotProps
|
|
100
|
+
slotProps: slotProps,
|
|
101
|
+
onItemClick: onLineClick,
|
|
102
|
+
skipAnimation: skipAnimation
|
|
91
103
|
})]
|
|
92
104
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
93
105
|
topAxis: topAxis,
|
|
@@ -98,7 +110,9 @@ var LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
98
110
|
slotProps: slotProps
|
|
99
111
|
}), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlight)), /*#__PURE__*/_jsx(MarkPlot, {
|
|
100
112
|
slots: slots,
|
|
101
|
-
slotProps: slotProps
|
|
113
|
+
slotProps: slotProps,
|
|
114
|
+
onItemClick: onMarkClick,
|
|
115
|
+
skipAnimation: skipAnimation
|
|
102
116
|
}), /*#__PURE__*/_jsx(LineHighlightPlot, {
|
|
103
117
|
slots: slots,
|
|
104
118
|
slotProps: slotProps
|
|
@@ -237,6 +251,16 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
237
251
|
right: PropTypes.number,
|
|
238
252
|
top: PropTypes.number
|
|
239
253
|
}),
|
|
254
|
+
onAreaClick: PropTypes.func,
|
|
255
|
+
/**
|
|
256
|
+
* The function called for onClick events.
|
|
257
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
258
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
259
|
+
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
260
|
+
*/
|
|
261
|
+
onAxisClick: PropTypes.func,
|
|
262
|
+
onLineClick: PropTypes.func,
|
|
263
|
+
onMarkClick: PropTypes.func,
|
|
240
264
|
/**
|
|
241
265
|
* Indicate which axis to display the right of the charts.
|
|
242
266
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -265,6 +289,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
265
289
|
tickSize: PropTypes.number
|
|
266
290
|
}), PropTypes.string]),
|
|
267
291
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
292
|
+
/**
|
|
293
|
+
* If `true`, animations are skipped.
|
|
294
|
+
* @default false
|
|
295
|
+
*/
|
|
296
|
+
skipAnimation: PropTypes.bool,
|
|
268
297
|
/**
|
|
269
298
|
* The props used for each component slot.
|
|
270
299
|
* @default {}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
3
|
+
var _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);
|
|
@@ -26,38 +25,6 @@ var useUtilityClasses = function useUtilityClasses(ownerState) {
|
|
|
26
25
|
};
|
|
27
26
|
return composeClasses(slots, getLineElementUtilityClass, classes);
|
|
28
27
|
};
|
|
29
|
-
export var LineElementPath = styled('path', {
|
|
30
|
-
name: 'MuiLineElement',
|
|
31
|
-
slot: 'Root',
|
|
32
|
-
overridesResolver: function overridesResolver(_, styles) {
|
|
33
|
-
return styles.root;
|
|
34
|
-
}
|
|
35
|
-
})(function (_ref) {
|
|
36
|
-
var ownerState = _ref.ownerState;
|
|
37
|
-
return {
|
|
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
|
-
});
|
|
46
|
-
LineElementPath.propTypes = {
|
|
47
|
-
// ----------------------------- Warning --------------------------------
|
|
48
|
-
// | These PropTypes are generated from the TypeScript type definitions |
|
|
49
|
-
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
50
|
-
// ----------------------------------------------------------------------
|
|
51
|
-
as: PropTypes.elementType,
|
|
52
|
-
ownerState: PropTypes.shape({
|
|
53
|
-
classes: PropTypes.object,
|
|
54
|
-
color: PropTypes.string.isRequired,
|
|
55
|
-
id: PropTypes.string.isRequired,
|
|
56
|
-
isFaded: PropTypes.bool.isRequired,
|
|
57
|
-
isHighlighted: PropTypes.bool.isRequired
|
|
58
|
-
}).isRequired,
|
|
59
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
|
60
|
-
};
|
|
61
28
|
/**
|
|
62
29
|
* Demos:
|
|
63
30
|
*
|
|
@@ -76,6 +43,7 @@ function LineElement(props) {
|
|
|
76
43
|
highlightScope = props.highlightScope,
|
|
77
44
|
slots = props.slots,
|
|
78
45
|
slotProps = props.slotProps,
|
|
46
|
+
onClick = props.onClick,
|
|
79
47
|
other = _objectWithoutProperties(props, _excluded);
|
|
80
48
|
var getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
81
49
|
var _React$useContext = React.useContext(InteractionContext),
|
|
@@ -96,7 +64,7 @@ function LineElement(props) {
|
|
|
96
64
|
isHighlighted: isHighlighted
|
|
97
65
|
};
|
|
98
66
|
var classes = useUtilityClasses(ownerState);
|
|
99
|
-
var Line = (_slots$line = slots == null ? void 0 : slots.line) != null ? _slots$line :
|
|
67
|
+
var Line = (_slots$line = slots == null ? void 0 : slots.line) != null ? _slots$line : AnimatedLine;
|
|
100
68
|
var lineProps = useSlotProps({
|
|
101
69
|
elementType: Line,
|
|
102
70
|
externalSlotProps: slotProps == null ? void 0 : slotProps.line,
|
|
@@ -104,7 +72,9 @@ function LineElement(props) {
|
|
|
104
72
|
type: 'line',
|
|
105
73
|
seriesId: id
|
|
106
74
|
}), {
|
|
107
|
-
className: classes.root
|
|
75
|
+
className: classes.root,
|
|
76
|
+
onClick: onClick,
|
|
77
|
+
cursor: onClick ? 'pointer' : 'unset'
|
|
108
78
|
}),
|
|
109
79
|
ownerState: ownerState
|
|
110
80
|
});
|
|
@@ -116,10 +86,18 @@ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
|
|
|
116
86
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
117
87
|
// ----------------------------------------------------------------------
|
|
118
88
|
classes: PropTypes.object,
|
|
89
|
+
color: PropTypes.string.isRequired,
|
|
90
|
+
d: PropTypes.string.isRequired,
|
|
119
91
|
highlightScope: PropTypes.shape({
|
|
120
92
|
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
121
93
|
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
122
94
|
}),
|
|
95
|
+
id: PropTypes.string.isRequired,
|
|
96
|
+
/**
|
|
97
|
+
* If `true`, animations are skipped.
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
skipAnimation: PropTypes.bool,
|
|
123
101
|
/**
|
|
124
102
|
* The props used for each component slot.
|
|
125
103
|
* @default {}
|
|
@@ -59,13 +59,14 @@ function LineHighlightElement(props) {
|
|
|
59
59
|
y: y
|
|
60
60
|
};
|
|
61
61
|
var classes = useUtilityClasses(ownerState);
|
|
62
|
-
return /*#__PURE__*/_jsx(HighlightElement, _extends({
|
|
62
|
+
return /*#__PURE__*/_jsx(HighlightElement, _extends({
|
|
63
|
+
pointerEvents: "none",
|
|
63
64
|
ownerState: ownerState,
|
|
64
65
|
className: classes.root,
|
|
65
66
|
cx: 0,
|
|
66
67
|
cy: 0,
|
|
67
68
|
r: other.r === undefined ? 5 : other.r
|
|
68
|
-
}));
|
|
69
|
+
}, other));
|
|
69
70
|
}
|
|
70
71
|
process.env.NODE_ENV !== "production" ? LineHighlightElement.propTypes = {
|
|
71
72
|
// ----------------------------- Warning --------------------------------
|