@mui/x-charts 6.0.0-alpha.1 → 6.0.0-alpha.11
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 +20 -6
- package/BarChart/BarChart.js +107 -34
- package/BarChart/BarElement.d.ts +22 -0
- package/BarChart/BarElement.js +21 -10
- package/BarChart/BarPlot.d.ts +14 -1
- package/BarChart/BarPlot.js +86 -23
- package/BarChart/extremums.js +19 -3
- package/BarChart/formatter.js +26 -13
- package/BarChart/legend.d.ts +3 -0
- package/BarChart/legend.js +20 -0
- package/CHANGELOG.md +913 -108
- package/ChartContainer/index.d.ts +3 -1
- package/ChartContainer/index.js +13 -6
- package/ChartsAxis/ChartsAxis.d.ts +15 -5
- package/ChartsAxis/ChartsAxis.js +55 -10
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +3 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +14 -5
- package/ChartsLegend/ChartsLegend.d.ts +28 -1
- package/ChartsLegend/ChartsLegend.js +53 -17
- package/ChartsLegend/utils.d.ts +1 -1
- package/ChartsLegend/utils.js +12 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +15 -11
- package/ChartsTooltip/ChartsItemTooltipContent.js +11 -2
- package/ChartsTooltip/ChartsTooltipTable.d.ts +4 -16
- package/ChartsXAxis/ChartsXAxis.js +44 -9
- package/ChartsYAxis/ChartsYAxis.js +44 -9
- package/LineChart/AreaElement.d.ts +23 -1
- package/LineChart/AreaElement.js +31 -11
- package/LineChart/AreaPlot.d.ts +14 -1
- package/LineChart/AreaPlot.js +32 -5
- package/LineChart/LineChart.d.ts +26 -6
- package/LineChart/LineChart.js +99 -24
- package/LineChart/LineElement.d.ts +23 -1
- package/LineChart/LineElement.js +31 -10
- package/LineChart/LineHighlightElement.d.ts +21 -0
- package/LineChart/LineHighlightElement.js +79 -0
- package/LineChart/LineHighlightPlot.d.ts +25 -0
- package/LineChart/LineHighlightPlot.js +99 -0
- package/LineChart/LinePlot.d.ts +14 -1
- package/LineChart/LinePlot.js +38 -6
- package/LineChart/MarkElement.d.ts +1 -1
- package/LineChart/MarkElement.js +2 -5
- package/LineChart/MarkPlot.d.ts +24 -1
- package/LineChart/MarkPlot.js +58 -15
- package/LineChart/extremums.js +2 -2
- package/LineChart/formatter.js +23 -12
- package/LineChart/index.d.ts +2 -0
- package/LineChart/index.js +20 -0
- package/LineChart/legend.d.ts +3 -0
- package/LineChart/legend.js +20 -0
- package/PieChart/PieArc.d.ts +36 -0
- package/PieChart/PieArc.js +128 -0
- package/PieChart/PieArcLabel.d.ts +36 -0
- package/PieChart/PieArcLabel.js +112 -0
- package/PieChart/PieChart.d.ts +32 -0
- package/PieChart/PieChart.js +339 -0
- package/PieChart/PiePlot.d.ts +28 -0
- package/PieChart/PiePlot.js +121 -0
- package/PieChart/formatter.d.ts +3 -0
- package/PieChart/formatter.js +49 -0
- package/PieChart/index.d.ts +4 -0
- package/PieChart/index.js +47 -0
- package/PieChart/legend.d.ts +3 -0
- package/PieChart/legend.js +19 -0
- package/PieChart/package.json +6 -0
- package/README.md +9 -15
- package/ResponsiveChartContainer/index.d.ts +1 -1
- package/ResponsiveChartContainer/index.js +24 -11
- package/ScatterChart/Scatter.d.ts +1 -1
- package/ScatterChart/Scatter.js +40 -54
- package/ScatterChart/ScatterChart.d.ts +19 -6
- package/ScatterChart/ScatterChart.js +75 -21
- package/ScatterChart/ScatterPlot.d.ts +24 -1
- package/ScatterChart/ScatterPlot.js +28 -4
- package/ScatterChart/legend.d.ts +3 -0
- package/ScatterChart/legend.js +20 -0
- package/SparkLineChart/SparkLineChart.d.ts +74 -0
- package/SparkLineChart/SparkLineChart.js +213 -0
- package/SparkLineChart/index.d.ts +1 -0
- package/SparkLineChart/index.js +12 -0
- package/SparkLineChart/package.json +6 -0
- package/colorPalettes/colorPalettes.js +2 -2
- package/context/CartesianContextProvider.d.ts +3 -1
- package/context/CartesianContextProvider.js +83 -34
- package/context/DrawingProvider.d.ts +1 -1
- package/context/DrawingProvider.js +1 -1
- package/context/SeriesContextProvider.d.ts +3 -2
- package/context/SeriesContextProvider.js +16 -4
- package/esm/BarChart/BarChart.js +109 -34
- package/esm/BarChart/BarElement.js +21 -11
- package/esm/BarChart/BarPlot.js +89 -24
- package/esm/BarChart/extremums.js +18 -2
- package/esm/BarChart/formatter.js +26 -13
- package/esm/BarChart/legend.js +13 -0
- package/esm/ChartContainer/index.js +10 -5
- package/esm/ChartsAxis/ChartsAxis.js +55 -10
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +14 -5
- package/esm/ChartsLegend/ChartsLegend.js +51 -14
- package/esm/ChartsLegend/utils.js +11 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +15 -11
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +11 -3
- package/esm/ChartsXAxis/ChartsXAxis.js +45 -9
- package/esm/ChartsYAxis/ChartsYAxis.js +45 -9
- package/esm/LineChart/AreaElement.js +31 -11
- package/esm/LineChart/AreaPlot.js +33 -5
- package/esm/LineChart/LineChart.js +100 -23
- package/esm/LineChart/LineElement.js +31 -11
- package/esm/LineChart/LineHighlightElement.js +68 -0
- package/esm/LineChart/LineHighlightPlot.js +92 -0
- package/esm/LineChart/LinePlot.js +45 -9
- package/esm/LineChart/MarkElement.js +2 -5
- package/esm/LineChart/MarkPlot.js +59 -15
- package/esm/LineChart/extremums.js +2 -2
- package/esm/LineChart/formatter.js +23 -13
- package/esm/LineChart/index.js +3 -1
- package/esm/LineChart/legend.js +13 -0
- package/esm/PieChart/PieArc.js +117 -0
- package/esm/PieChart/PieArcLabel.js +100 -0
- package/esm/PieChart/PieChart.js +332 -0
- package/esm/PieChart/PiePlot.js +117 -0
- package/esm/PieChart/formatter.js +48 -0
- package/esm/PieChart/index.js +4 -0
- package/esm/PieChart/legend.js +12 -0
- package/esm/ResponsiveChartContainer/index.js +22 -10
- package/esm/ScatterChart/Scatter.js +40 -54
- package/esm/ScatterChart/ScatterChart.js +73 -20
- package/esm/ScatterChart/ScatterPlot.js +29 -4
- package/esm/ScatterChart/legend.js +13 -0
- package/esm/SparkLineChart/SparkLineChart.js +205 -0
- package/esm/SparkLineChart/index.js +1 -0
- package/esm/colorPalettes/colorPalettes.js +2 -2
- package/esm/context/CartesianContextProvider.js +83 -32
- package/esm/context/DrawingProvider.js +1 -1
- package/esm/context/SeriesContextProvider.js +16 -4
- package/esm/hooks/index.js +2 -0
- package/esm/hooks/useAxisEvents.js +31 -43
- package/esm/hooks/useDrawingArea.js +16 -0
- package/esm/hooks/useScale.js +19 -21
- package/esm/hooks/useTicks.js +35 -19
- package/esm/index.js +3 -0
- package/esm/internals/components/AxisSharedComponents.js +10 -10
- package/esm/internals/defaultizeColor.js +7 -0
- package/esm/internals/getScale.js +17 -0
- package/esm/internals/isBandScale.js +3 -0
- package/esm/models/axis.js +6 -1
- package/esm/models/index.js +3 -1
- package/esm/models/seriesType/index.js +1 -8
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +27 -0
- package/hooks/package.json +6 -0
- package/hooks/useAxisEvents.js +31 -43
- package/hooks/useDrawingArea.d.ts +6 -0
- package/hooks/useDrawingArea.js +24 -0
- package/hooks/useScale.d.ts +3 -6
- package/hooks/useScale.js +24 -24
- package/hooks/useTicks.d.ts +21 -6
- package/hooks/useTicks.js +28 -15
- package/index.d.ts +3 -0
- package/index.js +34 -1
- package/internals/components/AxisSharedComponents.d.ts +4 -4
- package/internals/components/AxisSharedComponents.js +15 -15
- package/internals/defaultizeColor.d.ts +42 -2
- package/internals/defaultizeColor.js +7 -0
- package/internals/getScale.d.ts +2 -0
- package/internals/getScale.js +23 -0
- package/internals/isBandScale.d.ts +3 -0
- package/internals/isBandScale.js +9 -0
- package/legacy/BarChart/BarChart.js +114 -39
- package/legacy/BarChart/BarElement.js +20 -10
- package/legacy/BarChart/BarPlot.js +89 -26
- package/legacy/BarChart/extremums.js +22 -2
- package/legacy/BarChart/formatter.js +26 -11
- package/legacy/BarChart/legend.js +15 -0
- package/legacy/ChartContainer/index.js +10 -5
- package/legacy/ChartsAxis/ChartsAxis.js +55 -10
- package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +14 -5
- package/legacy/ChartsLegend/ChartsLegend.js +50 -15
- package/legacy/ChartsLegend/utils.js +12 -6
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +17 -11
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +10 -3
- package/legacy/ChartsXAxis/ChartsXAxis.js +45 -9
- package/legacy/ChartsYAxis/ChartsYAxis.js +45 -9
- package/legacy/LineChart/AreaElement.js +30 -10
- package/legacy/LineChart/AreaPlot.js +31 -5
- package/legacy/LineChart/LineChart.js +98 -23
- package/legacy/LineChart/LineElement.js +30 -10
- package/legacy/LineChart/LineHighlightElement.js +67 -0
- package/legacy/LineChart/LineHighlightPlot.js +85 -0
- package/legacy/LineChart/LinePlot.js +38 -6
- package/legacy/LineChart/MarkElement.js +2 -5
- package/legacy/LineChart/MarkPlot.js +49 -8
- package/legacy/LineChart/extremums.js +3 -3
- package/legacy/LineChart/formatter.js +23 -11
- package/legacy/LineChart/index.js +3 -1
- package/legacy/LineChart/legend.js +15 -0
- package/legacy/PieChart/PieArc.js +118 -0
- package/legacy/PieChart/PieArcLabel.js +100 -0
- package/legacy/PieChart/PieChart.js +344 -0
- package/legacy/PieChart/PiePlot.js +112 -0
- package/legacy/PieChart/formatter.js +55 -0
- package/legacy/PieChart/index.js +4 -0
- package/legacy/PieChart/legend.js +16 -0
- package/legacy/ResponsiveChartContainer/index.js +20 -10
- package/legacy/ScatterChart/Scatter.js +36 -47
- package/legacy/ScatterChart/ScatterChart.js +73 -20
- package/legacy/ScatterChart/ScatterPlot.js +27 -4
- package/legacy/ScatterChart/legend.js +15 -0
- package/legacy/SparkLineChart/SparkLineChart.js +211 -0
- package/legacy/SparkLineChart/index.js +1 -0
- package/legacy/colorPalettes/colorPalettes.js +2 -2
- package/legacy/context/CartesianContextProvider.js +92 -33
- package/legacy/context/DrawingProvider.js +1 -1
- package/legacy/context/SeriesContextProvider.js +17 -5
- package/legacy/hooks/index.js +2 -0
- package/legacy/hooks/useAxisEvents.js +31 -42
- package/legacy/hooks/useDrawingArea.js +17 -0
- package/legacy/hooks/useScale.js +17 -21
- package/legacy/hooks/useTicks.js +35 -22
- package/legacy/index.js +4 -1
- package/legacy/internals/components/AxisSharedComponents.js +10 -10
- package/legacy/internals/defaultizeColor.js +9 -0
- package/legacy/internals/getScale.js +17 -0
- package/legacy/internals/isBandScale.js +3 -0
- package/legacy/models/axis.js +6 -1
- package/legacy/models/index.js +3 -1
- package/legacy/models/seriesType/index.js +1 -8
- package/models/axis.d.ts +59 -15
- package/models/axis.js +9 -1
- package/models/index.d.ts +2 -0
- package/models/index.js +11 -0
- package/models/seriesType/bar.d.ts +14 -2
- package/models/seriesType/common.d.ts +2 -2
- package/models/seriesType/config.d.ts +33 -3
- package/models/seriesType/index.d.ts +7 -3
- package/models/seriesType/index.js +11 -0
- package/models/seriesType/line.d.ts +42 -2
- package/models/seriesType/pie.d.ts +103 -3
- package/models/seriesType/scatter.d.ts +1 -1
- package/modern/BarChart/BarChart.js +106 -34
- package/modern/BarChart/BarElement.js +20 -11
- package/modern/BarChart/BarPlot.js +88 -23
- package/modern/BarChart/extremums.js +18 -2
- package/modern/BarChart/formatter.js +26 -13
- package/modern/BarChart/legend.js +13 -0
- package/modern/ChartContainer/index.js +10 -5
- package/modern/ChartsAxis/ChartsAxis.js +55 -10
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +14 -5
- package/modern/ChartsLegend/ChartsLegend.js +50 -14
- package/modern/ChartsLegend/utils.js +11 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +15 -11
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +11 -2
- package/modern/ChartsXAxis/ChartsXAxis.js +44 -9
- package/modern/ChartsYAxis/ChartsYAxis.js +44 -9
- package/modern/LineChart/AreaElement.js +30 -11
- package/modern/LineChart/AreaPlot.js +33 -5
- package/modern/LineChart/LineChart.js +97 -23
- package/modern/LineChart/LineElement.js +30 -11
- package/modern/LineChart/LineHighlightElement.js +68 -0
- package/modern/LineChart/LineHighlightPlot.js +91 -0
- package/modern/LineChart/LinePlot.js +39 -6
- package/modern/LineChart/MarkElement.js +2 -5
- package/modern/LineChart/MarkPlot.js +58 -15
- package/modern/LineChart/extremums.js +2 -2
- package/modern/LineChart/formatter.js +23 -13
- package/modern/LineChart/index.js +3 -1
- package/modern/LineChart/legend.js +13 -0
- package/modern/PieChart/PieArc.js +116 -0
- package/modern/PieChart/PieArcLabel.js +100 -0
- package/modern/PieChart/PieChart.js +332 -0
- package/modern/PieChart/PiePlot.js +115 -0
- package/modern/PieChart/formatter.js +41 -0
- package/modern/PieChart/index.js +4 -0
- package/modern/PieChart/legend.js +12 -0
- package/modern/ResponsiveChartContainer/index.js +22 -10
- package/modern/ScatterChart/Scatter.js +40 -54
- package/modern/ScatterChart/ScatterChart.js +73 -20
- package/modern/ScatterChart/ScatterPlot.js +28 -4
- package/modern/ScatterChart/legend.js +13 -0
- package/modern/SparkLineChart/SparkLineChart.js +205 -0
- package/modern/SparkLineChart/index.js +1 -0
- package/modern/colorPalettes/colorPalettes.js +2 -2
- package/modern/context/CartesianContextProvider.js +81 -32
- package/modern/context/DrawingProvider.js +1 -1
- package/modern/context/SeriesContextProvider.js +16 -4
- package/modern/hooks/index.js +2 -0
- package/modern/hooks/useAxisEvents.js +31 -43
- package/modern/hooks/useDrawingArea.js +16 -0
- package/modern/hooks/useScale.js +19 -21
- package/modern/hooks/useTicks.js +27 -14
- package/modern/index.js +4 -1
- package/modern/internals/components/AxisSharedComponents.js +10 -10
- package/modern/internals/defaultizeColor.js +7 -0
- package/modern/internals/getScale.js +17 -0
- package/modern/internals/isBandScale.js +3 -0
- package/modern/models/axis.js +6 -1
- package/modern/models/index.js +3 -1
- package/modern/models/seriesType/index.js +1 -8
- package/package.json +26 -6
- package/themeAugmentation/components.d.ts +0 -10
- package/themeAugmentation/overrides.d.ts +0 -2
package/BarChart/extremums.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getExtremumY = exports.getExtremumX = void 0;
|
|
7
|
-
const
|
|
7
|
+
const getBaseExtremum = params => {
|
|
8
8
|
const {
|
|
9
9
|
axis
|
|
10
10
|
} = params;
|
|
@@ -12,8 +12,7 @@ const getExtremumX = params => {
|
|
|
12
12
|
const maxX = Math.max(...(axis.data ?? []));
|
|
13
13
|
return [minX, maxX];
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
const getExtremumY = params => {
|
|
15
|
+
const getValueExtremum = params => {
|
|
17
16
|
const {
|
|
18
17
|
series,
|
|
19
18
|
axis,
|
|
@@ -24,4 +23,21 @@ const getExtremumY = params => {
|
|
|
24
23
|
return [acc[0] === null ? seriesMin : Math.min(seriesMin, acc[0]), acc[1] === null ? seriesMax : Math.max(seriesMax, acc[1])];
|
|
25
24
|
}, [null, null]);
|
|
26
25
|
};
|
|
26
|
+
const getExtremumX = params => {
|
|
27
|
+
// Notice that bar should be all horizontal or all vertical.
|
|
28
|
+
// Don't think it's a problem for now
|
|
29
|
+
const isHorizontal = Object.keys(params.series).some(seriesId => params.series[seriesId].layout === 'horizontal');
|
|
30
|
+
if (isHorizontal) {
|
|
31
|
+
return getValueExtremum(params);
|
|
32
|
+
}
|
|
33
|
+
return getBaseExtremum(params);
|
|
34
|
+
};
|
|
35
|
+
exports.getExtremumX = getExtremumX;
|
|
36
|
+
const getExtremumY = params => {
|
|
37
|
+
const isHorizontal = Object.keys(params.series).some(seriesId => params.series[seriesId].layout === 'horizontal');
|
|
38
|
+
if (isHorizontal) {
|
|
39
|
+
return getBaseExtremum(params);
|
|
40
|
+
}
|
|
41
|
+
return getValueExtremum(params);
|
|
42
|
+
};
|
|
27
43
|
exports.getExtremumY = getExtremumY;
|
package/BarChart/formatter.js
CHANGED
|
@@ -9,7 +9,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _d3Shape = require("d3-shape");
|
|
10
10
|
var _stackSeries = require("../internals/stackSeries");
|
|
11
11
|
var _defaultizeValueFormatter = _interopRequireDefault(require("../internals/defaultizeValueFormatter"));
|
|
12
|
-
const formatter = params => {
|
|
12
|
+
const formatter = (params, dataset) => {
|
|
13
13
|
const {
|
|
14
14
|
seriesOrder,
|
|
15
15
|
series
|
|
@@ -17,17 +17,22 @@ const formatter = params => {
|
|
|
17
17
|
const stackingGroups = (0, _stackSeries.getStackingGroups)(params);
|
|
18
18
|
|
|
19
19
|
// Create a data set with format adapted to d3
|
|
20
|
-
const d3Dataset = [];
|
|
20
|
+
const d3Dataset = dataset ?? [];
|
|
21
21
|
seriesOrder.forEach(id => {
|
|
22
|
-
series[id].data
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
const data = series[id].data;
|
|
23
|
+
if (data !== undefined) {
|
|
24
|
+
data.forEach((value, index) => {
|
|
25
|
+
if (d3Dataset.length <= index) {
|
|
26
|
+
d3Dataset.push({
|
|
27
|
+
[id]: value
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
d3Dataset[index][id] = value;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
} else if (dataset === undefined) {
|
|
34
|
+
throw new Error([`MUI: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
35
|
+
}
|
|
31
36
|
});
|
|
32
37
|
const completedSeries = {};
|
|
33
38
|
stackingGroups.forEach(stackingGroup => {
|
|
@@ -37,9 +42,17 @@ const formatter = params => {
|
|
|
37
42
|
stackingOrder
|
|
38
43
|
} = stackingGroup;
|
|
39
44
|
// Get stacked values, and derive the domain
|
|
40
|
-
const stackedSeries = (0, _d3Shape.stack)().keys(ids
|
|
45
|
+
const stackedSeries = (0, _d3Shape.stack)().keys(ids.map(id => {
|
|
46
|
+
// Use dataKey if needed and available
|
|
47
|
+
const dataKey = series[id].dataKey;
|
|
48
|
+
return series[id].data === undefined && dataKey !== undefined ? dataKey : id;
|
|
49
|
+
})).order(stackingOrder).offset(stackingOffset)(d3Dataset);
|
|
41
50
|
ids.forEach((id, index) => {
|
|
42
|
-
|
|
51
|
+
const dataKey = series[id].dataKey;
|
|
52
|
+
completedSeries[id] = (0, _extends2.default)({
|
|
53
|
+
layout: 'vertical'
|
|
54
|
+
}, series[id], {
|
|
55
|
+
data: dataKey ? dataset.map(d => d[dataKey]) : series[id].data,
|
|
43
56
|
stackedData: stackedSeries[index].map(([a, b]) => [a, b])
|
|
44
57
|
});
|
|
45
58
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const legendGetter = params => {
|
|
8
|
+
const {
|
|
9
|
+
seriesOrder,
|
|
10
|
+
series
|
|
11
|
+
} = params;
|
|
12
|
+
const data = seriesOrder.map(seriesId => ({
|
|
13
|
+
color: series[seriesId].color,
|
|
14
|
+
label: series[seriesId].label,
|
|
15
|
+
id: seriesId
|
|
16
|
+
}));
|
|
17
|
+
return data.filter(item => item.label !== undefined);
|
|
18
|
+
};
|
|
19
|
+
var _default = legendGetter;
|
|
20
|
+
exports.default = _default;
|