@mui/x-charts 8.0.0-alpha.7 → 8.0.0-alpha.9
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 +10 -2
- package/BarChart/BarLabel/BarLabelPlot.js +1 -1
- package/BarChart/BarPlot.js +8 -9
- package/BarChart/extremums.d.ts +3 -3
- package/BarChart/formatter.d.ts +2 -2
- package/BarChart/formatter.js +2 -1
- package/BarChart/getColor.d.ts +1 -1
- package/BarChart/legend.d.ts +1 -1
- package/BarChart/legend.js +1 -1
- package/BarChart/plugin.d.ts +2 -2
- package/BarChart/plugin.js +3 -2
- package/BarChart/useBarChartProps.d.ts +1 -1
- package/CHANGELOG.md +551 -3
- package/ChartContainer/ChartContainer.d.ts +8 -4
- package/ChartContainer/ChartContainer.js +15 -9
- package/ChartContainer/useChartContainerProps.d.ts +6 -4
- package/ChartContainer/useChartContainerProps.js +7 -5
- package/ChartDataProvider/ChartDataProvider.d.ts +42 -0
- package/ChartDataProvider/ChartDataProvider.js +108 -0
- package/ChartDataProvider/package.json +6 -0
- package/ChartDataProvider/useChartDataProviderProps.d.ts +13 -0
- package/ChartDataProvider/useChartDataProviderProps.js +52 -0
- package/ChartsAxis/ChartsAxis.js +5 -3
- package/ChartsGrid/ChartsGrid.js +9 -5
- package/ChartsGrid/ChartsHorizontalGrid.d.ts +2 -2
- package/ChartsGrid/ChartsHorizontalGrid.js +4 -3
- package/ChartsGrid/ChartsVerticalGrid.d.ts +2 -2
- package/ChartsGrid/ChartsVerticalGrid.js +4 -3
- package/ChartsLabel/ChartsLabelGradient.js +11 -12
- package/ChartsLegend/ContinuousColorLegend.js +3 -3
- package/ChartsLegend/useAxis.js +7 -5
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +7 -6
- package/ChartsSurface/ChartsSurface.d.ts +1 -1
- package/ChartsSurface/ChartsSurface.js +17 -27
- package/ChartsTooltip/ChartsAxisTooltipContent.js +6 -3
- package/ChartsTooltip/ChartsItemTooltipContent.js +6 -3
- package/ChartsTooltip/ChartsTooltipTable.d.ts +0 -6
- package/ChartsTooltip/ChartsTooltipTable.js +0 -20
- package/ChartsTooltip/useAxisTooltip.d.ts +3 -1
- package/ChartsTooltip/useAxisTooltip.js +13 -9
- package/ChartsTooltip/useItemTooltip.d.ts +3 -1
- package/ChartsTooltip/useItemTooltip.js +14 -10
- package/ChartsTooltip/utils.js +2 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +16 -9
- package/ChartsXAxis/ChartsXAxis.js +11 -8
- package/ChartsYAxis/ChartsYAxis.js +8 -5
- package/Gauge/Gauge.js +5 -1
- package/Gauge/GaugeContainer.d.ts +3 -10
- package/Gauge/GaugeContainer.js +38 -38
- package/Gauge/GaugeProvider.js +2 -0
- package/LineChart/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AppearingMask.js +1 -1
- package/LineChart/AreaPlot.js +59 -25
- package/LineChart/CircleMarkElement.d.ts +0 -4
- package/LineChart/CircleMarkElement.js +2 -7
- package/LineChart/LineChart.d.ts +0 -4
- package/LineChart/LineChart.js +10 -6
- package/LineChart/LineHighlightElement.d.ts +5 -1
- package/LineChart/LineHighlightElement.js +29 -9
- package/LineChart/LineHighlightPlot.js +18 -13
- package/LineChart/LinePlot.js +59 -24
- package/LineChart/MarkPlot.d.ts +0 -6
- package/LineChart/MarkPlot.js +20 -23
- package/LineChart/extremums.d.ts +3 -3
- package/LineChart/formatter.d.ts +2 -2
- package/LineChart/formatter.js +3 -1
- package/LineChart/getColor.d.ts +1 -1
- package/LineChart/legend.d.ts +1 -1
- package/LineChart/legend.js +1 -1
- package/LineChart/plugin.d.ts +2 -2
- package/LineChart/plugin.js +3 -2
- package/LineChart/useLineChartProps.d.ts +1 -1
- package/LineChart/useLineChartProps.js +3 -5
- package/PieChart/PieArcLabelPlot.js +2 -2
- package/PieChart/PieArcPlot.js +2 -2
- package/PieChart/PieChart.js +10 -2
- package/PieChart/dataTransform/transition.d.ts +2 -2
- package/PieChart/dataTransform/transition.js +6 -6
- package/PieChart/formatter.d.ts +2 -2
- package/PieChart/formatter.js +4 -1
- package/PieChart/getColor.d.ts +1 -1
- package/PieChart/getPieCoordinates.d.ts +2 -2
- package/PieChart/legend.d.ts +1 -1
- package/PieChart/legend.js +1 -1
- package/PieChart/plugin.d.ts +2 -2
- package/PieChart/plugin.js +3 -2
- package/ScatterChart/Scatter.js +6 -4
- package/ScatterChart/ScatterChart.d.ts +1 -2
- package/ScatterChart/ScatterChart.js +17 -13
- package/ScatterChart/ScatterPlot.js +11 -10
- package/ScatterChart/extremums.d.ts +3 -3
- package/ScatterChart/extremums.js +3 -1
- package/ScatterChart/formatter.d.ts +2 -2
- package/ScatterChart/formatter.js +3 -1
- package/ScatterChart/getColor.d.ts +1 -1
- package/ScatterChart/legend.d.ts +1 -1
- package/ScatterChart/legend.js +1 -1
- package/ScatterChart/plugin.d.ts +2 -2
- package/ScatterChart/plugin.js +3 -2
- package/ScatterChart/useScatterChartProps.d.ts +1 -3
- package/ScatterChart/useScatterChartProps.js +1 -4
- package/SparkLineChart/SparkLineChart.d.ts +2 -2
- package/SparkLineChart/SparkLineChart.js +11 -2
- package/context/AnimationProvider/AnimationProvider.js +1 -1
- package/context/ChartProvider/ChartProvider.d.ts +5 -1
- package/context/ChartProvider/ChartProvider.js +22 -2
- package/context/ChartProvider/ChartProvider.types.d.ts +17 -2
- package/context/InteractionSelectors.d.ts +22 -22
- package/context/PolarProvider/PolarProvider.d.ts +0 -4
- package/context/PolarProvider/PolarProvider.js +59 -47
- package/context/PolarProvider/getAxisExtremum.d.ts +0 -4
- package/context/PolarProvider/getAxisExtremum.js +48 -20
- package/context/PolarProvider/usePolarContext.d.ts +0 -2
- package/context/PolarProvider/usePolarContext.js +9 -8
- package/context/index.d.ts +0 -4
- package/context/index.js +1 -3
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +3 -1
- package/hooks/useAxis.d.ts +9 -1
- package/hooks/useAxis.js +32 -6
- package/hooks/useAxisEvents.js +12 -8
- package/hooks/useChartGradientId.d.ts +31 -0
- package/hooks/useChartGradientId.js +47 -0
- package/hooks/useColorScale.js +5 -5
- package/hooks/useDrawingArea.d.ts +16 -2
- package/hooks/useDrawingArea.js +5 -20
- package/hooks/useLegend.js +8 -13
- package/hooks/useSeries.d.ts +11 -6
- package/hooks/useSeries.js +5 -10
- package/hooks/useZAxis.d.ts +3 -2
- package/hooks/useZAxis.js +25 -6
- package/index.d.ts +1 -0
- package/index.js +3 -2
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +0 -3
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +19 -27
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/internals/defaultizeColor.d.ts +24 -22
- package/internals/index.d.ts +14 -10
- package/internals/index.js +17 -11
- package/internals/plugins/allPlugins.d.ts +12 -1
- package/internals/plugins/allPlugins.js +5 -2
- package/internals/plugins/corePlugins/corePlugins.d.ts +1 -1
- package/internals/plugins/corePlugins/corePlugins.js +3 -1
- package/internals/plugins/corePlugins/useChartDimensions/index.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartDimensions/index.js +2 -0
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +175 -0
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +264 -0
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +25 -0
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +99 -0
- package/internals/plugins/corePlugins/useChartId/index.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartId/index.js +2 -1
- package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartId/useChartId.types.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/index.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartSeries/index.js +2 -0
- package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +18 -0
- package/{modern/context/SeriesProvider → internals/plugins/corePlugins/useChartSeries}/processSeries.js +9 -6
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +72 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +61 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +4 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +51 -0
- package/internals/plugins/corePlugins/useChartSeries/useColorProcessor.d.ts +10 -0
- package/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +29 -0
- package/internals/{computeAxisValue.js → plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js} +19 -27
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +18 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +61 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.d.ts +39 -0
- package/{modern/context/ChartDataProvider/useDefaultizeAxis.js → internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js} +3 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts +6 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +22 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +6 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.d.ts +4 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +68 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.d.ts +1336 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.js +89 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +75 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +18 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +11 -11
- package/internals/plugins/featurePlugins/useChartZAxis/index.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartZAxis/index.js +2 -0
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.js +86 -0
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +45 -0
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.js +3 -0
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.types.d.ts +39 -0
- package/internals/plugins/featurePlugins/useChartZAxis/utils.d.ts +0 -0
- package/internals/plugins/featurePlugins/useChartZAxis/utils.js +0 -0
- package/internals/plugins/models/index.d.ts +1 -0
- package/internals/plugins/models/index.js +2 -1
- package/internals/plugins/models/plugin.d.ts +32 -2
- package/internals/plugins/models/seriesConfig/colorProcessor.types.d.ts +5 -0
- package/internals/plugins/models/seriesConfig/extremumGetter.types.d.ts +22 -0
- package/internals/plugins/models/seriesConfig/index.d.ts +4 -0
- package/internals/plugins/models/seriesConfig/index.js +4 -0
- package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +15 -0
- package/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +18 -0
- package/internals/store/extractPluginParamsFromProps.d.ts +7 -0
- package/internals/store/extractPluginParamsFromProps.js +28 -0
- package/internals/store/useChartModels.d.ts +7 -0
- package/internals/store/useChartModels.js +64 -0
- package/internals/store/useCharts.d.ts +4 -2
- package/internals/store/useCharts.js +14 -9
- package/internals/store/useCharts.types.d.ts +1 -1
- package/internals/store/useStore.d.ts +5 -1
- package/internals/store/useStore.js +1 -9
- package/models/layout.d.ts +2 -1
- package/models/seriesType/line.d.ts +11 -0
- package/modern/BarChart/BarChart.js +10 -2
- package/modern/BarChart/BarLabel/BarLabelPlot.js +1 -1
- package/modern/BarChart/BarPlot.js +8 -9
- package/modern/BarChart/formatter.js +2 -1
- package/modern/BarChart/legend.js +1 -1
- package/modern/BarChart/plugin.js +3 -2
- package/modern/ChartContainer/ChartContainer.js +15 -9
- package/modern/ChartContainer/useChartContainerProps.js +7 -5
- package/modern/ChartDataProvider/ChartDataProvider.js +108 -0
- package/modern/ChartDataProvider/useChartDataProviderProps.js +52 -0
- package/modern/ChartsAxis/ChartsAxis.js +5 -3
- package/modern/ChartsGrid/ChartsGrid.js +9 -5
- package/modern/ChartsGrid/ChartsHorizontalGrid.js +4 -3
- package/modern/ChartsGrid/ChartsVerticalGrid.js +4 -3
- package/modern/ChartsLabel/ChartsLabelGradient.js +11 -12
- package/modern/ChartsLegend/ContinuousColorLegend.js +3 -3
- package/modern/ChartsLegend/useAxis.js +7 -5
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +7 -6
- package/modern/ChartsSurface/ChartsSurface.js +17 -27
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +6 -3
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +6 -3
- package/modern/ChartsTooltip/ChartsTooltipTable.js +0 -20
- package/modern/ChartsTooltip/useAxisTooltip.js +13 -9
- package/modern/ChartsTooltip/useItemTooltip.js +14 -10
- package/modern/ChartsTooltip/utils.js +2 -0
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +16 -9
- package/modern/ChartsXAxis/ChartsXAxis.js +11 -8
- package/modern/ChartsYAxis/ChartsYAxis.js +8 -5
- package/modern/Gauge/Gauge.js +5 -1
- package/modern/Gauge/GaugeContainer.js +38 -38
- package/modern/Gauge/GaugeProvider.js +2 -0
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AppearingMask.js +1 -1
- package/modern/LineChart/AreaPlot.js +59 -25
- package/modern/LineChart/CircleMarkElement.js +2 -7
- package/modern/LineChart/LineChart.js +10 -6
- package/modern/LineChart/LineHighlightElement.js +29 -9
- package/modern/LineChart/LineHighlightPlot.js +18 -13
- package/modern/LineChart/LinePlot.js +59 -24
- package/modern/LineChart/MarkPlot.js +20 -23
- package/modern/LineChart/formatter.js +3 -1
- package/modern/LineChart/legend.js +1 -1
- package/modern/LineChart/plugin.js +3 -2
- package/modern/LineChart/useLineChartProps.js +3 -5
- package/modern/PieChart/PieArcLabelPlot.js +2 -2
- package/modern/PieChart/PieArcPlot.js +2 -2
- package/modern/PieChart/PieChart.js +10 -2
- package/modern/PieChart/dataTransform/transition.js +6 -6
- package/modern/PieChart/formatter.js +4 -1
- package/modern/PieChart/legend.js +1 -1
- package/modern/PieChart/plugin.js +3 -2
- package/modern/ScatterChart/Scatter.js +6 -4
- package/modern/ScatterChart/ScatterChart.js +17 -13
- package/modern/ScatterChart/ScatterPlot.js +11 -10
- package/modern/ScatterChart/extremums.js +3 -1
- package/modern/ScatterChart/formatter.js +3 -1
- package/modern/ScatterChart/legend.js +1 -1
- package/modern/ScatterChart/plugin.js +3 -2
- package/modern/ScatterChart/useScatterChartProps.js +1 -4
- package/modern/SparkLineChart/SparkLineChart.js +11 -2
- package/modern/context/AnimationProvider/AnimationProvider.js +1 -1
- package/modern/context/ChartProvider/ChartProvider.js +22 -2
- package/modern/context/PolarProvider/PolarProvider.js +59 -47
- package/modern/context/PolarProvider/getAxisExtremum.js +48 -20
- package/modern/context/PolarProvider/usePolarContext.js +9 -8
- package/modern/context/index.js +1 -3
- package/modern/hooks/index.js +3 -1
- package/modern/hooks/useAxis.js +32 -6
- package/modern/hooks/useAxisEvents.js +12 -8
- package/modern/hooks/useChartGradientId.js +47 -0
- package/modern/hooks/useColorScale.js +5 -5
- package/modern/hooks/useDrawingArea.js +5 -20
- package/modern/hooks/useLegend.js +8 -13
- package/modern/hooks/useSeries.js +5 -10
- package/modern/hooks/useZAxis.js +25 -6
- package/modern/index.js +3 -2
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +19 -27
- package/modern/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/modern/internals/index.js +17 -11
- package/modern/internals/plugins/allPlugins.js +5 -2
- package/modern/internals/plugins/corePlugins/corePlugins.js +3 -1
- package/modern/internals/plugins/corePlugins/useChartDimensions/index.js +2 -0
- package/modern/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +175 -0
- package/modern/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +25 -0
- package/modern/internals/plugins/corePlugins/useChartId/index.js +2 -1
- package/modern/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/modern/internals/plugins/corePlugins/useChartSeries/index.js +2 -0
- package/{context/SeriesProvider → modern/internals/plugins/corePlugins/useChartSeries}/processSeries.js +9 -6
- package/modern/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +72 -0
- package/modern/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +4 -0
- package/modern/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +21 -0
- package/modern/internals/{computeAxisValue.js → plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js} +19 -27
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +61 -0
- package/{context/ChartDataProvider/useDefaultizeAxis.js → modern/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js} +3 -11
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +22 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +5 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +68 -0
- package/modern/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.js +89 -0
- package/modern/internals/plugins/featurePlugins/useChartZAxis/index.js +2 -0
- package/modern/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.js +86 -0
- package/modern/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.js +3 -0
- package/modern/internals/plugins/featurePlugins/useChartZAxis/utils.js +0 -0
- package/modern/internals/plugins/models/index.js +2 -1
- package/modern/internals/plugins/models/seriesConfig/index.js +4 -0
- package/modern/internals/plugins/models/seriesConfig/seriesConfig.types.js +1 -0
- package/modern/internals/plugins/models/seriesConfig/seriesProcessor.types.js +1 -0
- package/modern/internals/store/extractPluginParamsFromProps.js +28 -0
- package/modern/internals/store/useChartModels.js +64 -0
- package/modern/internals/store/useCharts.js +14 -9
- package/modern/internals/store/useStore.js +1 -9
- package/node/BarChart/BarChart.js +11 -3
- package/node/BarChart/BarLabel/BarLabelPlot.js +1 -1
- package/node/BarChart/BarPlot.js +6 -6
- package/node/BarChart/formatter.js +2 -1
- package/node/BarChart/legend.js +1 -1
- package/node/BarChart/plugin.js +3 -2
- package/node/ChartContainer/ChartContainer.js +15 -9
- package/node/ChartContainer/useChartContainerProps.js +7 -5
- package/node/ChartDataProvider/ChartDataProvider.js +114 -0
- package/node/ChartDataProvider/useChartDataProviderProps.js +59 -0
- package/node/ChartsAxis/ChartsAxis.js +5 -3
- package/node/ChartsGrid/ChartsGrid.js +9 -5
- package/node/ChartsGrid/ChartsHorizontalGrid.js +4 -3
- package/node/ChartsGrid/ChartsVerticalGrid.js +4 -3
- package/node/ChartsLabel/ChartsLabelGradient.js +11 -12
- package/node/ChartsLegend/ContinuousColorLegend.js +3 -3
- package/node/ChartsLegend/useAxis.js +6 -4
- package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +6 -5
- package/node/ChartsSurface/ChartsSurface.js +18 -28
- package/node/ChartsTooltip/ChartsAxisTooltipContent.js +5 -2
- package/node/ChartsTooltip/ChartsItemTooltipContent.js +5 -2
- package/node/ChartsTooltip/ChartsTooltipTable.js +1 -21
- package/node/ChartsTooltip/useAxisTooltip.js +11 -7
- package/node/ChartsTooltip/useItemTooltip.js +13 -9
- package/node/ChartsTooltip/utils.js +1 -0
- package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +19 -12
- package/node/ChartsXAxis/ChartsXAxis.js +11 -8
- package/node/ChartsYAxis/ChartsYAxis.js +8 -5
- package/node/Gauge/Gauge.js +5 -1
- package/node/Gauge/GaugeContainer.js +38 -38
- package/node/Gauge/GaugeProvider.js +2 -2
- package/node/LineChart/AnimatedArea.js +1 -1
- package/node/LineChart/AnimatedLine.js +1 -1
- package/node/LineChart/AppearingMask.js +1 -1
- package/node/LineChart/AreaPlot.js +59 -25
- package/node/LineChart/CircleMarkElement.js +2 -7
- package/node/LineChart/LineChart.js +11 -7
- package/node/LineChart/LineHighlightElement.js +29 -9
- package/node/LineChart/LineHighlightPlot.js +18 -13
- package/node/LineChart/LinePlot.js +59 -24
- package/node/LineChart/MarkPlot.js +20 -23
- package/node/LineChart/formatter.js +3 -1
- package/node/LineChart/legend.js +1 -1
- package/node/LineChart/plugin.js +3 -2
- package/node/LineChart/useLineChartProps.js +3 -5
- package/node/PieChart/PieArcLabelPlot.js +1 -1
- package/node/PieChart/PieArcPlot.js +1 -1
- package/node/PieChart/PieChart.js +11 -3
- package/node/PieChart/dataTransform/transition.js +9 -7
- package/node/PieChart/formatter.js +4 -1
- package/node/PieChart/legend.js +1 -1
- package/node/PieChart/plugin.js +3 -2
- package/node/ScatterChart/Scatter.js +6 -4
- package/node/ScatterChart/ScatterChart.js +18 -14
- package/node/ScatterChart/ScatterPlot.js +10 -9
- package/node/ScatterChart/extremums.js +3 -1
- package/node/ScatterChart/formatter.js +3 -1
- package/node/ScatterChart/legend.js +1 -1
- package/node/ScatterChart/plugin.js +3 -2
- package/node/ScatterChart/useScatterChartProps.js +1 -4
- package/node/SparkLineChart/SparkLineChart.js +10 -1
- package/node/context/AnimationProvider/AnimationProvider.js +1 -1
- package/node/context/ChartProvider/ChartProvider.js +23 -2
- package/node/context/PolarProvider/PolarProvider.js +59 -51
- package/node/context/PolarProvider/getAxisExtremum.js +49 -27
- package/node/context/PolarProvider/usePolarContext.js +9 -14
- package/node/context/index.js +1 -20
- package/node/hooks/index.js +29 -2
- package/node/hooks/useAxis.js +34 -6
- package/node/hooks/useAxisEvents.js +12 -8
- package/node/hooks/useChartGradientId.js +56 -0
- package/node/hooks/useColorScale.js +4 -4
- package/node/hooks/useDrawingArea.js +5 -21
- package/node/hooks/useLegend.js +8 -14
- package/node/hooks/useSeries.js +5 -9
- package/node/hooks/useZAxis.js +27 -9
- package/node/index.js +12 -1
- package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +17 -27
- package/node/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +3 -0
- package/node/internals/index.js +111 -63
- package/node/internals/plugins/allPlugins.js +4 -2
- package/node/internals/plugins/corePlugins/corePlugins.js +3 -1
- package/node/internals/plugins/corePlugins/useChartDimensions/index.js +27 -0
- package/node/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +183 -0
- package/node/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +32 -0
- package/node/internals/plugins/corePlugins/useChartId/index.js +16 -1
- package/node/internals/plugins/corePlugins/useChartId/useChartId.js +1 -1
- package/node/internals/plugins/corePlugins/useChartSeries/index.js +27 -0
- package/node/{context/SeriesProvider → internals/plugins/corePlugins/useChartSeries}/processSeries.js +9 -6
- package/node/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +80 -0
- package/node/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +11 -0
- package/node/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +27 -0
- package/node/internals/{computeAxisValue.js → plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js} +19 -27
- package/node/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +69 -0
- package/node/{context/ChartDataProvider/useDefaultizeAxis.js → internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js} +4 -13
- package/node/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +29 -0
- package/node/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +59 -0
- package/node/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +76 -0
- package/node/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.selectors.js +98 -0
- package/node/internals/plugins/featurePlugins/useChartZAxis/index.js +27 -0
- package/node/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.js +94 -0
- package/node/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.js +9 -0
- package/node/internals/plugins/featurePlugins/useChartZAxis/utils.js +1 -0
- package/node/internals/plugins/models/index.js +11 -0
- package/node/internals/plugins/models/seriesConfig/index.js +49 -0
- package/node/internals/plugins/models/seriesConfig/seriesProcessor.types.js +5 -0
- package/node/internals/store/extractPluginParamsFromProps.js +36 -0
- package/node/internals/store/useChartModels.js +73 -0
- package/node/internals/store/useCharts.js +14 -9
- package/node/internals/store/useStore.js +1 -9
- package/package.json +3 -3
- package/context/CartesianProvider/Cartesian.types.d.ts +0 -59
- package/context/CartesianProvider/CartesianContext.d.ts +0 -4
- package/context/CartesianProvider/CartesianContext.js +0 -13
- package/context/CartesianProvider/CartesianProvider.d.ts +0 -4
- package/context/CartesianProvider/CartesianProvider.js +0 -49
- package/context/CartesianProvider/defaultizeAxis.d.ts +0 -38
- package/context/CartesianProvider/defaultizeAxis.js +0 -13
- package/context/CartesianProvider/getAxisExtremum.d.ts +0 -5
- package/context/CartesianProvider/getAxisExtremum.js +0 -21
- package/context/CartesianProvider/index.d.ts +0 -4
- package/context/CartesianProvider/index.js +0 -4
- package/context/CartesianProvider/useCartesianContext.d.ts +0 -2
- package/context/CartesianProvider/useCartesianContext.js +0 -10
- package/context/ChartDataProvider/ChartDataProvider.d.ts +0 -58
- package/context/ChartDataProvider/ChartDataProvider.js +0 -270
- package/context/ChartDataProvider/useChartDataProviderProps.d.ts +0 -90
- package/context/ChartDataProvider/useChartDataProviderProps.js +0 -66
- package/context/ChartDataProvider/useDefaultizeAxis.d.ts +0 -39
- package/context/DrawingAreaProvider/DrawingArea.types.d.ts +0 -51
- package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +0 -3
- package/context/DrawingAreaProvider/DrawingAreaContext.js +0 -15
- package/context/DrawingAreaProvider/DrawingAreaProvider.d.ts +0 -3
- package/context/DrawingAreaProvider/DrawingAreaProvider.js +0 -48
- package/context/DrawingAreaProvider/index.d.ts +0 -3
- package/context/DrawingAreaProvider/index.js +0 -3
- package/context/PluginProvider/ColorProcessor.types.d.ts +0 -8
- package/context/PluginProvider/ExtremumGetter.types.d.ts +0 -25
- package/context/PluginProvider/Plugin.types.d.ts +0 -29
- package/context/PluginProvider/PluginContext.d.ts +0 -4
- package/context/PluginProvider/PluginContext.js +0 -15
- package/context/PluginProvider/PluginProvider.d.ts +0 -4
- package/context/PluginProvider/PluginProvider.js +0 -21
- package/context/PluginProvider/SeriesFormatter.types.d.ts +0 -21
- package/context/PluginProvider/index.d.ts +0 -12
- package/context/PluginProvider/index.js +0 -12
- package/context/PluginProvider/mergePlugins.d.ts +0 -46
- package/context/PluginProvider/mergePlugins.js +0 -40
- package/context/PluginProvider/useColorProcessor.d.ts +0 -4
- package/context/PluginProvider/useColorProcessor.js +0 -17
- package/context/PluginProvider/useRadiusExtremumGetter.d.ts +0 -4
- package/context/PluginProvider/useRadiusExtremumGetter.js +0 -17
- package/context/PluginProvider/useRotationExtremumGetter.d.ts +0 -4
- package/context/PluginProvider/useRotationExtremumGetter.js +0 -17
- package/context/PluginProvider/useSeriesFormatter.d.ts +0 -4
- package/context/PluginProvider/useSeriesFormatter.js +0 -17
- package/context/PluginProvider/useXExtremumGetter.d.ts +0 -4
- package/context/PluginProvider/useXExtremumGetter.js +0 -15
- package/context/PluginProvider/useYExtremumGetter.d.ts +0 -4
- package/context/PluginProvider/useYExtremumGetter.js +0 -15
- package/context/SeriesProvider/Series.types.d.ts +0 -26
- package/context/SeriesProvider/SeriesContext.d.ts +0 -4
- package/context/SeriesProvider/SeriesContext.js +0 -8
- package/context/SeriesProvider/SeriesProvider.d.ts +0 -5
- package/context/SeriesProvider/SeriesProvider.js +0 -33
- package/context/SeriesProvider/index.d.ts +0 -12
- package/context/SeriesProvider/index.js +0 -8
- package/context/SeriesProvider/processSeries.d.ts +0 -18
- package/context/SizeProvider/Size.types.d.ts +0 -30
- package/context/SizeProvider/SizeContext.d.ts +0 -4
- package/context/SizeProvider/SizeContext.js +0 -15
- package/context/SizeProvider/SizeProvider.d.ts +0 -11
- package/context/SizeProvider/SizeProvider.js +0 -26
- package/context/SizeProvider/index.d.ts +0 -4
- package/context/SizeProvider/index.js +0 -4
- package/context/SizeProvider/useChartContainerDimensions.d.ts +0 -9
- package/context/SizeProvider/useChartContainerDimensions.js +0 -108
- package/context/SizeProvider/useSize.d.ts +0 -5
- package/context/SizeProvider/useSize.js +0 -13
- package/context/ZAxisContextProvider.d.ts +0 -33
- package/context/ZAxisContextProvider.js +0 -96
- package/internals/computeAxisValue.d.ts +0 -38
- package/modern/context/CartesianProvider/CartesianContext.js +0 -13
- package/modern/context/CartesianProvider/CartesianProvider.js +0 -49
- package/modern/context/CartesianProvider/defaultizeAxis.js +0 -13
- package/modern/context/CartesianProvider/getAxisExtremum.js +0 -21
- package/modern/context/CartesianProvider/index.js +0 -4
- package/modern/context/CartesianProvider/useCartesianContext.js +0 -10
- package/modern/context/ChartDataProvider/ChartDataProvider.js +0 -270
- package/modern/context/ChartDataProvider/useChartDataProviderProps.js +0 -66
- package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +0 -15
- package/modern/context/DrawingAreaProvider/DrawingAreaProvider.js +0 -48
- package/modern/context/DrawingAreaProvider/index.js +0 -3
- package/modern/context/PluginProvider/PluginContext.js +0 -15
- package/modern/context/PluginProvider/PluginProvider.js +0 -21
- package/modern/context/PluginProvider/index.js +0 -12
- package/modern/context/PluginProvider/mergePlugins.js +0 -40
- package/modern/context/PluginProvider/useColorProcessor.js +0 -17
- package/modern/context/PluginProvider/useRadiusExtremumGetter.js +0 -17
- package/modern/context/PluginProvider/useRotationExtremumGetter.js +0 -17
- package/modern/context/PluginProvider/useSeriesFormatter.js +0 -17
- package/modern/context/PluginProvider/useXExtremumGetter.js +0 -15
- package/modern/context/PluginProvider/useYExtremumGetter.js +0 -15
- package/modern/context/SeriesProvider/SeriesContext.js +0 -8
- package/modern/context/SeriesProvider/SeriesProvider.js +0 -33
- package/modern/context/SeriesProvider/index.js +0 -8
- package/modern/context/SizeProvider/SizeContext.js +0 -15
- package/modern/context/SizeProvider/SizeProvider.js +0 -26
- package/modern/context/SizeProvider/index.js +0 -4
- package/modern/context/SizeProvider/useChartContainerDimensions.js +0 -108
- package/modern/context/SizeProvider/useSize.js +0 -13
- package/modern/context/ZAxisContextProvider.js +0 -96
- package/node/context/CartesianProvider/CartesianContext.js +0 -20
- package/node/context/CartesianProvider/CartesianProvider.js +0 -54
- package/node/context/CartesianProvider/defaultizeAxis.js +0 -21
- package/node/context/CartesianProvider/getAxisExtremum.js +0 -28
- package/node/context/CartesianProvider/index.js +0 -49
- package/node/context/CartesianProvider/useCartesianContext.js +0 -17
- package/node/context/ChartDataProvider/ChartDataProvider.js +0 -276
- package/node/context/ChartDataProvider/useChartDataProviderProps.js +0 -72
- package/node/context/DrawingAreaProvider/DrawingAreaContext.js +0 -21
- package/node/context/DrawingAreaProvider/DrawingAreaProvider.js +0 -55
- package/node/context/DrawingAreaProvider/index.js +0 -38
- package/node/context/PluginProvider/PluginContext.js +0 -22
- package/node/context/PluginProvider/PluginProvider.js +0 -26
- package/node/context/PluginProvider/index.js +0 -137
- package/node/context/PluginProvider/mergePlugins.js +0 -47
- package/node/context/PluginProvider/useColorProcessor.js +0 -23
- package/node/context/PluginProvider/useRadiusExtremumGetter.js +0 -23
- package/node/context/PluginProvider/useRotationExtremumGetter.js +0 -23
- package/node/context/PluginProvider/useSeriesFormatter.js +0 -23
- package/node/context/PluginProvider/useXExtremumGetter.js +0 -22
- package/node/context/PluginProvider/useYExtremumGetter.js +0 -22
- package/node/context/SeriesProvider/SeriesContext.js +0 -15
- package/node/context/SeriesProvider/SeriesProvider.js +0 -38
- package/node/context/SeriesProvider/index.js +0 -49
- package/node/context/SizeProvider/SizeContext.js +0 -22
- package/node/context/SizeProvider/SizeProvider.js +0 -29
- package/node/context/SizeProvider/index.js +0 -49
- package/node/context/SizeProvider/useChartContainerDimensions.js +0 -116
- package/node/context/SizeProvider/useSize.js +0 -20
- package/node/context/ZAxisContextProvider.js +0 -103
- /package/{context/ChartDataProvider → ChartDataProvider}/index.d.ts +0 -0
- /package/{context/ChartDataProvider → ChartDataProvider}/index.js +0 -0
- /package/{context/CartesianProvider/Cartesian.types.js → internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.js} +0 -0
- /package/{context/DrawingAreaProvider/DrawingArea.types.js → internals/plugins/corePlugins/useChartSeries/useChartSeries.types.js} +0 -0
- /package/{context/PluginProvider/ColorProcessor.types.js → internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.js} +0 -0
- /package/{context/CartesianProvider → internals/plugins/featurePlugins/useChartCartesianAxis}/zoom.d.ts +0 -0
- /package/{context/CartesianProvider → internals/plugins/featurePlugins/useChartCartesianAxis}/zoom.js +0 -0
- /package/{context/PluginProvider/ExtremumGetter.types.js → internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.js} +0 -0
- /package/{context/PluginProvider/Plugin.types.js → internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.types.js} +0 -0
- /package/{context/PluginProvider/SeriesFormatter.types.js → internals/plugins/models/seriesConfig/colorProcessor.types.js} +0 -0
- /package/{context/SeriesProvider/Series.types.js → internals/plugins/models/seriesConfig/extremumGetter.types.js} +0 -0
- /package/{context/SizeProvider/Size.types.js → internals/plugins/models/seriesConfig/seriesConfig.types.js} +0 -0
- /package/{modern/context/CartesianProvider/Cartesian.types.js → internals/plugins/models/seriesConfig/seriesProcessor.types.js} +0 -0
- /package/modern/{context/ChartDataProvider → ChartDataProvider}/index.js +0 -0
- /package/modern/{context/DrawingAreaProvider/DrawingArea.types.js → internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.js} +0 -0
- /package/modern/{context/PluginProvider/ColorProcessor.types.js → internals/plugins/corePlugins/useChartSeries/useChartSeries.types.js} +0 -0
- /package/modern/{context/PluginProvider/ExtremumGetter.types.js → internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.js} +0 -0
- /package/modern/{context/CartesianProvider → internals/plugins/featurePlugins/useChartCartesianAxis}/zoom.js +0 -0
- /package/modern/{context/PluginProvider/Plugin.types.js → internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.js} +0 -0
- /package/modern/{context/PluginProvider/SeriesFormatter.types.js → internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.types.js} +0 -0
- /package/modern/{context/SeriesProvider/Series.types.js → internals/plugins/models/seriesConfig/colorProcessor.types.js} +0 -0
- /package/modern/{context/SizeProvider/Size.types.js → internals/plugins/models/seriesConfig/extremumGetter.types.js} +0 -0
- /package/node/{context/ChartDataProvider → ChartDataProvider}/index.js +0 -0
- /package/node/{context/CartesianProvider/Cartesian.types.js → internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.js} +0 -0
- /package/node/{context/DrawingAreaProvider/DrawingArea.types.js → internals/plugins/corePlugins/useChartSeries/useChartSeries.types.js} +0 -0
- /package/node/{context/PluginProvider/ColorProcessor.types.js → internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.js} +0 -0
- /package/node/{context/CartesianProvider → internals/plugins/featurePlugins/useChartCartesianAxis}/zoom.js +0 -0
- /package/node/{context/PluginProvider/ExtremumGetter.types.js → internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.js} +0 -0
- /package/node/{context/PluginProvider/Plugin.types.js → internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.types.js} +0 -0
- /package/node/{context/PluginProvider/SeriesFormatter.types.js → internals/plugins/models/seriesConfig/colorProcessor.types.js} +0 -0
- /package/node/{context/SeriesProvider/Series.types.js → internals/plugins/models/seriesConfig/extremumGetter.types.js} +0 -0
- /package/node/{context/SizeProvider/Size.types.js → internals/plugins/models/seriesConfig/seriesConfig.types.js} +0 -0
|
@@ -2,25 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
6
5
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
7
6
|
import { getSVGPoint } from "../internals/getSVGPoint.js";
|
|
8
7
|
import { useSvgRef } from "./useSvgRef.js";
|
|
9
|
-
import { useDrawingArea } from "./useDrawingArea.js";
|
|
10
8
|
import { useStore } from "../internals/store/useStore.js";
|
|
9
|
+
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
10
|
+
import { useXAxes, useYAxes } from "./useAxis.js";
|
|
11
11
|
function getAsANumber(value) {
|
|
12
12
|
return value instanceof Date ? value.getTime() : value;
|
|
13
13
|
}
|
|
14
14
|
export const useAxisEvents = disableAxisListener => {
|
|
15
15
|
const svgRef = useSvgRef();
|
|
16
|
-
const
|
|
16
|
+
const {
|
|
17
|
+
instance
|
|
18
|
+
} = useChartContext();
|
|
17
19
|
const {
|
|
18
20
|
xAxis,
|
|
21
|
+
xAxisIds
|
|
22
|
+
} = useXAxes();
|
|
23
|
+
const {
|
|
19
24
|
yAxis,
|
|
20
|
-
xAxisIds,
|
|
21
25
|
yAxisIds
|
|
22
|
-
} =
|
|
23
|
-
const store = useStore(
|
|
26
|
+
} = useYAxes();
|
|
27
|
+
const store = useStore();
|
|
24
28
|
const usedXAxis = xAxisIds[0];
|
|
25
29
|
const usedYAxis = yAxisIds[0];
|
|
26
30
|
|
|
@@ -106,7 +110,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
106
110
|
const svgPoint = getSVGPoint(element, target);
|
|
107
111
|
mousePosition.current.x = svgPoint.x;
|
|
108
112
|
mousePosition.current.y = svgPoint.y;
|
|
109
|
-
if (!
|
|
113
|
+
if (!instance.isPointInside(svgPoint, {
|
|
110
114
|
targetElement: event.target
|
|
111
115
|
})) {
|
|
112
116
|
if (mousePosition.current.isInChart) {
|
|
@@ -157,5 +161,5 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
157
161
|
element.removeEventListener('pointercancel', handleOut);
|
|
158
162
|
element.removeEventListener('pointerleave', handleOut);
|
|
159
163
|
};
|
|
160
|
-
}, [svgRef, store, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener,
|
|
164
|
+
}, [svgRef, store, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, instance]);
|
|
161
165
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useChartId } from "./useChartId.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns a function that generates a gradient id for the given axis id.
|
|
7
|
+
*/
|
|
8
|
+
export function useChartGradientIdBuilder() {
|
|
9
|
+
const chartId = useChartId();
|
|
10
|
+
return React.useCallback(axisId => `${chartId}-gradient-${axisId}`, [chartId]);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns a function that generates a gradient id for the given axis id.
|
|
15
|
+
*/
|
|
16
|
+
export function useChartGradientIdObjectBoundBuilder() {
|
|
17
|
+
const chartId = useChartId();
|
|
18
|
+
return React.useCallback(axisId => `${chartId}-gradient-${axisId}-object-bound`, [chartId]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns a gradient id for the given axis id.
|
|
23
|
+
*
|
|
24
|
+
* Can be useful when reusing the same gradient on custom components.
|
|
25
|
+
*
|
|
26
|
+
* For a gradient that respects the coordinates of the object on which it is applied, use `useChartGradientIdObjectBound` instead.
|
|
27
|
+
*
|
|
28
|
+
* @param axisId the axis id
|
|
29
|
+
* @returns the gradient id
|
|
30
|
+
*/
|
|
31
|
+
export function useChartGradientId(axisId) {
|
|
32
|
+
return useChartGradientIdBuilder()(axisId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns a gradient id for the given axis id.
|
|
37
|
+
*
|
|
38
|
+
* Can be useful when reusing the same gradient on custom components.
|
|
39
|
+
*
|
|
40
|
+
* This gradient differs from `useChartGradientId` in that it respects the coordinates of the object on which it is applied.
|
|
41
|
+
*
|
|
42
|
+
* @param axisId the axis id
|
|
43
|
+
* @returns the gradient id
|
|
44
|
+
*/
|
|
45
|
+
export function useChartGradientIdObjectBound(axisId) {
|
|
46
|
+
return useChartGradientIdObjectBoundBuilder()(axisId);
|
|
47
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useXAxes, useYAxes } from "./useAxis.js";
|
|
4
|
+
import { useZAxes } from "./useZAxis.js";
|
|
5
5
|
export function useXColorScale(identifier) {
|
|
6
6
|
const {
|
|
7
7
|
xAxis,
|
|
8
8
|
xAxisIds
|
|
9
|
-
} =
|
|
9
|
+
} = useXAxes();
|
|
10
10
|
const id = typeof identifier === 'string' ? identifier : xAxisIds[identifier ?? 0];
|
|
11
11
|
return xAxis[id].colorScale;
|
|
12
12
|
}
|
|
@@ -14,7 +14,7 @@ export function useYColorScale(identifier) {
|
|
|
14
14
|
const {
|
|
15
15
|
yAxis,
|
|
16
16
|
yAxisIds
|
|
17
|
-
} =
|
|
17
|
+
} = useYAxes();
|
|
18
18
|
const id = typeof identifier === 'string' ? identifier : yAxisIds[identifier ?? 0];
|
|
19
19
|
return yAxis[id].colorScale;
|
|
20
20
|
}
|
|
@@ -22,7 +22,7 @@ export function useZColorScale(identifier) {
|
|
|
22
22
|
const {
|
|
23
23
|
zAxis,
|
|
24
24
|
zAxisIds
|
|
25
|
-
} =
|
|
25
|
+
} = useZAxes();
|
|
26
26
|
const id = typeof identifier === 'string' ? identifier : zAxisIds[identifier ?? 0];
|
|
27
27
|
return zAxis[id]?.colorScale;
|
|
28
28
|
}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
4
|
+
import { useSelector } from "../internals/store/useSelector.js";
|
|
5
|
+
import { selectorChartDrawingArea } from "../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js";
|
|
5
6
|
export function useDrawingArea() {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
top,
|
|
9
|
-
width,
|
|
10
|
-
height,
|
|
11
|
-
bottom,
|
|
12
|
-
right,
|
|
13
|
-
isPointInside
|
|
14
|
-
} = React.useContext(DrawingAreaContext);
|
|
15
|
-
return React.useMemo(() => ({
|
|
16
|
-
left,
|
|
17
|
-
top,
|
|
18
|
-
width,
|
|
19
|
-
height,
|
|
20
|
-
bottom,
|
|
21
|
-
right,
|
|
22
|
-
isPointInside
|
|
23
|
-
}), [height, left, top, width, bottom, right, isPointInside]);
|
|
7
|
+
const store = useStore();
|
|
8
|
+
return useSelector(store, selectorChartDrawingArea);
|
|
24
9
|
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import getScatterLegend from "../ScatterChart/legend.js";
|
|
5
|
-
import getLineLegend from "../LineChart/legend.js";
|
|
6
|
-
import getPieLegend from "../PieChart/legend.js";
|
|
3
|
+
import { selectorChartSeriesConfig } from "../internals/plugins/corePlugins/useChartSeries/index.js";
|
|
7
4
|
import { useSeries } from "./useSeries.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
line: getLineLegend,
|
|
12
|
-
pie: getPieLegend
|
|
13
|
-
};
|
|
14
|
-
function getSeriesToDisplay(series) {
|
|
5
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
6
|
+
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
|
+
function getSeriesToDisplay(series, seriesConfig) {
|
|
15
8
|
return Object.keys(series).flatMap(seriesType => {
|
|
16
|
-
const getter =
|
|
9
|
+
const getter = seriesConfig[seriesType].legendGetter;
|
|
17
10
|
return getter === undefined ? [] : getter(series[seriesType]);
|
|
18
11
|
});
|
|
19
12
|
}
|
|
@@ -29,7 +22,9 @@ function getSeriesToDisplay(series) {
|
|
|
29
22
|
*/
|
|
30
23
|
export function useLegend() {
|
|
31
24
|
const series = useSeries();
|
|
25
|
+
const store = useStore();
|
|
26
|
+
const seriesConfig = useSelector(store, selectorChartSeriesConfig);
|
|
32
27
|
return {
|
|
33
|
-
items: getSeriesToDisplay(series)
|
|
28
|
+
items: getSeriesToDisplay(series, seriesConfig)
|
|
34
29
|
};
|
|
35
30
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
5
|
+
import { useSelector } from "../internals/store/useSelector.js";
|
|
6
|
+
import { selectorChartSeriesProcessed } from "../internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
6
7
|
/**
|
|
7
8
|
* Get access to the internal state of series.
|
|
8
9
|
* Structured by type of series:
|
|
@@ -10,14 +11,8 @@ import { SeriesContext } from "../context/SeriesProvider/index.js";
|
|
|
10
11
|
* @returns FormattedSeries series
|
|
11
12
|
*/
|
|
12
13
|
export function useSeries() {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
data
|
|
16
|
-
} = React.useContext(SeriesContext);
|
|
17
|
-
if (!isInitialized) {
|
|
18
|
-
throw new Error(['MUI X: Could not find the series ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
19
|
-
}
|
|
20
|
-
return data;
|
|
14
|
+
const store = useStore();
|
|
15
|
+
return useSelector(store, selectorChartSeriesProcessed);
|
|
21
16
|
}
|
|
22
17
|
|
|
23
18
|
/**
|
package/modern/hooks/useZAxis.js
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
4
|
+
import { selectorChartZAxis } from "../internals/plugins/featurePlugins/useChartZAxis/index.js";
|
|
5
|
+
import { useSelector } from "../internals/store/useSelector.js";
|
|
6
|
+
export function useZAxes() {
|
|
7
|
+
const store = useStore();
|
|
8
|
+
const {
|
|
9
|
+
axis: zAxis,
|
|
10
|
+
axisIds: zAxisIds
|
|
11
|
+
} = useSelector(store, selectorChartZAxis) ?? {
|
|
12
|
+
axis: {},
|
|
13
|
+
axisIds: []
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
zAxis,
|
|
17
|
+
zAxisIds
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function useZAxis(identifier) {
|
|
21
|
+
const {
|
|
22
|
+
zAxis,
|
|
23
|
+
zAxisIds
|
|
24
|
+
} = useZAxes();
|
|
25
|
+
const id = typeof identifier === 'string' ? identifier : zAxisIds[identifier ?? 0];
|
|
26
|
+
return zAxis[id];
|
|
27
|
+
}
|
package/modern/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v8.0.0-alpha.
|
|
2
|
+
* @mui/x-charts v8.0.0-alpha.9
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -30,4 +30,5 @@ export * from "./ScatterChart/index.js";
|
|
|
30
30
|
export * from "./SparkLineChart/index.js";
|
|
31
31
|
export * from "./Gauge/index.js";
|
|
32
32
|
export * from "./ChartsSurface/index.js";
|
|
33
|
-
export * from "./ChartContainer/index.js";
|
|
33
|
+
export * from "./ChartContainer/index.js";
|
|
34
|
+
export * from "./ChartDataProvider/index.js";
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { useChartId, useDrawingArea } from "../../../hooks/index.js";
|
|
2
|
+
import { useDrawingArea, useXAxes, useYAxes } from "../../../hooks/index.js";
|
|
4
3
|
import ChartsPiecewiseGradient from "./ChartsPiecewiseGradient.js";
|
|
5
4
|
import ChartsContinuousGradient from "./ChartsContinuousGradient.js";
|
|
6
5
|
import ChartsContinuousGradientObjectBound from "./ChartsContinuousGradientObjectBound.js";
|
|
7
|
-
import {
|
|
6
|
+
import { useZAxes } from "../../../hooks/useZAxis.js";
|
|
7
|
+
import { useChartGradientIdBuilder, useChartGradientIdObjectBoundBuilder } from "../../../hooks/useChartGradientId.js";
|
|
8
8
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
export function useChartGradient() {
|
|
10
|
-
const chartId = useChartId();
|
|
11
|
-
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// TODO: make public?
|
|
15
|
-
export function useChartGradientObjectBound() {
|
|
16
|
-
const chartId = useChartId();
|
|
17
|
-
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}-object-bound`, [chartId]);
|
|
18
|
-
}
|
|
19
9
|
export function ChartsAxesGradients() {
|
|
20
10
|
const {
|
|
21
11
|
top,
|
|
@@ -27,18 +17,20 @@ export function ChartsAxesGradients() {
|
|
|
27
17
|
} = useDrawingArea();
|
|
28
18
|
const svgHeight = top + height + bottom;
|
|
29
19
|
const svgWidth = left + width + right;
|
|
30
|
-
const getGradientId =
|
|
31
|
-
const getObjectBoundGradientId =
|
|
20
|
+
const getGradientId = useChartGradientIdBuilder();
|
|
21
|
+
const getObjectBoundGradientId = useChartGradientIdObjectBoundBuilder();
|
|
32
22
|
const {
|
|
33
|
-
xAxisIds,
|
|
34
23
|
xAxis,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} = useCartesianContext();
|
|
24
|
+
xAxisIds
|
|
25
|
+
} = useXAxes();
|
|
38
26
|
const {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} =
|
|
27
|
+
yAxis,
|
|
28
|
+
yAxisIds
|
|
29
|
+
} = useYAxes();
|
|
30
|
+
const {
|
|
31
|
+
zAxis,
|
|
32
|
+
zAxisIds
|
|
33
|
+
} = useZAxes();
|
|
42
34
|
const filteredYAxisIds = yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined);
|
|
43
35
|
const filteredXAxisIds = xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined);
|
|
44
36
|
const filteredZAxisIds = zAxisIds.filter(axisId => zAxis[axisId].colorMap !== undefined);
|
|
@@ -47,8 +39,8 @@ export function ChartsAxesGradients() {
|
|
|
47
39
|
}
|
|
48
40
|
return /*#__PURE__*/_jsxs("defs", {
|
|
49
41
|
children: [filteredYAxisIds.map(axisId => {
|
|
50
|
-
const gradientId = getGradientId(axisId
|
|
51
|
-
const objectBoundGradientId = getObjectBoundGradientId(axisId
|
|
42
|
+
const gradientId = getGradientId(axisId);
|
|
43
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId);
|
|
52
44
|
const {
|
|
53
45
|
colorMap,
|
|
54
46
|
scale,
|
|
@@ -85,8 +77,8 @@ export function ChartsAxesGradients() {
|
|
|
85
77
|
}
|
|
86
78
|
return null;
|
|
87
79
|
}), filteredXAxisIds.map(axisId => {
|
|
88
|
-
const gradientId = getGradientId(axisId
|
|
89
|
-
const objectBoundGradientId = getObjectBoundGradientId(axisId
|
|
80
|
+
const gradientId = getGradientId(axisId);
|
|
81
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId);
|
|
90
82
|
const {
|
|
91
83
|
colorMap,
|
|
92
84
|
scale,
|
|
@@ -123,7 +115,7 @@ export function ChartsAxesGradients() {
|
|
|
123
115
|
}
|
|
124
116
|
return null;
|
|
125
117
|
}), filteredZAxisIds.map(axisId => {
|
|
126
|
-
const objectBoundGradientId = getObjectBoundGradientId(axisId
|
|
118
|
+
const objectBoundGradientId = getObjectBoundGradientId(axisId);
|
|
127
119
|
const {
|
|
128
120
|
colorMap,
|
|
129
121
|
colorScale
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Components
|
|
2
2
|
export * from "./components/ChartsAxesGradients/index.js";
|
|
3
3
|
export * from "./components/ChartsWrapper/index.js";
|
|
4
|
+
export * from "../ChartsLabel/ChartsLabelMark.js";
|
|
4
5
|
|
|
5
6
|
// hooks
|
|
6
7
|
export { useSeries } from "../hooks/useSeries.js";
|
|
@@ -10,7 +11,19 @@ export { useScatterChartProps } from "../ScatterChart/useScatterChartProps.js";
|
|
|
10
11
|
export { useLineChartProps } from "../LineChart/useLineChartProps.js";
|
|
11
12
|
export { useBarChartProps } from "../BarChart/useBarChartProps.js";
|
|
12
13
|
export * from "../ChartContainer/useChartContainerProps.js";
|
|
13
|
-
export * from "../
|
|
14
|
+
export * from "../ChartDataProvider/useChartDataProviderProps.js";
|
|
15
|
+
|
|
16
|
+
// plugins
|
|
17
|
+
export * from "./plugins/corePlugins/useChartId/index.js";
|
|
18
|
+
export * from "./plugins/corePlugins/useChartSeries/index.js";
|
|
19
|
+
export * from "./plugins/corePlugins/useChartDimensions/index.js";
|
|
20
|
+
export * from "./plugins/featurePlugins/useChartZAxis/index.js";
|
|
21
|
+
export * from "./plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
22
|
+
export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
23
|
+
export * from "./plugins/utils/selectors.js";
|
|
24
|
+
export * from "./store/useCharts.js";
|
|
25
|
+
export * from "./store/useStore.js";
|
|
26
|
+
export * from "./store/useSelector.js";
|
|
14
27
|
|
|
15
28
|
// utils
|
|
16
29
|
export * from "./defaultizeValueFormatter.js";
|
|
@@ -20,23 +33,16 @@ export * from "./getSVGPoint.js";
|
|
|
20
33
|
export * from "./isDefined.js";
|
|
21
34
|
export { unstable_cleanupDOM } from "./domUtils.js";
|
|
22
35
|
export * from "./getScale.js";
|
|
23
|
-
export * from "./computeAxisValue.js";
|
|
24
36
|
|
|
25
37
|
// contexts
|
|
26
38
|
|
|
27
|
-
export * from "../context/CartesianProvider/index.js";
|
|
28
|
-
export * from "../context/DrawingAreaProvider/index.js";
|
|
29
|
-
export * from "../context/SeriesProvider/index.js";
|
|
30
|
-
export * from "../context/ZAxisContextProvider.js";
|
|
31
|
-
export * from "../context/PluginProvider/index.js";
|
|
32
39
|
export * from "../context/AnimationProvider/index.js";
|
|
33
|
-
export { getAxisExtremum } from "
|
|
34
|
-
export * from "../context/ChartDataProvider/index.js";
|
|
35
|
-
export * from "../context/SizeProvider/index.js";
|
|
40
|
+
export { getAxisExtremum } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js";
|
|
36
41
|
export * from "../context/ChartProvider/index.js";
|
|
37
42
|
|
|
38
43
|
// series configuration
|
|
39
44
|
export * from "../models/seriesType/config.js";
|
|
40
45
|
export * from "../models/seriesType/common.js";
|
|
41
46
|
export * from "../models/z-axis.js";
|
|
42
|
-
export * from "../models/axis.js";
|
|
47
|
+
export * from "../models/axis.js";
|
|
48
|
+
export * from "./plugins/models/index.js";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
// This file should be removed after creating all plugins
|
|
1
|
+
// This file should be removed after creating all plugins in favor of a file per chart type.
|
|
2
|
+
|
|
3
|
+
import { useChartCartesianAxis } from "./featurePlugins/useChartCartesianAxis/index.js";
|
|
2
4
|
import { useChartInteraction } from "./featurePlugins/useChartInteraction/index.js";
|
|
3
|
-
|
|
5
|
+
import { useChartZAxis } from "./featurePlugins/useChartZAxis/index.js";
|
|
6
|
+
export const ALL_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { useChartDimensions } from "./useChartDimensions/useChartDimensions.js";
|
|
1
2
|
import { useChartId } from "./useChartId/index.js";
|
|
3
|
+
import { useChartSeries } from "./useChartSeries/index.js";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Internal plugins that create the tools used by the other plugins.
|
|
5
7
|
* These plugins are used by the Charts components.
|
|
6
8
|
*/
|
|
7
|
-
export const CHART_CORE_PLUGINS = [useChartId];
|
|
9
|
+
export const CHART_CORE_PLUGINS = [useChartId, useChartDimensions, useChartSeries];
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable react-compiler/react-compiler */
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
|
+
import ownerWindow from '@mui/utils/ownerWindow';
|
|
8
|
+
import { DEFAULT_MARGINS } from "../../../../constants/index.js";
|
|
9
|
+
import { selectorChartDimensionsState } from "./useChartDimensions.selectors.js";
|
|
10
|
+
const MAX_COMPUTE_RUN = 10;
|
|
11
|
+
export const useChartDimensions = ({
|
|
12
|
+
params,
|
|
13
|
+
store,
|
|
14
|
+
svgRef
|
|
15
|
+
}) => {
|
|
16
|
+
const hasInSize = params.width !== undefined && params.height !== undefined;
|
|
17
|
+
const stateRef = React.useRef({
|
|
18
|
+
displayError: false,
|
|
19
|
+
initialCompute: true,
|
|
20
|
+
computeRun: 0
|
|
21
|
+
});
|
|
22
|
+
// States only used for the initialization of the size.
|
|
23
|
+
const [innerWidth, setInnerWidth] = React.useState(0);
|
|
24
|
+
const [innerHeight, setInnerHeight] = React.useState(0);
|
|
25
|
+
const computeSize = React.useCallback(() => {
|
|
26
|
+
const mainEl = svgRef?.current;
|
|
27
|
+
if (!mainEl) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
const win = ownerWindow(mainEl);
|
|
31
|
+
const computedStyle = win.getComputedStyle(mainEl);
|
|
32
|
+
const newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
|
|
33
|
+
const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
|
|
34
|
+
store.update(prev => {
|
|
35
|
+
const prevWidth = prev.dimensions.width + prev.dimensions.left + prev.dimensions.right;
|
|
36
|
+
const prevHeight = prev.dimensions.height + prev.dimensions.top + prev.dimensions.bottom;
|
|
37
|
+
if (prevWidth === newWidth && prevHeight === newHeight) {
|
|
38
|
+
return prev;
|
|
39
|
+
}
|
|
40
|
+
return _extends({}, prev, {
|
|
41
|
+
dimensions: _extends({}, prev.dimensions, {
|
|
42
|
+
width: newWidth - prev.dimensions.left - prev.dimensions.right,
|
|
43
|
+
height: newHeight - prev.dimensions.top - prev.dimensions.bottom
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
height: newHeight,
|
|
49
|
+
width: newWidth
|
|
50
|
+
};
|
|
51
|
+
}, [store, svgRef]);
|
|
52
|
+
store.update(prev => {
|
|
53
|
+
if ((params.width === undefined || prev.dimensions.propsWidth === params.width) && (params.height === undefined || prev.dimensions.propsHeight === params.height)) {
|
|
54
|
+
return prev;
|
|
55
|
+
}
|
|
56
|
+
return _extends({}, prev, {
|
|
57
|
+
dimensions: _extends({}, prev.dimensions, {
|
|
58
|
+
width: params.width === undefined ? prev.dimensions.width : params.width - prev.dimensions.left - prev.dimensions.right,
|
|
59
|
+
height: params.height === undefined ? prev.dimensions.height : params.height - prev.dimensions.top - prev.dimensions.bottom,
|
|
60
|
+
propsWidth: params.width,
|
|
61
|
+
propsHeight: params.height
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
// Ensure the error detection occurs after the first rendering.
|
|
67
|
+
stateRef.current.displayError = true;
|
|
68
|
+
}, []);
|
|
69
|
+
|
|
70
|
+
// This effect is used to compute the size of the container on the initial render.
|
|
71
|
+
// It is not bound to the raf loop to avoid an unwanted "resize" event.
|
|
72
|
+
// https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
|
|
73
|
+
useEnhancedEffect(() => {
|
|
74
|
+
// computeRun is used to avoid infinite loops.
|
|
75
|
+
if (hasInSize || !stateRef.current.initialCompute || stateRef.current.computeRun > MAX_COMPUTE_RUN) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const computedSize = computeSize();
|
|
79
|
+
if (computedSize.width !== innerWidth || computedSize.height !== innerHeight) {
|
|
80
|
+
stateRef.current.computeRun += 1;
|
|
81
|
+
if (computedSize.width !== undefined) {
|
|
82
|
+
setInnerWidth(computedSize.width);
|
|
83
|
+
}
|
|
84
|
+
if (computedSize.height !== undefined) {
|
|
85
|
+
setInnerHeight(computedSize.height);
|
|
86
|
+
}
|
|
87
|
+
} else if (stateRef.current.initialCompute) {
|
|
88
|
+
stateRef.current.initialCompute = false;
|
|
89
|
+
}
|
|
90
|
+
}, [innerHeight, innerWidth, computeSize, hasInSize]);
|
|
91
|
+
useEnhancedEffect(() => {
|
|
92
|
+
if (hasInSize) {
|
|
93
|
+
return () => {};
|
|
94
|
+
}
|
|
95
|
+
computeSize();
|
|
96
|
+
const elementToObserve = svgRef.current;
|
|
97
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
98
|
+
return () => {};
|
|
99
|
+
}
|
|
100
|
+
let animationFrame;
|
|
101
|
+
const observer = new ResizeObserver(() => {
|
|
102
|
+
// See https://github.com/mui/mui-x/issues/8733
|
|
103
|
+
animationFrame = requestAnimationFrame(() => {
|
|
104
|
+
computeSize();
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
if (elementToObserve) {
|
|
108
|
+
observer.observe(elementToObserve);
|
|
109
|
+
}
|
|
110
|
+
return () => {
|
|
111
|
+
if (animationFrame) {
|
|
112
|
+
cancelAnimationFrame(animationFrame);
|
|
113
|
+
}
|
|
114
|
+
if (elementToObserve) {
|
|
115
|
+
observer.unobserve(elementToObserve);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}, [computeSize, hasInSize, svgRef]);
|
|
119
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
120
|
+
if (stateRef.current.displayError && params.width === undefined && innerWidth === 0) {
|
|
121
|
+
console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
|
|
122
|
+
stateRef.current.displayError = false;
|
|
123
|
+
}
|
|
124
|
+
if (stateRef.current.displayError && params.height === undefined && innerHeight === 0) {
|
|
125
|
+
console.error(`MUI X: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
|
|
126
|
+
stateRef.current.displayError = false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const isPointInside = React.useCallback(({
|
|
130
|
+
x,
|
|
131
|
+
y
|
|
132
|
+
}, options) => {
|
|
133
|
+
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
134
|
+
if (options?.targetElement && options?.targetElement.closest('[data-drawing-container]')) {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
const drawingArea = selectorChartDimensionsState(store.value);
|
|
138
|
+
const isInsideX = x >= drawingArea.left - 1 && x <= drawingArea.left + drawingArea.width;
|
|
139
|
+
const isInsideY = y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height;
|
|
140
|
+
if (options?.direction === 'x') {
|
|
141
|
+
return isInsideX;
|
|
142
|
+
}
|
|
143
|
+
if (options?.direction === 'y') {
|
|
144
|
+
return isInsideY;
|
|
145
|
+
}
|
|
146
|
+
return isInsideX && isInsideY;
|
|
147
|
+
}, [store.value]);
|
|
148
|
+
return {
|
|
149
|
+
instance: {
|
|
150
|
+
isPointInside
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
useChartDimensions.params = {
|
|
155
|
+
width: true,
|
|
156
|
+
height: true,
|
|
157
|
+
margin: true
|
|
158
|
+
};
|
|
159
|
+
useChartDimensions.getDefaultizedParams = ({
|
|
160
|
+
params
|
|
161
|
+
}) => _extends({}, params, {
|
|
162
|
+
margin: params.margin ? _extends({}, DEFAULT_MARGINS, params.margin) : DEFAULT_MARGINS
|
|
163
|
+
});
|
|
164
|
+
useChartDimensions.getInitialState = ({
|
|
165
|
+
width,
|
|
166
|
+
height,
|
|
167
|
+
margin
|
|
168
|
+
}) => ({
|
|
169
|
+
dimensions: _extends({}, margin, {
|
|
170
|
+
width: (width ?? 0) - margin.left - margin.right,
|
|
171
|
+
height: (height ?? 0) - margin.top - margin.bottom,
|
|
172
|
+
propsWidth: width,
|
|
173
|
+
propsHeight: height
|
|
174
|
+
})
|
|
175
|
+
});
|
package/modern/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSelector } from "../../utils/selectors.js";
|
|
2
|
+
export const selectorChartDimensionsState = state => state.dimensions;
|
|
3
|
+
export const selectorChartDrawingArea = createSelector(selectorChartDimensionsState, dimensionsState => ({
|
|
4
|
+
width: dimensionsState.width,
|
|
5
|
+
left: dimensionsState.left,
|
|
6
|
+
right: dimensionsState.right,
|
|
7
|
+
height: dimensionsState.height,
|
|
8
|
+
top: dimensionsState.top,
|
|
9
|
+
bottom: dimensionsState.bottom
|
|
10
|
+
}));
|
|
11
|
+
export const selectorChartPropsSize = createSelector(selectorChartDimensionsState, dimensionsState => ({
|
|
12
|
+
width: dimensionsState.propsWidth,
|
|
13
|
+
height: dimensionsState.propsHeight
|
|
14
|
+
}));
|
|
15
|
+
export const selectorChartContainerSize = createSelector(selectorChartDimensionsState, dimensionsState => ({
|
|
16
|
+
width: dimensionsState.width + dimensionsState.left + dimensionsState.right,
|
|
17
|
+
height: dimensionsState.height + dimensionsState.top + dimensionsState.bottom
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the id attribute of the chart.
|
|
22
|
+
* @param {ChartState<[UseChartIdSignature]>} state The state of the chart.
|
|
23
|
+
* @returns {string} The id attribute of the chart.
|
|
24
|
+
*/
|
|
25
|
+
export const selectorChartHasIntrinsicSize = createSelector(selectorChartContainerSize, svgSize => svgSize.width > 0 && svgSize.height > 0);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { useChartId } from "./useChartId.js";
|
|
1
|
+
export { useChartId } from "./useChartId.js";
|
|
2
|
+
export * from "./useChartId.selectors.js";
|