@mui/x-charts 7.22.2 → 8.0.0-alpha.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 +7 -7
- package/BarChart/BarChart.js +7 -29
- package/BarChart/BarElement.d.ts +1 -1
- package/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
- package/BarChart/BarPlot.js +12 -4
- package/BarChart/extremums.js +3 -3
- package/BarChart/useBarChartProps.d.ts +2 -2
- package/BarChart/useBarChartProps.js +3 -4
- package/CHANGELOG.md +142 -155
- package/ChartContainer/ChartContainer.d.ts +16 -33
- package/ChartContainer/ChartContainer.js +22 -41
- package/{ResponsiveChartContainer → ChartContainer}/ResizableContainer.d.ts +2 -2
- package/{ResponsiveChartContainer → ChartContainer}/useChartContainerDimensions.d.ts +1 -1
- package/{ResponsiveChartContainer → ChartContainer}/useChartContainerDimensions.js +6 -4
- package/ChartContainer/useChartContainerProps.d.ts +11 -94
- package/ChartContainer/useChartContainerProps.js +42 -58
- package/ChartsLegend/ChartsLegend.js +0 -3
- package/ChartsLegend/DefaultChartsLegend.d.ts +0 -5
- package/ChartsLegend/DefaultChartsLegend.js +1 -12
- package/ChartsLegend/LegendPerItem.d.ts +1 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/ChartsOverlay/ChartsOverlay.d.ts +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
- package/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
- package/ChartsTooltip/ChartsTooltip.js +45 -6
- package/ChartsTooltip/useAxisTooltip.js +3 -3
- package/ChartsTooltip/useItemTooltip.js +3 -3
- package/ChartsTooltip/utils.d.ts +5 -13
- package/ChartsTooltip/utils.js +45 -42
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -5
- package/Gauge/GaugeContainer.js +1 -1
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/AreaPlot.js +2 -6
- package/LineChart/LineChart.d.ts +7 -7
- package/LineChart/LineChart.js +7 -29
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/LineHighlightPlot.d.ts +1 -1
- package/LineChart/LineHighlightPlot.js +2 -6
- package/LineChart/LinePlot.js +2 -6
- package/LineChart/MarkPlot.js +2 -6
- package/LineChart/extremums.js +10 -6
- package/LineChart/useLineChartProps.d.ts +2 -2
- package/LineChart/useLineChartProps.js +3 -4
- package/PieChart/PieArc.d.ts +0 -5
- package/PieChart/PieArc.js +1 -10
- package/PieChart/PieArcPlot.js +0 -5
- package/PieChart/PieChart.d.ts +9 -32
- package/PieChart/PieChart.js +17 -102
- package/README.md +2 -2
- package/ScatterChart/ScatterChart.d.ts +7 -7
- package/ScatterChart/ScatterChart.js +7 -29
- package/ScatterChart/ScatterPlot.js +3 -6
- package/ScatterChart/extremums.js +6 -6
- package/ScatterChart/useScatterChartProps.d.ts +2 -2
- package/ScatterChart/useScatterChartProps.js +3 -4
- package/SparkLineChart/SparkLineChart.d.ts +4 -4
- package/SparkLineChart/SparkLineChart.js +2 -2
- package/context/CartesianProvider/defaultizeAxis.d.ts +1 -1
- package/context/ChartDataProvider/ChartDataProvider.d.ts +41 -0
- package/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +46 -27
- package/context/ChartDataProvider/index.d.ts +1 -0
- package/context/ChartDataProvider/index.js +1 -0
- package/context/ChartDataProvider/useChartDataProviderProps.d.ts +97 -0
- package/context/ChartDataProvider/useChartDataProviderProps.js +86 -0
- package/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.d.ts +12 -12
- package/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
- package/context/HighlightedProvider/HighlightedContext.d.ts +0 -8
- package/context/HighlightedProvider/HighlightedProvider.js +1 -16
- package/context/PluginProvider/ExtremumGetter.types.d.ts +2 -2
- package/context/ZAxisContextProvider.d.ts +1 -1
- package/index.d.ts +1 -2
- package/index.js +2 -3
- package/internals/defaultizeColor.d.ts +1 -8
- package/internals/getSymbol.js +19 -3
- package/internals/index.d.ts +5 -5
- package/internals/index.js +5 -5
- package/internals/useStringInterpolator.js +1 -0
- package/models/seriesType/bar.d.ts +1 -1
- package/models/seriesType/common.d.ts +0 -10
- package/models/seriesType/config.d.ts +1 -1
- package/models/seriesType/line.d.ts +1 -1
- package/models/seriesType/pie.d.ts +1 -1
- package/models/seriesType/scatter.d.ts +1 -6
- package/modern/BarChart/BarChart.js +7 -29
- package/modern/BarChart/BarPlot.js +12 -4
- package/modern/BarChart/extremums.js +3 -3
- package/modern/BarChart/useBarChartProps.js +3 -4
- package/modern/ChartContainer/ChartContainer.js +22 -41
- package/modern/{ResponsiveChartContainer → ChartContainer}/useChartContainerDimensions.js +6 -4
- package/modern/ChartContainer/useChartContainerProps.js +42 -58
- package/modern/ChartsLegend/ChartsLegend.js +0 -3
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -12
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
- package/modern/ChartsTooltip/ChartsTooltip.js +45 -6
- package/modern/ChartsTooltip/useAxisTooltip.js +3 -3
- package/modern/ChartsTooltip/useItemTooltip.js +3 -3
- package/modern/ChartsTooltip/utils.js +45 -42
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -5
- package/modern/Gauge/GaugeContainer.js +1 -1
- package/modern/LineChart/AreaPlot.js +2 -6
- package/modern/LineChart/LineChart.js +7 -29
- package/modern/LineChart/LineHighlightPlot.js +2 -6
- package/modern/LineChart/LinePlot.js +2 -6
- package/modern/LineChart/MarkPlot.js +2 -6
- package/modern/LineChart/extremums.js +10 -6
- package/modern/LineChart/useLineChartProps.js +3 -4
- package/modern/PieChart/PieArc.js +1 -10
- package/modern/PieChart/PieArcPlot.js +0 -5
- package/modern/PieChart/PieChart.js +17 -102
- package/modern/ScatterChart/ScatterChart.js +7 -29
- package/modern/ScatterChart/ScatterPlot.js +3 -6
- package/modern/ScatterChart/extremums.js +6 -6
- package/modern/ScatterChart/useScatterChartProps.js +3 -4
- package/modern/SparkLineChart/SparkLineChart.js +2 -2
- package/modern/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +46 -27
- package/modern/context/ChartDataProvider/index.js +1 -0
- package/modern/context/ChartDataProvider/useChartDataProviderProps.js +86 -0
- package/modern/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
- package/modern/context/HighlightedProvider/HighlightedProvider.js +1 -16
- package/modern/index.js +2 -3
- package/modern/internals/getSymbol.js +19 -3
- package/modern/internals/index.js +5 -5
- package/modern/internals/useStringInterpolator.js +1 -0
- package/node/BarChart/BarChart.js +7 -29
- package/node/BarChart/BarPlot.js +11 -3
- package/node/BarChart/extremums.js +3 -3
- package/node/BarChart/useBarChartProps.js +3 -4
- package/node/ChartContainer/ChartContainer.js +21 -40
- package/node/{ResponsiveChartContainer → ChartContainer}/useChartContainerDimensions.js +6 -4
- package/node/ChartContainer/useChartContainerProps.js +42 -59
- package/node/ChartsLegend/ChartsLegend.js +0 -3
- package/node/ChartsLegend/DefaultChartsLegend.js +1 -12
- package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +2 -2
- package/node/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
- package/node/ChartsTooltip/ChartsItemTooltipContent.js +3 -3
- package/node/ChartsTooltip/ChartsTooltip.js +44 -5
- package/node/ChartsTooltip/useAxisTooltip.js +3 -3
- package/node/ChartsTooltip/useItemTooltip.js +3 -3
- package/node/ChartsTooltip/utils.js +46 -44
- package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +3 -5
- package/node/Gauge/GaugeContainer.js +1 -1
- package/node/LineChart/AreaPlot.js +2 -6
- package/node/LineChart/LineChart.js +7 -29
- package/node/LineChart/LineHighlightPlot.js +2 -6
- package/node/LineChart/LinePlot.js +2 -6
- package/node/LineChart/MarkPlot.js +2 -6
- package/node/LineChart/extremums.js +10 -6
- package/node/LineChart/useLineChartProps.js +3 -4
- package/node/PieChart/PieArc.js +1 -10
- package/node/PieChart/PieArcPlot.js +0 -5
- package/node/PieChart/PieChart.js +17 -102
- package/node/ScatterChart/ScatterChart.js +7 -29
- package/node/ScatterChart/ScatterPlot.js +3 -6
- package/node/ScatterChart/extremums.js +6 -6
- package/node/ScatterChart/useScatterChartProps.js +3 -4
- package/node/SparkLineChart/SparkLineChart.js +2 -2
- package/node/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +45 -26
- package/node/context/ChartDataProvider/index.js +16 -0
- package/node/context/ChartDataProvider/useChartDataProviderProps.js +94 -0
- package/node/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
- package/node/context/HighlightedProvider/HighlightedProvider.js +1 -16
- package/node/index.js +5 -16
- package/node/internals/getSymbol.js +19 -3
- package/node/internals/index.js +37 -29
- package/node/internals/useStringInterpolator.js +2 -0
- package/package.json +4 -4
- package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -24
- package/ResponsiveChartContainer/index.d.ts +0 -1
- package/ResponsiveChartContainer/index.js +0 -1
- package/ResponsiveChartContainer/package.json +0 -6
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +0 -19
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -70
- package/internals/SlotComponentPropsFromProps.d.ts +0 -1
- package/internals/SlotComponentPropsFromProps.js +0 -1
- package/models/helpers.d.ts +0 -3
- package/models/helpers.js +0 -1
- package/modern/ResponsiveChartContainer/index.js +0 -1
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -70
- package/modern/internals/SlotComponentPropsFromProps.js +0 -1
- package/modern/models/helpers.js +0 -1
- package/node/ResponsiveChartContainer/index.js +0 -16
- package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -77
- package/node/internals/SlotComponentPropsFromProps.js +0 -5
- package/node/models/helpers.js +0 -5
- /package/{ResponsiveChartContainer → ChartContainer}/ResizableContainer.js +0 -0
- /package/modern/{ResponsiveChartContainer → ChartContainer}/ResizableContainer.js +0 -0
- /package/node/{ResponsiveChartContainer → ChartContainer}/ResizableContainer.js +0 -0
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
/* eslint-disable react-compiler/react-compiler */
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
6
|
import ownerWindow from '@mui/utils/ownerWindow';
|
|
6
7
|
export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBeforeRender) => {
|
|
8
|
+
const hasInSize = inWidth !== undefined && inHeight !== undefined;
|
|
7
9
|
const stateRef = React.useRef({
|
|
8
10
|
displayError: false,
|
|
9
11
|
initialCompute: true,
|
|
@@ -40,7 +42,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
40
42
|
// https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
|
|
41
43
|
useEnhancedEffect(() => {
|
|
42
44
|
// computeRun is used to avoid infinite loops.
|
|
43
|
-
if (!resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
|
|
45
|
+
if (hasInSize || !resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
|
|
44
46
|
return;
|
|
45
47
|
}
|
|
46
48
|
const computedSize = computeSize();
|
|
@@ -49,9 +51,9 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
49
51
|
} else if (stateRef.current.initialCompute) {
|
|
50
52
|
stateRef.current.initialCompute = false;
|
|
51
53
|
}
|
|
52
|
-
}, [width, height, computeSize, resolveSizeBeforeRender]);
|
|
54
|
+
}, [width, height, computeSize, resolveSizeBeforeRender, hasInSize]);
|
|
53
55
|
useEnhancedEffect(() => {
|
|
54
|
-
if (
|
|
56
|
+
if (hasInSize) {
|
|
55
57
|
return () => {};
|
|
56
58
|
}
|
|
57
59
|
computeSize();
|
|
@@ -77,7 +79,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
77
79
|
observer.unobserve(elementToObserve);
|
|
78
80
|
}
|
|
79
81
|
};
|
|
80
|
-
}, [computeSize,
|
|
82
|
+
}, [computeSize, hasInSize]);
|
|
81
83
|
if (process.env.NODE_ENV !== 'production') {
|
|
82
84
|
if (stateRef.current.displayError && inWidth === undefined && width === 0) {
|
|
83
85
|
console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
|
|
@@ -1,97 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { DrawingProviderProps } from '../context/DrawingProvider';
|
|
3
|
-
import type { CartesianProviderProps } from '../context/CartesianProvider';
|
|
4
|
-
import type { SeriesProviderProps } from '../context/SeriesProvider';
|
|
5
|
-
import type { ZAxisContextProviderProps } from '../context/ZAxisContextProvider';
|
|
1
|
+
import { ChartDataProviderProps } from '../context/ChartDataProvider';
|
|
6
2
|
import type { ChartContainerProps } from './ChartContainer';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
zAxisContextProps: Omit<ZAxisContextProviderProps, "children">;
|
|
17
|
-
highlightedProviderProps: Omit<HighlightedProviderProps, "children">;
|
|
18
|
-
chartsSurfaceProps: ChartsSurfaceProps & {
|
|
19
|
-
ref: any;
|
|
3
|
+
export type UseChartContainerPropsReturnValue = {
|
|
4
|
+
hasIntrinsicSize: boolean;
|
|
5
|
+
chartDataProviderProps: ChartDataProviderProps;
|
|
6
|
+
resizableChartContainerProps: {
|
|
7
|
+
ownerState: {
|
|
8
|
+
width: ChartContainerProps['width'];
|
|
9
|
+
height: ChartContainerProps['height'];
|
|
10
|
+
};
|
|
11
|
+
ref: React.Ref<HTMLDivElement>;
|
|
20
12
|
};
|
|
21
|
-
pluginProviderProps: Omit<PluginProviderProps, "children">;
|
|
22
|
-
animationProviderProps: Omit<AnimationProviderProps, "children">;
|
|
23
|
-
xAxis: {
|
|
24
|
-
reverse?: boolean | undefined;
|
|
25
|
-
fill?: string | undefined;
|
|
26
|
-
stroke?: string | undefined;
|
|
27
|
-
data?: any[] | undefined;
|
|
28
|
-
label?: string | undefined;
|
|
29
|
-
max?: (number | Date) | undefined;
|
|
30
|
-
min?: (number | Date) | undefined;
|
|
31
|
-
valueFormatter?: ((value: any, context: import("../internals").AxisValueFormatterContext) => string) | undefined;
|
|
32
|
-
dataKey?: string | undefined;
|
|
33
|
-
sx?: import("@mui/system").SxProps | undefined;
|
|
34
|
-
classes?: Partial<import("..").ChartsAxisClasses> | undefined;
|
|
35
|
-
tickMaxStep?: number | undefined;
|
|
36
|
-
tickMinStep?: number | undefined;
|
|
37
|
-
tickNumber?: number | undefined;
|
|
38
|
-
disableLine?: boolean | undefined;
|
|
39
|
-
disableTicks?: boolean | undefined;
|
|
40
|
-
tickFontSize?: number | undefined;
|
|
41
|
-
tickLabelStyle?: import("..").ChartsTextProps["style"];
|
|
42
|
-
labelStyle?: import("..").ChartsTextProps["style"];
|
|
43
|
-
tickLabelInterval?: ("auto" | ((value: any, index: number) => boolean)) | undefined;
|
|
44
|
-
labelFontSize?: number | undefined;
|
|
45
|
-
tickSize?: number | undefined;
|
|
46
|
-
slots?: Partial<import("../internals").ChartsAxisSlots> | undefined;
|
|
47
|
-
slotProps?: Partial<import("../internals").ChartsAxisSlotProps> | undefined;
|
|
48
|
-
tickInterval?: ("auto" | ((value: any, index: number) => boolean) | any[]) | undefined;
|
|
49
|
-
tickPlacement?: ("start" | "end" | "middle" | "extremities") | undefined;
|
|
50
|
-
tickLabelPlacement?: ("middle" | "tick") | undefined;
|
|
51
|
-
scaleType?: "linear" | "time" | "log" | "band" | "point" | "pow" | "sqrt" | "utc" | undefined;
|
|
52
|
-
colorMap?: import("../models/colorMapping").ContinuousColorConfig<number | Date> | import("../models/colorMapping").PiecewiseColorConfig<number | Date> | import("../models/colorMapping").OrdinalColorConfig<string | number | Date> | undefined;
|
|
53
|
-
hideTooltip?: boolean | undefined;
|
|
54
|
-
domainLimit?: ("nice" | "strict" | ((min: number, max: number) => {
|
|
55
|
-
min: number;
|
|
56
|
-
max: number;
|
|
57
|
-
})) | undefined;
|
|
58
|
-
id: import("../internals").AxisId;
|
|
59
|
-
}[];
|
|
60
|
-
yAxis: {
|
|
61
|
-
reverse?: boolean | undefined;
|
|
62
|
-
fill?: string | undefined;
|
|
63
|
-
stroke?: string | undefined;
|
|
64
|
-
data?: any[] | undefined;
|
|
65
|
-
label?: string | undefined;
|
|
66
|
-
max?: (number | Date) | undefined;
|
|
67
|
-
min?: (number | Date) | undefined;
|
|
68
|
-
valueFormatter?: ((value: any, context: import("../internals").AxisValueFormatterContext) => string) | undefined;
|
|
69
|
-
dataKey?: string | undefined;
|
|
70
|
-
sx?: import("@mui/system").SxProps | undefined;
|
|
71
|
-
classes?: Partial<import("..").ChartsAxisClasses> | undefined;
|
|
72
|
-
tickMaxStep?: number | undefined;
|
|
73
|
-
tickMinStep?: number | undefined;
|
|
74
|
-
tickNumber?: number | undefined;
|
|
75
|
-
disableLine?: boolean | undefined;
|
|
76
|
-
disableTicks?: boolean | undefined;
|
|
77
|
-
tickFontSize?: number | undefined;
|
|
78
|
-
tickLabelStyle?: import("..").ChartsTextProps["style"];
|
|
79
|
-
labelStyle?: import("..").ChartsTextProps["style"];
|
|
80
|
-
tickLabelInterval?: ("auto" | ((value: any, index: number) => boolean)) | undefined;
|
|
81
|
-
labelFontSize?: number | undefined;
|
|
82
|
-
tickSize?: number | undefined;
|
|
83
|
-
slots?: Partial<import("../internals").ChartsAxisSlots> | undefined;
|
|
84
|
-
slotProps?: Partial<import("../internals").ChartsAxisSlotProps> | undefined;
|
|
85
|
-
tickInterval?: ("auto" | ((value: any, index: number) => boolean) | any[]) | undefined;
|
|
86
|
-
tickPlacement?: ("start" | "end" | "middle" | "extremities") | undefined;
|
|
87
|
-
tickLabelPlacement?: ("middle" | "tick") | undefined;
|
|
88
|
-
scaleType?: "linear" | "time" | "log" | "band" | "point" | "pow" | "sqrt" | "utc" | undefined;
|
|
89
|
-
colorMap?: import("../models/colorMapping").ContinuousColorConfig<number | Date> | import("../models/colorMapping").PiecewiseColorConfig<number | Date> | import("../models/colorMapping").OrdinalColorConfig<string | number | Date> | undefined;
|
|
90
|
-
hideTooltip?: boolean | undefined;
|
|
91
|
-
domainLimit?: ("nice" | "strict" | ((min: number, max: number) => {
|
|
92
|
-
min: number;
|
|
93
|
-
max: number;
|
|
94
|
-
})) | undefined;
|
|
95
|
-
id: import("../internals").AxisId;
|
|
96
|
-
}[];
|
|
97
13
|
};
|
|
14
|
+
export declare const useChartContainerProps: (props: ChartContainerProps, ref: React.Ref<SVGSVGElement>) => UseChartContainerPropsReturnValue;
|
|
@@ -2,85 +2,69 @@
|
|
|
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", "
|
|
6
|
-
import
|
|
7
|
-
import useForkRef from '@mui/utils/useForkRef';
|
|
8
|
-
import { useDefaultizeAxis } from "./useDefaultizeAxis.js";
|
|
5
|
+
const _excluded = ["width", "height", "resolveSizeBeforeRender", "margin", "children", "series", "colors", "dataset", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "sx", "title", "viewBox", "xAxis", "yAxis", "zAxis", "skipAnimation"];
|
|
6
|
+
import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
|
|
9
7
|
export const useChartContainerProps = (props, ref) => {
|
|
10
8
|
const {
|
|
11
9
|
width,
|
|
12
10
|
height,
|
|
13
|
-
|
|
11
|
+
resolveSizeBeforeRender,
|
|
14
12
|
margin,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
zAxis,
|
|
13
|
+
children,
|
|
14
|
+
series,
|
|
18
15
|
colors,
|
|
19
16
|
dataset,
|
|
20
|
-
sx,
|
|
21
|
-
title,
|
|
22
17
|
desc,
|
|
23
18
|
disableAxisListener,
|
|
24
19
|
highlightedItem,
|
|
25
20
|
onHighlightChange,
|
|
26
21
|
plugins,
|
|
27
|
-
|
|
22
|
+
sx,
|
|
23
|
+
title,
|
|
24
|
+
viewBox,
|
|
25
|
+
xAxis,
|
|
26
|
+
yAxis,
|
|
27
|
+
zAxis,
|
|
28
28
|
skipAnimation
|
|
29
29
|
} = props,
|
|
30
30
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const {
|
|
32
|
+
containerRef,
|
|
33
|
+
width: dWidth,
|
|
34
|
+
height: dHeight
|
|
35
|
+
} = useChartContainerDimensions(width, height, resolveSizeBeforeRender);
|
|
36
|
+
const resizableChartContainerProps = _extends({}, other, {
|
|
37
|
+
ownerState: {
|
|
38
|
+
width,
|
|
39
|
+
height
|
|
40
|
+
},
|
|
41
|
+
ref: containerRef
|
|
42
|
+
});
|
|
43
|
+
const chartDataProviderProps = {
|
|
37
44
|
margin,
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
const animationProviderProps = {
|
|
41
|
-
skipAnimation
|
|
42
|
-
};
|
|
43
|
-
const pluginProviderProps = {
|
|
44
|
-
plugins
|
|
45
|
-
};
|
|
46
|
-
const seriesProviderProps = {
|
|
45
|
+
children,
|
|
47
46
|
series,
|
|
48
47
|
colors,
|
|
49
|
-
dataset
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
xAxis: defaultizedXAxis,
|
|
53
|
-
yAxis: defaultizedYAxis,
|
|
54
|
-
dataset
|
|
55
|
-
};
|
|
56
|
-
const zAxisContextProps = {
|
|
57
|
-
zAxis,
|
|
58
|
-
dataset
|
|
59
|
-
};
|
|
60
|
-
const highlightedProviderProps = {
|
|
48
|
+
dataset,
|
|
49
|
+
desc,
|
|
50
|
+
disableAxisListener,
|
|
61
51
|
highlightedItem,
|
|
62
|
-
onHighlightChange
|
|
63
|
-
|
|
64
|
-
const chartsSurfaceProps = _extends({}, other, {
|
|
65
|
-
width,
|
|
66
|
-
height,
|
|
67
|
-
ref: chartSurfaceRef,
|
|
52
|
+
onHighlightChange,
|
|
53
|
+
plugins,
|
|
68
54
|
sx,
|
|
69
55
|
title,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
56
|
+
viewBox,
|
|
57
|
+
xAxis,
|
|
58
|
+
yAxis,
|
|
59
|
+
zAxis,
|
|
60
|
+
skipAnimation,
|
|
61
|
+
width: dWidth,
|
|
62
|
+
height: dHeight,
|
|
63
|
+
ref
|
|
64
|
+
};
|
|
73
65
|
return {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
cartesianProviderProps,
|
|
78
|
-
zAxisContextProps,
|
|
79
|
-
highlightedProviderProps,
|
|
80
|
-
chartsSurfaceProps,
|
|
81
|
-
pluginProviderProps,
|
|
82
|
-
animationProviderProps,
|
|
83
|
-
xAxis: defaultizedXAxis,
|
|
84
|
-
yAxis: defaultizedYAxis
|
|
66
|
+
hasIntrinsicSize: Boolean(dWidth && dHeight),
|
|
67
|
+
chartDataProviderProps,
|
|
68
|
+
resizableChartContainerProps
|
|
85
69
|
};
|
|
86
70
|
};
|
|
@@ -11,7 +11,6 @@ import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
|
11
11
|
import { getSeriesToDisplay } from "./utils.js";
|
|
12
12
|
import { getLegendUtilityClass } from "./chartsLegendClasses.js";
|
|
13
13
|
import { DefaultChartsLegend } from "./DefaultChartsLegend.js";
|
|
14
|
-
import { useDrawingArea } from "../hooks/index.js";
|
|
15
14
|
import { useSeries } from "../hooks/useSeries.js";
|
|
16
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
16
|
const useUtilityClasses = ownerState => {
|
|
@@ -50,7 +49,6 @@ function ChartsLegend(inProps) {
|
|
|
50
49
|
const classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
51
50
|
theme
|
|
52
51
|
}));
|
|
53
|
-
const drawingArea = useDrawingArea();
|
|
54
52
|
const series = useSeries();
|
|
55
53
|
const seriesToDisplay = getSeriesToDisplay(series);
|
|
56
54
|
const ChartLegendRender = slots?.legend ?? DefaultChartsLegend;
|
|
@@ -59,7 +57,6 @@ function ChartsLegend(inProps) {
|
|
|
59
57
|
externalSlotProps: slotProps?.legend,
|
|
60
58
|
additionalProps: _extends({}, other, {
|
|
61
59
|
classes,
|
|
62
|
-
drawingArea,
|
|
63
60
|
series,
|
|
64
61
|
seriesToDisplay
|
|
65
62
|
}),
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { FormattedSeries } from '../context/SeriesProvider';
|
|
3
3
|
import { LegendPerItemProps } from './LegendPerItem';
|
|
4
|
-
import { DrawingArea } from '../context/DrawingProvider';
|
|
5
4
|
import { SeriesLegendItemContext } from './chartsLegend.types';
|
|
6
5
|
export interface LegendRendererProps extends Omit<LegendPerItemProps, 'itemsToDisplay' | 'onItemClick'> {
|
|
7
6
|
series: FormattedSeries;
|
|
8
7
|
seriesToDisplay: LegendPerItemProps['itemsToDisplay'];
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use the `useDrawingArea` hook instead.
|
|
11
|
-
*/
|
|
12
|
-
drawingArea: Omit<DrawingArea, 'isPointInside'>;
|
|
13
8
|
/**
|
|
14
9
|
* Callback fired when a legend item is clicked.
|
|
15
10
|
* @param {React.MouseEvent<SVGRectElement, MouseEvent>} event The click event.
|
|
@@ -2,7 +2,7 @@
|
|
|
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 = ["
|
|
5
|
+
const _excluded = ["seriesToDisplay", "hidden", "onItemClick"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { LegendPerItem } from "./LegendPerItem.js";
|
|
@@ -43,17 +43,6 @@ process.env.NODE_ENV !== "production" ? DefaultChartsLegend.propTypes = {
|
|
|
43
43
|
* The default depends on the chart.
|
|
44
44
|
*/
|
|
45
45
|
direction: PropTypes.oneOf(['column', 'row']).isRequired,
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated Use the `useDrawingArea` hook instead.
|
|
48
|
-
*/
|
|
49
|
-
drawingArea: PropTypes.shape({
|
|
50
|
-
bottom: PropTypes.number.isRequired,
|
|
51
|
-
height: PropTypes.number.isRequired,
|
|
52
|
-
left: PropTypes.number.isRequired,
|
|
53
|
-
right: PropTypes.number.isRequired,
|
|
54
|
-
top: PropTypes.number.isRequired,
|
|
55
|
-
width: PropTypes.number.isRequired
|
|
56
|
-
}).isRequired,
|
|
57
46
|
/**
|
|
58
47
|
* Set to true to hide the legend.
|
|
59
48
|
* @default false
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { DefaultizedProps } from '@mui/x-internals/types';
|
|
2
3
|
import { DrawingArea } from '../context/DrawingProvider';
|
|
3
4
|
import { ChartsTextStyle } from '../ChartsText';
|
|
4
5
|
import { CardinalDirections } from '../models/layout';
|
|
5
6
|
import { LegendItemParams } from './chartsLegend.types';
|
|
6
7
|
import { AnchorPosition, Direction, LegendPlacement } from './legend.types';
|
|
7
8
|
import { ChartsLegendClasses } from './chartsLegendClasses';
|
|
8
|
-
import { DefaultizedProps } from '../models/helpers';
|
|
9
9
|
export type ChartsLegendRootOwnerState = {
|
|
10
10
|
position: AnchorPosition;
|
|
11
11
|
direction: Direction;
|
|
@@ -39,8 +39,8 @@ function ChartsOnAxisClickHandler(props) {
|
|
|
39
39
|
Object.keys(series).filter(seriesType => ['bar', 'line'].includes(seriesType)).forEach(seriesType => {
|
|
40
40
|
series[seriesType]?.seriesOrder.forEach(seriesId => {
|
|
41
41
|
const seriesItem = series[seriesType].series[seriesId];
|
|
42
|
-
const providedXAxisId = seriesItem.xAxisId
|
|
43
|
-
const providedYAxisId = seriesItem.yAxisId
|
|
42
|
+
const providedXAxisId = seriesItem.xAxisId;
|
|
43
|
+
const providedYAxisId = seriesItem.yAxisId;
|
|
44
44
|
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
45
45
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
46
46
|
seriesValues[seriesId] = seriesItem.data[dataIndex];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
-
import { SlotComponentPropsFromProps } from '
|
|
3
|
+
import { SlotComponentPropsFromProps } from '@mui/x-internals/types';
|
|
4
4
|
export declare function useNoData(): boolean;
|
|
5
5
|
export type CommonOverlayProps = React.SVGAttributes<SVGTextElement> & {
|
|
6
6
|
/**
|
|
@@ -40,14 +40,14 @@ function ChartsAxisTooltipContent(props) {
|
|
|
40
40
|
Object.keys(series).filter(isCartesianSeriesType).forEach(seriesType => {
|
|
41
41
|
series[seriesType].seriesOrder.forEach(seriesId => {
|
|
42
42
|
const item = series[seriesType].series[seriesId];
|
|
43
|
-
const providedXAxisId = item.xAxisId
|
|
44
|
-
const providedYAxisId = item.yAxisId
|
|
43
|
+
const providedXAxisId = item.xAxisId;
|
|
44
|
+
const providedYAxisId = item.yAxisId;
|
|
45
45
|
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
46
46
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
47
47
|
const seriesToAdd = series[seriesType].series[seriesId];
|
|
48
48
|
const xAxisId = providedXAxisId ?? xAxisIds[0];
|
|
49
49
|
const yAxisId = providedYAxisId ?? yAxisIds[0];
|
|
50
|
-
const zAxisId = seriesToAdd.zAxisId ??
|
|
50
|
+
const zAxisId = seriesToAdd.zAxisId ?? zAxisIds[0];
|
|
51
51
|
const getColor = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
52
52
|
rep.push(_extends({}, seriesToAdd, {
|
|
53
53
|
getColor
|
|
@@ -30,9 +30,9 @@ function ChartsItemTooltipContent(props) {
|
|
|
30
30
|
zAxisIds
|
|
31
31
|
} = React.useContext(ZAxisContext);
|
|
32
32
|
const colorProcessors = useColorProcessor();
|
|
33
|
-
const xAxisId = series.xAxisId ??
|
|
34
|
-
const yAxisId = series.yAxisId ??
|
|
35
|
-
const zAxisId = series.zAxisId ??
|
|
33
|
+
const xAxisId = series.xAxisId ?? xAxisIds[0];
|
|
34
|
+
const yAxisId = series.yAxisId ?? yAxisIds[0];
|
|
35
|
+
const zAxisId = series.zAxisId ?? zAxisIds[0];
|
|
36
36
|
const getColor = colorProcessors[series.type]?.(series, xAxisId && xAxis[xAxisId], yAxisId && yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
37
37
|
const Content = content ?? DefaultChartsItemTooltipContent;
|
|
38
38
|
const chartTooltipContentProps = useSlotProps({
|
|
@@ -4,12 +4,14 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
+
import useLazyRef from '@mui/utils/useLazyRef';
|
|
7
8
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
9
|
import Popper from '@mui/material/Popper';
|
|
9
10
|
import NoSsr from '@mui/material/NoSsr';
|
|
10
11
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
11
12
|
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
12
|
-
import {
|
|
13
|
+
import { useSvgRef } from "../hooks/useSvgRef.js";
|
|
14
|
+
import { getTooltipHasData, usePointerType } from "./utils.js";
|
|
13
15
|
import { ChartsItemTooltipContent } from "./ChartsItemTooltipContent.js";
|
|
14
16
|
import { ChartsAxisTooltipContent } from "./ChartsAxisTooltipContent.js";
|
|
15
17
|
import { getChartsTooltipUtilityClass } from "./chartsTooltipClasses.js";
|
|
@@ -63,14 +65,20 @@ function ChartsTooltip(inProps) {
|
|
|
63
65
|
slots,
|
|
64
66
|
slotProps
|
|
65
67
|
} = props;
|
|
66
|
-
const
|
|
68
|
+
const svgRef = useSvgRef();
|
|
69
|
+
const pointerType = usePointerType();
|
|
70
|
+
const popperRef = React.useRef(null);
|
|
71
|
+
const positionRef = useLazyRef(() => ({
|
|
72
|
+
x: 0,
|
|
73
|
+
y: 0
|
|
74
|
+
}));
|
|
67
75
|
const {
|
|
68
76
|
item,
|
|
69
77
|
axis
|
|
70
78
|
} = React.useContext(InteractionContext);
|
|
71
79
|
const displayedData = trigger === 'item' ? item : axis;
|
|
72
80
|
const tooltipHasData = getTooltipHasData(trigger, displayedData);
|
|
73
|
-
const popperOpen =
|
|
81
|
+
const popperOpen = pointerType !== null && tooltipHasData;
|
|
74
82
|
const classes = useUtilityClasses({
|
|
75
83
|
classes: props.classes
|
|
76
84
|
});
|
|
@@ -80,17 +88,48 @@ function ChartsTooltip(inProps) {
|
|
|
80
88
|
externalSlotProps: slotProps?.popper,
|
|
81
89
|
additionalProps: {
|
|
82
90
|
open: popperOpen,
|
|
83
|
-
placement:
|
|
84
|
-
|
|
91
|
+
placement: pointerType?.pointerType === 'mouse' ? 'right-start' : 'top',
|
|
92
|
+
popperRef,
|
|
93
|
+
anchorEl: {
|
|
94
|
+
getBoundingClientRect: () => ({
|
|
95
|
+
x: positionRef.current.x,
|
|
96
|
+
y: positionRef.current.y,
|
|
97
|
+
top: positionRef.current.y,
|
|
98
|
+
left: positionRef.current.x,
|
|
99
|
+
right: positionRef.current.x,
|
|
100
|
+
bottom: positionRef.current.y,
|
|
101
|
+
width: 0,
|
|
102
|
+
height: 0,
|
|
103
|
+
toJSON: () => ''
|
|
104
|
+
})
|
|
105
|
+
},
|
|
85
106
|
modifiers: [{
|
|
86
107
|
name: 'offset',
|
|
87
108
|
options: {
|
|
88
|
-
offset: [0,
|
|
109
|
+
offset: [0, pointerType?.pointerType === 'touch' ? 40 - pointerType.height : 0]
|
|
89
110
|
}
|
|
90
111
|
}]
|
|
91
112
|
},
|
|
92
113
|
ownerState: {}
|
|
93
114
|
});
|
|
115
|
+
React.useEffect(() => {
|
|
116
|
+
const element = svgRef.current;
|
|
117
|
+
if (element === null) {
|
|
118
|
+
return () => {};
|
|
119
|
+
}
|
|
120
|
+
const handleMove = event => {
|
|
121
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
122
|
+
positionRef.current = {
|
|
123
|
+
x: event.clientX,
|
|
124
|
+
y: event.clientY
|
|
125
|
+
};
|
|
126
|
+
popperRef.current?.update();
|
|
127
|
+
};
|
|
128
|
+
element.addEventListener('pointermove', handleMove);
|
|
129
|
+
return () => {
|
|
130
|
+
element.removeEventListener('pointermove', handleMove);
|
|
131
|
+
};
|
|
132
|
+
}, [svgRef, positionRef]);
|
|
94
133
|
if (trigger === 'none') {
|
|
95
134
|
return null;
|
|
96
135
|
}
|
|
@@ -45,15 +45,15 @@ export function useAxisTooltip() {
|
|
|
45
45
|
}
|
|
46
46
|
return seriesOfType.seriesOrder.map(seriesId => {
|
|
47
47
|
const seriesToAdd = seriesOfType.series[seriesId];
|
|
48
|
-
const providedXAxisId = seriesToAdd.xAxisId
|
|
49
|
-
const providedYAxisId = seriesToAdd.yAxisId
|
|
48
|
+
const providedXAxisId = seriesToAdd.xAxisId;
|
|
49
|
+
const providedYAxisId = seriesToAdd.yAxisId;
|
|
50
50
|
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
51
51
|
|
|
52
52
|
// Test if the series uses the default axis
|
|
53
53
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
54
54
|
const xAxisId = providedXAxisId ?? xAxisIds[0];
|
|
55
55
|
const yAxisId = providedYAxisId ?? yAxisIds[0];
|
|
56
|
-
const zAxisId = seriesToAdd.zAxisId ??
|
|
56
|
+
const zAxisId = seriesToAdd.zAxisId ?? zAxisIds[0];
|
|
57
57
|
const color = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId && zAxis[zAxisId])(dataIndex) ?? '';
|
|
58
58
|
const value = seriesToAdd.data[dataIndex] ?? null;
|
|
59
59
|
const formattedValue = seriesToAdd.valueFormatter(value, {
|
|
@@ -24,9 +24,9 @@ export function useItemTooltip() {
|
|
|
24
24
|
zAxisIds
|
|
25
25
|
} = React.useContext(ZAxisContext);
|
|
26
26
|
const colorProcessors = useColorProcessor();
|
|
27
|
-
const xAxisId = series.xAxisId ??
|
|
28
|
-
const yAxisId = series.yAxisId ??
|
|
29
|
-
const zAxisId = series.zAxisId ??
|
|
27
|
+
const xAxisId = series.xAxisId ?? xAxisIds[0];
|
|
28
|
+
const yAxisId = series.yAxisId ?? yAxisIds[0];
|
|
29
|
+
const zAxisId = series.zAxisId ?? zAxisIds[0];
|
|
30
30
|
if (!item || item.dataIndex === undefined) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
package/ChartsTooltip/utils.d.ts
CHANGED
|
@@ -6,21 +6,13 @@ type MousePosition = {
|
|
|
6
6
|
pointerType: 'mouse' | 'touch' | 'pen';
|
|
7
7
|
height: number;
|
|
8
8
|
};
|
|
9
|
-
export declare function generateVirtualElement(mousePosition: MousePosition | null): {
|
|
10
|
-
getBoundingClientRect: () => {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
x: number;
|
|
14
|
-
y: number;
|
|
15
|
-
top: number;
|
|
16
|
-
right: number;
|
|
17
|
-
bottom: number;
|
|
18
|
-
left: number;
|
|
19
|
-
toJSON: () => string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
9
|
export type UseMouseTrackerReturnValue = null | MousePosition;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated We recommend using vanilla JS to let popper track mouse position.
|
|
12
|
+
*/
|
|
23
13
|
export declare function useMouseTracker(): UseMouseTrackerReturnValue;
|
|
14
|
+
type PointerType = Pick<MousePosition, 'height' | 'pointerType'>;
|
|
15
|
+
export declare function usePointerType(): null | PointerType;
|
|
24
16
|
export type TriggerOptions = 'item' | 'axis' | 'none';
|
|
25
17
|
export declare function getTooltipHasData(trigger: TriggerOptions, displayedData: null | AxisInteractionData | ItemInteractionData<ChartSeriesType>): boolean;
|
|
26
18
|
export declare function utcFormatter(v: string | number | Date): string;
|