@mui/x-charts 6.0.0-alpha.8 → 6.18.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.d.ts +19 -5
- package/BarChart/BarChart.js +52 -13
- package/BarChart/BarElement.d.ts +1319 -4
- package/BarChart/BarElement.js +10 -10
- package/BarChart/BarPlot.d.ts +17 -1
- package/BarChart/BarPlot.js +152 -66
- package/BarChart/formatter.js +2 -3
- package/BarChart/legend.js +1 -2
- package/CHANGELOG.md +786 -48
- package/ChartContainer/index.js +7 -5
- package/ChartsAxis/ChartsAxis.d.ts +9 -0
- package/ChartsAxis/ChartsAxis.js +28 -2
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsAxis/axisClasses.js +1 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +21 -0
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +61 -22
- package/ChartsClipPath/ChartsClipPath.d.ts +5 -0
- package/ChartsClipPath/ChartsClipPath.js +7 -2
- package/ChartsLegend/ChartsLegend.d.ts +44 -24
- package/ChartsLegend/ChartsLegend.js +192 -150
- package/ChartsLegend/chartsLegendClasses.js +1 -2
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsSurface.d.ts +1 -1
- package/ChartsSurface.js +9 -18
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.js +46 -32
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +18 -9
- package/ChartsTooltip/ChartsTooltip.d.ts +32 -0
- package/ChartsTooltip/ChartsTooltip.js +62 -18
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -10
- package/ChartsTooltip/ChartsTooltipTable.js +22 -20
- package/ChartsTooltip/tooltipClasses.js +1 -2
- package/ChartsTooltip/utils.js +2 -2
- package/ChartsXAxis/ChartsXAxis.d.ts +9 -0
- package/ChartsXAxis/ChartsXAxis.js +161 -40
- package/ChartsYAxis/ChartsYAxis.d.ts +9 -0
- package/ChartsYAxis/ChartsYAxis.js +86 -33
- package/LineChart/AreaElement.d.ts +12 -2
- package/LineChart/AreaElement.js +14 -6
- package/LineChart/AreaPlot.d.ts +11 -0
- package/LineChart/AreaPlot.js +27 -8
- package/LineChart/LineChart.d.ts +21 -3
- package/LineChart/LineChart.js +61 -14
- package/LineChart/LineElement.d.ts +12 -2
- package/LineChart/LineElement.js +14 -6
- package/LineChart/LineHighlightElement.d.ts +31 -0
- package/LineChart/LineHighlightElement.js +88 -0
- package/LineChart/LineHighlightPlot.d.ts +35 -0
- package/LineChart/LineHighlightPlot.js +110 -0
- package/LineChart/LinePlot.d.ts +10 -0
- package/LineChart/LinePlot.js +25 -12
- package/LineChart/MarkElement.d.ts +11 -1
- package/LineChart/MarkElement.js +15 -9
- package/LineChart/MarkPlot.d.ts +10 -0
- package/LineChart/MarkPlot.js +62 -15
- package/LineChart/formatter.js +5 -5
- package/LineChart/index.d.ts +2 -0
- package/LineChart/index.js +20 -0
- package/LineChart/legend.js +1 -2
- package/PieChart/PieArc.d.ts +12 -14
- package/PieChart/PieArc.js +28 -60
- package/PieChart/PieArcLabel.d.ts +9 -10
- package/PieChart/PieArcLabel.js +46 -38
- package/PieChart/PieArcLabelPlot.d.ts +28 -0
- package/PieChart/PieArcLabelPlot.js +99 -0
- package/PieChart/PieArcPlot.d.ts +35 -0
- package/PieChart/PieArcPlot.js +92 -0
- package/PieChart/PieChart.d.ts +19 -5
- package/PieChart/PieChart.js +61 -14
- package/PieChart/PiePlot.d.ts +15 -9
- package/PieChart/PiePlot.js +77 -55
- package/PieChart/dataTransform/transition.d.ts +4 -0
- package/PieChart/dataTransform/transition.js +136 -0
- package/PieChart/dataTransform/useTransformData.d.ts +15 -0
- package/PieChart/dataTransform/useTransformData.js +67 -0
- package/PieChart/formatter.js +1 -2
- package/PieChart/legend.js +1 -2
- package/README.md +8 -14
- package/ResponsiveChartContainer/index.js +7 -8
- package/ScatterChart/Scatter.d.ts +10 -0
- package/ScatterChart/Scatter.js +12 -2
- package/ScatterChart/ScatterChart.d.ts +16 -3
- package/ScatterChart/ScatterChart.js +43 -12
- package/ScatterChart/ScatterPlot.d.ts +10 -0
- package/ScatterChart/ScatterPlot.js +12 -2
- package/ScatterChart/formatter.js +1 -2
- package/ScatterChart/legend.js +1 -2
- package/SparkLineChart/SparkLineChart.d.ts +13 -3
- package/SparkLineChart/SparkLineChart.js +34 -18
- package/colorPalettes/colorPalettes.js +6 -12
- package/constants.js +5 -8
- package/context/CartesianContextProvider.d.ts +5 -0
- package/context/CartesianContextProvider.js +31 -16
- package/context/DrawingProvider.d.ts +7 -0
- package/context/DrawingProvider.js +12 -6
- package/context/HighlightProvider.js +3 -4
- package/context/InteractionProvider.js +3 -4
- package/context/SeriesContextProvider.js +3 -4
- package/esm/BarChart/BarChart.js +49 -9
- package/esm/BarChart/BarElement.js +7 -4
- package/esm/BarChart/BarPlot.js +152 -67
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsAxis/ChartsAxis.js +26 -0
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
- package/esm/ChartsClipPath/ChartsClipPath.js +5 -0
- package/esm/ChartsLegend/ChartsLegend.js +188 -142
- package/esm/ChartsSurface.js +4 -12
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/esm/ChartsTooltip/ChartsTooltip.js +59 -14
- package/esm/ChartsTooltip/ChartsTooltipTable.js +17 -10
- package/esm/ChartsXAxis/ChartsXAxis.js +158 -37
- package/esm/ChartsYAxis/ChartsYAxis.js +83 -30
- package/esm/LineChart/AreaElement.js +10 -0
- package/esm/LineChart/AreaPlot.js +26 -6
- package/esm/LineChart/LineChart.js +58 -10
- package/esm/LineChart/LineElement.js +10 -0
- package/esm/LineChart/LineHighlightElement.js +78 -0
- package/esm/LineChart/LineHighlightPlot.js +103 -0
- package/esm/LineChart/LinePlot.js +25 -14
- package/esm/LineChart/MarkElement.js +12 -5
- package/esm/LineChart/MarkPlot.js +60 -13
- package/esm/LineChart/formatter.js +7 -3
- package/esm/LineChart/index.js +3 -1
- package/esm/PieChart/PieArc.js +26 -58
- package/esm/PieChart/PieArcLabel.js +43 -34
- package/esm/PieChart/PieArcLabelPlot.js +92 -0
- package/esm/PieChart/PieArcPlot.js +84 -0
- package/esm/PieChart/PieChart.js +59 -12
- package/esm/PieChart/PiePlot.js +76 -57
- package/esm/PieChart/dataTransform/transition.js +130 -0
- package/esm/PieChart/dataTransform/useTransformData.js +59 -0
- package/esm/ResponsiveChartContainer/index.js +3 -3
- package/esm/ScatterChart/Scatter.js +10 -0
- package/esm/ScatterChart/ScatterChart.js +40 -8
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +32 -15
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +30 -14
- package/esm/context/DrawingProvider.js +8 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useMounted.js +16 -0
- package/esm/hooks/useReducedMotion.js +27 -0
- package/esm/hooks/useTicks.js +15 -9
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +77 -0
- package/esm/internals/domUtils.js +113 -0
- package/esm/internals/geometry.js +36 -0
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +5 -4
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +2 -2
- package/hooks/useMounted.d.ts +1 -0
- package/hooks/useMounted.js +25 -0
- package/hooks/useReducedMotion.d.ts +8 -0
- package/hooks/useReducedMotion.js +33 -0
- package/hooks/useScale.d.ts +2 -2
- package/hooks/useScale.js +2 -2
- package/hooks/useTicks.d.ts +19 -11
- package/hooks/useTicks.js +19 -14
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +18 -78
- package/internals/components/ChartsText.d.ts +35 -0
- package/internals/components/ChartsText.js +87 -0
- package/internals/defaultizeColor.d.ts +8 -1
- package/internals/defaultizeValueFormatter.js +1 -2
- package/internals/domUtils.d.ts +13 -0
- package/internals/domUtils.js +122 -0
- package/internals/geometry.d.ts +9 -0
- package/internals/geometry.js +42 -0
- package/internals/stackSeries.js +2 -4
- package/legacy/BarChart/BarChart.js +49 -9
- package/legacy/BarChart/BarElement.js +6 -3
- package/legacy/BarChart/BarPlot.js +151 -63
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsAxis/ChartsAxis.js +26 -0
- package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +60 -20
- package/legacy/ChartsClipPath/ChartsClipPath.js +5 -0
- package/legacy/ChartsLegend/ChartsLegend.js +203 -140
- package/legacy/ChartsSurface.js +3 -12
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +22 -10
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/legacy/ChartsTooltip/ChartsTooltip.js +62 -14
- package/legacy/ChartsTooltip/ChartsTooltipTable.js +34 -26
- package/legacy/ChartsXAxis/ChartsXAxis.js +162 -39
- package/legacy/ChartsYAxis/ChartsYAxis.js +83 -30
- package/legacy/LineChart/AreaElement.js +10 -0
- package/legacy/LineChart/AreaPlot.js +31 -7
- package/legacy/LineChart/LineChart.js +58 -10
- package/legacy/LineChart/LineElement.js +10 -0
- package/legacy/LineChart/LineHighlightElement.js +77 -0
- package/legacy/LineChart/LineHighlightPlot.js +96 -0
- package/legacy/LineChart/LinePlot.js +29 -12
- package/legacy/LineChart/MarkElement.js +12 -5
- package/legacy/LineChart/MarkPlot.js +50 -5
- package/legacy/LineChart/formatter.js +7 -3
- package/legacy/LineChart/index.js +3 -1
- package/legacy/PieChart/PieArc.js +30 -62
- package/legacy/PieChart/PieArcLabel.js +48 -34
- package/legacy/PieChart/PieArcLabelPlot.js +93 -0
- package/legacy/PieChart/PieArcPlot.js +84 -0
- package/legacy/PieChart/PieChart.js +59 -12
- package/legacy/PieChart/PiePlot.js +76 -59
- package/legacy/PieChart/dataTransform/transition.js +142 -0
- package/legacy/PieChart/dataTransform/useTransformData.js +60 -0
- package/legacy/ResponsiveChartContainer/index.js +3 -3
- package/legacy/ScatterChart/Scatter.js +10 -0
- package/legacy/ScatterChart/ScatterChart.js +40 -8
- package/legacy/ScatterChart/ScatterPlot.js +10 -0
- package/legacy/SparkLineChart/SparkLineChart.js +32 -13
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +30 -14
- package/legacy/context/DrawingProvider.js +8 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useMounted.js +21 -0
- package/legacy/hooks/useReducedMotion.js +27 -0
- package/legacy/hooks/useTicks.js +16 -9
- package/legacy/index.js +1 -1
- package/legacy/internals/components/AxisSharedComponents.js +11 -65
- package/legacy/internals/components/ChartsText.js +79 -0
- package/legacy/internals/domUtils.js +121 -0
- package/legacy/internals/geometry.js +37 -0
- package/models/axis.d.ts +27 -9
- package/models/layout.d.ts +7 -6
- package/models/seriesType/line.d.ts +39 -1
- package/models/seriesType/pie.d.ts +5 -1
- package/modern/BarChart/BarChart.js +49 -9
- package/modern/BarChart/BarElement.js +7 -4
- package/modern/BarChart/BarPlot.js +149 -65
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsAxis/ChartsAxis.js +26 -0
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
- package/modern/ChartsClipPath/ChartsClipPath.js +5 -0
- package/modern/ChartsLegend/ChartsLegend.js +188 -142
- package/modern/ChartsSurface.js +4 -12
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/modern/ChartsTooltip/ChartsTooltip.js +58 -14
- package/modern/ChartsTooltip/ChartsTooltipTable.js +17 -10
- package/modern/ChartsXAxis/ChartsXAxis.js +158 -37
- package/modern/ChartsYAxis/ChartsYAxis.js +83 -30
- package/modern/LineChart/AreaElement.js +10 -0
- package/modern/LineChart/AreaPlot.js +25 -6
- package/modern/LineChart/LineChart.js +58 -10
- package/modern/LineChart/LineElement.js +10 -0
- package/modern/LineChart/LineHighlightElement.js +78 -0
- package/modern/LineChart/LineHighlightPlot.js +102 -0
- package/modern/LineChart/LinePlot.js +23 -10
- package/modern/LineChart/MarkElement.js +12 -5
- package/modern/LineChart/MarkPlot.js +60 -13
- package/modern/LineChart/formatter.js +4 -3
- package/modern/LineChart/index.js +3 -1
- package/modern/PieChart/PieArc.js +26 -57
- package/modern/PieChart/PieArcLabel.js +43 -34
- package/modern/PieChart/PieArcLabelPlot.js +90 -0
- package/modern/PieChart/PieArcPlot.js +83 -0
- package/modern/PieChart/PieChart.js +59 -12
- package/modern/PieChart/PiePlot.js +76 -55
- package/modern/PieChart/dataTransform/transition.js +130 -0
- package/modern/PieChart/dataTransform/useTransformData.js +58 -0
- package/modern/ResponsiveChartContainer/index.js +3 -3
- package/modern/ScatterChart/Scatter.js +10 -0
- package/modern/ScatterChart/ScatterChart.js +40 -8
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +32 -15
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +29 -13
- package/modern/context/DrawingProvider.js +8 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useMounted.js +16 -0
- package/modern/hooks/useReducedMotion.js +27 -0
- package/modern/hooks/useTicks.js +15 -9
- package/modern/index.js +1 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +77 -0
- package/modern/internals/domUtils.js +113 -0
- package/modern/internals/geometry.js +36 -0
- package/package.json +9 -6
- package/themeAugmentation/components.d.ts +1 -0
- package/themeAugmentation/overrides.d.ts +2 -0
package/BarChart/BarElement.js
CHANGED
|
@@ -5,9 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.BarElement = BarElement;
|
|
8
|
-
exports.BarElementPath = void 0;
|
|
8
|
+
exports.barElementClasses = exports.BarElementPath = void 0;
|
|
9
9
|
exports.getBarElementUtilityClass = getBarElementUtilityClass;
|
|
10
|
-
exports.lineElementClasses = void 0;
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
13
12
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -17,17 +16,17 @@ var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateU
|
|
|
17
16
|
var _styles = require("@mui/material/styles");
|
|
18
17
|
var _d3Color = require("d3-color");
|
|
19
18
|
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
19
|
+
var _web = require("@react-spring/web");
|
|
20
20
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
21
21
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
22
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
|
-
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
24
|
-
function _getRequireWildcardCache(
|
|
25
|
-
function _interopRequireWildcard(
|
|
23
|
+
const _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style"];
|
|
24
|
+
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); }
|
|
25
|
+
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; }
|
|
26
26
|
function getBarElementUtilityClass(slot) {
|
|
27
27
|
return (0, _generateUtilityClass.default)('MuiBarElement', slot);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
exports.lineElementClasses = lineElementClasses;
|
|
29
|
+
const barElementClasses = exports.barElementClasses = (0, _generateUtilityClasses.default)('MuiBarElement', ['root']);
|
|
31
30
|
const useUtilityClasses = ownerState => {
|
|
32
31
|
const {
|
|
33
32
|
classes,
|
|
@@ -38,7 +37,7 @@ const useUtilityClasses = ownerState => {
|
|
|
38
37
|
};
|
|
39
38
|
return (0, _composeClasses.default)(slots, getBarElementUtilityClass, classes);
|
|
40
39
|
};
|
|
41
|
-
const BarElementPath = (0, _styles.styled)(
|
|
40
|
+
const BarElementPath = exports.BarElementPath = (0, _styles.styled)(_web.animated.rect, {
|
|
42
41
|
name: 'MuiBarElement',
|
|
43
42
|
slot: 'Root',
|
|
44
43
|
overridesResolver: (_, styles) => styles.root
|
|
@@ -51,7 +50,6 @@ const BarElementPath = (0, _styles.styled)('rect', {
|
|
|
51
50
|
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
52
51
|
opacity: ownerState.isFaded && 0.3 || 1
|
|
53
52
|
}));
|
|
54
|
-
exports.BarElementPath = BarElementPath;
|
|
55
53
|
function BarElement(props) {
|
|
56
54
|
const {
|
|
57
55
|
id,
|
|
@@ -60,7 +58,8 @@ function BarElement(props) {
|
|
|
60
58
|
color,
|
|
61
59
|
highlightScope,
|
|
62
60
|
slots,
|
|
63
|
-
slotProps
|
|
61
|
+
slotProps,
|
|
62
|
+
style
|
|
64
63
|
} = props,
|
|
65
64
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
66
65
|
const getInteractionItemProps = (0, _useInteractionItemProps.useInteractionItemProps)(highlightScope);
|
|
@@ -95,6 +94,7 @@ function BarElement(props) {
|
|
|
95
94
|
seriesId: id,
|
|
96
95
|
dataIndex
|
|
97
96
|
}), {
|
|
97
|
+
style,
|
|
98
98
|
className: classes.root
|
|
99
99
|
}),
|
|
100
100
|
ownerState
|
package/BarChart/BarPlot.d.ts
CHANGED
|
@@ -7,8 +7,24 @@ export interface BarPlotSlotComponentProps {
|
|
|
7
7
|
bar?: Partial<BarElementProps>;
|
|
8
8
|
}
|
|
9
9
|
export interface BarPlotProps extends Pick<BarElementProps, 'slots' | 'slotProps'> {
|
|
10
|
+
/**
|
|
11
|
+
* If `true`, animations are skiped.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
skipAnimation?: boolean;
|
|
10
15
|
}
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Demos:
|
|
18
|
+
*
|
|
19
|
+
* - [Bars](https://mui.com/x/react-charts/bars/)
|
|
20
|
+
* - [Bar demonstration](https://mui.com/x/react-charts/bar-demo/)
|
|
21
|
+
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
22
|
+
*
|
|
23
|
+
* API:
|
|
24
|
+
*
|
|
25
|
+
* - [BarPlot API](https://mui.com/x/api/charts/bar-plot/)
|
|
26
|
+
*/
|
|
27
|
+
declare function BarPlot(props: BarPlotProps): React.JSX.Element;
|
|
12
28
|
declare namespace BarPlot {
|
|
13
29
|
var propTypes: any;
|
|
14
30
|
}
|
package/BarChart/BarPlot.js
CHANGED
|
@@ -5,16 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.BarPlot = BarPlot;
|
|
8
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var React = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _web = require("@react-spring/web");
|
|
11
13
|
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
12
14
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
13
15
|
var _BarElement = require("./BarElement");
|
|
14
16
|
var _axis = require("../models/axis");
|
|
15
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
+
const _excluded = ["skipAnimation"];
|
|
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
|
+
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; }
|
|
18
21
|
/**
|
|
19
22
|
* Solution of the equations
|
|
20
23
|
* W = barWidth * N + offset * (N-1)
|
|
@@ -23,7 +26,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
26
|
* @param numberOfGroups The number of bars to place in that space.
|
|
24
27
|
* @param gapRatio The ratio of the gap between bars over the bar width.
|
|
25
28
|
* @returns The bar width and the offset between bars.
|
|
26
|
-
*/
|
|
29
|
+
*/
|
|
30
|
+
function getBandSize({
|
|
27
31
|
bandWidth: W,
|
|
28
32
|
numberOfGroups: N,
|
|
29
33
|
gapRatio: r
|
|
@@ -41,12 +45,13 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
41
45
|
offset
|
|
42
46
|
};
|
|
43
47
|
}
|
|
44
|
-
|
|
45
|
-
const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).bar
|
|
48
|
+
const useCompletedData = () => {
|
|
49
|
+
const seriesData = React.useContext(_SeriesContextProvider.SeriesContext).bar ?? {
|
|
50
|
+
series: {},
|
|
51
|
+
stackingGroups: [],
|
|
52
|
+
seriesOrder: []
|
|
53
|
+
};
|
|
46
54
|
const axisData = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
47
|
-
if (seriesData === undefined) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
55
|
const {
|
|
51
56
|
series,
|
|
52
57
|
stackingGroups
|
|
@@ -59,66 +64,142 @@ function BarPlot(props) {
|
|
|
59
64
|
} = axisData;
|
|
60
65
|
const defaultXAxisId = xAxisIds[0];
|
|
61
66
|
const defaultYAxisId = yAxisIds[0];
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
|
|
79
|
-
}
|
|
80
|
-
baseScaleConfig = xAxisConfig;
|
|
81
|
-
} else {
|
|
82
|
-
if (!(0, _axis.isBandScaleConfig)(yAxisConfig)) {
|
|
83
|
-
throw new Error(`Axis with id "${yAxisKey}" shoud be of type "band" to display the bar series of id "${seriesId}"`);
|
|
84
|
-
}
|
|
85
|
-
if (yAxis[yAxisKey].data === undefined) {
|
|
86
|
-
throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
|
|
87
|
-
}
|
|
88
|
-
baseScaleConfig = yAxisConfig;
|
|
67
|
+
const data = stackingGroups.flatMap(({
|
|
68
|
+
ids: groupIds
|
|
69
|
+
}, groupIndex) => {
|
|
70
|
+
return groupIds.flatMap(seriesId => {
|
|
71
|
+
const xAxisKey = series[seriesId].xAxisKey ?? defaultXAxisId;
|
|
72
|
+
const yAxisKey = series[seriesId].yAxisKey ?? defaultYAxisId;
|
|
73
|
+
const xAxisConfig = xAxis[xAxisKey];
|
|
74
|
+
const yAxisConfig = yAxis[yAxisKey];
|
|
75
|
+
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
76
|
+
let baseScaleConfig;
|
|
77
|
+
if (verticalLayout) {
|
|
78
|
+
if (!(0, _axis.isBandScaleConfig)(xAxisConfig)) {
|
|
79
|
+
throw new Error(`Axis with id "${xAxisKey}" shoud be of type "band" to display the bar series of id "${seriesId}"`);
|
|
80
|
+
}
|
|
81
|
+
if (xAxis[xAxisKey].data === undefined) {
|
|
82
|
+
throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
|
|
89
83
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
84
|
+
baseScaleConfig = xAxisConfig;
|
|
85
|
+
} else {
|
|
86
|
+
if (!(0, _axis.isBandScaleConfig)(yAxisConfig)) {
|
|
87
|
+
throw new Error(`Axis with id "${yAxisKey}" shoud be of type "band" to display the bar series of id "${seriesId}"`);
|
|
88
|
+
}
|
|
89
|
+
if (yAxis[yAxisKey].data === undefined) {
|
|
90
|
+
throw new Error(`Axis with id "${xAxisKey}" shoud have data property`);
|
|
91
|
+
}
|
|
92
|
+
baseScaleConfig = yAxisConfig;
|
|
93
|
+
}
|
|
94
|
+
const xScale = xAxisConfig.scale;
|
|
95
|
+
const yScale = yAxisConfig.scale;
|
|
96
|
+
const bandWidth = baseScaleConfig.scale.bandwidth();
|
|
97
|
+
const {
|
|
98
|
+
barWidth,
|
|
99
|
+
offset
|
|
100
|
+
} = getBandSize({
|
|
101
|
+
bandWidth,
|
|
102
|
+
numberOfGroups: stackingGroups.length,
|
|
103
|
+
gapRatio: baseScaleConfig.barGapRatio
|
|
104
|
+
});
|
|
105
|
+
const barOffset = groupIndex * (barWidth + offset);
|
|
106
|
+
const {
|
|
107
|
+
stackedData,
|
|
108
|
+
color
|
|
109
|
+
} = series[seriesId];
|
|
110
|
+
return stackedData.map((values, dataIndex) => {
|
|
111
|
+
const bottom = Math.min(...values);
|
|
112
|
+
const top = Math.max(...values);
|
|
113
|
+
return {
|
|
114
|
+
bottom,
|
|
115
|
+
top,
|
|
116
|
+
seriesId,
|
|
117
|
+
dataIndex,
|
|
118
|
+
layout: series[seriesId].layout,
|
|
119
|
+
x: verticalLayout ? xScale(xAxis[xAxisKey].data?.[dataIndex]) + barOffset : xScale(bottom),
|
|
120
|
+
y: verticalLayout ? yScale(top) : yScale(yAxis[yAxisKey].data?.[dataIndex]) + barOffset,
|
|
121
|
+
xOrigin: xScale(0),
|
|
122
|
+
yOrigin: yScale(0),
|
|
123
|
+
height: verticalLayout ? Math.abs(yScale(bottom) - yScale(top)) : barWidth,
|
|
124
|
+
width: verticalLayout ? barWidth : Math.abs(xScale(bottom) - xScale(top)),
|
|
125
|
+
color,
|
|
126
|
+
highlightScope: series[seriesId].highlightScope
|
|
127
|
+
};
|
|
120
128
|
});
|
|
121
|
-
})
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
return data;
|
|
132
|
+
};
|
|
133
|
+
const getOutStyle = ({
|
|
134
|
+
layout,
|
|
135
|
+
yOrigin,
|
|
136
|
+
x,
|
|
137
|
+
width,
|
|
138
|
+
y,
|
|
139
|
+
xOrigin,
|
|
140
|
+
height
|
|
141
|
+
}) => (0, _extends2.default)({}, layout === 'vertical' ? {
|
|
142
|
+
y: yOrigin,
|
|
143
|
+
x,
|
|
144
|
+
height: 0,
|
|
145
|
+
width
|
|
146
|
+
} : {
|
|
147
|
+
y,
|
|
148
|
+
x: xOrigin,
|
|
149
|
+
height,
|
|
150
|
+
width: 0
|
|
151
|
+
});
|
|
152
|
+
const getInStyle = ({
|
|
153
|
+
x,
|
|
154
|
+
width,
|
|
155
|
+
y,
|
|
156
|
+
height
|
|
157
|
+
}) => ({
|
|
158
|
+
y,
|
|
159
|
+
x,
|
|
160
|
+
height,
|
|
161
|
+
width
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Demos:
|
|
166
|
+
*
|
|
167
|
+
* - [Bars](https://mui.com/x/react-charts/bars/)
|
|
168
|
+
* - [Bar demonstration](https://mui.com/x/react-charts/bar-demo/)
|
|
169
|
+
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
170
|
+
*
|
|
171
|
+
* API:
|
|
172
|
+
*
|
|
173
|
+
* - [BarPlot API](https://mui.com/x/api/charts/bar-plot/)
|
|
174
|
+
*/
|
|
175
|
+
function BarPlot(props) {
|
|
176
|
+
const completedData = useCompletedData();
|
|
177
|
+
const {
|
|
178
|
+
skipAnimation
|
|
179
|
+
} = props,
|
|
180
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
181
|
+
const transition = (0, _web.useTransition)(completedData, {
|
|
182
|
+
keys: bar => `${bar.seriesId}-${bar.dataIndex}`,
|
|
183
|
+
from: getOutStyle,
|
|
184
|
+
leave: getOutStyle,
|
|
185
|
+
enter: getInStyle,
|
|
186
|
+
update: getInStyle,
|
|
187
|
+
immediate: skipAnimation
|
|
188
|
+
});
|
|
189
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
|
|
190
|
+
children: transition((style, {
|
|
191
|
+
seriesId,
|
|
192
|
+
dataIndex,
|
|
193
|
+
color,
|
|
194
|
+
highlightScope
|
|
195
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_BarElement.BarElement, (0, _extends2.default)({
|
|
196
|
+
id: seriesId,
|
|
197
|
+
dataIndex: dataIndex,
|
|
198
|
+
highlightScope: highlightScope,
|
|
199
|
+
color: color
|
|
200
|
+
}, other, {
|
|
201
|
+
style: style
|
|
202
|
+
})))
|
|
122
203
|
});
|
|
123
204
|
}
|
|
124
205
|
process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
@@ -126,6 +207,11 @@ process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
|
126
207
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
127
208
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
128
209
|
// ----------------------------------------------------------------------
|
|
210
|
+
/**
|
|
211
|
+
* If `true`, animations are skiped.
|
|
212
|
+
* @default false
|
|
213
|
+
*/
|
|
214
|
+
skipAnimation: _propTypes.default.bool,
|
|
129
215
|
/**
|
|
130
216
|
* The props used for each component slot.
|
|
131
217
|
* @default {}
|
package/BarChart/formatter.js
CHANGED
|
@@ -60,8 +60,7 @@ const formatter = (params, dataset) => {
|
|
|
60
60
|
return {
|
|
61
61
|
seriesOrder,
|
|
62
62
|
stackingGroups,
|
|
63
|
-
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v
|
|
63
|
+
series: (0, _defaultizeValueFormatter.default)(completedSeries, v => v?.toLocaleString())
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
|
-
var _default = formatter;
|
|
67
|
-
exports.default = _default;
|
|
66
|
+
var _default = exports.default = formatter;
|
package/BarChart/legend.js
CHANGED