@mui/x-charts 8.6.0 → 8.8.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 +1 -1
- package/BarChart/BarChart.js +16 -0
- package/BarChart/BarPlot.js +11 -150
- package/BarChart/useBarPlotData.d.ts +8 -0
- package/BarChart/useBarPlotData.js +146 -0
- package/CHANGELOG.md +202 -1
- package/ChartContainer/ChartContainer.d.ts +1 -21
- package/ChartContainer/ChartContainer.js +22 -8
- package/ChartContainer/index.d.ts +8 -1
- package/ChartContainer/useChartContainerProps.js +8 -2
- package/ChartDataProvider/ChartDataProvider.js +6 -0
- package/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
- package/ChartDataProvider/useChartDataProviderProps.js +6 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +34 -24
- package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +34 -24
- 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/Gauge/GaugeContainer.d.ts +1 -1
- package/LineChart/AreaPlot.js +5 -115
- package/LineChart/LineChart.js +22 -0
- package/LineChart/LineHighlightPlot.js +10 -4
- package/LineChart/LinePlot.js +5 -99
- package/LineChart/MarkPlot.js +17 -3
- package/LineChart/useAreaPlotData.d.ts +12 -0
- package/LineChart/useAreaPlotData.js +126 -0
- package/LineChart/useLinePlotData.d.ts +11 -0
- package/LineChart/useLinePlotData.js +108 -0
- package/PieChart/PieChart.d.ts +1 -1
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +1 -1
- package/ScatterChart/Scatter.js +22 -48
- package/ScatterChart/ScatterChart.d.ts +1 -1
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/ScatterChart/useScatterPlotData.d.ts +8 -0
- package/ScatterChart/useScatterPlotData.js +33 -0
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +16 -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/BarChart.d.ts +1 -1
- package/esm/BarChart/BarChart.js +16 -0
- package/esm/BarChart/BarPlot.js +12 -152
- 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 +22 -8
- package/esm/ChartContainer/index.d.ts +8 -1
- package/esm/ChartContainer/index.js +6 -1
- package/esm/ChartContainer/useChartContainerProps.js +8 -2
- package/esm/ChartDataProvider/ChartDataProvider.js +6 -0
- package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
- package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -2
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +36 -26
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +36 -26
- 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/Gauge/GaugeContainer.d.ts +1 -1
- package/esm/LineChart/AreaPlot.js +5 -115
- package/esm/LineChart/LineChart.js +22 -0
- package/esm/LineChart/LineHighlightPlot.js +11 -5
- package/esm/LineChart/LinePlot.js +5 -99
- package/esm/LineChart/MarkPlot.js +17 -3
- package/esm/LineChart/useAreaPlotData.d.ts +12 -0
- package/esm/LineChart/useAreaPlotData.js +119 -0
- package/esm/LineChart/useLinePlotData.d.ts +11 -0
- package/esm/LineChart/useLinePlotData.js +101 -0
- package/esm/PieChart/PieChart.d.ts +1 -1
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +1 -1
- package/esm/ScatterChart/Scatter.js +23 -49
- package/esm/ScatterChart/ScatterChart.d.ts +1 -1
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/esm/ScatterChart/useScatterPlotData.d.ts +8 -0
- package/esm/ScatterChart/useScatterPlotData.js +26 -0
- package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +16 -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/useAxis.d.ts +2 -2
- 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/constants.d.ts +3 -0
- package/esm/internals/constants.js +4 -0
- package/esm/internals/getLabel.d.ts +1 -1
- package/esm/internals/index.d.ts +6 -0
- package/esm/internals/index.js +6 -0
- package/esm/internals/plugins/corePlugins/corePlugins.d.ts +4 -2
- package/esm/internals/plugins/corePlugins/corePlugins.js +3 -1
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -29
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +0 -6
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +2 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +27 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +1 -0
- 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/computeAxisValue.d.ts +5 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +5 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +14 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +90 -36
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +76 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +8 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +48 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +16 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
- 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 +34 -34
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- 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/plugins/utils/useLazySelectorEffect.d.ts +7 -0
- package/esm/internals/plugins/utils/useLazySelectorEffect.js +70 -0
- 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/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/models/axis.d.ts +15 -0
- package/esm/models/axis.js +4 -0
- package/esm/models/index.d.ts +1 -1
- package/esm/models/seriesType/scatter.d.ts +11 -2
- package/esm/themeAugmentation/components.d.ts +3 -0
- package/esm/themeAugmentation/props.d.ts +2 -0
- package/hooks/useAxis.d.ts +2 -2
- 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/constants.d.ts +3 -0
- package/internals/constants.js +5 -1
- package/internals/getLabel.d.ts +1 -1
- package/internals/index.d.ts +6 -0
- package/internals/index.js +52 -0
- package/internals/plugins/corePlugins/corePlugins.d.ts +4 -2
- package/internals/plugins/corePlugins/corePlugins.js +3 -1
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -29
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +0 -6
- package/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +27 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +34 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +10 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +5 -0
- 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/computeAxisValue.d.ts +5 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +24 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +90 -36
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +82 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +55 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +18 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
- 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 +34 -34
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- 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/plugins/utils/useLazySelectorEffect.d.ts +7 -0
- package/internals/plugins/utils/useLazySelectorEffect.js +77 -0
- package/internals/store/useCharts.d.ts +1 -1
- package/locales/elGR.d.ts +19 -0
- package/locales/elGR.js +21 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/models/axis.d.ts +15 -0
- package/models/axis.js +4 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/scatter.d.ts +11 -2
- package/package.json +4 -3
- package/themeAugmentation/components.d.ts +3 -0
- package/themeAugmentation/props.d.ts +2 -0
package/ChartsTooltip/utils.js
CHANGED
|
@@ -12,55 +12,44 @@ exports.usePointerType = usePointerType;
|
|
|
12
12
|
exports.utcFormatter = utcFormatter;
|
|
13
13
|
var React = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
|
|
15
|
+
var _ChartProvider = require("../context/ChartProvider");
|
|
15
16
|
var _hooks = require("../hooks");
|
|
16
17
|
/**
|
|
17
18
|
* @deprecated We recommend using vanilla JS to let popper track mouse position.
|
|
18
19
|
*/
|
|
19
20
|
function useMouseTracker() {
|
|
20
|
-
const
|
|
21
|
+
const {
|
|
22
|
+
instance
|
|
23
|
+
} = (0, _ChartProvider.useChartContext)();
|
|
21
24
|
|
|
22
25
|
// Use a ref to avoid rerendering on every mousemove event.
|
|
23
26
|
const [mousePosition, setMousePosition] = React.useState(null);
|
|
24
27
|
React.useEffect(() => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
return () => {};
|
|
28
|
-
}
|
|
29
|
-
const controller = new AbortController();
|
|
30
|
-
const handleOut = event => {
|
|
31
|
-
if (event.pointerType !== 'mouse') {
|
|
28
|
+
const moveEndHandler = instance.addInteractionListener('moveEnd', event => {
|
|
29
|
+
if (!event.detail.activeGestures.pan) {
|
|
32
30
|
setMousePosition(null);
|
|
33
31
|
}
|
|
34
|
-
};
|
|
35
|
-
const
|
|
32
|
+
});
|
|
33
|
+
const gestureHandler = event => {
|
|
36
34
|
setMousePosition({
|
|
37
|
-
x: event.
|
|
38
|
-
y: event.
|
|
39
|
-
height: event.height,
|
|
40
|
-
pointerType: event.pointerType
|
|
35
|
+
x: event.detail.centroid.x,
|
|
36
|
+
y: event.detail.centroid.y,
|
|
37
|
+
height: event.detail.srcEvent.height,
|
|
38
|
+
pointerType: event.detail.srcEvent.pointerType
|
|
41
39
|
});
|
|
42
40
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
element.addEventListener('pointermove', handleMove, {
|
|
47
|
-
signal: controller.signal
|
|
48
|
-
});
|
|
49
|
-
element.addEventListener('pointerup', handleOut, {
|
|
50
|
-
signal: controller.signal
|
|
51
|
-
});
|
|
41
|
+
const moveHandler = instance.addInteractionListener('move', gestureHandler);
|
|
42
|
+
const panHandler = instance.addInteractionListener('pan', gestureHandler);
|
|
52
43
|
return () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
moveHandler.cleanup();
|
|
45
|
+
panHandler.cleanup();
|
|
46
|
+
moveEndHandler.cleanup();
|
|
56
47
|
};
|
|
57
|
-
}, [
|
|
48
|
+
}, [instance]);
|
|
58
49
|
return mousePosition;
|
|
59
50
|
}
|
|
60
51
|
function usePointerType() {
|
|
61
52
|
const svgRef = (0, _hooks.useSvgRef)();
|
|
62
|
-
|
|
63
|
-
// Use a ref to avoid rerendering on every mousemove event.
|
|
64
53
|
const [pointerType, setPointerType] = React.useState(null);
|
|
65
54
|
React.useEffect(() => {
|
|
66
55
|
const element = svgRef.current;
|
|
@@ -3,7 +3,7 @@ import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
|
|
|
3
3
|
import { GaugeProviderProps } from "./GaugeProvider.js";
|
|
4
4
|
import { MergeSignaturesProperty } from "../internals/plugins/models/index.js";
|
|
5
5
|
import { ChartCorePluginSignatures } from "../internals/plugins/corePlugins/index.js";
|
|
6
|
-
export interface GaugeContainerProps extends Omit<ChartsSurfaceProps, 'children'>, Omit<MergeSignaturesProperty<ChartCorePluginSignatures, 'params'>, 'series' | 'dataset' | 'colors' | 'theme'>, Omit<GaugeProviderProps, 'children'>, Omit<React.SVGProps<SVGSVGElement>, 'width' | 'height'> {
|
|
6
|
+
export interface GaugeContainerProps extends Omit<ChartsSurfaceProps, 'children'>, Omit<MergeSignaturesProperty<ChartCorePluginSignatures, 'params'>, 'series' | 'dataset' | 'colors' | 'theme' | 'experimentalFeatures'>, Omit<GaugeProviderProps, 'children'>, Omit<React.SVGProps<SVGSVGElement>, 'width' | 'height'> {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
}
|
|
9
9
|
declare const GaugeContainer: React.ForwardRefExoticComponent<Omit<GaugeContainerProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
package/LineChart/AreaPlot.js
CHANGED
|
@@ -7,22 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.AreaPlot = AreaPlot;
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
|
-
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
16
15
|
var _AreaElement = require("./AreaElement");
|
|
17
|
-
var _useScale = require("../hooks/useScale");
|
|
18
|
-
var _getCurve = require("../internals/getCurve");
|
|
19
|
-
var _isBandScale = require("../internals/isBandScale");
|
|
20
|
-
var _constants = require("../constants");
|
|
21
|
-
var _useLineSeries = require("../hooks/useLineSeries");
|
|
22
16
|
var _useSkipAnimation = require("../hooks/useSkipAnimation");
|
|
23
|
-
var _useChartGradientId = require("../hooks/useChartGradientId");
|
|
24
17
|
var _useAxis = require("../hooks/useAxis");
|
|
25
18
|
var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
|
|
19
|
+
var _useAreaPlotData = require("./useAreaPlotData");
|
|
26
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
21
|
const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
|
|
28
22
|
const AreaPlotRoot = (0, _styles.styled)('g', {
|
|
@@ -34,117 +28,13 @@ const AreaPlotRoot = (0, _styles.styled)('g', {
|
|
|
34
28
|
}
|
|
35
29
|
});
|
|
36
30
|
const useAggregatedData = () => {
|
|
37
|
-
const seriesData = (0, _useLineSeries.useLineSeriesContext)();
|
|
38
31
|
const {
|
|
39
|
-
xAxis
|
|
40
|
-
xAxisIds
|
|
32
|
+
xAxis: xAxes
|
|
41
33
|
} = (0, _useAxis.useXAxes)();
|
|
42
34
|
const {
|
|
43
|
-
yAxis
|
|
44
|
-
yAxisIds
|
|
35
|
+
yAxis: yAxes
|
|
45
36
|
} = (0, _useAxis.useYAxes)();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// This memo prevents odd line chart behavior when hydrating.
|
|
49
|
-
const allData = React.useMemo(() => {
|
|
50
|
-
if (seriesData === undefined) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const {
|
|
54
|
-
series,
|
|
55
|
-
stackingGroups
|
|
56
|
-
} = seriesData;
|
|
57
|
-
const defaultXAxisId = xAxisIds[0];
|
|
58
|
-
const defaultYAxisId = yAxisIds[0];
|
|
59
|
-
return stackingGroups.flatMap(({
|
|
60
|
-
ids: groupIds
|
|
61
|
-
}) => {
|
|
62
|
-
return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
|
|
63
|
-
.map(seriesId => {
|
|
64
|
-
const {
|
|
65
|
-
xAxisId = defaultXAxisId,
|
|
66
|
-
yAxisId = defaultYAxisId,
|
|
67
|
-
stackedData,
|
|
68
|
-
data,
|
|
69
|
-
connectNulls,
|
|
70
|
-
baseline,
|
|
71
|
-
curve,
|
|
72
|
-
strictStepCurve
|
|
73
|
-
} = series[seriesId];
|
|
74
|
-
const xScale = xAxis[xAxisId].scale;
|
|
75
|
-
const xPosition = (0, _useScale.getValueToPositionMapper)(xScale);
|
|
76
|
-
const yScale = yAxis[yAxisId].scale;
|
|
77
|
-
const xData = xAxis[xAxisId].data;
|
|
78
|
-
const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
|
|
79
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
80
|
-
if (xData === undefined) {
|
|
81
|
-
throw new Error(`MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
82
|
-
}
|
|
83
|
-
if (xData.length < stackedData.length) {
|
|
84
|
-
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const shouldExpand = curve?.includes('step') && !strictStepCurve && (0, _isBandScale.isBandScale)(xScale);
|
|
88
|
-
const formattedData = xData?.flatMap((x, index) => {
|
|
89
|
-
const nullData = data[index] == null;
|
|
90
|
-
if (shouldExpand) {
|
|
91
|
-
const rep = [{
|
|
92
|
-
x,
|
|
93
|
-
y: stackedData[index],
|
|
94
|
-
nullData,
|
|
95
|
-
isExtension: false
|
|
96
|
-
}];
|
|
97
|
-
if (!nullData && (index === 0 || data[index - 1] == null)) {
|
|
98
|
-
rep.unshift({
|
|
99
|
-
x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
|
|
100
|
-
y: stackedData[index],
|
|
101
|
-
nullData,
|
|
102
|
-
isExtension: true
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
|
|
106
|
-
rep.push({
|
|
107
|
-
x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
|
|
108
|
-
y: stackedData[index],
|
|
109
|
-
nullData,
|
|
110
|
-
isExtension: true
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
return rep;
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
x,
|
|
117
|
-
y: stackedData[index],
|
|
118
|
-
nullData
|
|
119
|
-
};
|
|
120
|
-
}) ?? [];
|
|
121
|
-
const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
|
|
122
|
-
const areaPath = (0, _d3Shape.area)().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y0(d => {
|
|
123
|
-
if (typeof baseline === 'number') {
|
|
124
|
-
return yScale(baseline);
|
|
125
|
-
}
|
|
126
|
-
if (baseline === 'max') {
|
|
127
|
-
return yScale.range()[1];
|
|
128
|
-
}
|
|
129
|
-
if (baseline === 'min') {
|
|
130
|
-
return yScale.range()[0];
|
|
131
|
-
}
|
|
132
|
-
const value = d.y && yScale(d.y[0]);
|
|
133
|
-
if (Number.isNaN(value)) {
|
|
134
|
-
return yScale.range()[0];
|
|
135
|
-
}
|
|
136
|
-
return value;
|
|
137
|
-
}).y1(d => d.y && yScale(d.y[1]));
|
|
138
|
-
const d = areaPath.curve((0, _getCurve.getCurveFactory)(curve))(d3Data) || '';
|
|
139
|
-
return (0, _extends2.default)({}, series[seriesId], {
|
|
140
|
-
gradientId,
|
|
141
|
-
d,
|
|
142
|
-
seriesId
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}, [seriesData, xAxisIds, yAxisIds, xAxis, yAxis, getGradientId]);
|
|
147
|
-
return allData;
|
|
37
|
+
return (0, _useAreaPlotData.useAreaPlotData)(xAxes, yAxes);
|
|
148
38
|
};
|
|
149
39
|
|
|
150
40
|
/**
|
package/LineChart/LineChart.js
CHANGED
|
@@ -118,6 +118,12 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
118
118
|
* If `true`, render the line highlight item.
|
|
119
119
|
*/
|
|
120
120
|
disableLineItemHighlight: _propTypes.default.bool,
|
|
121
|
+
/**
|
|
122
|
+
* Options to enable features planned for the next major.
|
|
123
|
+
*/
|
|
124
|
+
experimentalFeatures: _propTypes.default.shape({
|
|
125
|
+
preferStrictDomainInLineCharts: _propTypes.default.bool
|
|
126
|
+
}),
|
|
121
127
|
/**
|
|
122
128
|
* Option to display a cartesian grid in the background.
|
|
123
129
|
*/
|
|
@@ -133,6 +139,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
133
139
|
* If `true`, the legend is not rendered.
|
|
134
140
|
*/
|
|
135
141
|
hideLegend: _propTypes.default.bool,
|
|
142
|
+
/**
|
|
143
|
+
* The controlled axis highlight.
|
|
144
|
+
* Identified by the axis id, and data index.
|
|
145
|
+
*/
|
|
146
|
+
highlightedAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
147
|
+
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
148
|
+
dataIndex: _propTypes.default.number.isRequired
|
|
149
|
+
})),
|
|
136
150
|
/**
|
|
137
151
|
* The highlighted item.
|
|
138
152
|
* Used when the highlight is controlled.
|
|
@@ -184,6 +198,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
184
198
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
185
199
|
*/
|
|
186
200
|
onHighlightChange: _propTypes.default.func,
|
|
201
|
+
/**
|
|
202
|
+
* The function called when the pointer position corresponds to a new axis data item.
|
|
203
|
+
* This update can either be caused by a pointer movement, or an axis update.
|
|
204
|
+
* In case of multiple axes, the function is called if at least one axis is updated.
|
|
205
|
+
* The argument contains the identifier for all axes with a `data` property.
|
|
206
|
+
* @param {AxisItemIdentifier[]} axisItems The array of axes item identifiers.
|
|
207
|
+
*/
|
|
208
|
+
onHighlightedAxisChange: _propTypes.default.func,
|
|
187
209
|
/**
|
|
188
210
|
* Callback fired when a line element is clicked.
|
|
189
211
|
*/
|
|
@@ -52,8 +52,8 @@ function LineHighlightPlot(props) {
|
|
|
52
52
|
instance
|
|
53
53
|
} = (0, _ChartProvider.useChartContext)();
|
|
54
54
|
const store = (0, _useStore.useStore)();
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
55
|
+
const highlightedIndexes = (0, _useSelector.useSelector)(store, _useChartCartesianAxis.selectorChartsHighlightXAxisIndex);
|
|
56
|
+
if (highlightedIndexes.length === 0) {
|
|
57
57
|
return null;
|
|
58
58
|
}
|
|
59
59
|
if (seriesData === undefined) {
|
|
@@ -67,7 +67,10 @@ function LineHighlightPlot(props) {
|
|
|
67
67
|
const defaultYAxisId = yAxisIds[0];
|
|
68
68
|
const Element = slots?.lineHighlight ?? _LineHighlightElement.LineHighlightElement;
|
|
69
69
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", (0, _extends2.default)({}, other, {
|
|
70
|
-
children:
|
|
70
|
+
children: highlightedIndexes.flatMap(({
|
|
71
|
+
dataIndex: highlightedIndex,
|
|
72
|
+
axisId: highlightedAxisId
|
|
73
|
+
}) => stackingGroups.flatMap(({
|
|
71
74
|
ids: groupIds
|
|
72
75
|
}) => {
|
|
73
76
|
return groupIds.flatMap(seriesId => {
|
|
@@ -82,6 +85,9 @@ function LineHighlightPlot(props) {
|
|
|
82
85
|
if (disableHighlight || data[highlightedIndex] == null) {
|
|
83
86
|
return null;
|
|
84
87
|
}
|
|
88
|
+
if (highlightedAxisId !== xAxisId) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
85
91
|
const xScale = (0, _useScale.getValueToPositionMapper)(xAxis[xAxisId].scale);
|
|
86
92
|
const yScale = yAxis[yAxisId].scale;
|
|
87
93
|
const xData = xAxis[xAxisId].data;
|
|
@@ -103,7 +109,7 @@ function LineHighlightPlot(props) {
|
|
|
103
109
|
shape: shape
|
|
104
110
|
}, slotProps?.lineHighlight), `${seriesId}`);
|
|
105
111
|
});
|
|
106
|
-
})
|
|
112
|
+
}))
|
|
107
113
|
}));
|
|
108
114
|
}
|
|
109
115
|
process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
|
package/LineChart/LinePlot.js
CHANGED
|
@@ -7,23 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.LinePlot = LinePlot;
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
|
-
var _warning = require("@mui/x-internals/warning");
|
|
16
|
-
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
17
15
|
var _LineElement = require("./LineElement");
|
|
18
|
-
var _useScale = require("../hooks/useScale");
|
|
19
|
-
var _getCurve = require("../internals/getCurve");
|
|
20
|
-
var _isBandScale = require("../internals/isBandScale");
|
|
21
|
-
var _constants = require("../constants");
|
|
22
|
-
var _useLineSeries = require("../hooks/useLineSeries");
|
|
23
16
|
var _useSkipAnimation = require("../hooks/useSkipAnimation");
|
|
24
|
-
var _useChartGradientId = require("../hooks/useChartGradientId");
|
|
25
17
|
var _hooks = require("../hooks");
|
|
26
18
|
var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
|
|
19
|
+
var _useLinePlotData = require("./useLinePlotData");
|
|
27
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
21
|
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
29
22
|
const LinePlotRoot = (0, _styles.styled)('g', {
|
|
@@ -35,100 +28,13 @@ const LinePlotRoot = (0, _styles.styled)('g', {
|
|
|
35
28
|
}
|
|
36
29
|
});
|
|
37
30
|
const useAggregatedData = () => {
|
|
38
|
-
const seriesData = (0, _useLineSeries.useLineSeriesContext)();
|
|
39
31
|
const {
|
|
40
|
-
xAxis
|
|
41
|
-
xAxisIds
|
|
32
|
+
xAxis: xAxes
|
|
42
33
|
} = (0, _hooks.useXAxes)();
|
|
43
34
|
const {
|
|
44
|
-
yAxis
|
|
45
|
-
yAxisIds
|
|
35
|
+
yAxis: yAxes
|
|
46
36
|
} = (0, _hooks.useYAxes)();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// This memo prevents odd line chart behavior when hydrating.
|
|
50
|
-
const allData = React.useMemo(() => {
|
|
51
|
-
if (seriesData === undefined) {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
const {
|
|
55
|
-
series,
|
|
56
|
-
stackingGroups
|
|
57
|
-
} = seriesData;
|
|
58
|
-
const defaultXAxisId = xAxisIds[0];
|
|
59
|
-
const defaultYAxisId = yAxisIds[0];
|
|
60
|
-
return stackingGroups.flatMap(({
|
|
61
|
-
ids: groupIds
|
|
62
|
-
}) => {
|
|
63
|
-
return groupIds.flatMap(seriesId => {
|
|
64
|
-
const {
|
|
65
|
-
xAxisId = defaultXAxisId,
|
|
66
|
-
yAxisId = defaultYAxisId,
|
|
67
|
-
stackedData,
|
|
68
|
-
data,
|
|
69
|
-
connectNulls,
|
|
70
|
-
curve,
|
|
71
|
-
strictStepCurve
|
|
72
|
-
} = series[seriesId];
|
|
73
|
-
const xScale = xAxis[xAxisId].scale;
|
|
74
|
-
const xPosition = (0, _useScale.getValueToPositionMapper)(xScale);
|
|
75
|
-
const yScale = yAxis[yAxisId].scale;
|
|
76
|
-
const xData = xAxis[xAxisId].data;
|
|
77
|
-
const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
|
|
78
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
79
|
-
if (xData === undefined) {
|
|
80
|
-
throw new Error(`MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
81
|
-
}
|
|
82
|
-
if (xData.length < stackedData.length) {
|
|
83
|
-
(0, _warning.warnOnce)(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`, 'error');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const shouldExpand = curve?.includes('step') && !strictStepCurve && (0, _isBandScale.isBandScale)(xScale);
|
|
87
|
-
const formattedData = xData?.flatMap((x, index) => {
|
|
88
|
-
const nullData = data[index] == null;
|
|
89
|
-
if (shouldExpand) {
|
|
90
|
-
const rep = [{
|
|
91
|
-
x,
|
|
92
|
-
y: stackedData[index],
|
|
93
|
-
nullData,
|
|
94
|
-
isExtension: false
|
|
95
|
-
}];
|
|
96
|
-
if (!nullData && (index === 0 || data[index - 1] == null)) {
|
|
97
|
-
rep.unshift({
|
|
98
|
-
x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
|
|
99
|
-
y: stackedData[index],
|
|
100
|
-
nullData,
|
|
101
|
-
isExtension: true
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
|
|
105
|
-
rep.push({
|
|
106
|
-
x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
|
|
107
|
-
y: stackedData[index],
|
|
108
|
-
nullData,
|
|
109
|
-
isExtension: true
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return rep;
|
|
113
|
-
}
|
|
114
|
-
return {
|
|
115
|
-
x,
|
|
116
|
-
y: stackedData[index],
|
|
117
|
-
nullData
|
|
118
|
-
};
|
|
119
|
-
}) ?? [];
|
|
120
|
-
const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
|
|
121
|
-
const linePath = (0, _d3Shape.line)().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y(d => yScale(d.y[1]));
|
|
122
|
-
const d = linePath.curve((0, _getCurve.getCurveFactory)(curve))(d3Data) || '';
|
|
123
|
-
return (0, _extends2.default)({}, series[seriesId], {
|
|
124
|
-
gradientId,
|
|
125
|
-
d,
|
|
126
|
-
seriesId
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
}, [seriesData, xAxisIds, yAxisIds, xAxis, yAxis, getGradientId]);
|
|
131
|
-
return allData;
|
|
37
|
+
return (0, _useLinePlotData.useLinePlotData)(xAxes, yAxes);
|
|
132
38
|
};
|
|
133
39
|
|
|
134
40
|
/**
|
package/LineChart/MarkPlot.js
CHANGED
|
@@ -11,7 +11,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
var React = _interopRequireWildcard(require("react"));
|
|
14
|
-
var _useChartCartesianInteraction = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors");
|
|
15
14
|
var _constants = require("../constants");
|
|
16
15
|
var _useSkipAnimation = require("../hooks/useSkipAnimation");
|
|
17
16
|
var _useChartId = require("../hooks/useChartId");
|
|
@@ -24,6 +23,7 @@ var _MarkElement = require("./MarkElement");
|
|
|
24
23
|
var _ChartProvider = require("../context/ChartProvider");
|
|
25
24
|
var _hooks = require("../hooks");
|
|
26
25
|
var _useInternalIsZoomInteracting = require("../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting");
|
|
26
|
+
var _useChartCartesianAxis = require("../internals/plugins/featurePlugins/useChartCartesianAxis");
|
|
27
27
|
var _useSelector = require("../internals/store/useSelector");
|
|
28
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
29
|
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
@@ -65,7 +65,21 @@ function MarkPlot(props) {
|
|
|
65
65
|
isFaded,
|
|
66
66
|
isHighlighted
|
|
67
67
|
} = (0, _hooks.useItemHighlightedGetter)();
|
|
68
|
-
const
|
|
68
|
+
const xAxisHighlightIndexes = (0, _useSelector.useSelector)(store, _useChartCartesianAxis.selectorChartsHighlightXAxisIndex);
|
|
69
|
+
const highlightedItems = React.useMemo(() => {
|
|
70
|
+
const rep = {};
|
|
71
|
+
for (const {
|
|
72
|
+
dataIndex,
|
|
73
|
+
axisId
|
|
74
|
+
} of xAxisHighlightIndexes) {
|
|
75
|
+
if (rep[axisId] === undefined) {
|
|
76
|
+
rep[axisId] = new Set([dataIndex]);
|
|
77
|
+
} else {
|
|
78
|
+
rep[axisId].add(dataIndex);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return rep;
|
|
82
|
+
}, [xAxisHighlightIndexes]);
|
|
69
83
|
if (seriesData === undefined) {
|
|
70
84
|
return null;
|
|
71
85
|
}
|
|
@@ -163,7 +177,7 @@ function MarkPlot(props) {
|
|
|
163
177
|
seriesId,
|
|
164
178
|
dataIndex: index
|
|
165
179
|
})),
|
|
166
|
-
isHighlighted:
|
|
180
|
+
isHighlighted: highlightedItems[xAxisId]?.has(index) || isSeriesHighlighted,
|
|
167
181
|
isFaded: isSeriesFaded
|
|
168
182
|
}, slotProps?.mark), `${seriesId}-${index}`);
|
|
169
183
|
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
2
|
+
import { ChartsXAxisProps, ChartsYAxisProps } from "../models/index.js";
|
|
3
|
+
import { SeriesId } from "../models/seriesType/common.js";
|
|
4
|
+
interface AreaPlotDataPoint {
|
|
5
|
+
d: string;
|
|
6
|
+
seriesId: SeriesId;
|
|
7
|
+
color: string;
|
|
8
|
+
area?: boolean;
|
|
9
|
+
gradientId?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function useAreaPlotData(xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): AreaPlotDataPoint[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useAreaPlotData = useAreaPlotData;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
10
|
+
var _useChartGradientId = require("../hooks/useChartGradientId");
|
|
11
|
+
var _isBandScale = require("../internals/isBandScale");
|
|
12
|
+
var _getCurve = require("../internals/getCurve");
|
|
13
|
+
var _hooks = require("../hooks");
|
|
14
|
+
var _constants = require("../constants");
|
|
15
|
+
function useAreaPlotData(xAxes, yAxes) {
|
|
16
|
+
const seriesData = (0, _hooks.useLineSeriesContext)();
|
|
17
|
+
const defaultXAxisId = (0, _hooks.useXAxes)().xAxisIds[0];
|
|
18
|
+
const defaultYAxisId = (0, _hooks.useYAxes)().yAxisIds[0];
|
|
19
|
+
const getGradientId = (0, _useChartGradientId.useChartGradientIdBuilder)();
|
|
20
|
+
|
|
21
|
+
// This memo prevents odd line chart behavior when hydrating.
|
|
22
|
+
const allData = React.useMemo(() => {
|
|
23
|
+
if (seriesData === undefined) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const {
|
|
27
|
+
series,
|
|
28
|
+
stackingGroups
|
|
29
|
+
} = seriesData;
|
|
30
|
+
const areaPlotData = [];
|
|
31
|
+
for (const stackingGroup of stackingGroups) {
|
|
32
|
+
const groupIds = stackingGroup.ids;
|
|
33
|
+
for (let i = groupIds.length - 1; i >= 0; i -= 1) {
|
|
34
|
+
const seriesId = groupIds[i];
|
|
35
|
+
const {
|
|
36
|
+
xAxisId = defaultXAxisId,
|
|
37
|
+
yAxisId = defaultYAxisId,
|
|
38
|
+
stackedData,
|
|
39
|
+
data,
|
|
40
|
+
connectNulls,
|
|
41
|
+
baseline,
|
|
42
|
+
curve,
|
|
43
|
+
strictStepCurve,
|
|
44
|
+
area
|
|
45
|
+
} = series[seriesId];
|
|
46
|
+
if (!area || !(xAxisId in xAxes) || !(yAxisId in yAxes)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const xScale = xAxes[xAxisId].scale;
|
|
50
|
+
const xPosition = (0, _hooks.getValueToPositionMapper)(xScale);
|
|
51
|
+
const yScale = yAxes[yAxisId].scale;
|
|
52
|
+
const xData = xAxes[xAxisId].data;
|
|
53
|
+
const gradientId = yAxes[yAxisId].colorScale && getGradientId(yAxisId) || xAxes[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
|
|
54
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
55
|
+
if (xData === undefined) {
|
|
56
|
+
throw new Error(`MUI X Charts: ${xAxisId === _constants.DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
57
|
+
}
|
|
58
|
+
if (xData.length < stackedData.length) {
|
|
59
|
+
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const shouldExpand = curve?.includes('step') && !strictStepCurve && (0, _isBandScale.isBandScale)(xScale);
|
|
63
|
+
const formattedData = xData?.flatMap((x, index) => {
|
|
64
|
+
const nullData = data[index] == null;
|
|
65
|
+
if (shouldExpand) {
|
|
66
|
+
const rep = [{
|
|
67
|
+
x,
|
|
68
|
+
y: stackedData[index],
|
|
69
|
+
nullData,
|
|
70
|
+
isExtension: false
|
|
71
|
+
}];
|
|
72
|
+
if (!nullData && (index === 0 || data[index - 1] == null)) {
|
|
73
|
+
rep.unshift({
|
|
74
|
+
x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
|
|
75
|
+
y: stackedData[index],
|
|
76
|
+
nullData,
|
|
77
|
+
isExtension: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
|
|
81
|
+
rep.push({
|
|
82
|
+
x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
|
|
83
|
+
y: stackedData[index],
|
|
84
|
+
nullData,
|
|
85
|
+
isExtension: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return rep;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
x,
|
|
92
|
+
y: stackedData[index],
|
|
93
|
+
nullData
|
|
94
|
+
};
|
|
95
|
+
}) ?? [];
|
|
96
|
+
const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
|
|
97
|
+
const areaPath = (0, _d3Shape.area)().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y0(d => {
|
|
98
|
+
if (typeof baseline === 'number') {
|
|
99
|
+
return yScale(baseline);
|
|
100
|
+
}
|
|
101
|
+
if (baseline === 'max') {
|
|
102
|
+
return yScale.range()[1];
|
|
103
|
+
}
|
|
104
|
+
if (baseline === 'min') {
|
|
105
|
+
return yScale.range()[0];
|
|
106
|
+
}
|
|
107
|
+
const value = d.y && yScale(d.y[0]);
|
|
108
|
+
if (Number.isNaN(value)) {
|
|
109
|
+
return yScale.range()[0];
|
|
110
|
+
}
|
|
111
|
+
return value;
|
|
112
|
+
}).y1(d => d.y && yScale(d.y[1]));
|
|
113
|
+
const d = areaPath.curve((0, _getCurve.getCurveFactory)(curve))(d3Data) || '';
|
|
114
|
+
areaPlotData.push({
|
|
115
|
+
area: series[seriesId].area,
|
|
116
|
+
color: series[seriesId].color,
|
|
117
|
+
gradientId,
|
|
118
|
+
d,
|
|
119
|
+
seriesId
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return areaPlotData;
|
|
124
|
+
}, [seriesData, defaultXAxisId, defaultYAxisId, xAxes, yAxes, getGradientId]);
|
|
125
|
+
return allData;
|
|
126
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
2
|
+
import { ChartsXAxisProps, ChartsYAxisProps } from "../models/index.js";
|
|
3
|
+
import { SeriesId } from "../models/seriesType/common.js";
|
|
4
|
+
interface LinePlotDataPoint {
|
|
5
|
+
d: string;
|
|
6
|
+
seriesId: SeriesId;
|
|
7
|
+
color: string;
|
|
8
|
+
gradientId?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function useLinePlotData(xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): LinePlotDataPoint[];
|
|
11
|
+
export {};
|