@mui/x-charts 7.1.1 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +32 -2
- package/BarChart/BarPlot.js +12 -5
- package/BarChart/extremums.js +1 -1
- package/BarChart/getColor.d.ts +3 -0
- package/BarChart/getColor.js +33 -0
- package/CHANGELOG.md +211 -0
- package/ChartContainer/ChartContainer.js +35 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsClipPath/ChartsClipPath.js +2 -2
- package/ChartsLegend/ChartsLegend.js +2 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +4 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -2
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +6 -0
- package/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -3
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +13 -4
- package/ChartsTooltip/utils.d.ts +5 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/ChartsXAxis/ChartsXAxis.js +7 -7
- package/ChartsYAxis/ChartsYAxis.js +9 -6
- package/Gauge/GaugeProvider.js +5 -5
- package/LineChart/AnimatedArea.js +6 -5
- package/LineChart/AnimatedLine.js +7 -5
- package/LineChart/AreaElement.d.ts +1 -0
- package/LineChart/AreaElement.js +4 -1
- package/LineChart/AreaPlot.js +7 -1
- package/LineChart/LineChart.js +32 -2
- package/LineChart/LineElement.d.ts +1 -0
- package/LineChart/LineElement.js +4 -1
- package/LineChart/LineHighlightPlot.js +4 -1
- package/LineChart/LinePlot.js +7 -1
- package/LineChart/MarkPlot.js +5 -5
- package/LineChart/getColor.d.ts +3 -0
- package/LineChart/getColor.js +31 -0
- package/PieChart/PieChart.js +32 -2
- package/PieChart/PiePlot.js +26 -6
- package/PieChart/formatter.js +4 -2
- package/PieChart/getColor.d.ts +2 -0
- package/PieChart/getColor.js +11 -0
- package/PieChart/getPieCoordinates.d.ts +7 -0
- package/PieChart/getPieCoordinates.js +25 -0
- package/PieChart/index.d.ts +1 -0
- package/PieChart/index.js +11 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -2
- package/ScatterChart/Scatter.d.ts +1 -0
- package/ScatterChart/Scatter.js +6 -3
- package/ScatterChart/ScatterChart.js +32 -2
- package/ScatterChart/ScatterPlot.js +3 -0
- package/ScatterChart/getColor.d.ts +3 -0
- package/ScatterChart/getColor.js +31 -0
- package/SparkLineChart/SparkLineChart.js +15 -0
- package/context/CartesianContextProvider.d.ts +2 -2
- package/context/CartesianContextProvider.js +23 -8
- package/esm/BarChart/BarChart.js +32 -2
- package/esm/BarChart/BarPlot.js +13 -5
- package/esm/BarChart/extremums.js +1 -1
- package/esm/BarChart/getColor.js +27 -0
- package/esm/ChartContainer/ChartContainer.js +36 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsClipPath/ChartsClipPath.js +2 -2
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -2
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -3
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +13 -4
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/esm/ChartsXAxis/ChartsXAxis.js +7 -7
- package/esm/ChartsYAxis/ChartsYAxis.js +9 -6
- package/esm/Gauge/GaugeProvider.js +5 -5
- package/esm/LineChart/AnimatedArea.js +6 -5
- package/esm/LineChart/AnimatedLine.js +7 -5
- package/esm/LineChart/AreaElement.js +4 -1
- package/esm/LineChart/AreaPlot.js +7 -1
- package/esm/LineChart/LineChart.js +32 -2
- package/esm/LineChart/LineElement.js +4 -1
- package/esm/LineChart/LineHighlightPlot.js +4 -1
- package/esm/LineChart/LinePlot.js +7 -1
- package/esm/LineChart/MarkPlot.js +5 -5
- package/esm/LineChart/getColor.js +25 -0
- package/esm/PieChart/PieChart.js +32 -2
- package/esm/PieChart/PiePlot.js +26 -6
- package/esm/PieChart/formatter.js +4 -2
- package/esm/PieChart/getColor.js +5 -0
- package/esm/PieChart/getPieCoordinates.js +19 -0
- package/esm/PieChart/index.js +2 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -2
- package/esm/ScatterChart/Scatter.js +6 -3
- package/esm/ScatterChart/ScatterChart.js +32 -2
- package/esm/ScatterChart/ScatterPlot.js +3 -0
- package/esm/ScatterChart/getColor.js +25 -0
- package/esm/SparkLineChart/SparkLineChart.js +15 -0
- package/esm/context/CartesianContextProvider.js +23 -8
- package/esm/hooks/index.js +4 -1
- package/esm/hooks/useAxisEvents.js +7 -6
- package/esm/hooks/useChartId.js +8 -0
- package/esm/hooks/useSeries.js +64 -0
- package/esm/hooks/useSvgRef.js +9 -0
- package/esm/internals/colorGetter.js +22 -0
- package/esm/internals/colorScale.js +16 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +96 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +41 -0
- package/esm/internals/components/ChartsAxesGradients/index.js +1 -0
- package/esm/models/colorMapping.js +1 -0
- package/esm/models/seriesType/index.js +6 -1
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +65 -1
- package/hooks/useAxisEvents.js +7 -6
- package/hooks/useChartId.d.ts +1 -0
- package/hooks/useChartId.js +16 -0
- package/hooks/useSeries.d.ts +45 -0
- package/hooks/useSeries.js +75 -0
- package/hooks/useSvgRef.d.ts +2 -0
- package/hooks/useSvgRef.js +17 -0
- package/hooks/useTicks.d.ts +1 -1
- package/index.js +1 -1
- package/internals/colorGetter.d.ts +5 -0
- package/internals/colorGetter.js +29 -0
- package/internals/colorScale.d.ts +5 -0
- package/internals/colorScale.js +24 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +3 -0
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +105 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +13 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +63 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +12 -0
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +48 -0
- package/internals/components/ChartsAxesGradients/index.d.ts +1 -0
- package/internals/components/ChartsAxesGradients/index.js +16 -0
- package/internals/defaultizeColor.d.ts +4 -4
- package/internals/defaultizeValueFormatter.d.ts +5 -5
- package/internals/getScale.d.ts +2 -2
- package/models/axis.d.ts +44 -4
- package/models/colorMapping.d.ts +45 -0
- package/models/colorMapping.js +5 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/common.d.ts +10 -2
- package/models/seriesType/index.d.ts +2 -0
- package/models/seriesType/index.js +17 -1
- package/modern/BarChart/BarChart.js +32 -2
- package/modern/BarChart/BarPlot.js +13 -5
- package/modern/BarChart/extremums.js +1 -1
- package/modern/BarChart/getColor.js +27 -0
- package/modern/ChartContainer/ChartContainer.js +36 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsClipPath/ChartsClipPath.js +2 -2
- package/modern/ChartsLegend/ChartsLegend.js +2 -2
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -2
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -1
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +6 -3
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +13 -4
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +6 -6
- package/modern/ChartsXAxis/ChartsXAxis.js +7 -7
- package/modern/ChartsYAxis/ChartsYAxis.js +9 -6
- package/modern/Gauge/GaugeProvider.js +5 -5
- package/modern/LineChart/AnimatedArea.js +6 -5
- package/modern/LineChart/AnimatedLine.js +7 -5
- package/modern/LineChart/AreaElement.js +4 -1
- package/modern/LineChart/AreaPlot.js +7 -1
- package/modern/LineChart/LineChart.js +32 -2
- package/modern/LineChart/LineElement.js +4 -1
- package/modern/LineChart/LineHighlightPlot.js +4 -1
- package/modern/LineChart/LinePlot.js +7 -1
- package/modern/LineChart/MarkPlot.js +5 -5
- package/modern/LineChart/getColor.js +25 -0
- package/modern/PieChart/PieChart.js +32 -2
- package/modern/PieChart/PiePlot.js +26 -6
- package/modern/PieChart/formatter.js +4 -2
- package/modern/PieChart/getColor.js +5 -0
- package/modern/PieChart/getPieCoordinates.js +19 -0
- package/modern/PieChart/index.js +2 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +32 -2
- package/modern/ScatterChart/Scatter.js +6 -3
- package/modern/ScatterChart/ScatterChart.js +32 -2
- package/modern/ScatterChart/ScatterPlot.js +3 -0
- package/modern/ScatterChart/getColor.js +25 -0
- package/modern/SparkLineChart/SparkLineChart.js +15 -0
- package/modern/context/CartesianContextProvider.js +23 -8
- package/modern/hooks/index.js +4 -1
- package/modern/hooks/useAxisEvents.js +7 -6
- package/modern/hooks/useChartId.js +8 -0
- package/modern/hooks/useSeries.js +64 -0
- package/modern/hooks/useSvgRef.js +9 -0
- package/modern/index.js +1 -1
- package/modern/internals/colorGetter.js +22 -0
- package/modern/internals/colorScale.js +16 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +96 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +55 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +41 -0
- package/modern/internals/components/ChartsAxesGradients/index.js +1 -0
- package/modern/models/colorMapping.js +1 -0
- package/modern/models/seriesType/index.js +6 -1
- package/package.json +1 -1
|
@@ -49,10 +49,13 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
49
49
|
id,
|
|
50
50
|
label,
|
|
51
51
|
valueFormatter,
|
|
52
|
-
data
|
|
52
|
+
data,
|
|
53
|
+
getColor
|
|
53
54
|
}) => {
|
|
54
55
|
// @ts-ignore
|
|
55
|
-
const formattedValue = valueFormatter(data[dataIndex] ?? null
|
|
56
|
+
const formattedValue = valueFormatter(data[dataIndex] ?? null, {
|
|
57
|
+
dataIndex
|
|
58
|
+
});
|
|
56
59
|
if (formattedValue == null) {
|
|
57
60
|
return null;
|
|
58
61
|
}
|
|
@@ -62,7 +65,7 @@ function DefaultChartsAxisTooltipContent(props) {
|
|
|
62
65
|
className: (0, _clsx.default)(classes.markCell, classes.cell),
|
|
63
66
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipMark, {
|
|
64
67
|
ownerState: {
|
|
65
|
-
color
|
|
68
|
+
color: getColor(dataIndex) ?? color
|
|
66
69
|
},
|
|
67
70
|
boxShadow: 1,
|
|
68
71
|
className: classes.mark
|
|
@@ -17,7 +17,8 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
17
17
|
series,
|
|
18
18
|
itemData,
|
|
19
19
|
sx,
|
|
20
|
-
classes
|
|
20
|
+
classes,
|
|
21
|
+
getColor
|
|
21
22
|
} = props;
|
|
22
23
|
if (itemData.dataIndex === undefined || !series.data[itemData.dataIndex]) {
|
|
23
24
|
return null;
|
|
@@ -26,14 +27,16 @@ function DefaultChartsItemTooltipContent(props) {
|
|
|
26
27
|
displayedLabel,
|
|
27
28
|
color
|
|
28
29
|
} = series.type === 'pie' ? {
|
|
29
|
-
color:
|
|
30
|
+
color: getColor(itemData.dataIndex),
|
|
30
31
|
displayedLabel: series.data[itemData.dataIndex].label
|
|
31
32
|
} : {
|
|
32
|
-
color: series.color,
|
|
33
|
+
color: getColor(itemData.dataIndex) ?? series.color,
|
|
33
34
|
displayedLabel: series.label
|
|
34
35
|
};
|
|
35
36
|
const value = series.data[itemData.dataIndex];
|
|
36
|
-
const formattedValue = series.valueFormatter?.(value
|
|
37
|
+
const formattedValue = series.valueFormatter?.(value, {
|
|
38
|
+
dataIndex: itemData.dataIndex
|
|
39
|
+
});
|
|
37
40
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipPaper, {
|
|
38
41
|
sx: sx,
|
|
39
42
|
className: classes.root,
|
|
@@ -71,6 +74,12 @@ process.env.NODE_ENV !== "production" ? DefaultChartsItemTooltipContent.propType
|
|
|
71
74
|
* Override or extend the styles applied to the component.
|
|
72
75
|
*/
|
|
73
76
|
classes: _propTypes.default.object.isRequired,
|
|
77
|
+
/**
|
|
78
|
+
* Get the color of the item with index `dataIndex`.
|
|
79
|
+
* @param {number} dataIndex The data index of the item.
|
|
80
|
+
* @returns {string} The color to display.
|
|
81
|
+
*/
|
|
82
|
+
getColor: _propTypes.default.func.isRequired,
|
|
74
83
|
/**
|
|
75
84
|
* The data used to identify the triggered item.
|
|
76
85
|
*/
|
package/ChartsTooltip/utils.d.ts
CHANGED
|
@@ -23,5 +23,9 @@ export declare function useMouseTracker(): {
|
|
|
23
23
|
export type TriggerOptions = 'item' | 'axis' | 'none';
|
|
24
24
|
export declare function getTooltipHasData(trigger: TriggerOptions, displayedData: null | AxisInteractionData | ItemInteractionData<ChartSeriesType>): boolean;
|
|
25
25
|
export declare function isCartesianSeriesType(seriesType: string): seriesType is CartesianChartSeriesType;
|
|
26
|
-
export declare function isCartesianSeries(series: ChartSeriesDefaultized<ChartSeriesType>
|
|
26
|
+
export declare function isCartesianSeries(series: ChartSeriesDefaultized<ChartSeriesType> & {
|
|
27
|
+
getColor: (dataIndex: number) => string;
|
|
28
|
+
}): series is ChartSeriesDefaultized<CartesianChartSeriesType> & {
|
|
29
|
+
getColor: (dataIndex: number) => string;
|
|
30
|
+
};
|
|
27
31
|
export declare function utcFormatter(v: string | number | Date): string;
|
|
@@ -11,10 +11,10 @@ var _d3Delaunay = require("d3-delaunay");
|
|
|
11
11
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
12
12
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
13
13
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
14
|
-
var _DrawingProvider = require("../context/DrawingProvider");
|
|
15
14
|
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
16
15
|
var _useScale = require("../hooks/useScale");
|
|
17
16
|
var _utils = require("../internals/utils");
|
|
17
|
+
var _hooks = require("../hooks");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -23,13 +23,13 @@ function ChartsVoronoiHandler(props) {
|
|
|
23
23
|
voronoiMaxRadius,
|
|
24
24
|
onItemClick
|
|
25
25
|
} = props;
|
|
26
|
-
const svgRef =
|
|
26
|
+
const svgRef = (0, _hooks.useSvgRef)();
|
|
27
27
|
const {
|
|
28
|
-
|
|
29
|
-
height,
|
|
28
|
+
left,
|
|
30
29
|
top,
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
width,
|
|
31
|
+
height
|
|
32
|
+
} = (0, _hooks.useDrawingArea)();
|
|
33
33
|
const {
|
|
34
34
|
xAxis,
|
|
35
35
|
yAxis,
|
|
@@ -13,13 +13,13 @@ var _utils = require("@mui/base/utils");
|
|
|
13
13
|
var _utils2 = require("@mui/utils");
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
15
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
16
|
-
var _DrawingProvider = require("../context/DrawingProvider");
|
|
17
16
|
var _useTicks = require("../hooks/useTicks");
|
|
18
17
|
var _axisClasses = require("../ChartsAxis/axisClasses");
|
|
19
18
|
var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
|
|
20
19
|
var _ChartsText = require("../ChartsText");
|
|
21
20
|
var _geometry = require("../internals/geometry");
|
|
22
21
|
var _useMounted = require("../hooks/useMounted");
|
|
22
|
+
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
23
23
|
var _getWordsByLines = require("../internals/getWordsByLines");
|
|
24
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
25
|
const _excluded = ["scale", "tickNumber", "reverse"];
|
|
@@ -71,7 +71,7 @@ function addLabelDimension(xTicks, {
|
|
|
71
71
|
|
|
72
72
|
// Filter label to avoid overlap
|
|
73
73
|
let currentTextLimit = 0;
|
|
74
|
-
let
|
|
74
|
+
let previousTextLimit = 0;
|
|
75
75
|
const direction = reverse ? -1 : 1;
|
|
76
76
|
return withDimension.map((item, labelIndex) => {
|
|
77
77
|
const {
|
|
@@ -85,14 +85,14 @@ function addLabelDimension(xTicks, {
|
|
|
85
85
|
const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
|
|
86
86
|
|
|
87
87
|
currentTextLimit = textPosition - direction * (gapRatio * distance) / 2;
|
|
88
|
-
if (labelIndex > 0 && direction * currentTextLimit < direction *
|
|
88
|
+
if (labelIndex > 0 && direction * currentTextLimit < direction * previousTextLimit) {
|
|
89
89
|
// Except for the first label, we skip all label that overlap with the last accepted.
|
|
90
|
-
// Notice that the early return prevents `
|
|
90
|
+
// Notice that the early return prevents `previousTextLimit` from being updated.
|
|
91
91
|
return (0, _extends2.default)({}, item, {
|
|
92
92
|
skipLabel: true
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
previousTextLimit = textPosition + direction * (gapRatio * distance) / 2;
|
|
96
96
|
return item;
|
|
97
97
|
});
|
|
98
98
|
}
|
|
@@ -161,7 +161,7 @@ function ChartsXAxis(inProps) {
|
|
|
161
161
|
top,
|
|
162
162
|
width,
|
|
163
163
|
height
|
|
164
|
-
} =
|
|
164
|
+
} = (0, _useDrawingArea.useDrawingArea)();
|
|
165
165
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
166
166
|
const positionSign = position === 'bottom' ? 1 : -1;
|
|
167
167
|
const Line = slots?.axisLine ?? 'line';
|
|
@@ -354,7 +354,7 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
354
354
|
*/
|
|
355
355
|
tickMinStep: _propTypes.default.number,
|
|
356
356
|
/**
|
|
357
|
-
* The number of ticks. This number is not
|
|
357
|
+
* The number of ticks. This number is not guaranteed.
|
|
358
358
|
* Not supported by categorical axis (band, points).
|
|
359
359
|
*/
|
|
360
360
|
tickNumber: _propTypes.default.number,
|
|
@@ -13,8 +13,8 @@ var _utils = require("@mui/base/utils");
|
|
|
13
13
|
var _utils2 = require("@mui/utils");
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
15
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
16
|
-
var _DrawingProvider = require("../context/DrawingProvider");
|
|
17
16
|
var _useTicks = require("../hooks/useTicks");
|
|
17
|
+
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
18
18
|
var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
|
|
19
19
|
var _ChartsText = require("../ChartsText");
|
|
20
20
|
var _axisClasses = require("../ChartsAxis/axisClasses");
|
|
@@ -90,7 +90,8 @@ function ChartsYAxis(inProps) {
|
|
|
90
90
|
slotProps,
|
|
91
91
|
tickPlacement,
|
|
92
92
|
tickLabelPlacement,
|
|
93
|
-
tickInterval
|
|
93
|
+
tickInterval,
|
|
94
|
+
tickLabelInterval
|
|
94
95
|
} = defaultizedProps;
|
|
95
96
|
const theme = (0, _styles.useTheme)();
|
|
96
97
|
const classes = useUtilityClasses((0, _extends2.default)({}, defaultizedProps, {
|
|
@@ -101,7 +102,7 @@ function ChartsYAxis(inProps) {
|
|
|
101
102
|
top,
|
|
102
103
|
width,
|
|
103
104
|
height
|
|
104
|
-
} =
|
|
105
|
+
} = (0, _useDrawingArea.useDrawingArea)();
|
|
105
106
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
106
107
|
const yTicks = (0, _useTicks.useTicks)({
|
|
107
108
|
scale: yScale,
|
|
@@ -156,17 +157,19 @@ function ChartsYAxis(inProps) {
|
|
|
156
157
|
}, slotProps?.axisLine)), yTicks.map(({
|
|
157
158
|
formattedValue,
|
|
158
159
|
offset,
|
|
159
|
-
labelOffset
|
|
160
|
+
labelOffset,
|
|
161
|
+
value
|
|
160
162
|
}, index) => {
|
|
161
163
|
const xTickLabel = positionSign * (tickSize + 2);
|
|
162
164
|
const yTickLabel = labelOffset;
|
|
165
|
+
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
163
166
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
164
167
|
transform: `translate(0, ${offset})`,
|
|
165
168
|
className: classes.tickContainer,
|
|
166
169
|
children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tick, (0, _extends2.default)({
|
|
167
170
|
x2: positionSign * tickSize,
|
|
168
171
|
className: classes.tick
|
|
169
|
-
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
|
|
172
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
|
|
170
173
|
x: xTickLabel,
|
|
171
174
|
y: yTickLabel,
|
|
172
175
|
text: formattedValue.toString()
|
|
@@ -286,7 +289,7 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
286
289
|
*/
|
|
287
290
|
tickMinStep: _propTypes.default.number,
|
|
288
291
|
/**
|
|
289
|
-
* The number of ticks. This number is not
|
|
292
|
+
* The number of ticks. This number is not guaranteed.
|
|
290
293
|
* Not supported by categorical axis (band, points).
|
|
291
294
|
*/
|
|
292
295
|
tickNumber: _propTypes.default.number,
|
package/Gauge/GaugeProvider.js
CHANGED
|
@@ -7,9 +7,9 @@ exports.GaugeContext = void 0;
|
|
|
7
7
|
exports.GaugeProvider = GaugeProvider;
|
|
8
8
|
exports.useGaugeState = useGaugeState;
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _DrawingProvider = require("../context/DrawingProvider");
|
|
11
10
|
var _utils = require("../internals/utils");
|
|
12
11
|
var _utils2 = require("./utils");
|
|
12
|
+
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -47,11 +47,11 @@ function GaugeProvider(props) {
|
|
|
47
47
|
children
|
|
48
48
|
} = props;
|
|
49
49
|
const {
|
|
50
|
-
|
|
51
|
-
height,
|
|
50
|
+
left,
|
|
52
51
|
top,
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
width,
|
|
53
|
+
height
|
|
54
|
+
} = (0, _useDrawingArea.useDrawingArea)();
|
|
55
55
|
const ratios = (0, _utils2.getArcRatios)(startAngle, endAngle);
|
|
56
56
|
const innerCx = cxParam ? (0, _utils.getPercentageValue)(cxParam, width) : ratios.cx * width;
|
|
57
57
|
const innerCy = cyParam ? (0, _utils.getPercentageValue)(cyParam, height) : ratios.cy * height;
|
|
@@ -14,8 +14,8 @@ var _styles = require("@mui/material/styles");
|
|
|
14
14
|
var _d3Color = require("d3-color");
|
|
15
15
|
var _web = require("@react-spring/web");
|
|
16
16
|
var _useAnimatedPath = require("../internals/useAnimatedPath");
|
|
17
|
-
var _DrawingProvider = require("../context/DrawingProvider");
|
|
18
17
|
var _utils = require("../internals/utils");
|
|
18
|
+
var _hooks = require("../hooks");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
const _excluded = ["d", "skipAnimation", "ownerState"];
|
|
21
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -28,7 +28,7 @@ const AreaElementPath = exports.AreaElementPath = (0, _styles.styled)(_web.anima
|
|
|
28
28
|
ownerState
|
|
29
29
|
}) => ({
|
|
30
30
|
stroke: 'none',
|
|
31
|
-
fill: ownerState.isHighlighted
|
|
31
|
+
fill: ownerState.gradientId && `url(#${ownerState.gradientId})` || ownerState.isHighlighted && (0, _d3Color.color)(ownerState.color).brighter(1).formatHex() || (0, _d3Color.color)(ownerState.color).brighter(0.5).formatHex(),
|
|
32
32
|
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
33
33
|
opacity: ownerState.isFaded ? 0.3 : 1
|
|
34
34
|
}));
|
|
@@ -55,9 +55,9 @@ function AnimatedArea(props) {
|
|
|
55
55
|
right,
|
|
56
56
|
bottom,
|
|
57
57
|
width,
|
|
58
|
-
height
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
height
|
|
59
|
+
} = (0, _hooks.useDrawingArea)();
|
|
60
|
+
const chartId = (0, _hooks.useChartId)();
|
|
61
61
|
const path = (0, _useAnimatedPath.useAnimatedPath)(d, skipAnimation);
|
|
62
62
|
const {
|
|
63
63
|
animatedWidth
|
|
@@ -99,6 +99,7 @@ process.env.NODE_ENV !== "production" ? AnimatedArea.propTypes = {
|
|
|
99
99
|
ownerState: _propTypes.default.shape({
|
|
100
100
|
classes: _propTypes.default.object,
|
|
101
101
|
color: _propTypes.default.string.isRequired,
|
|
102
|
+
gradientId: _propTypes.default.string,
|
|
102
103
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
103
104
|
isFaded: _propTypes.default.bool.isRequired,
|
|
104
105
|
isHighlighted: _propTypes.default.bool.isRequired
|
|
@@ -14,8 +14,9 @@ var _web = require("@react-spring/web");
|
|
|
14
14
|
var _d3Color = require("d3-color");
|
|
15
15
|
var _styles = require("@mui/material/styles");
|
|
16
16
|
var _useAnimatedPath = require("../internals/useAnimatedPath");
|
|
17
|
-
var _DrawingProvider = require("../context/DrawingProvider");
|
|
18
17
|
var _utils = require("../internals/utils");
|
|
18
|
+
var _useChartId = require("../hooks/useChartId");
|
|
19
|
+
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
const _excluded = ["d", "skipAnimation", "ownerState"];
|
|
21
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -30,7 +31,7 @@ const LineElementPath = exports.LineElementPath = (0, _styles.styled)(_web.anima
|
|
|
30
31
|
strokeWidth: 2,
|
|
31
32
|
strokeLinejoin: 'round',
|
|
32
33
|
fill: 'none',
|
|
33
|
-
stroke: ownerState.isHighlighted
|
|
34
|
+
stroke: ownerState.gradientId && `url(#${ownerState.gradientId})` || ownerState.isHighlighted && (0, _d3Color.color)(ownerState.color).brighter(0.5).formatHex() || ownerState.color,
|
|
34
35
|
transition: 'opacity 0.2s ease-in, stroke 0.2s ease-in',
|
|
35
36
|
opacity: ownerState.isFaded ? 0.3 : 1
|
|
36
37
|
}));
|
|
@@ -57,9 +58,9 @@ function AnimatedLine(props) {
|
|
|
57
58
|
bottom,
|
|
58
59
|
width,
|
|
59
60
|
height,
|
|
60
|
-
right
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
right
|
|
62
|
+
} = (0, _useDrawingArea.useDrawingArea)();
|
|
63
|
+
const chartId = (0, _useChartId.useChartId)();
|
|
63
64
|
const path = (0, _useAnimatedPath.useAnimatedPath)(d, skipAnimation);
|
|
64
65
|
const {
|
|
65
66
|
animatedWidth
|
|
@@ -101,6 +102,7 @@ process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
|
|
|
101
102
|
ownerState: _propTypes.default.shape({
|
|
102
103
|
classes: _propTypes.default.object,
|
|
103
104
|
color: _propTypes.default.string.isRequired,
|
|
105
|
+
gradientId: _propTypes.default.string,
|
|
104
106
|
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
105
107
|
isFaded: _propTypes.default.bool.isRequired,
|
|
106
108
|
isHighlighted: _propTypes.default.bool.isRequired
|
package/LineChart/AreaElement.js
CHANGED
|
@@ -19,7 +19,7 @@ var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
|
19
19
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
20
20
|
var _AnimatedArea = require("./AnimatedArea");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps", "onClick"];
|
|
22
|
+
const _excluded = ["id", "classes", "color", "gradientId", "highlightScope", "slots", "slotProps", "onClick"];
|
|
23
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
24
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
25
|
function getAreaElementUtilityClass(slot) {
|
|
@@ -53,6 +53,7 @@ function AreaElement(props) {
|
|
|
53
53
|
id,
|
|
54
54
|
classes: innerClasses,
|
|
55
55
|
color,
|
|
56
|
+
gradientId,
|
|
56
57
|
highlightScope,
|
|
57
58
|
slots,
|
|
58
59
|
slotProps,
|
|
@@ -75,6 +76,7 @@ function AreaElement(props) {
|
|
|
75
76
|
id,
|
|
76
77
|
classes: innerClasses,
|
|
77
78
|
color,
|
|
79
|
+
gradientId,
|
|
78
80
|
isFaded,
|
|
79
81
|
isHighlighted
|
|
80
82
|
};
|
|
@@ -103,6 +105,7 @@ process.env.NODE_ENV !== "production" ? AreaElement.propTypes = {
|
|
|
103
105
|
classes: _propTypes.default.object,
|
|
104
106
|
color: _propTypes.default.string.isRequired,
|
|
105
107
|
d: _propTypes.default.string.isRequired,
|
|
108
|
+
gradientId: _propTypes.default.string,
|
|
106
109
|
highlightScope: _propTypes.default.shape({
|
|
107
110
|
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
108
111
|
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
package/LineChart/AreaPlot.js
CHANGED
|
@@ -16,6 +16,7 @@ var _AreaElement = require("./AreaElement");
|
|
|
16
16
|
var _useScale = require("../hooks/useScale");
|
|
17
17
|
var _getCurve = _interopRequireDefault(require("../internals/getCurve"));
|
|
18
18
|
var _constants = require("../constants");
|
|
19
|
+
var _ChartsAxesGradients = require("../internals/components/ChartsAxesGradients");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
|
|
21
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -52,6 +53,7 @@ const useAggregatedData = () => {
|
|
|
52
53
|
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisKey].scale);
|
|
53
54
|
const yScale = yAxis[yAxisKey].scale;
|
|
54
55
|
const xData = xAxis[xAxisKey].data;
|
|
56
|
+
const gradientUsed = yAxis[yAxisKey].colorScale && [yAxisKey, 'y'] || xAxis[xAxisKey].colorScale && [xAxisKey, 'x'] || undefined;
|
|
55
57
|
if (process.env.NODE_ENV !== 'production') {
|
|
56
58
|
if (xData === undefined) {
|
|
57
59
|
throw new Error(`MUI X Charts: ${xAxisKey === _constants.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.`);
|
|
@@ -69,6 +71,7 @@ const useAggregatedData = () => {
|
|
|
69
71
|
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
70
72
|
const d = areaPath.curve(curve)(d3Data) || '';
|
|
71
73
|
return (0, _extends2.default)({}, series[seriesId], {
|
|
74
|
+
gradientUsed,
|
|
72
75
|
d,
|
|
73
76
|
seriesId
|
|
74
77
|
});
|
|
@@ -95,6 +98,7 @@ function AreaPlot(props) {
|
|
|
95
98
|
skipAnimation
|
|
96
99
|
} = props,
|
|
97
100
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
101
|
+
const getGradientId = (0, _ChartsAxesGradients.useChartGradient)();
|
|
98
102
|
const completedData = useAggregatedData();
|
|
99
103
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", (0, _extends2.default)({}, other, {
|
|
100
104
|
children: completedData.reverse().map(({
|
|
@@ -102,11 +106,13 @@ function AreaPlot(props) {
|
|
|
102
106
|
seriesId,
|
|
103
107
|
color,
|
|
104
108
|
highlightScope,
|
|
105
|
-
area
|
|
109
|
+
area,
|
|
110
|
+
gradientUsed
|
|
106
111
|
}) => !!area && /*#__PURE__*/(0, _jsxRuntime.jsx)(_AreaElement.AreaElement, {
|
|
107
112
|
id: seriesId,
|
|
108
113
|
d: d,
|
|
109
114
|
color: color,
|
|
115
|
+
gradientId: gradientUsed && getGradientId(...gradientUsed),
|
|
110
116
|
highlightScope: highlightScope,
|
|
111
117
|
slots: slots,
|
|
112
118
|
slotProps: slotProps,
|
package/LineChart/LineChart.js
CHANGED
|
@@ -387,11 +387,26 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
387
387
|
width: _propTypes.default.number,
|
|
388
388
|
/**
|
|
389
389
|
* The configuration of the x-axes.
|
|
390
|
-
* If not provided, a default axis config is used
|
|
390
|
+
* If not provided, a default axis config is used.
|
|
391
391
|
*/
|
|
392
392
|
xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
393
393
|
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
394
394
|
classes: _propTypes.default.object,
|
|
395
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
396
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
397
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
398
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
399
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
400
|
+
}), _propTypes.default.shape({
|
|
401
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
402
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
403
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
404
|
+
}), _propTypes.default.shape({
|
|
405
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
406
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
407
|
+
unknownColor: _propTypes.default.string,
|
|
408
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
409
|
+
})]),
|
|
395
410
|
data: _propTypes.default.array,
|
|
396
411
|
dataKey: _propTypes.default.string,
|
|
397
412
|
disableLine: _propTypes.default.bool,
|
|
@@ -424,11 +439,26 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
424
439
|
})),
|
|
425
440
|
/**
|
|
426
441
|
* The configuration of the y-axes.
|
|
427
|
-
* If not provided, a default axis config is used
|
|
442
|
+
* If not provided, a default axis config is used.
|
|
428
443
|
*/
|
|
429
444
|
yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
430
445
|
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
431
446
|
classes: _propTypes.default.object,
|
|
447
|
+
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
448
|
+
color: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string.isRequired), _propTypes.default.func]).isRequired,
|
|
449
|
+
max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
450
|
+
min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]),
|
|
451
|
+
type: _propTypes.default.oneOf(['continuous']).isRequired
|
|
452
|
+
}), _propTypes.default.shape({
|
|
453
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
454
|
+
thresholds: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]).isRequired).isRequired,
|
|
455
|
+
type: _propTypes.default.oneOf(['piecewise']).isRequired
|
|
456
|
+
}), _propTypes.default.shape({
|
|
457
|
+
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
458
|
+
type: _propTypes.default.oneOf(['ordinal']).isRequired,
|
|
459
|
+
unknownColor: _propTypes.default.string,
|
|
460
|
+
values: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]).isRequired)
|
|
461
|
+
})]),
|
|
432
462
|
data: _propTypes.default.array,
|
|
433
463
|
dataKey: _propTypes.default.string,
|
|
434
464
|
disableLine: _propTypes.default.bool,
|
package/LineChart/LineElement.js
CHANGED
|
@@ -19,7 +19,7 @@ var _InteractionProvider = require("../context/InteractionProvider");
|
|
|
19
19
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
20
20
|
var _AnimatedLine = require("./AnimatedLine");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps", "onClick"];
|
|
22
|
+
const _excluded = ["id", "classes", "color", "gradientId", "highlightScope", "slots", "slotProps", "onClick"];
|
|
23
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
24
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
25
|
function getLineElementUtilityClass(slot) {
|
|
@@ -53,6 +53,7 @@ function LineElement(props) {
|
|
|
53
53
|
id,
|
|
54
54
|
classes: innerClasses,
|
|
55
55
|
color,
|
|
56
|
+
gradientId,
|
|
56
57
|
highlightScope,
|
|
57
58
|
slots,
|
|
58
59
|
slotProps,
|
|
@@ -75,6 +76,7 @@ function LineElement(props) {
|
|
|
75
76
|
id,
|
|
76
77
|
classes: innerClasses,
|
|
77
78
|
color,
|
|
79
|
+
gradientId,
|
|
78
80
|
isFaded,
|
|
79
81
|
isHighlighted
|
|
80
82
|
};
|
|
@@ -103,6 +105,7 @@ process.env.NODE_ENV !== "production" ? LineElement.propTypes = {
|
|
|
103
105
|
classes: _propTypes.default.object,
|
|
104
106
|
color: _propTypes.default.string.isRequired,
|
|
105
107
|
d: _propTypes.default.string.isRequired,
|
|
108
|
+
gradientId: _propTypes.default.string,
|
|
106
109
|
highlightScope: _propTypes.default.shape({
|
|
107
110
|
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
108
111
|
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
@@ -15,6 +15,7 @@ var _LineHighlightElement = require("./LineHighlightElement");
|
|
|
15
15
|
var _useScale = require("../hooks/useScale");
|
|
16
16
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
17
17
|
var _constants = require("../constants");
|
|
18
|
+
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
20
|
const _excluded = ["slots", "slotProps"];
|
|
20
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -83,9 +84,11 @@ function LineHighlightPlot(props) {
|
|
|
83
84
|
}
|
|
84
85
|
const x = xScale(xData[highlightedIndex]);
|
|
85
86
|
const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
|
|
87
|
+
|
|
88
|
+
const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
|
|
86
89
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Element, (0, _extends2.default)({
|
|
87
90
|
id: seriesId,
|
|
88
|
-
color:
|
|
91
|
+
color: colorGetter(highlightedIndex),
|
|
89
92
|
x: x,
|
|
90
93
|
y: y
|
|
91
94
|
}, slotProps?.lineHighlight), `${seriesId}`);
|
package/LineChart/LinePlot.js
CHANGED
|
@@ -16,6 +16,7 @@ var _LineElement = require("./LineElement");
|
|
|
16
16
|
var _useScale = require("../hooks/useScale");
|
|
17
17
|
var _getCurve = _interopRequireDefault(require("../internals/getCurve"));
|
|
18
18
|
var _constants = require("../constants");
|
|
19
|
+
var _ChartsAxesGradients = require("../internals/components/ChartsAxesGradients");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
21
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -52,6 +53,7 @@ const useAggregatedData = () => {
|
|
|
52
53
|
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisKey].scale);
|
|
53
54
|
const yScale = yAxis[yAxisKey].scale;
|
|
54
55
|
const xData = xAxis[xAxisKey].data;
|
|
56
|
+
const gradientUsed = yAxis[yAxisKey].colorScale && [yAxisKey, 'y'] || xAxis[xAxisKey].colorScale && [xAxisKey, 'x'] || undefined;
|
|
55
57
|
if (process.env.NODE_ENV !== 'production') {
|
|
56
58
|
if (xData === undefined) {
|
|
57
59
|
throw new Error(`MUI X Charts: ${xAxisKey === _constants.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.`);
|
|
@@ -68,6 +70,7 @@ const useAggregatedData = () => {
|
|
|
68
70
|
const d3Data = connectNulls ? formattedData.filter((_, i) => data[i] != null) : formattedData;
|
|
69
71
|
const d = linePath.curve((0, _getCurve.default)(series[seriesId].curve))(d3Data) || '';
|
|
70
72
|
return (0, _extends2.default)({}, series[seriesId], {
|
|
73
|
+
gradientUsed,
|
|
71
74
|
d,
|
|
72
75
|
seriesId
|
|
73
76
|
});
|
|
@@ -93,18 +96,21 @@ function LinePlot(props) {
|
|
|
93
96
|
onItemClick
|
|
94
97
|
} = props,
|
|
95
98
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
99
|
+
const getGradientId = (0, _ChartsAxesGradients.useChartGradient)();
|
|
96
100
|
const completedData = useAggregatedData();
|
|
97
101
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", (0, _extends2.default)({}, other, {
|
|
98
102
|
children: completedData.map(({
|
|
99
103
|
d,
|
|
100
104
|
seriesId,
|
|
101
105
|
color,
|
|
102
|
-
highlightScope
|
|
106
|
+
highlightScope,
|
|
107
|
+
gradientUsed
|
|
103
108
|
}) => {
|
|
104
109
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_LineElement.LineElement, {
|
|
105
110
|
id: seriesId,
|
|
106
111
|
d: d,
|
|
107
112
|
color: color,
|
|
113
|
+
gradientId: gradientUsed && getGradientId(...gradientUsed),
|
|
108
114
|
highlightScope: highlightScope,
|
|
109
115
|
skipAnimation: skipAnimation,
|
|
110
116
|
slots: slots,
|
package/LineChart/MarkPlot.js
CHANGED
|
@@ -13,9 +13,10 @@ var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
|
13
13
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
14
14
|
var _MarkElement = require("./MarkElement");
|
|
15
15
|
var _useScale = require("../hooks/useScale");
|
|
16
|
+
var _useChartId = require("../hooks/useChartId");
|
|
16
17
|
var _constants = require("../constants");
|
|
17
|
-
var _DrawingProvider = require("../context/DrawingProvider");
|
|
18
18
|
var _utils = require("../internals/utils");
|
|
19
|
+
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
21
22
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -40,9 +41,7 @@ function MarkPlot(props) {
|
|
|
40
41
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
41
42
|
const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).line;
|
|
42
43
|
const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
43
|
-
const
|
|
44
|
-
chartId
|
|
45
|
-
} = React.useContext(_DrawingProvider.DrawingContext);
|
|
44
|
+
const chartId = (0, _useChartId.useChartId)();
|
|
46
45
|
const Mark = slots?.mark ?? _MarkElement.MarkElement;
|
|
47
46
|
if (seriesData === undefined) {
|
|
48
47
|
return null;
|
|
@@ -96,6 +95,7 @@ function MarkPlot(props) {
|
|
|
96
95
|
}
|
|
97
96
|
const clipId = (0, _utils.cleanId)(`${chartId}-${seriesId}-line-clip`); // We assume that if displaying line mark, the line will also be rendered
|
|
98
97
|
|
|
98
|
+
const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisKey], yAxis[yAxisKey]);
|
|
99
99
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
100
100
|
clipPath: `url(#${clipId})`,
|
|
101
101
|
children: xData?.map((x, index) => {
|
|
@@ -144,7 +144,7 @@ function MarkPlot(props) {
|
|
|
144
144
|
id: seriesId,
|
|
145
145
|
dataIndex: index,
|
|
146
146
|
shape: "circle",
|
|
147
|
-
color:
|
|
147
|
+
color: colorGetter(index),
|
|
148
148
|
x: x,
|
|
149
149
|
y: y // Don't know why TS doesn't get from the filter that y can't be null
|
|
150
150
|
,
|