@mui/x-charts 7.17.0 → 7.19.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 +10 -0
- package/BarChart/BarElement.d.ts +1 -1
- package/BarChart/BarLabel/BarLabel.d.ts +1 -1
- package/BarChart/formatter.js +5 -4
- package/CHANGELOG.md +208 -5
- package/ChartContainer/useDefaultizeAxis.d.ts +4 -4
- package/ChartContainer/useDefaultizeAxis.js +1 -1
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +1 -1
- package/ChartsGrid/styledCommonents.d.ts +2 -2
- package/ChartsLegend/ChartsLegend.d.ts +2 -2
- package/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/ChartsLegend/LegendPerItem.d.ts +1 -1
- package/ChartsLegend/LegendPerItem.js +1 -1
- package/ChartsLegend/PiecewiseColorLegend.js +1 -1
- package/ChartsReferenceLine/common.d.ts +1 -1
- package/ChartsTooltip/ChartsTooltipTable.d.ts +5 -5
- package/ChartsTooltip/index.d.ts +3 -0
- package/ChartsTooltip/index.js +4 -1
- package/ChartsTooltip/useAxisTooltip.d.ts +18 -0
- package/ChartsTooltip/useAxisTooltip.js +84 -0
- package/ChartsTooltip/useItemTooltip.d.ts +10 -0
- package/ChartsTooltip/useItemTooltip.js +64 -0
- package/ChartsTooltip/utils.d.ts +2 -1
- package/LineChart/AnimatedArea.d.ts +1 -1
- package/LineChart/AnimatedArea.js +9 -45
- package/LineChart/AnimatedLine.d.ts +1 -1
- package/LineChart/AnimatedLine.js +9 -46
- package/LineChart/AppearingMask.d.ts +12 -0
- package/LineChart/AppearingMask.js +42 -0
- package/LineChart/LineChart.js +10 -0
- package/LineChart/formatter.js +5 -5
- package/PieChart/PieChart.js +10 -0
- package/ResponsiveChartContainer/ResizableContainer.d.ts +1 -1
- package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +10 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -0
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +1 -1
- package/ResponsiveChartContainer/useChartContainerDimensions.js +32 -8
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +1 -1
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +3 -2
- package/ScatterChart/ScatterChart.js +10 -0
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +10 -0
- package/context/CartesianProvider/CartesianProvider.js +3 -3
- package/context/CartesianProvider/defaultizeAxis.d.ts +4 -4
- package/context/CartesianProvider/getAxisExtremum.d.ts +1 -1
- package/context/CartesianProvider/getAxisExtremum.js +5 -4
- package/context/CartesianProvider/index.d.ts +0 -5
- package/context/CartesianProvider/index.js +1 -6
- package/context/PluginProvider/ExtremumGetter.types.d.ts +1 -0
- package/context/PluginProvider/Plugin.types.d.ts +4 -0
- package/context/PluginProvider/PluginContext.js +3 -1
- package/context/PluginProvider/index.d.ts +2 -0
- package/context/PluginProvider/index.js +3 -1
- package/context/PluginProvider/mergePlugins.d.ts +14 -4
- package/context/PluginProvider/mergePlugins.js +11 -1
- package/context/PluginProvider/useRadiusExtremumGetter.d.ts +4 -0
- package/context/PluginProvider/useRadiusExtremumGetter.js +17 -0
- package/context/PluginProvider/useRotationExtremumGetter.d.ts +4 -0
- package/context/PluginProvider/useRotationExtremumGetter.js +17 -0
- package/context/PolarProvider/Polar.types.d.ts +42 -0
- package/context/PolarProvider/Polar.types.js +1 -0
- package/context/PolarProvider/PolarContext.d.ts +4 -0
- package/context/PolarProvider/PolarContext.js +13 -0
- package/context/PolarProvider/PolarProvider.d.ts +4 -0
- package/context/PolarProvider/PolarProvider.js +49 -0
- package/context/PolarProvider/getAxisExtremum.d.ts +4 -0
- package/context/PolarProvider/getAxisExtremum.js +20 -0
- package/context/PolarProvider/index.d.ts +0 -0
- package/context/PolarProvider/index.js +0 -0
- package/context/PolarProvider/usePolarContext.d.ts +2 -0
- package/context/PolarProvider/usePolarContext.js +10 -0
- package/context/ZAxisContextProvider.js +1 -1
- package/hooks/useReducedMotion.js +2 -2
- package/hooks/useSeries.d.ts +4 -4
- package/hooks/useSeries.js +4 -4
- package/index.js +1 -1
- package/internals/components/AxisSharedComponents.d.ts +1 -1
- package/internals/computeAxisValue.d.ts +38 -0
- package/{context/CartesianProvider/computeValue.js → internals/computeAxisValue.js} +28 -15
- package/internals/configInit.d.ts +1 -1
- package/internals/defaultizeColor.d.ts +8 -8
- package/internals/domUtils.js +1 -1
- package/internals/geometry.js +3 -5
- package/internals/getPercentageValue.js +1 -1
- package/internals/index.d.ts +1 -0
- package/internals/index.js +1 -0
- package/models/axis.d.ts +20 -0
- package/models/seriesType/config.d.ts +6 -2
- package/models/seriesType/line.d.ts +5 -0
- package/modern/BarChart/BarChart.js +10 -0
- package/modern/BarChart/formatter.js +5 -4
- package/modern/ChartContainer/useDefaultizeAxis.js +1 -1
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/modern/ChartsLegend/LegendPerItem.js +1 -1
- package/modern/ChartsLegend/PiecewiseColorLegend.js +1 -1
- package/modern/ChartsTooltip/index.js +4 -1
- package/modern/ChartsTooltip/useAxisTooltip.js +84 -0
- package/modern/ChartsTooltip/useItemTooltip.js +64 -0
- package/modern/LineChart/AnimatedArea.js +9 -45
- package/modern/LineChart/AnimatedLine.js +9 -46
- package/modern/LineChart/AppearingMask.js +42 -0
- package/modern/LineChart/LineChart.js +10 -0
- package/modern/LineChart/formatter.js +5 -5
- package/modern/PieChart/PieChart.js +10 -0
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -0
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +32 -8
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +3 -2
- package/modern/ScatterChart/ScatterChart.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +10 -0
- package/modern/context/CartesianProvider/CartesianProvider.js +3 -3
- package/modern/context/CartesianProvider/getAxisExtremum.js +5 -4
- package/modern/context/CartesianProvider/index.js +1 -6
- package/modern/context/PluginProvider/PluginContext.js +3 -1
- package/modern/context/PluginProvider/index.js +3 -1
- package/modern/context/PluginProvider/mergePlugins.js +11 -1
- package/modern/context/PluginProvider/useRadiusExtremumGetter.js +17 -0
- package/modern/context/PluginProvider/useRotationExtremumGetter.js +17 -0
- package/modern/context/PolarProvider/Polar.types.js +1 -0
- package/modern/context/PolarProvider/PolarContext.js +13 -0
- package/modern/context/PolarProvider/PolarProvider.js +49 -0
- package/modern/context/PolarProvider/getAxisExtremum.js +20 -0
- package/modern/context/PolarProvider/index.js +0 -0
- package/modern/context/PolarProvider/usePolarContext.js +10 -0
- package/modern/context/ZAxisContextProvider.js +1 -1
- package/modern/hooks/useReducedMotion.js +2 -2
- package/modern/hooks/useSeries.js +4 -4
- package/modern/index.js +1 -1
- package/modern/{context/CartesianProvider/computeValue.js → internals/computeAxisValue.js} +28 -15
- package/modern/internals/domUtils.js +1 -1
- package/modern/internals/geometry.js +3 -5
- package/modern/internals/getPercentageValue.js +1 -1
- package/modern/internals/index.js +1 -0
- package/node/BarChart/BarChart.js +10 -0
- package/node/BarChart/formatter.js +5 -4
- package/node/ChartContainer/useDefaultizeAxis.js +1 -1
- package/node/ChartsAxis/ChartsAxis.js +4 -4
- package/node/ChartsLegend/DefaultChartsLegend.js +1 -1
- package/node/ChartsLegend/LegendPerItem.js +1 -1
- package/node/ChartsLegend/PiecewiseColorLegend.js +1 -1
- package/node/ChartsTooltip/index.js +42 -1
- package/node/ChartsTooltip/useAxisTooltip.js +90 -0
- package/node/ChartsTooltip/useItemTooltip.js +71 -0
- package/node/LineChart/AnimatedArea.js +8 -44
- package/node/LineChart/AnimatedLine.js +8 -45
- package/node/LineChart/AppearingMask.js +48 -0
- package/node/LineChart/LineChart.js +10 -0
- package/node/LineChart/formatter.js +5 -5
- package/node/PieChart/PieChart.js +10 -0
- package/node/ResponsiveChartContainer/ResponsiveChartContainer.js +10 -0
- package/node/ResponsiveChartContainer/useChartContainerDimensions.js +32 -8
- package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +3 -2
- package/node/ScatterChart/ScatterChart.js +10 -0
- package/node/SparkLineChart/SparkLineChart.js +10 -0
- package/node/context/CartesianProvider/CartesianProvider.js +3 -3
- package/node/context/CartesianProvider/getAxisExtremum.js +5 -4
- package/node/context/CartesianProvider/index.js +1 -13
- package/node/context/PluginProvider/PluginContext.js +3 -1
- package/node/context/PluginProvider/index.js +22 -0
- package/node/context/PluginProvider/mergePlugins.js +11 -1
- package/node/context/PluginProvider/useRadiusExtremumGetter.js +23 -0
- package/node/context/PluginProvider/useRotationExtremumGetter.js +23 -0
- package/node/context/PolarProvider/Polar.types.js +5 -0
- package/node/context/PolarProvider/PolarContext.js +20 -0
- package/node/context/PolarProvider/PolarProvider.js +54 -0
- package/node/context/PolarProvider/getAxisExtremum.js +27 -0
- package/node/context/PolarProvider/index.js +1 -0
- package/node/context/PolarProvider/usePolarContext.js +17 -0
- package/node/context/ZAxisContextProvider.js +1 -1
- package/node/hooks/useReducedMotion.js +2 -2
- package/node/hooks/useSeries.js +4 -4
- package/node/index.js +1 -1
- package/node/{context/CartesianProvider/computeValue.js → internals/computeAxisValue.js} +29 -16
- package/node/internals/domUtils.js +1 -1
- package/node/internals/geometry.js +3 -5
- package/node/internals/getPercentageValue.js +1 -1
- package/node/internals/index.js +12 -0
- package/package.json +4 -4
- package/context/CartesianProvider/computeValue.d.ts +0 -30
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number) => {
|
|
2
|
+
export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number, resolveSizeBeforeRender?: boolean) => {
|
|
3
3
|
containerRef: React.MutableRefObject<null>;
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import ownerWindow from '@mui/utils/ownerWindow';
|
|
6
|
-
export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
7
|
-
const
|
|
6
|
+
export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBeforeRender) => {
|
|
7
|
+
const stateRef = React.useRef({
|
|
8
|
+
displayError: false,
|
|
9
|
+
initialCompute: true,
|
|
10
|
+
computeRun: 0
|
|
11
|
+
});
|
|
8
12
|
const rootRef = React.useRef(null);
|
|
9
13
|
const [width, setWidth] = React.useState(0);
|
|
10
14
|
const [height, setHeight] = React.useState(0);
|
|
@@ -13,7 +17,7 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
13
17
|
const computeSize = React.useCallback(() => {
|
|
14
18
|
const mainEl = rootRef?.current;
|
|
15
19
|
if (!mainEl) {
|
|
16
|
-
return;
|
|
20
|
+
return {};
|
|
17
21
|
}
|
|
18
22
|
const win = ownerWindow(mainEl);
|
|
19
23
|
const computedStyle = win.getComputedStyle(mainEl);
|
|
@@ -21,11 +25,31 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
21
25
|
const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
|
|
22
26
|
setWidth(newWidth);
|
|
23
27
|
setHeight(newHeight);
|
|
28
|
+
return {
|
|
29
|
+
width: newWidth,
|
|
30
|
+
height: newHeight
|
|
31
|
+
};
|
|
24
32
|
}, []);
|
|
25
33
|
React.useEffect(() => {
|
|
26
34
|
// Ensure the error detection occurs after the first rendering.
|
|
27
|
-
|
|
35
|
+
stateRef.current.displayError = true;
|
|
28
36
|
}, []);
|
|
37
|
+
|
|
38
|
+
// This effect is used to compute the size of the container on the initial render.
|
|
39
|
+
// It is not bound to the raf loop to avoid an unwanted "resize" event.
|
|
40
|
+
// https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
|
|
41
|
+
useEnhancedEffect(() => {
|
|
42
|
+
// computeRun is used to avoid infinite loops.
|
|
43
|
+
if (!resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const computedSize = computeSize();
|
|
47
|
+
if (computedSize.width !== width || computedSize.height !== height) {
|
|
48
|
+
stateRef.current.computeRun += 1;
|
|
49
|
+
} else if (stateRef.current.initialCompute) {
|
|
50
|
+
stateRef.current.initialCompute = false;
|
|
51
|
+
}
|
|
52
|
+
}, [width, height, computeSize, resolveSizeBeforeRender]);
|
|
29
53
|
useEnhancedEffect(() => {
|
|
30
54
|
if (inWidth !== undefined && inHeight !== undefined) {
|
|
31
55
|
return () => {};
|
|
@@ -55,13 +79,13 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
55
79
|
};
|
|
56
80
|
}, [computeSize, inHeight, inWidth]);
|
|
57
81
|
if (process.env.NODE_ENV !== 'production') {
|
|
58
|
-
if (
|
|
82
|
+
if (stateRef.current.displayError && inWidth === undefined && width === 0) {
|
|
59
83
|
console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
|
|
60
|
-
|
|
84
|
+
stateRef.current.displayError = false;
|
|
61
85
|
}
|
|
62
|
-
if (
|
|
86
|
+
if (stateRef.current.displayError && inHeight === undefined && height === 0) {
|
|
63
87
|
console.error(`MUI X: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
|
|
64
|
-
|
|
88
|
+
stateRef.current.displayError = false;
|
|
65
89
|
}
|
|
66
90
|
}
|
|
67
91
|
return {
|
|
@@ -4,7 +4,7 @@ export declare const useResponsiveChartContainerProps: (props: ResponsiveChartCo
|
|
|
4
4
|
chartContainerProps: Omit<import("..").ChartsSurfaceProps & Omit<import("../internals").SeriesProviderProps, "seriesFormatters"> & Omit<import("../internals").DrawingProviderProps, "svgRef"> & Pick<import("../internals").CartesianProviderProps, "dataset"> & import("..").ZAxisContextProviderProps & import("..").HighlightedProviderProps & import("../internals").PluginProviderProps, "children"> & {
|
|
5
5
|
xAxis?: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsXAxisProps>, "id">[];
|
|
6
6
|
yAxis?: import("../internals").MakeOptional<import("..").AxisConfig<import("..").ScaleName, any, import("..").ChartsYAxisProps>, "id">[];
|
|
7
|
-
children?:
|
|
7
|
+
children?: React.ReactNode;
|
|
8
8
|
} & {
|
|
9
9
|
ref: React.ForwardedRef<unknown>;
|
|
10
10
|
};
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis"];
|
|
5
|
+
const _excluded = ["width", "height", "resolveSizeBeforeRender", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis"];
|
|
6
6
|
import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
|
|
7
7
|
export const useResponsiveChartContainerProps = (props, ref) => {
|
|
8
8
|
const {
|
|
9
9
|
width,
|
|
10
10
|
height,
|
|
11
|
+
resolveSizeBeforeRender,
|
|
11
12
|
margin,
|
|
12
13
|
children,
|
|
13
14
|
series,
|
|
@@ -30,7 +31,7 @@ export const useResponsiveChartContainerProps = (props, ref) => {
|
|
|
30
31
|
containerRef,
|
|
31
32
|
width: dWidth,
|
|
32
33
|
height: dHeight
|
|
33
|
-
} = useChartContainerDimensions(width, height);
|
|
34
|
+
} = useChartContainerDimensions(width, height, resolveSizeBeforeRender);
|
|
34
35
|
const resizableChartContainerProps = _extends({}, other, {
|
|
35
36
|
ownerState: {
|
|
36
37
|
width,
|
|
@@ -177,6 +177,16 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
177
177
|
* @param {ScatterItemIdentifier} scatterItemIdentifier The scatter item identifier.
|
|
178
178
|
*/
|
|
179
179
|
onItemClick: PropTypes.func,
|
|
180
|
+
/**
|
|
181
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
182
|
+
* before it renders for the first time.
|
|
183
|
+
*
|
|
184
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
185
|
+
* the first render, like when used inside a grid.
|
|
186
|
+
*
|
|
187
|
+
* @default false
|
|
188
|
+
*/
|
|
189
|
+
resolveSizeBeforeRender: PropTypes.bool,
|
|
180
190
|
/**
|
|
181
191
|
* Indicate which axis to display the right of the charts.
|
|
182
192
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -4,7 +4,7 @@ import { ChartsTooltipProps, ChartsTooltipSlotProps, ChartsTooltipSlots } from '
|
|
|
4
4
|
import { ChartsAxisHighlightProps } from '../ChartsAxisHighlight';
|
|
5
5
|
import { AxisConfig, ChartsXAxisProps, ChartsYAxisProps, ScaleName } from '../models/axis';
|
|
6
6
|
import { MakeOptional } from '../models/helpers';
|
|
7
|
-
import { LineSeriesType } from '../models/seriesType
|
|
7
|
+
import { LineSeriesType } from '../models/seriesType';
|
|
8
8
|
import { CardinalDirections } from '../models/layout';
|
|
9
9
|
import { AreaPlotSlots, AreaPlotSlotProps } from '../LineChart/AreaPlot';
|
|
10
10
|
import { LinePlotSlots, LinePlotSlotProps } from '../LineChart/LinePlot';
|
|
@@ -193,6 +193,16 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
193
193
|
* @default 'line'
|
|
194
194
|
*/
|
|
195
195
|
plotType: PropTypes.oneOf(['bar', 'line']),
|
|
196
|
+
/**
|
|
197
|
+
* The chart will try to wait for the parent container to resolve its size
|
|
198
|
+
* before it renders for the first time.
|
|
199
|
+
*
|
|
200
|
+
* This can be useful in some scenarios where the chart appear to grow after
|
|
201
|
+
* the first render, like when used inside a grid.
|
|
202
|
+
*
|
|
203
|
+
* @default false
|
|
204
|
+
*/
|
|
205
|
+
resolveSizeBeforeRender: PropTypes.bool,
|
|
196
206
|
/**
|
|
197
207
|
* Set to `true` to highlight the value.
|
|
198
208
|
* With line, it shows a point.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
+
import { computeAxisValue } from "../../internals/computeAxisValue.js";
|
|
4
5
|
import { useDrawingArea } from "../../hooks/useDrawingArea.js";
|
|
5
6
|
import { useSeries } from "../../hooks/useSeries.js";
|
|
6
7
|
import { CartesianContext } from "./CartesianContext.js";
|
|
7
|
-
import { computeValue } from "./computeValue.js";
|
|
8
8
|
import { useXExtremumGetter } from "../PluginProvider/useXExtremumGetter.js";
|
|
9
9
|
import { useYExtremumGetter } from "../PluginProvider/index.js";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -18,14 +18,14 @@ function CartesianProvider(props) {
|
|
|
18
18
|
const drawingArea = useDrawingArea();
|
|
19
19
|
const xExtremumGetters = useXExtremumGetter();
|
|
20
20
|
const yExtremumGetters = useYExtremumGetter();
|
|
21
|
-
const xValues = React.useMemo(() =>
|
|
21
|
+
const xValues = React.useMemo(() => computeAxisValue({
|
|
22
22
|
drawingArea,
|
|
23
23
|
formattedSeries,
|
|
24
24
|
axis: xAxis,
|
|
25
25
|
extremumGetters: xExtremumGetters,
|
|
26
26
|
axisDirection: 'x'
|
|
27
27
|
}), [drawingArea, formattedSeries, xAxis, xExtremumGetters]);
|
|
28
|
-
const yValues = React.useMemo(() =>
|
|
28
|
+
const yValues = React.useMemo(() => computeAxisValue({
|
|
29
29
|
drawingArea,
|
|
30
30
|
formattedSeries,
|
|
31
31
|
axis: yAxis,
|
|
@@ -9,7 +9,7 @@ export declare const defaultizeAxis: (inAxis: MakeOptional<AxisConfig<ScaleName,
|
|
|
9
9
|
label?: string | undefined;
|
|
10
10
|
max?: (number | Date) | undefined;
|
|
11
11
|
min?: (number | Date) | undefined;
|
|
12
|
-
valueFormatter?: ((value: any, context: import("../../
|
|
12
|
+
valueFormatter?: ((value: any, context: import("../../internals").AxisValueFormatterContext) => string) | undefined;
|
|
13
13
|
dataKey?: string | undefined;
|
|
14
14
|
sx?: import("@mui/system").SxProps | undefined;
|
|
15
15
|
classes?: Partial<import("../..").ChartsAxisClasses> | undefined;
|
|
@@ -24,13 +24,13 @@ export declare const defaultizeAxis: (inAxis: MakeOptional<AxisConfig<ScaleName,
|
|
|
24
24
|
tickLabelInterval?: ("auto" | ((value: any, index: number) => boolean)) | undefined;
|
|
25
25
|
labelFontSize?: number | undefined;
|
|
26
26
|
tickSize?: number | undefined;
|
|
27
|
-
slots?: Partial<import("../../
|
|
28
|
-
slotProps?: Partial<import("../../
|
|
27
|
+
slots?: Partial<import("../../internals").ChartsAxisSlots> | undefined;
|
|
28
|
+
slotProps?: Partial<import("../../internals").ChartsAxisSlotProps> | undefined;
|
|
29
29
|
tickInterval?: ("auto" | ((value: any, index: number) => boolean) | any[]) | undefined;
|
|
30
30
|
tickPlacement?: ("start" | "end" | "middle" | "extremities") | undefined;
|
|
31
31
|
tickLabelPlacement?: ("middle" | "tick") | undefined;
|
|
32
32
|
scaleType?: "linear" | "time" | "log" | "band" | "point" | "pow" | "sqrt" | "utc" | undefined;
|
|
33
33
|
colorMap?: import("../../models/colorMapping").ContinuousColorConfig<number | Date> | import("../../models/colorMapping").PiecewiseColorConfig<number | Date> | import("../../models/colorMapping").OrdinalColorConfig<string | number | Date> | undefined;
|
|
34
34
|
hideTooltip?: boolean | undefined;
|
|
35
|
-
id: import("../../
|
|
35
|
+
id: import("../../internals").AxisId;
|
|
36
36
|
}[];
|
|
@@ -2,4 +2,4 @@ import { AxisConfig } from '../../models';
|
|
|
2
2
|
import { FormattedSeries } from '../SeriesProvider';
|
|
3
3
|
import { ExtremumGettersConfig } from '../PluginProvider';
|
|
4
4
|
import { GetZoomAxisFilters } from './Cartesian.types';
|
|
5
|
-
export declare const getAxisExtremum: (axis: AxisConfig, getters: ExtremumGettersConfig,
|
|
5
|
+
export declare const getAxisExtremum: (axis: AxisConfig, getters: ExtremumGettersConfig, axisIndex: number, formattedSeries: FormattedSeries, getFilters?: GetZoomAxisFilters) => number[];
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
const axisExtremumCallback = (acc, chartType, axis, getters,
|
|
1
|
+
const axisExtremumCallback = (acc, chartType, axis, getters, axisIndex, formattedSeries, getFilters) => {
|
|
2
2
|
const getter = getters[chartType];
|
|
3
3
|
const series = formattedSeries[chartType]?.series ?? {};
|
|
4
4
|
const [minChartTypeData, maxChartTypeData] = getter?.({
|
|
5
5
|
series,
|
|
6
6
|
axis,
|
|
7
|
-
|
|
7
|
+
axisIndex,
|
|
8
|
+
isDefaultAxis: axisIndex === 0,
|
|
8
9
|
getFilters
|
|
9
10
|
}) ?? [Infinity, -Infinity];
|
|
10
11
|
const [minData, maxData] = acc;
|
|
11
12
|
return [Math.min(minChartTypeData, minData), Math.max(maxChartTypeData, maxData)];
|
|
12
13
|
};
|
|
13
|
-
export const getAxisExtremum = (axis, getters,
|
|
14
|
+
export const getAxisExtremum = (axis, getters, axisIndex, formattedSeries, getFilters) => {
|
|
14
15
|
const charTypes = Object.keys(getters);
|
|
15
|
-
const extremums = charTypes.reduce((acc, charType) => axisExtremumCallback(acc, charType, axis, getters,
|
|
16
|
+
const extremums = charTypes.reduce((acc, charType) => axisExtremumCallback(acc, charType, axis, getters, axisIndex, formattedSeries, getFilters), [Infinity, -Infinity]);
|
|
16
17
|
if (Number.isNaN(extremums[0]) || Number.isNaN(extremums[1])) {
|
|
17
18
|
return [Infinity, -Infinity];
|
|
18
19
|
}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { computeValue } from './computeValue';
|
|
2
1
|
export * from './CartesianProvider';
|
|
3
2
|
export * from './CartesianContext';
|
|
4
3
|
export * from './useCartesianContext';
|
|
5
4
|
export * from './Cartesian.types';
|
|
6
|
-
declare const cartesianProviderUtils: {
|
|
7
|
-
computeValue: typeof computeValue;
|
|
8
|
-
};
|
|
9
|
-
export { cartesianProviderUtils };
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { computeValue } from "./computeValue.js";
|
|
2
1
|
export * from "./CartesianProvider.js";
|
|
3
2
|
export * from "./CartesianContext.js";
|
|
4
3
|
export * from "./useCartesianContext.js";
|
|
5
|
-
export * from "./Cartesian.types.js";
|
|
6
|
-
const cartesianProviderUtils = {
|
|
7
|
-
computeValue
|
|
8
|
-
};
|
|
9
|
-
export { cartesianProviderUtils };
|
|
4
|
+
export * from "./Cartesian.types.js";
|
|
@@ -7,6 +7,7 @@ export type ExtremumGettersConfig<T extends ChartSeriesType = CartesianChartSeri
|
|
|
7
7
|
type ExtremumGetterParams<T extends ChartSeriesType> = {
|
|
8
8
|
series: Record<SeriesId, ChartSeries<T>>;
|
|
9
9
|
axis: AxisConfig;
|
|
10
|
+
axisIndex: number;
|
|
10
11
|
isDefaultAxis: boolean;
|
|
11
12
|
getFilters?: (params: {
|
|
12
13
|
currentAxisId: AxisId | undefined;
|
|
@@ -15,6 +15,8 @@ export type PluginContextState = {
|
|
|
15
15
|
colorProcessors: ColorProcessorsConfig<ChartSeriesType>;
|
|
16
16
|
xExtremumGetters: ExtremumGettersConfig<ChartSeriesType>;
|
|
17
17
|
yExtremumGetters: ExtremumGettersConfig<ChartSeriesType>;
|
|
18
|
+
rotationExtremumGetters: ExtremumGettersConfig<ChartSeriesType>;
|
|
19
|
+
radiusExtremumGetters: ExtremumGettersConfig<ChartSeriesType>;
|
|
18
20
|
};
|
|
19
21
|
export type ChartsPlugin<T> = T extends ChartSeriesType ? {
|
|
20
22
|
seriesType: T;
|
|
@@ -22,4 +24,6 @@ export type ChartsPlugin<T> = T extends ChartSeriesType ? {
|
|
|
22
24
|
colorProcessor: ColorProcessor<T>;
|
|
23
25
|
xExtremumGetter?: ExtremumGetter<T>;
|
|
24
26
|
yExtremumGetter?: ExtremumGetter<T>;
|
|
27
|
+
rotationExtremumGetter?: ExtremumGetter<T>;
|
|
28
|
+
radiusExtremumGetter?: ExtremumGetter<T>;
|
|
25
29
|
} : never;
|
|
@@ -5,7 +5,9 @@ export const PluginContext = /*#__PURE__*/React.createContext({
|
|
|
5
5
|
colorProcessors: {},
|
|
6
6
|
seriesFormatters: {},
|
|
7
7
|
xExtremumGetters: {},
|
|
8
|
-
yExtremumGetters: {}
|
|
8
|
+
yExtremumGetters: {},
|
|
9
|
+
rotationExtremumGetters: {},
|
|
10
|
+
radiusExtremumGetters: {}
|
|
9
11
|
}
|
|
10
12
|
});
|
|
11
13
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -7,4 +7,6 @@ export * from "./ExtremumGetter.types.js";
|
|
|
7
7
|
export * from "./useColorProcessor.js";
|
|
8
8
|
export * from "./useSeriesFormatter.js";
|
|
9
9
|
export * from "./useXExtremumGetter.js";
|
|
10
|
-
export * from "./useYExtremumGetter.js";
|
|
10
|
+
export * from "./useYExtremumGetter.js";
|
|
11
|
+
export * from "./useRadiusExtremumGetter.js";
|
|
12
|
+
export * from "./useRotationExtremumGetter.js";
|
|
@@ -9,28 +9,38 @@ export declare const defaultPlugins: ({
|
|
|
9
9
|
colorProcessor: ColorProcessor<"bar">;
|
|
10
10
|
xExtremumGetter?: ExtremumGetter<"bar"> | undefined;
|
|
11
11
|
yExtremumGetter?: ExtremumGetter<"bar"> | undefined;
|
|
12
|
+
rotationExtremumGetter?: ExtremumGetter<"bar"> | undefined;
|
|
13
|
+
radiusExtremumGetter?: ExtremumGetter<"bar"> | undefined;
|
|
12
14
|
} | {
|
|
13
15
|
seriesType: "line";
|
|
14
16
|
seriesFormatter: SeriesFormatter<"line">;
|
|
15
17
|
colorProcessor: ColorProcessor<"line">;
|
|
16
18
|
xExtremumGetter?: ExtremumGetter<"line"> | undefined;
|
|
17
19
|
yExtremumGetter?: ExtremumGetter<"line"> | undefined;
|
|
20
|
+
rotationExtremumGetter?: ExtremumGetter<"line"> | undefined;
|
|
21
|
+
radiusExtremumGetter?: ExtremumGetter<"line"> | undefined;
|
|
18
22
|
} | {
|
|
19
23
|
seriesType: "scatter";
|
|
20
24
|
seriesFormatter: SeriesFormatter<"scatter">;
|
|
21
25
|
colorProcessor: ColorProcessor<"scatter">;
|
|
22
26
|
xExtremumGetter?: ExtremumGetter<"scatter"> | undefined;
|
|
23
27
|
yExtremumGetter?: ExtremumGetter<"scatter"> | undefined;
|
|
28
|
+
rotationExtremumGetter?: ExtremumGetter<"scatter"> | undefined;
|
|
29
|
+
radiusExtremumGetter?: ExtremumGetter<"scatter"> | undefined;
|
|
24
30
|
} | {
|
|
25
31
|
seriesType: "pie";
|
|
26
32
|
seriesFormatter: SeriesFormatter<"pie">;
|
|
27
33
|
colorProcessor: ColorProcessor<"pie">;
|
|
28
34
|
xExtremumGetter?: ExtremumGetter<"pie"> | undefined;
|
|
29
35
|
yExtremumGetter?: ExtremumGetter<"pie"> | undefined;
|
|
36
|
+
rotationExtremumGetter?: ExtremumGetter<"pie"> | undefined;
|
|
37
|
+
radiusExtremumGetter?: ExtremumGetter<"pie"> | undefined;
|
|
30
38
|
})[];
|
|
31
39
|
export declare function mergePlugins(plugins?: ChartsPlugin<ChartSeriesType>[]): {
|
|
32
|
-
seriesFormatters: SeriesFormatterConfig<keyof import("../../
|
|
33
|
-
colorProcessors: ColorProcessorsConfig<keyof import("../../
|
|
34
|
-
xExtremumGetters: ExtremumGettersConfig<keyof import("../../
|
|
35
|
-
yExtremumGetters: ExtremumGettersConfig<keyof import("../../
|
|
40
|
+
seriesFormatters: SeriesFormatterConfig<keyof import("../../internals").ChartsSeriesConfig>;
|
|
41
|
+
colorProcessors: ColorProcessorsConfig<keyof import("../../internals").ChartsSeriesConfig>;
|
|
42
|
+
xExtremumGetters: ExtremumGettersConfig<keyof import("../../internals").ChartsSeriesConfig>;
|
|
43
|
+
yExtremumGetters: ExtremumGettersConfig<keyof import("../../internals").ChartsSeriesConfig>;
|
|
44
|
+
rotationExtremumGetters: ExtremumGettersConfig<keyof import("../../internals").ChartsSeriesConfig>;
|
|
45
|
+
radiusExtremumGetters: ExtremumGettersConfig<keyof import("../../internals").ChartsSeriesConfig>;
|
|
36
46
|
};
|
|
@@ -9,6 +9,8 @@ export function mergePlugins(plugins) {
|
|
|
9
9
|
const colorProcessors = {};
|
|
10
10
|
const xExtremumGetters = {};
|
|
11
11
|
const yExtremumGetters = {};
|
|
12
|
+
const rotationExtremumGetters = {};
|
|
13
|
+
const radiusExtremumGetters = {};
|
|
12
14
|
for (let i = 0; i < defaultizedPlugins.length; i += 1) {
|
|
13
15
|
const plugin = defaultizedPlugins[i];
|
|
14
16
|
const seriesType = plugin.seriesType;
|
|
@@ -20,11 +22,19 @@ export function mergePlugins(plugins) {
|
|
|
20
22
|
if (plugin.yExtremumGetter) {
|
|
21
23
|
yExtremumGetters[seriesType] = plugin.yExtremumGetter;
|
|
22
24
|
}
|
|
25
|
+
if (plugin.rotationExtremumGetter) {
|
|
26
|
+
rotationExtremumGetters[seriesType] = plugin.rotationExtremumGetter;
|
|
27
|
+
}
|
|
28
|
+
if (plugin.radiusExtremumGetter) {
|
|
29
|
+
radiusExtremumGetters[seriesType] = plugin.radiusExtremumGetter;
|
|
30
|
+
}
|
|
23
31
|
}
|
|
24
32
|
return {
|
|
25
33
|
seriesFormatters,
|
|
26
34
|
colorProcessors,
|
|
27
35
|
xExtremumGetters,
|
|
28
|
-
yExtremumGetters
|
|
36
|
+
yExtremumGetters,
|
|
37
|
+
rotationExtremumGetters,
|
|
38
|
+
radiusExtremumGetters
|
|
29
39
|
};
|
|
30
40
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChartSeriesType } from '../../models/seriesType/config';
|
|
2
|
+
import { ExtremumGettersConfig } from './ExtremumGetter.types';
|
|
3
|
+
export declare function useRadiusExtremumGetter<T extends ChartSeriesType>(seriesType: T): ExtremumGettersConfig<T>[T];
|
|
4
|
+
export declare function useRadiusExtremumGetter(): ExtremumGettersConfig<ChartSeriesType>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { PluginContext } from "./PluginContext.js";
|
|
5
|
+
export function useRadiusExtremumGetter(seriesType) {
|
|
6
|
+
const {
|
|
7
|
+
isInitialized,
|
|
8
|
+
data
|
|
9
|
+
} = React.useContext(PluginContext);
|
|
10
|
+
if (!isInitialized) {
|
|
11
|
+
throw new Error(['MUI X: Could not find the plugin context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
12
|
+
}
|
|
13
|
+
if (!seriesType) {
|
|
14
|
+
return data.radiusExtremumGetters;
|
|
15
|
+
}
|
|
16
|
+
return data.radiusExtremumGetters[seriesType];
|
|
17
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChartSeriesType } from '../../models/seriesType/config';
|
|
2
|
+
import { ExtremumGettersConfig } from './ExtremumGetter.types';
|
|
3
|
+
export declare function useRotationExtremumGetter<T extends ChartSeriesType>(seriesType: T): ExtremumGettersConfig<T>[T];
|
|
4
|
+
export declare function useRotationExtremumGetter(): ExtremumGettersConfig<ChartSeriesType>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { PluginContext } from "./PluginContext.js";
|
|
5
|
+
export function useRotationExtremumGetter(seriesType) {
|
|
6
|
+
const {
|
|
7
|
+
isInitialized,
|
|
8
|
+
data
|
|
9
|
+
} = React.useContext(PluginContext);
|
|
10
|
+
if (!isInitialized) {
|
|
11
|
+
throw new Error(['MUI X: Could not find the plugin context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
12
|
+
}
|
|
13
|
+
if (!seriesType) {
|
|
14
|
+
return data.rotationExtremumGetters;
|
|
15
|
+
}
|
|
16
|
+
return data.rotationExtremumGetters[seriesType];
|
|
17
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { DatasetType } from '../../models/seriesType/config';
|
|
2
|
+
import { AxisDefaultized, ScaleName, AxisId, AxisConfig, ChartsRotationAxisProps, ChartsRadiusAxisProps } from '../../models/axis';
|
|
3
|
+
export type PolarProviderProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The configuration of the rotation-axes.
|
|
6
|
+
* If not provided, a default axis config is used.
|
|
7
|
+
* An array of [[AxisConfig]] objects.
|
|
8
|
+
*/
|
|
9
|
+
rotationAxis: AxisConfig<ScaleName, any, ChartsRotationAxisProps>[];
|
|
10
|
+
/**
|
|
11
|
+
* The configuration of the radial-axes.
|
|
12
|
+
* If not provided, a default axis config is used.
|
|
13
|
+
* An array of [[AxisConfig]] objects.
|
|
14
|
+
*/
|
|
15
|
+
radiusAxis: AxisConfig<'linear', any, ChartsRadiusAxisProps>[];
|
|
16
|
+
/**
|
|
17
|
+
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
18
|
+
*/
|
|
19
|
+
dataset?: DatasetType;
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
};
|
|
22
|
+
export type DefaultizedAxisConfig<Axis> = {
|
|
23
|
+
[axisId: AxisId]: AxisDefaultized<ScaleName, any, Axis>;
|
|
24
|
+
};
|
|
25
|
+
export type PolarContextState = {
|
|
26
|
+
/**
|
|
27
|
+
* Mapping from rotation-axis key to scaling configuration.
|
|
28
|
+
*/
|
|
29
|
+
rotationAxis: DefaultizedAxisConfig<ChartsRotationAxisProps>;
|
|
30
|
+
/**
|
|
31
|
+
* Mapping from radius-axis key to scaling configuration.
|
|
32
|
+
*/
|
|
33
|
+
radiusAxis: DefaultizedAxisConfig<ChartsRadiusAxisProps>;
|
|
34
|
+
/**
|
|
35
|
+
* The rotation-axes IDs sorted by order they got provided.
|
|
36
|
+
*/
|
|
37
|
+
rotationAxisIds: AxisId[];
|
|
38
|
+
/**
|
|
39
|
+
* The radius-axes IDs sorted by order they got provided.
|
|
40
|
+
*/
|
|
41
|
+
radiusAxisIds: AxisId[];
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const PolarContext = /*#__PURE__*/React.createContext({
|
|
3
|
+
isInitialized: false,
|
|
4
|
+
data: {
|
|
5
|
+
rotationAxis: {},
|
|
6
|
+
radiusAxis: {},
|
|
7
|
+
rotationAxisIds: [],
|
|
8
|
+
radiusAxisIds: []
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
12
|
+
PolarContext.displayName = 'PolarContext';
|
|
13
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { computeAxisValue } from "../../internals/computeAxisValue.js";
|
|
5
|
+
import { useDrawingArea } from "../../hooks/useDrawingArea.js";
|
|
6
|
+
import { useSeries } from "../../hooks/useSeries.js";
|
|
7
|
+
import { PolarContext } from "./PolarContext.js";
|
|
8
|
+
import { useRadiusExtremumGetter } from "../PluginProvider/useRadiusExtremumGetter.js";
|
|
9
|
+
import { useRotationExtremumGetter } from "../PluginProvider/useRotationExtremumGetter.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
function PolarProvider(props) {
|
|
12
|
+
const {
|
|
13
|
+
rotationAxis,
|
|
14
|
+
radiusAxis,
|
|
15
|
+
children
|
|
16
|
+
} = props;
|
|
17
|
+
const formattedSeries = useSeries();
|
|
18
|
+
const drawingArea = useDrawingArea();
|
|
19
|
+
const rotationExtremumGetters = useRotationExtremumGetter();
|
|
20
|
+
const radiusExtremumGetters = useRadiusExtremumGetter();
|
|
21
|
+
const rotationValues = React.useMemo(() => computeAxisValue({
|
|
22
|
+
drawingArea,
|
|
23
|
+
formattedSeries,
|
|
24
|
+
axis: rotationAxis,
|
|
25
|
+
extremumGetters: rotationExtremumGetters,
|
|
26
|
+
axisDirection: 'rotation'
|
|
27
|
+
}), [drawingArea, formattedSeries, rotationAxis, rotationExtremumGetters]);
|
|
28
|
+
const radiusValues = React.useMemo(() => computeAxisValue({
|
|
29
|
+
drawingArea,
|
|
30
|
+
formattedSeries,
|
|
31
|
+
axis: radiusAxis,
|
|
32
|
+
extremumGetters: radiusExtremumGetters,
|
|
33
|
+
axisDirection: 'radius'
|
|
34
|
+
}), [drawingArea, formattedSeries, radiusAxis, radiusExtremumGetters]);
|
|
35
|
+
const value = React.useMemo(() => ({
|
|
36
|
+
isInitialized: true,
|
|
37
|
+
data: {
|
|
38
|
+
rotationAxis: rotationValues.axis,
|
|
39
|
+
radiusAxis: radiusValues.axis,
|
|
40
|
+
rotationAxisIds: rotationValues.axisIds,
|
|
41
|
+
radiusAxisIds: radiusValues.axisIds
|
|
42
|
+
}
|
|
43
|
+
}), [rotationValues, radiusValues]);
|
|
44
|
+
return /*#__PURE__*/_jsx(PolarContext.Provider, {
|
|
45
|
+
value: value,
|
|
46
|
+
children: children
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export { PolarProvider };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AxisConfig } from '../../models';
|
|
2
|
+
import { FormattedSeries } from '../SeriesProvider';
|
|
3
|
+
import { ExtremumGettersConfig } from '../PluginProvider';
|
|
4
|
+
export declare const getAxisExtremum: (axis: AxisConfig, getters: ExtremumGettersConfig, axisIndex: number, formattedSeries: FormattedSeries) => number[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const axisExtremumCallback = (acc, chartType, axis, getters, axisIndex, formattedSeries) => {
|
|
2
|
+
const getter = getters[chartType];
|
|
3
|
+
const series = formattedSeries[chartType]?.series ?? {};
|
|
4
|
+
const [minChartTypeData, maxChartTypeData] = getter?.({
|
|
5
|
+
series,
|
|
6
|
+
axis,
|
|
7
|
+
axisIndex,
|
|
8
|
+
isDefaultAxis: axisIndex === 0
|
|
9
|
+
}) ?? [Infinity, -Infinity];
|
|
10
|
+
const [minData, maxData] = acc;
|
|
11
|
+
return [Math.min(minChartTypeData, minData), Math.max(maxChartTypeData, maxData)];
|
|
12
|
+
};
|
|
13
|
+
export const getAxisExtremum = (axis, getters, axisIndex, formattedSeries) => {
|
|
14
|
+
const charTypes = Object.keys(getters);
|
|
15
|
+
const extremums = charTypes.reduce((acc, charType) => axisExtremumCallback(acc, charType, axis, getters, axisIndex, formattedSeries), [Infinity, -Infinity]);
|
|
16
|
+
if (Number.isNaN(extremums[0]) || Number.isNaN(extremums[1])) {
|
|
17
|
+
return [Infinity, -Infinity];
|
|
18
|
+
}
|
|
19
|
+
return extremums;
|
|
20
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -24,7 +24,7 @@ function ZAxisContextProvider(props) {
|
|
|
24
24
|
return axisConfig;
|
|
25
25
|
}
|
|
26
26
|
if (dataset === undefined) {
|
|
27
|
-
throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
27
|
+
throw new Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
28
28
|
}
|
|
29
29
|
return _extends({}, axisConfig, {
|
|
30
30
|
data: dataset.map(d => d[dataKey])
|