@mui/x-charts 8.5.3 → 8.7.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/AnimatedBarElement.js +3 -1
- package/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
- package/BarChart/BarLabel/BarLabelPlot.js +33 -25
- package/BarChart/BarPlot.js +59 -183
- package/BarChart/barClasses.d.ts +12 -0
- package/BarChart/barClasses.js +25 -0
- package/BarChart/index.d.ts +3 -1
- package/BarChart/index.js +23 -1
- package/BarChart/types.d.ts +5 -1
- package/BarChart/useBarPlotData.d.ts +8 -0
- package/BarChart/useBarPlotData.js +146 -0
- package/CHANGELOG.md +210 -0
- package/ChartContainer/ChartContainer.d.ts +1 -21
- package/ChartContainer/ChartContainer.js +0 -8
- package/ChartContainer/index.d.ts +8 -1
- package/ChartsLegend/ChartsLegend.js +1 -0
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +48 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
- package/ChartsReferenceLine/ChartsYReferenceLine.js +48 -1
- package/ChartsReferenceLine/index.d.ts +3 -1
- package/ChartsSurface/ChartsSurface.js +2 -1
- package/ChartsTooltip/ChartsTooltipContainer.js +6 -3
- package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
- package/ChartsTooltip/utils.js +18 -29
- package/ChartsXAxis/ChartsXAxis.js +4 -108
- package/ChartsXAxis/getVisibleLabels.d.ts +14 -0
- package/ChartsXAxis/getVisibleLabels.js +71 -0
- package/ChartsXAxis/shortenLabels.d.ts +4 -0
- package/ChartsXAxis/shortenLabels.js +48 -0
- package/ChartsYAxis/ChartsYAxis.js +2 -39
- package/ChartsYAxis/shortenLabels.d.ts +4 -0
- package/ChartsYAxis/shortenLabels.js +46 -0
- package/LineChart/AnimatedArea.js +4 -1
- package/LineChart/AnimatedLine.js +4 -1
- package/LineChart/AreaPlot.js +5 -115
- package/LineChart/CircleMarkElement.js +4 -1
- package/LineChart/LinePlot.js +5 -99
- package/LineChart/MarkElement.js +4 -1
- package/LineChart/MarkPlot.js +1 -0
- package/LineChart/useAreaPlotData.d.ts +12 -0
- package/LineChart/useAreaPlotData.js +125 -0
- package/LineChart/useLinePlotData.d.ts +11 -0
- package/LineChart/useLinePlotData.js +108 -0
- package/PieChart/PieArc.js +3 -1
- package/PieChart/PiePlot.js +6 -0
- package/PieChart/index.d.ts +3 -1
- package/PieChart/index.js +18 -1
- package/PieChart/pieClasses.d.ts +12 -0
- package/PieChart/pieClasses.js +24 -0
- package/ScatterChart/Scatter.js +22 -48
- package/ScatterChart/useScatterPlotData.d.ts +8 -0
- package/ScatterChart/useScatterPlotData.js +33 -0
- package/Toolbar/ToolbarButton.js +2 -0
- package/context/ChartApi.d.ts +22 -0
- package/context/ChartApi.js +5 -0
- package/context/ChartProvider/ChartContext.js +1 -0
- package/context/index.d.ts +2 -1
- package/context/useChartApiContext.d.ts +1 -1
- package/esm/BarChart/AnimatedBarElement.js +3 -1
- package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
- package/esm/BarChart/BarLabel/BarLabelPlot.js +33 -25
- package/esm/BarChart/BarPlot.js +60 -185
- package/esm/BarChart/barClasses.d.ts +12 -0
- package/esm/BarChart/barClasses.js +15 -0
- package/esm/BarChart/index.d.ts +3 -1
- package/esm/BarChart/index.js +2 -1
- package/esm/BarChart/types.d.ts +5 -1
- package/esm/BarChart/useBarPlotData.d.ts +8 -0
- package/esm/BarChart/useBarPlotData.js +139 -0
- package/esm/ChartContainer/ChartContainer.d.ts +1 -21
- package/esm/ChartContainer/ChartContainer.js +0 -8
- package/esm/ChartContainer/index.d.ts +8 -1
- package/esm/ChartContainer/index.js +6 -1
- package/esm/ChartsLegend/ChartsLegend.js +1 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +47 -0
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +47 -0
- package/esm/ChartsReferenceLine/index.d.ts +3 -1
- package/esm/ChartsReferenceLine/index.js +2 -1
- package/esm/ChartsSurface/ChartsSurface.js +2 -1
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +6 -3
- package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
- package/esm/ChartsTooltip/utils.js +18 -29
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -106
- package/esm/ChartsXAxis/getVisibleLabels.d.ts +14 -0
- package/esm/ChartsXAxis/getVisibleLabels.js +67 -0
- package/esm/ChartsXAxis/shortenLabels.d.ts +4 -0
- package/esm/ChartsXAxis/shortenLabels.js +42 -0
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -38
- package/esm/ChartsYAxis/shortenLabels.d.ts +4 -0
- package/esm/ChartsYAxis/shortenLabels.js +41 -0
- package/esm/LineChart/AnimatedArea.js +4 -1
- package/esm/LineChart/AnimatedLine.js +4 -1
- package/esm/LineChart/AreaPlot.js +5 -115
- package/esm/LineChart/CircleMarkElement.js +4 -1
- package/esm/LineChart/LinePlot.js +5 -99
- package/esm/LineChart/MarkElement.js +4 -1
- package/esm/LineChart/MarkPlot.js +1 -0
- package/esm/LineChart/useAreaPlotData.d.ts +12 -0
- package/esm/LineChart/useAreaPlotData.js +118 -0
- package/esm/LineChart/useLinePlotData.d.ts +11 -0
- package/esm/LineChart/useLinePlotData.js +101 -0
- package/esm/PieChart/PieArc.js +3 -1
- package/esm/PieChart/PiePlot.js +6 -0
- package/esm/PieChart/index.d.ts +3 -1
- package/esm/PieChart/index.js +2 -1
- package/esm/PieChart/pieClasses.d.ts +12 -0
- package/esm/PieChart/pieClasses.js +15 -0
- package/esm/ScatterChart/Scatter.js +23 -49
- package/esm/ScatterChart/useScatterPlotData.d.ts +8 -0
- package/esm/ScatterChart/useScatterPlotData.js +26 -0
- package/esm/Toolbar/ToolbarButton.js +2 -0
- package/esm/context/ChartApi.d.ts +22 -0
- package/esm/context/ChartApi.js +1 -0
- package/esm/context/ChartProvider/ChartContext.js +2 -0
- package/esm/context/index.d.ts +2 -1
- package/esm/context/useChartApiContext.d.ts +1 -1
- package/esm/hooks/useInteractionItemProps.d.ts +14 -9
- package/esm/hooks/useInteractionItemProps.js +28 -28
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/internals/components/NotRendered.d.ts +9 -0
- package/esm/internals/components/NotRendered.js +10 -0
- package/esm/internals/index.d.ts +6 -0
- package/esm/internals/index.js +6 -0
- package/esm/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
- package/esm/internals/plugins/corePlugins/corePlugins.js +2 -1
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +2 -2
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.js +2 -0
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.js +1 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +77 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +1 -0
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +44 -33
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +7 -7
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +52 -36
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +6 -6
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +47 -30
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
- package/esm/internals/store/useCharts.d.ts +1 -1
- package/esm/locales/elGR.d.ts +19 -0
- package/esm/locales/elGR.js +15 -0
- package/esm/locales/enUS.d.ts +3 -0
- package/esm/locales/enUS.js +8 -2
- package/esm/locales/frFR.d.ts +3 -0
- package/esm/locales/frFR.js +7 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/locales/ptBR.d.ts +3 -0
- package/esm/locales/ptBR.js +7 -1
- package/esm/locales/ptPT.d.ts +3 -0
- package/esm/locales/ptPT.js +7 -1
- package/esm/locales/utils/chartsLocaleTextApi.d.ts +17 -0
- package/esm/locales/utils/getChartsLocalization.d.ts +3 -0
- package/esm/locales/utils/imageMimeTypes.d.ts +2 -0
- package/esm/locales/utils/imageMimeTypes.js +5 -0
- package/esm/models/slots/chartsBaseSlotProps.d.ts +4 -0
- package/hooks/useInteractionItemProps.d.ts +14 -9
- package/hooks/useInteractionItemProps.js +29 -28
- package/index.d.ts +2 -1
- package/index.js +37 -11
- package/internals/components/NotRendered.d.ts +9 -0
- package/internals/components/NotRendered.js +16 -0
- package/internals/index.d.ts +6 -0
- package/internals/index.js +56 -0
- package/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
- package/internals/plugins/corePlugins/corePlugins.js +2 -1
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +2 -2
- package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/index.js +12 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +84 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +5 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +44 -33
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +7 -7
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +52 -36
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +6 -6
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +46 -30
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
- package/internals/store/useCharts.d.ts +1 -1
- package/locales/elGR.d.ts +19 -0
- package/locales/elGR.js +21 -0
- package/locales/enUS.d.ts +3 -0
- package/locales/enUS.js +8 -2
- package/locales/frFR.d.ts +3 -0
- package/locales/frFR.js +7 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/locales/ptBR.d.ts +3 -0
- package/locales/ptBR.js +7 -1
- package/locales/ptPT.d.ts +3 -0
- package/locales/ptPT.js +7 -1
- package/locales/utils/chartsLocaleTextApi.d.ts +17 -0
- package/locales/utils/getChartsLocalization.d.ts +3 -0
- package/locales/utils/imageMimeTypes.d.ts +2 -0
- package/locales/utils/imageMimeTypes.js +11 -0
- package/models/slots/chartsBaseSlotProps.d.ts +4 -0
- package/package.json +3 -2
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import getColor from "./seriesConfig/getColor.js";
|
|
2
|
+
import { useChartId, useXAxes, useYAxes } from "../hooks/index.js";
|
|
3
|
+
import { checkScaleErrors } from "./checkScaleErrors.js";
|
|
4
|
+
import { useBarSeriesContext } from "../hooks/useBarSeries.js";
|
|
5
|
+
export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
6
|
+
const seriesData = useBarSeriesContext() ?? {
|
|
7
|
+
series: {},
|
|
8
|
+
stackingGroups: [],
|
|
9
|
+
seriesOrder: []
|
|
10
|
+
};
|
|
11
|
+
const defaultXAxisId = useXAxes().xAxisIds[0];
|
|
12
|
+
const defaultYAxisId = useYAxes().yAxisIds[0];
|
|
13
|
+
const chartId = useChartId();
|
|
14
|
+
const {
|
|
15
|
+
series,
|
|
16
|
+
stackingGroups
|
|
17
|
+
} = seriesData;
|
|
18
|
+
const masks = {};
|
|
19
|
+
const data = stackingGroups.flatMap(({
|
|
20
|
+
ids: seriesIds
|
|
21
|
+
}, groupIndex) => {
|
|
22
|
+
const xMin = drawingArea.left;
|
|
23
|
+
const xMax = drawingArea.left + drawingArea.width;
|
|
24
|
+
const yMin = drawingArea.top;
|
|
25
|
+
const yMax = drawingArea.top + drawingArea.height;
|
|
26
|
+
return seriesIds.map(seriesId => {
|
|
27
|
+
const xAxisId = series[seriesId].xAxisId ?? defaultXAxisId;
|
|
28
|
+
const yAxisId = series[seriesId].yAxisId ?? defaultYAxisId;
|
|
29
|
+
const xAxisConfig = xAxes[xAxisId];
|
|
30
|
+
const yAxisConfig = yAxes[yAxisId];
|
|
31
|
+
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
32
|
+
checkScaleErrors(verticalLayout, seriesId, series[seriesId], xAxisId, xAxes, yAxisId, yAxes);
|
|
33
|
+
const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
34
|
+
const xScale = xAxisConfig.scale;
|
|
35
|
+
const yScale = yAxisConfig.scale;
|
|
36
|
+
const colorGetter = getColor(series[seriesId], xAxes[xAxisId], yAxes[yAxisId]);
|
|
37
|
+
const bandWidth = baseScaleConfig.scale.bandwidth();
|
|
38
|
+
const {
|
|
39
|
+
barWidth,
|
|
40
|
+
offset
|
|
41
|
+
} = getBandSize({
|
|
42
|
+
bandWidth,
|
|
43
|
+
numberOfGroups: stackingGroups.length,
|
|
44
|
+
gapRatio: baseScaleConfig.barGapRatio
|
|
45
|
+
});
|
|
46
|
+
const barOffset = groupIndex * (barWidth + offset);
|
|
47
|
+
const {
|
|
48
|
+
stackedData,
|
|
49
|
+
data: currentSeriesData,
|
|
50
|
+
layout
|
|
51
|
+
} = series[seriesId];
|
|
52
|
+
const seriesDataPoints = baseScaleConfig.data.map((baseValue, dataIndex) => {
|
|
53
|
+
if (currentSeriesData[dataIndex] == null) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const values = stackedData[dataIndex];
|
|
57
|
+
const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
|
|
58
|
+
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
59
|
+
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
60
|
+
const stackId = series[seriesId].stack;
|
|
61
|
+
const result = {
|
|
62
|
+
seriesId,
|
|
63
|
+
dataIndex,
|
|
64
|
+
layout,
|
|
65
|
+
x: verticalLayout ? xScale(baseValue) + barOffset : minValueCoord,
|
|
66
|
+
y: verticalLayout ? minValueCoord : yScale(baseValue) + barOffset,
|
|
67
|
+
xOrigin: xScale(0) ?? 0,
|
|
68
|
+
yOrigin: yScale(0) ?? 0,
|
|
69
|
+
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
|
|
70
|
+
width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
|
|
71
|
+
color: colorGetter(dataIndex),
|
|
72
|
+
value: currentSeriesData[dataIndex],
|
|
73
|
+
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
74
|
+
};
|
|
75
|
+
if (result.x > xMax || result.x + result.width < xMin || result.y > yMax || result.y + result.height < yMin) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
if (!masks[result.maskId]) {
|
|
79
|
+
masks[result.maskId] = {
|
|
80
|
+
id: result.maskId,
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0,
|
|
83
|
+
hasNegative: false,
|
|
84
|
+
hasPositive: false,
|
|
85
|
+
layout: result.layout,
|
|
86
|
+
xOrigin: xScale(0),
|
|
87
|
+
yOrigin: yScale(0),
|
|
88
|
+
x: 0,
|
|
89
|
+
y: 0
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const mask = masks[result.maskId];
|
|
93
|
+
mask.width = result.layout === 'vertical' ? result.width : mask.width + result.width;
|
|
94
|
+
mask.height = result.layout === 'vertical' ? mask.height + result.height : result.height;
|
|
95
|
+
mask.x = Math.min(mask.x === 0 ? Infinity : mask.x, result.x);
|
|
96
|
+
mask.y = Math.min(mask.y === 0 ? Infinity : mask.y, result.y);
|
|
97
|
+
mask.hasNegative = mask.hasNegative || (result.value ?? 0) < 0;
|
|
98
|
+
mask.hasPositive = mask.hasPositive || (result.value ?? 0) > 0;
|
|
99
|
+
return result;
|
|
100
|
+
}).filter(rectangle => rectangle !== null);
|
|
101
|
+
return {
|
|
102
|
+
seriesId,
|
|
103
|
+
data: seriesDataPoints
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
completedData: data,
|
|
109
|
+
masksData: Object.values(masks)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Solution of the equations
|
|
115
|
+
* W = barWidth * N + offset * (N-1)
|
|
116
|
+
* offset / (offset + barWidth) = r
|
|
117
|
+
* @param bandWidth The width available to place bars.
|
|
118
|
+
* @param numberOfGroups The number of bars to place in that space.
|
|
119
|
+
* @param gapRatio The ratio of the gap between bars over the bar width.
|
|
120
|
+
* @returns The bar width and the offset between bars.
|
|
121
|
+
*/
|
|
122
|
+
function getBandSize({
|
|
123
|
+
bandWidth: W,
|
|
124
|
+
numberOfGroups: N,
|
|
125
|
+
gapRatio: r
|
|
126
|
+
}) {
|
|
127
|
+
if (r === 0) {
|
|
128
|
+
return {
|
|
129
|
+
barWidth: W / N,
|
|
130
|
+
offset: 0
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const barWidth = W / (N + (N - 1) * r);
|
|
134
|
+
const offset = r * barWidth;
|
|
135
|
+
return {
|
|
136
|
+
barWidth,
|
|
137
|
+
offset
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -1,30 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { PieChartPluginSignatures } from "../PieChart/PieChart.plugins.js";
|
|
3
|
-
import { BarChartPluginsSignatures } from "../BarChart/BarChart.plugins.js";
|
|
4
|
-
import { ScatterChartPluginsSignatures } from "../ScatterChart/ScatterChart.plugins.js";
|
|
5
|
-
import { LineChartPluginsSignatures } from "../LineChart/LineChart.plugins.js";
|
|
6
2
|
import { ChartSeriesType } from "../models/seriesType/config.js";
|
|
7
3
|
import { ChartDataProviderProps } from "../ChartDataProvider/index.js";
|
|
8
4
|
import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
|
|
9
|
-
import { AllPluginSignatures
|
|
5
|
+
import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
10
6
|
import { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
|
|
11
|
-
import { ChartPublicAPI } from "../internals/plugins/models/index.js";
|
|
12
7
|
export type ChartContainerProps<SeriesType extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<SeriesType>> = Omit<ChartDataProviderProps<SeriesType, TSignatures>, 'children'> & ChartsSurfaceProps;
|
|
13
|
-
type PluginsPerSeriesType = {
|
|
14
|
-
line: LineChartPluginsSignatures;
|
|
15
|
-
scatter: ScatterChartPluginsSignatures;
|
|
16
|
-
bar: BarChartPluginsSignatures;
|
|
17
|
-
pie: PieChartPluginSignatures;
|
|
18
|
-
composition: DefaultPluginSignatures;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The API of the chart `apiRef` object.
|
|
22
|
-
* The chart type can be passed as the first generic parameter to narrow down the API to the specific chart type.
|
|
23
|
-
* @example ChartApi<'bar'>
|
|
24
|
-
* If the chart is being created using composition, the `composition` value can be used.
|
|
25
|
-
* @example ChartApi<'composition'>
|
|
26
|
-
*/
|
|
27
|
-
export type ChartApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartPublicAPI<TSignatures>;
|
|
28
8
|
/**
|
|
29
9
|
* It sets up the data providers as well as the `<svg>` for the chart.
|
|
30
10
|
*
|
|
@@ -6,14 +6,6 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { ChartDataProvider } from "../ChartDataProvider/index.js";
|
|
7
7
|
import { useChartContainerProps } from "./useChartContainerProps.js";
|
|
8
8
|
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* The API of the chart `apiRef` object.
|
|
12
|
-
* The chart type can be passed as the first generic parameter to narrow down the API to the specific chart type.
|
|
13
|
-
* @example ChartApi<'bar'>
|
|
14
|
-
* If the chart is being created using composition, the `composition` value can be used.
|
|
15
|
-
* @example ChartApi<'composition'>
|
|
16
|
-
*/
|
|
17
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
10
|
/**
|
|
19
11
|
* It sets up the data providers as well as the `<svg>` for the chart.
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ChartApi as ChartApiOriginal, PluginsPerSeriesType } from "../context/ChartApi.js";
|
|
2
|
+
import type { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
|
|
3
|
+
import type { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
4
|
+
export * from "./ChartContainer.js";
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `ChartApi` from `@mui/x-charts/context` instead.
|
|
7
|
+
*/
|
|
8
|
+
export type ChartApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartApiOriginal<TSeries, TSignatures>;
|
|
@@ -81,6 +81,7 @@ const ChartsLegend = consumeSlots('MuiChartsLegend', 'legend', {
|
|
|
81
81
|
children: data.items.map((item, i) => {
|
|
82
82
|
return /*#__PURE__*/_jsx("li", {
|
|
83
83
|
className: classes?.item,
|
|
84
|
+
"data-series": item.id,
|
|
84
85
|
children: /*#__PURE__*/_jsxs(Element, {
|
|
85
86
|
className: classes?.series,
|
|
86
87
|
role: onItemClick ? 'button' : undefined,
|
|
@@ -10,4 +10,7 @@ export type ChartsXReferenceLineProps<TValue extends string | number | Date = st
|
|
|
10
10
|
};
|
|
11
11
|
export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
|
|
12
12
|
declare function ChartsXReferenceLine(props: ChartsXReferenceLineProps): React.JSX.Element | null;
|
|
13
|
+
declare namespace ChartsXReferenceLine {
|
|
14
|
+
var propTypes: any;
|
|
15
|
+
}
|
|
13
16
|
export { ChartsXReferenceLine };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
7
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
7
8
|
import { useDrawingArea, useXScale } from "../hooks/index.js";
|
|
@@ -99,4 +100,50 @@ function ChartsXReferenceLine(props) {
|
|
|
99
100
|
}))]
|
|
100
101
|
});
|
|
101
102
|
}
|
|
103
|
+
process.env.NODE_ENV !== "production" ? ChartsXReferenceLine.propTypes = {
|
|
104
|
+
// ----------------------------- Warning --------------------------------
|
|
105
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
106
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
107
|
+
// ----------------------------------------------------------------------
|
|
108
|
+
/**
|
|
109
|
+
* The id of the axis used for the reference value.
|
|
110
|
+
* @default The `id` of the first defined axis.
|
|
111
|
+
*/
|
|
112
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
113
|
+
/**
|
|
114
|
+
* Override or extend the styles applied to the component.
|
|
115
|
+
*/
|
|
116
|
+
classes: PropTypes.object,
|
|
117
|
+
/**
|
|
118
|
+
* The label to display along the reference line.
|
|
119
|
+
*/
|
|
120
|
+
label: PropTypes.string,
|
|
121
|
+
/**
|
|
122
|
+
* The alignment if the label is in the chart drawing area.
|
|
123
|
+
* @default 'middle'
|
|
124
|
+
*/
|
|
125
|
+
labelAlign: PropTypes.oneOf(['end', 'middle', 'start']),
|
|
126
|
+
/**
|
|
127
|
+
* The style applied to the label.
|
|
128
|
+
*/
|
|
129
|
+
labelStyle: PropTypes.object,
|
|
130
|
+
/**
|
|
131
|
+
* The style applied to the line.
|
|
132
|
+
*/
|
|
133
|
+
lineStyle: PropTypes.object,
|
|
134
|
+
/**
|
|
135
|
+
* Additional space around the label in px.
|
|
136
|
+
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
137
|
+
* @default 5
|
|
138
|
+
*/
|
|
139
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
140
|
+
x: PropTypes.number,
|
|
141
|
+
y: PropTypes.number
|
|
142
|
+
})]),
|
|
143
|
+
/**
|
|
144
|
+
* The x value associated with the reference line.
|
|
145
|
+
* If defined the reference line will be vertical.
|
|
146
|
+
*/
|
|
147
|
+
x: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
148
|
+
} : void 0;
|
|
102
149
|
export { ChartsXReferenceLine };
|
|
@@ -10,4 +10,7 @@ export type ChartsYReferenceLineProps<TValue extends string | number | Date = st
|
|
|
10
10
|
};
|
|
11
11
|
export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
|
|
12
12
|
declare function ChartsYReferenceLine(props: ChartsYReferenceLineProps): React.JSX.Element | null;
|
|
13
|
+
declare namespace ChartsYReferenceLine {
|
|
14
|
+
var propTypes: any;
|
|
15
|
+
}
|
|
13
16
|
export { ChartsYReferenceLine };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
7
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
7
8
|
import { useDrawingArea, useYScale } from "../hooks/index.js";
|
|
@@ -99,4 +100,50 @@ function ChartsYReferenceLine(props) {
|
|
|
99
100
|
}))]
|
|
100
101
|
});
|
|
101
102
|
}
|
|
103
|
+
process.env.NODE_ENV !== "production" ? ChartsYReferenceLine.propTypes = {
|
|
104
|
+
// ----------------------------- Warning --------------------------------
|
|
105
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
106
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
107
|
+
// ----------------------------------------------------------------------
|
|
108
|
+
/**
|
|
109
|
+
* The id of the axis used for the reference value.
|
|
110
|
+
* @default The `id` of the first defined axis.
|
|
111
|
+
*/
|
|
112
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
113
|
+
/**
|
|
114
|
+
* Override or extend the styles applied to the component.
|
|
115
|
+
*/
|
|
116
|
+
classes: PropTypes.object,
|
|
117
|
+
/**
|
|
118
|
+
* The label to display along the reference line.
|
|
119
|
+
*/
|
|
120
|
+
label: PropTypes.string,
|
|
121
|
+
/**
|
|
122
|
+
* The alignment if the label is in the chart drawing area.
|
|
123
|
+
* @default 'middle'
|
|
124
|
+
*/
|
|
125
|
+
labelAlign: PropTypes.oneOf(['end', 'middle', 'start']),
|
|
126
|
+
/**
|
|
127
|
+
* The style applied to the label.
|
|
128
|
+
*/
|
|
129
|
+
labelStyle: PropTypes.object,
|
|
130
|
+
/**
|
|
131
|
+
* The style applied to the line.
|
|
132
|
+
*/
|
|
133
|
+
lineStyle: PropTypes.object,
|
|
134
|
+
/**
|
|
135
|
+
* Additional space around the label in px.
|
|
136
|
+
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
137
|
+
* @default 5
|
|
138
|
+
*/
|
|
139
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
140
|
+
x: PropTypes.number,
|
|
141
|
+
y: PropTypes.number
|
|
142
|
+
})]),
|
|
143
|
+
/**
|
|
144
|
+
* The y value associated with the reference line.
|
|
145
|
+
* If defined the reference line will be horizontal.
|
|
146
|
+
*/
|
|
147
|
+
y: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
148
|
+
} : void 0;
|
|
102
149
|
export { ChartsYReferenceLine };
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export * from "./ChartsReferenceLine.js";
|
|
2
|
-
export * from "./chartsReferenceLineClasses.js";
|
|
2
|
+
export * from "./chartsReferenceLineClasses.js";
|
|
3
|
+
export type { ChartsXReferenceLineProps } from "./ChartsXReferenceLine.js";
|
|
4
|
+
export type { ChartsYReferenceLineProps } from "./ChartsYReferenceLine.js";
|
|
@@ -29,7 +29,8 @@ const ChartsSurfaceStyles = styled('svg', {
|
|
|
29
29
|
overflow: 'hidden',
|
|
30
30
|
// This prevents default touch actions when using the svg on mobile devices.
|
|
31
31
|
// For example, prevent page scroll & zoom.
|
|
32
|
-
touchAction: '
|
|
32
|
+
touchAction: 'pan-y',
|
|
33
|
+
userSelect: 'none'
|
|
33
34
|
}));
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -10,7 +10,7 @@ import useLazyRef from '@mui/utils/useLazyRef';
|
|
|
10
10
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
11
11
|
import Popper from '@mui/material/Popper';
|
|
12
12
|
import NoSsr from '@mui/material/NoSsr';
|
|
13
|
-
import {
|
|
13
|
+
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
14
14
|
import { useIsFineMainPointer, usePointerType } from "./utils.js";
|
|
15
15
|
import { useUtilityClasses } from "./chartsTooltipClasses.js";
|
|
16
16
|
import { useSelector } from "../internals/store/useSelector.js";
|
|
@@ -19,6 +19,7 @@ import { selectorChartsInteractionItemIsDefined } from "../internals/plugins/fea
|
|
|
19
19
|
import { selectorChartsInteractionAxisTooltip } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
20
20
|
import { selectorChartsInteractionPolarAxisTooltip } from "../internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js";
|
|
21
21
|
import { useAxisSystem } from "../hooks/useAxisSystem.js";
|
|
22
|
+
import { useSvgRef } from "../hooks/index.js";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
24
|
const noAxis = () => false;
|
|
24
25
|
const ChartsTooltipRoot = styled(Popper, {
|
|
@@ -51,8 +52,8 @@ function ChartsTooltipContainer(inProps) {
|
|
|
51
52
|
children
|
|
52
53
|
} = props,
|
|
53
54
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
54
|
-
const classes = useUtilityClasses(propClasses);
|
|
55
55
|
const svgRef = useSvgRef();
|
|
56
|
+
const classes = useUtilityClasses(propClasses);
|
|
56
57
|
const pointerType = usePointerType();
|
|
57
58
|
const isFineMainPointer = useIsFineMainPointer();
|
|
58
59
|
const popperRef = React.useRef(null);
|
|
@@ -68,19 +69,21 @@ function ChartsTooltipContainer(inProps) {
|
|
|
68
69
|
if (element === null) {
|
|
69
70
|
return () => {};
|
|
70
71
|
}
|
|
72
|
+
const update = rafThrottle(() => popperRef.current?.update());
|
|
71
73
|
const handlePointerEvent = event => {
|
|
72
74
|
// eslint-disable-next-line react-compiler/react-compiler
|
|
73
75
|
positionRef.current = {
|
|
74
76
|
x: event.clientX,
|
|
75
77
|
y: event.clientY
|
|
76
78
|
};
|
|
77
|
-
|
|
79
|
+
update();
|
|
78
80
|
};
|
|
79
81
|
element.addEventListener('pointerdown', handlePointerEvent);
|
|
80
82
|
element.addEventListener('pointermove', handlePointerEvent);
|
|
81
83
|
return () => {
|
|
82
84
|
element.removeEventListener('pointerdown', handlePointerEvent);
|
|
83
85
|
element.removeEventListener('pointermove', handlePointerEvent);
|
|
86
|
+
update.clear();
|
|
84
87
|
};
|
|
85
88
|
}, [svgRef, positionRef]);
|
|
86
89
|
const anchorEl = React.useMemo(() => ({
|
|
@@ -13,6 +13,6 @@ export declare const ChartsTooltipRow: import("@emotion/styled").StyledComponent
|
|
|
13
13
|
/**
|
|
14
14
|
* @ignore - internal component.
|
|
15
15
|
*/
|
|
16
|
-
export declare const ChartsTooltipCell: import("@emotion/styled").StyledComponent<Pick<import("@mui/material/Typography").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "p" | "style" | "typography" | "zIndex" | "classes" | "border" | "boxShadow" | "fontWeight" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "color" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "className" | "children" | "sx" | "align" | "variant" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping">, "p" | "slot" | "style" | "title" | "ref" | "typography" | "zIndex" | "classes" | "border" | "boxShadow" | "fontWeight" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "color" | "columnGap" | "content" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "translate" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "
|
|
16
|
+
export declare const ChartsTooltipCell: import("@emotion/styled").StyledComponent<Pick<import("@mui/material/Typography").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "p" | "style" | "typography" | "zIndex" | "classes" | "border" | "boxShadow" | "fontWeight" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "color" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "className" | "children" | "sx" | "align" | "variant" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping">, "p" | "slot" | "style" | "title" | "ref" | "typography" | "zIndex" | "classes" | "border" | "boxShadow" | "fontWeight" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "color" | "columnGap" | "content" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBlockEnd" | "marginBlockStart" | "marginBottom" | "marginInlineEnd" | "marginInlineStart" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBlockEnd" | "paddingBlockStart" | "paddingBottom" | "paddingInlineEnd" | "paddingInlineStart" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "translate" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "marginBlock" | "marginInline" | "overflow" | "padding" | "paddingBlock" | "paddingInline" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "displayPrint" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoCapitalize" | "autoFocus" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "enterKeyHint" | "hidden" | "id" | "lang" | "nonce" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "rel" | "resource" | "rev" | "typeof" | "vocab" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "popover" | "popoverTargetAction" | "popoverTarget" | "inert" | "inputMode" | "is" | "exportparts" | "part" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "sx" | "align" | "variant" | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
17
17
|
component?: React.ElementType;
|
|
18
18
|
}, {}, {}>;
|
|
@@ -2,55 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
5
|
+
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
5
6
|
import { useSvgRef } from "../hooks/index.js";
|
|
6
7
|
/**
|
|
7
8
|
* @deprecated We recommend using vanilla JS to let popper track mouse position.
|
|
8
9
|
*/
|
|
9
10
|
export function useMouseTracker() {
|
|
10
|
-
const
|
|
11
|
+
const {
|
|
12
|
+
instance
|
|
13
|
+
} = useChartContext();
|
|
11
14
|
|
|
12
15
|
// Use a ref to avoid rerendering on every mousemove event.
|
|
13
16
|
const [mousePosition, setMousePosition] = React.useState(null);
|
|
14
17
|
React.useEffect(() => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
return () => {};
|
|
18
|
-
}
|
|
19
|
-
const controller = new AbortController();
|
|
20
|
-
const handleOut = event => {
|
|
21
|
-
if (event.pointerType !== 'mouse') {
|
|
18
|
+
const moveEndHandler = instance.addInteractionListener('moveEnd', event => {
|
|
19
|
+
if (!event.detail.activeGestures.pan) {
|
|
22
20
|
setMousePosition(null);
|
|
23
21
|
}
|
|
24
|
-
};
|
|
25
|
-
const
|
|
22
|
+
});
|
|
23
|
+
const gestureHandler = event => {
|
|
26
24
|
setMousePosition({
|
|
27
|
-
x: event.
|
|
28
|
-
y: event.
|
|
29
|
-
height: event.height,
|
|
30
|
-
pointerType: event.pointerType
|
|
25
|
+
x: event.detail.centroid.x,
|
|
26
|
+
y: event.detail.centroid.y,
|
|
27
|
+
height: event.detail.srcEvent.height,
|
|
28
|
+
pointerType: event.detail.srcEvent.pointerType
|
|
31
29
|
});
|
|
32
30
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
element.addEventListener('pointermove', handleMove, {
|
|
37
|
-
signal: controller.signal
|
|
38
|
-
});
|
|
39
|
-
element.addEventListener('pointerup', handleOut, {
|
|
40
|
-
signal: controller.signal
|
|
41
|
-
});
|
|
31
|
+
const moveHandler = instance.addInteractionListener('move', gestureHandler);
|
|
32
|
+
const panHandler = instance.addInteractionListener('pan', gestureHandler);
|
|
42
33
|
return () => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
moveHandler.cleanup();
|
|
35
|
+
panHandler.cleanup();
|
|
36
|
+
moveEndHandler.cleanup();
|
|
46
37
|
};
|
|
47
|
-
}, [
|
|
38
|
+
}, [instance]);
|
|
48
39
|
return mousePosition;
|
|
49
40
|
}
|
|
50
41
|
export function usePointerType() {
|
|
51
42
|
const svgRef = useSvgRef();
|
|
52
|
-
|
|
53
|
-
// Use a ref to avoid rerendering on every mousemove event.
|
|
54
43
|
const [pointerType, setPointerType] = React.useState(null);
|
|
55
44
|
React.useEffect(() => {
|
|
56
45
|
const element = svgRef.current;
|