@mui/x-charts 7.22.3 → 8.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/AnimatedBarElement.d.ts +15 -0
- package/BarChart/AnimatedBarElement.js +21 -0
- package/BarChart/BarChart.d.ts +11 -16
- package/BarChart/BarChart.js +9 -59
- package/BarChart/BarElement.d.ts +6 -1343
- package/BarChart/BarElement.js +10 -20
- package/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
- package/BarChart/BarPlot.js +24 -6
- package/BarChart/extremums.js +3 -3
- package/BarChart/useBarChartProps.d.ts +2 -4
- package/BarChart/useBarChartProps.js +4 -11
- package/CHANGELOG.md +348 -12
- package/ChartContainer/ChartContainer.d.ts +4 -38
- package/ChartContainer/ChartContainer.js +15 -44
- package/ChartContainer/ResizableContainer.d.ts +22 -0
- package/ChartContainer/ResizableContainer.js +60 -0
- package/ChartContainer/useChartContainerProps.d.ts +8 -92
- package/ChartContainer/useChartContainerProps.js +29 -59
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +1 -17
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
- package/ChartsAxisHighlight/ChartsAxisHighlight.types.d.ts +5 -0
- package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +6 -0
- package/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +10 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
- package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +10 -0
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
- package/ChartsAxisHighlight/chartsAxisHighlightClasses.d.ts +7 -0
- package/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
- package/ChartsAxisHighlight/index.d.ts +3 -0
- package/ChartsAxisHighlight/index.js +4 -1
- package/ChartsGrid/ChartsGrid.js +1 -1
- package/ChartsGrid/ChartsHorizontalGrid.d.ts +2 -2
- package/ChartsGrid/ChartsHorizontalGrid.js +3 -3
- package/ChartsGrid/ChartsVerticalGrid.d.ts +2 -2
- package/ChartsGrid/ChartsVerticalGrid.js +3 -3
- package/ChartsLegend/ChartsLegend.js +0 -3
- package/ChartsLegend/DefaultChartsLegend.d.ts +0 -5
- package/ChartsLegend/DefaultChartsLegend.js +1 -12
- package/ChartsLegend/LegendPerItem.d.ts +3 -3
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +11 -9
- package/ChartsOverlay/ChartsOverlay.d.ts +1 -1
- package/ChartsSurface/ChartsSurface.d.ts +0 -15
- package/ChartsSurface/ChartsSurface.js +35 -34
- package/ChartsTooltip/ChartTooltip.types.d.ts +15 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +7 -39
- package/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -28
- package/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
- package/ChartsTooltip/ChartsTooltip.d.ts +3 -69
- package/ChartsTooltip/ChartsTooltip.js +162 -107
- package/ChartsTooltip/ChartsTooltipContainer.d.ts +33 -0
- package/ChartsTooltip/ChartsTooltipContainer.js +298 -0
- package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -0
- package/ChartsTooltip/chartsTooltipClasses.js +18 -2
- package/ChartsTooltip/index.d.ts +3 -3
- package/ChartsTooltip/index.js +2 -3
- package/ChartsTooltip/useAxisTooltip.d.ts +2 -2
- package/ChartsTooltip/useAxisTooltip.js +21 -21
- package/ChartsTooltip/useItemTooltip.d.ts +1 -1
- package/ChartsTooltip/useItemTooltip.js +8 -7
- package/ChartsTooltip/utils.d.ts +5 -16
- package/ChartsTooltip/utils.js +45 -50
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +50 -39
- package/Gauge/Gauge.d.ts +1 -1
- package/Gauge/Gauge.js +0 -6
- package/Gauge/GaugeContainer.d.ts +3 -3
- package/Gauge/GaugeContainer.js +60 -61
- package/LineChart/AnimatedArea.d.ts +0 -1333
- package/LineChart/AnimatedArea.js +9 -18
- package/LineChart/AnimatedLine.d.ts +0 -1333
- package/LineChart/AnimatedLine.js +9 -20
- package/LineChart/AreaElement.d.ts +1 -1
- package/LineChart/AreaPlot.js +14 -8
- package/LineChart/CircleMarkElement.js +6 -5
- package/LineChart/LineChart.d.ts +11 -17
- package/LineChart/LineChart.js +9 -60
- package/LineChart/LineElement.d.ts +1 -1
- package/LineChart/LineHighlightPlot.d.ts +1 -1
- package/LineChart/LineHighlightPlot.js +8 -11
- package/LineChart/LinePlot.js +14 -8
- package/LineChart/MarkElement.js +6 -5
- package/LineChart/MarkPlot.js +2 -6
- package/LineChart/extremums.js +10 -6
- package/LineChart/useLineChartProps.d.ts +2 -4
- package/LineChart/useLineChartProps.js +4 -11
- package/PieChart/PieArc.d.ts +0 -5
- package/PieChart/PieArc.js +1 -10
- package/PieChart/PieArcPlot.js +0 -5
- package/PieChart/PieChart.d.ts +10 -39
- package/PieChart/PieChart.js +20 -137
- package/PieChart/PiePlot.js +2 -2
- package/PieChart/getPieCoordinates.d.ts +2 -2
- package/README.md +4 -4
- package/ScatterChart/Scatter.js +6 -5
- package/ScatterChart/ScatterChart.d.ts +11 -17
- package/ScatterChart/ScatterChart.js +11 -60
- package/ScatterChart/ScatterPlot.js +3 -6
- package/ScatterChart/extremums.js +6 -6
- package/ScatterChart/useScatterChartProps.d.ts +2 -4
- package/ScatterChart/useScatterChartProps.js +3 -12
- package/SparkLineChart/SparkLineChart.d.ts +7 -8
- package/SparkLineChart/SparkLineChart.js +6 -33
- package/context/CartesianProvider/defaultizeAxis.d.ts +1 -1
- package/context/ChartDataProvider/ChartDataProvider.d.ts +31 -0
- package/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +45 -39
- package/context/ChartDataProvider/index.d.ts +1 -0
- package/context/ChartDataProvider/index.js +1 -0
- package/context/ChartDataProvider/useChartDataProviderProps.d.ts +94 -0
- package/context/ChartDataProvider/useChartDataProviderProps.js +66 -0
- package/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.d.ts +12 -12
- package/{modern/ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
- package/context/{DrawingProvider.d.ts → DrawingAreaProvider/DrawingArea.types.d.ts} +3 -14
- package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +8 -0
- package/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
- package/context/DrawingAreaProvider/DrawingAreaProvider.d.ts +3 -0
- package/{modern/context/DrawingProvider.js → context/DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
- package/context/DrawingAreaProvider/index.d.ts +3 -0
- package/context/DrawingAreaProvider/index.js +3 -0
- package/context/HighlightedProvider/HighlightedContext.d.ts +0 -8
- package/context/HighlightedProvider/HighlightedProvider.js +1 -16
- package/context/InteractionProvider.d.ts +5 -48
- package/context/InteractionProvider.js +8 -64
- package/context/InteractionSelectors.d.ts +359 -0
- package/context/InteractionSelectors.js +12 -0
- package/context/PluginProvider/ExtremumGetter.types.d.ts +2 -2
- package/context/SizeProvider/Size.types.d.ts +30 -0
- package/context/SizeProvider/SizeContext.d.ts +4 -0
- package/context/SizeProvider/SizeContext.js +13 -0
- package/context/SizeProvider/SizeProvider.d.ts +11 -0
- package/context/SizeProvider/SizeProvider.js +26 -0
- package/context/SizeProvider/index.d.ts +4 -0
- package/context/SizeProvider/index.js +4 -0
- package/context/SizeProvider/useChartContainerDimensions.d.ts +9 -0
- package/{modern/ResponsiveChartContainer → context/SizeProvider}/useChartContainerDimensions.js +15 -7
- package/context/SizeProvider/useSize.d.ts +5 -0
- package/context/SizeProvider/useSize.js +13 -0
- package/context/SvgRefProvider/SvgRef.types.d.ts +8 -0
- package/context/SvgRefProvider/SvgRef.types.js +1 -0
- package/context/SvgRefProvider/SvgRefContext.d.ts +4 -0
- package/context/SvgRefProvider/SvgRefContext.js +17 -0
- package/context/SvgRefProvider/SvgRefProvider.d.ts +3 -0
- package/context/SvgRefProvider/SvgRefProvider.js +24 -0
- package/context/SvgRefProvider/index.d.ts +4 -0
- package/context/SvgRefProvider/index.js +4 -0
- package/context/SvgRefProvider/useSurfaceRef.d.ts +2 -0
- package/context/SvgRefProvider/useSurfaceRef.js +14 -0
- package/context/ZAxisContextProvider.d.ts +1 -1
- package/context/index.d.ts +2 -0
- package/context/index.js +2 -1
- package/hooks/useAxisEvents.js +32 -19
- package/hooks/useChartId.js +2 -2
- package/hooks/useDrawingArea.d.ts +2 -2
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +19 -12
- package/hooks/useSvgRef.js +3 -3
- package/index.d.ts +1 -2
- package/index.js +2 -3
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +1 -1
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
- package/internals/computeAxisValue.d.ts +2 -2
- package/internals/defaultizeColor.d.ts +1 -8
- package/internals/getSymbol.js +19 -3
- package/internals/index.d.ts +7 -6
- package/internals/index.js +7 -6
- package/internals/plugins/models/index.d.ts +35 -0
- package/internals/plugins/models/index.js +1 -0
- package/internals/plugins/utils/ChartStore.d.ts +12 -0
- package/internals/plugins/utils/ChartStore.js +26 -0
- package/internals/plugins/utils/ChartsStore.d.ts +12 -0
- package/internals/plugins/utils/ChartsStore.js +26 -0
- package/internals/plugins/utils/selectors.d.ts +9 -0
- package/internals/plugins/utils/selectors.js +37 -0
- package/internals/useCharts.d.ts +6 -0
- package/internals/useCharts.js +29 -0
- package/internals/useSelector.d.ts +4 -0
- package/internals/useSelector.js +6 -0
- package/internals/useStore.d.ts +2 -0
- package/internals/useStore.js +17 -0
- package/internals/useStringInterpolator.js +1 -0
- package/models/seriesType/bar.d.ts +1 -1
- package/models/seriesType/common.d.ts +0 -10
- package/models/seriesType/config.d.ts +1 -1
- package/models/seriesType/line.d.ts +1 -1
- package/models/seriesType/pie.d.ts +1 -1
- package/models/seriesType/scatter.d.ts +1 -6
- package/modern/BarChart/AnimatedBarElement.js +21 -0
- package/modern/BarChart/BarChart.js +9 -59
- package/modern/BarChart/BarElement.js +10 -20
- package/modern/BarChart/BarPlot.js +24 -6
- package/modern/BarChart/extremums.js +3 -3
- package/modern/BarChart/useBarChartProps.js +4 -11
- package/modern/ChartContainer/ChartContainer.js +15 -44
- package/modern/ChartContainer/ResizableContainer.js +60 -0
- package/modern/ChartContainer/useChartContainerProps.js +29 -59
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
- package/modern/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
- package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
- package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
- package/modern/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
- package/modern/ChartsAxisHighlight/index.js +4 -1
- package/modern/ChartsGrid/ChartsGrid.js +1 -1
- package/modern/ChartsGrid/ChartsHorizontalGrid.js +3 -3
- package/modern/ChartsGrid/ChartsVerticalGrid.js +3 -3
- package/modern/ChartsLegend/ChartsLegend.js +0 -3
- package/modern/ChartsLegend/DefaultChartsLegend.js +1 -12
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +11 -9
- package/modern/ChartsSurface/ChartsSurface.js +35 -34
- package/modern/ChartsTooltip/ChartTooltip.types.js +1 -0
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
- package/modern/ChartsTooltip/ChartsTooltip.js +162 -107
- package/modern/ChartsTooltip/ChartsTooltipContainer.js +298 -0
- package/modern/ChartsTooltip/chartsTooltipClasses.js +18 -2
- package/modern/ChartsTooltip/index.js +2 -3
- package/modern/ChartsTooltip/useAxisTooltip.js +21 -21
- package/modern/ChartsTooltip/useItemTooltip.js +8 -7
- package/modern/ChartsTooltip/utils.js +45 -50
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +50 -39
- package/modern/Gauge/Gauge.js +0 -6
- package/modern/Gauge/GaugeContainer.js +60 -61
- package/modern/LineChart/AnimatedArea.js +9 -18
- package/modern/LineChart/AnimatedLine.js +9 -20
- package/modern/LineChart/AreaPlot.js +14 -8
- package/modern/LineChart/CircleMarkElement.js +6 -5
- package/modern/LineChart/LineChart.js +9 -60
- package/modern/LineChart/LineHighlightPlot.js +8 -11
- package/modern/LineChart/LinePlot.js +14 -8
- package/modern/LineChart/MarkElement.js +6 -5
- package/modern/LineChart/MarkPlot.js +2 -6
- package/modern/LineChart/extremums.js +10 -6
- package/modern/LineChart/useLineChartProps.js +4 -11
- package/modern/PieChart/PieArc.js +1 -10
- package/modern/PieChart/PieArcPlot.js +0 -5
- package/modern/PieChart/PieChart.js +20 -137
- package/modern/PieChart/PiePlot.js +2 -2
- package/modern/ScatterChart/Scatter.js +6 -5
- package/modern/ScatterChart/ScatterChart.js +11 -60
- package/modern/ScatterChart/ScatterPlot.js +3 -6
- package/modern/ScatterChart/extremums.js +6 -6
- package/modern/ScatterChart/useScatterChartProps.js +3 -12
- package/modern/SparkLineChart/SparkLineChart.js +6 -33
- package/modern/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +45 -39
- package/modern/context/ChartDataProvider/index.js +1 -0
- package/modern/context/ChartDataProvider/useChartDataProviderProps.js +66 -0
- package/{ChartContainer → modern/context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
- package/modern/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
- package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
- package/{context/DrawingProvider.js → modern/context/DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
- package/modern/context/DrawingAreaProvider/index.js +3 -0
- package/modern/context/HighlightedProvider/HighlightedProvider.js +1 -16
- package/modern/context/InteractionProvider.js +8 -64
- package/modern/context/InteractionSelectors.js +12 -0
- package/modern/context/SizeProvider/Size.types.js +1 -0
- package/modern/context/SizeProvider/SizeContext.js +13 -0
- package/modern/context/SizeProvider/SizeProvider.js +26 -0
- package/modern/context/SizeProvider/index.js +4 -0
- package/{ResponsiveChartContainer → modern/context/SizeProvider}/useChartContainerDimensions.js +15 -7
- package/modern/context/SizeProvider/useSize.js +13 -0
- package/modern/context/SvgRefProvider/SvgRef.types.js +1 -0
- package/modern/context/SvgRefProvider/SvgRefContext.js +17 -0
- package/modern/context/SvgRefProvider/SvgRefProvider.js +24 -0
- package/modern/context/SvgRefProvider/index.js +4 -0
- package/modern/context/SvgRefProvider/useSurfaceRef.js +14 -0
- package/modern/context/index.js +2 -1
- package/modern/hooks/useAxisEvents.js +32 -19
- package/modern/hooks/useChartId.js +2 -2
- package/modern/hooks/useDrawingArea.js +2 -2
- package/modern/hooks/useInteractionItemProps.js +19 -12
- package/modern/hooks/useSvgRef.js +3 -3
- package/modern/index.js +2 -3
- package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
- package/modern/internals/getSymbol.js +19 -3
- package/modern/internals/index.js +7 -6
- package/modern/internals/plugins/models/index.js +1 -0
- package/modern/internals/plugins/utils/ChartStore.js +26 -0
- package/modern/internals/plugins/utils/ChartsStore.js +26 -0
- package/modern/internals/plugins/utils/selectors.js +37 -0
- package/modern/internals/useCharts.js +29 -0
- package/modern/internals/useSelector.js +6 -0
- package/modern/internals/useStore.js +17 -0
- package/modern/internals/useStringInterpolator.js +1 -0
- package/node/BarChart/AnimatedBarElement.js +28 -0
- package/node/BarChart/BarChart.js +9 -59
- package/node/BarChart/BarElement.js +11 -21
- package/node/BarChart/BarPlot.js +22 -4
- package/node/BarChart/extremums.js +3 -3
- package/node/BarChart/useBarChartProps.js +4 -11
- package/node/ChartContainer/ChartContainer.js +14 -43
- package/node/ChartContainer/ResizableContainer.js +68 -0
- package/node/ChartContainer/useChartContainerProps.js +29 -60
- package/node/ChartsAxisHighlight/ChartsAxisHighlight.js +12 -100
- package/node/ChartsAxisHighlight/ChartsAxisHighlightPath.js +40 -0
- package/node/ChartsAxisHighlight/ChartsXAxisHighlight.js +57 -0
- package/node/ChartsAxisHighlight/ChartsYAxisHighlight.js +57 -0
- package/node/ChartsAxisHighlight/chartsAxisHighlightClasses.js +14 -0
- package/node/ChartsAxisHighlight/index.js +33 -0
- package/node/ChartsGrid/ChartsGrid.js +2 -2
- package/node/ChartsGrid/ChartsHorizontalGrid.js +4 -4
- package/node/ChartsGrid/ChartsVerticalGrid.js +4 -4
- package/node/ChartsLegend/ChartsLegend.js +0 -3
- package/node/ChartsLegend/DefaultChartsLegend.js +1 -12
- package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +11 -9
- package/node/ChartsSurface/ChartsSurface.js +35 -34
- package/node/ChartsTooltip/ChartsAxisTooltipContent.js +83 -73
- package/node/ChartsTooltip/ChartsItemTooltipContent.js +54 -45
- package/node/ChartsTooltip/ChartsTooltip.js +161 -106
- package/node/ChartsTooltip/ChartsTooltipContainer.js +304 -0
- package/node/ChartsTooltip/chartsTooltipClasses.js +22 -3
- package/node/ChartsTooltip/index.js +19 -28
- package/node/ChartsTooltip/useAxisTooltip.js +21 -21
- package/node/ChartsTooltip/useItemTooltip.js +8 -7
- package/node/ChartsTooltip/utils.js +46 -53
- package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +51 -40
- package/node/Gauge/Gauge.js +0 -6
- package/node/Gauge/GaugeContainer.js +60 -61
- package/node/LineChart/AnimatedArea.js +9 -19
- package/node/LineChart/AnimatedLine.js +9 -21
- package/node/LineChart/AreaPlot.js +13 -7
- package/node/LineChart/CircleMarkElement.js +6 -5
- package/node/LineChart/LineChart.js +9 -60
- package/node/LineChart/LineHighlightPlot.js +8 -11
- package/node/LineChart/LinePlot.js +13 -7
- package/node/LineChart/MarkElement.js +6 -5
- package/node/LineChart/MarkPlot.js +2 -6
- package/node/LineChart/extremums.js +10 -6
- package/node/LineChart/useLineChartProps.js +4 -11
- package/node/PieChart/PieArc.js +1 -10
- package/node/PieChart/PieArcPlot.js +0 -5
- package/node/PieChart/PieChart.js +20 -137
- package/node/PieChart/PiePlot.js +2 -2
- package/node/ScatterChart/Scatter.js +6 -5
- package/node/ScatterChart/ScatterChart.js +11 -60
- package/node/ScatterChart/ScatterPlot.js +3 -6
- package/node/ScatterChart/extremums.js +6 -6
- package/node/ScatterChart/useScatterChartProps.js +3 -12
- package/node/SparkLineChart/SparkLineChart.js +6 -33
- package/node/{ResponsiveChartContainer/ResponsiveChartContainer.js → context/ChartDataProvider/ChartDataProvider.js} +45 -39
- package/node/context/ChartDataProvider/index.js +16 -0
- package/node/context/ChartDataProvider/useChartDataProviderProps.js +72 -0
- package/node/{ChartContainer → context/ChartDataProvider}/useDefaultizeAxis.js +1 -1
- package/node/context/DrawingAreaProvider/DrawingArea.types.js +5 -0
- package/node/context/DrawingAreaProvider/DrawingAreaContext.js +22 -0
- package/node/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +12 -44
- package/node/context/DrawingAreaProvider/index.js +38 -0
- package/node/context/HighlightedProvider/HighlightedProvider.js +1 -16
- package/node/context/InteractionProvider.js +9 -66
- package/node/context/InteractionSelectors.js +18 -0
- package/node/context/SizeProvider/Size.types.js +5 -0
- package/node/context/SizeProvider/SizeContext.js +20 -0
- package/node/context/SizeProvider/SizeProvider.js +29 -0
- package/node/context/SizeProvider/index.js +49 -0
- package/node/{ResponsiveChartContainer → context/SizeProvider}/useChartContainerDimensions.js +15 -7
- package/node/context/SizeProvider/useSize.js +20 -0
- package/node/context/SvgRefProvider/SvgRef.types.js +5 -0
- package/node/context/SvgRefProvider/SvgRefContext.js +23 -0
- package/node/context/SvgRefProvider/SvgRefProvider.js +31 -0
- package/node/context/SvgRefProvider/index.js +49 -0
- package/node/context/SvgRefProvider/useSurfaceRef.js +20 -0
- package/node/context/index.js +10 -2
- package/node/hooks/useAxisEvents.js +33 -19
- package/node/hooks/useChartId.js +2 -2
- package/node/hooks/useDrawingArea.js +2 -2
- package/node/hooks/useInteractionItemProps.js +20 -13
- package/node/hooks/useSvgRef.js +3 -3
- package/node/index.js +5 -16
- package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
- package/node/internals/getSymbol.js +19 -3
- package/node/internals/index.js +64 -44
- package/node/internals/plugins/models/index.js +5 -0
- package/node/internals/plugins/utils/ChartStore.js +33 -0
- package/node/internals/plugins/utils/ChartsStore.js +33 -0
- package/node/internals/plugins/utils/selectors.js +44 -0
- package/node/internals/useCharts.js +36 -0
- package/node/internals/useSelector.js +13 -0
- package/node/internals/useStore.js +24 -0
- package/node/internals/useStringInterpolator.js +2 -0
- package/package.json +8 -6
- package/themeAugmentation/props.d.ts +1 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +0 -7
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
- package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +0 -8
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
- package/ResponsiveChartContainer/ResizableContainer.d.ts +0 -9
- package/ResponsiveChartContainer/ResizableContainer.js +0 -26
- package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +0 -24
- package/ResponsiveChartContainer/index.d.ts +0 -1
- package/ResponsiveChartContainer/index.js +0 -1
- package/ResponsiveChartContainer/package.json +0 -6
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +0 -6
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +0 -19
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -70
- package/internals/SlotComponentPropsFromProps.d.ts +0 -1
- package/models/helpers.d.ts +0 -3
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
- package/modern/ResponsiveChartContainer/ResizableContainer.js +0 -26
- package/modern/ResponsiveChartContainer/index.js +0 -1
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -70
- package/node/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -129
- package/node/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -98
- package/node/ResponsiveChartContainer/ResizableContainer.js +0 -32
- package/node/ResponsiveChartContainer/index.js +0 -16
- package/node/ResponsiveChartContainer/useResponsiveChartContainerProps.js +0 -77
- /package/{internals/SlotComponentPropsFromProps.js → ChartsAxisHighlight/ChartsAxisHighlight.types.js} +0 -0
- /package/ChartsGrid/{styledCommonents.d.ts → styledComponents.d.ts} +0 -0
- /package/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
- /package/{models/helpers.js → ChartsTooltip/ChartTooltip.types.js} +0 -0
- /package/{modern/internals/SlotComponentPropsFromProps.js → context/DrawingAreaProvider/DrawingArea.types.js} +0 -0
- /package/{modern/models/helpers.js → context/SizeProvider/Size.types.js} +0 -0
- /package/modern/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
- /package/node/{internals/SlotComponentPropsFromProps.js → ChartsAxisHighlight/ChartsAxisHighlight.types.js} +0 -0
- /package/node/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
- /package/node/{models/helpers.js → ChartsTooltip/ChartTooltip.types.js} +0 -0
|
@@ -3,27 +3,58 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { DrawingAreaProvider } from "../DrawingAreaProvider/index.js";
|
|
7
|
+
import { SeriesProvider } from "../SeriesProvider/index.js";
|
|
8
|
+
import { InteractionProvider } from "../InteractionProvider.js";
|
|
9
|
+
import { CartesianProvider } from "../CartesianProvider/index.js";
|
|
10
|
+
import { PluginProvider } from "../PluginProvider/index.js";
|
|
11
|
+
import { useChartDataProviderProps } from "./useChartDataProviderProps.js";
|
|
12
|
+
import { AnimationProvider } from "../AnimationProvider/index.js";
|
|
13
|
+
import { ZAxisContextProvider } from "../ZAxisContextProvider.js";
|
|
14
|
+
import { HighlightedProvider } from "../HighlightedProvider/index.js";
|
|
15
|
+
import { SizeProvider } from "../SizeProvider/index.js";
|
|
16
|
+
import { SvgRefProvider } from "../SvgRefProvider/index.js";
|
|
9
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
|
|
18
|
+
function ChartDataProvider(props) {
|
|
11
19
|
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
children,
|
|
21
|
+
drawingAreaProviderProps,
|
|
22
|
+
seriesProviderProps,
|
|
23
|
+
cartesianProviderProps,
|
|
24
|
+
zAxisContextProps,
|
|
25
|
+
highlightedProviderProps,
|
|
26
|
+
pluginProviderProps,
|
|
27
|
+
animationProviderProps,
|
|
28
|
+
sizeProviderProps
|
|
29
|
+
} = useChartDataProviderProps(props);
|
|
30
|
+
return /*#__PURE__*/_jsx(SizeProvider, _extends({}, sizeProviderProps, {
|
|
31
|
+
children: /*#__PURE__*/_jsx(DrawingAreaProvider, _extends({}, drawingAreaProviderProps, {
|
|
32
|
+
children: /*#__PURE__*/_jsx(PluginProvider, _extends({}, pluginProviderProps, {
|
|
33
|
+
children: /*#__PURE__*/_jsx(SeriesProvider, _extends({}, seriesProviderProps, {
|
|
34
|
+
children: /*#__PURE__*/_jsx(CartesianProvider, _extends({}, cartesianProviderProps, {
|
|
35
|
+
children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {
|
|
36
|
+
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
37
|
+
children: /*#__PURE__*/_jsx(HighlightedProvider, _extends({}, highlightedProviderProps, {
|
|
38
|
+
children: /*#__PURE__*/_jsx(AnimationProvider, _extends({}, animationProviderProps, {
|
|
39
|
+
children: /*#__PURE__*/_jsx(SvgRefProvider, {
|
|
40
|
+
children: children
|
|
41
|
+
})
|
|
42
|
+
}))
|
|
43
|
+
}))
|
|
44
|
+
})
|
|
45
|
+
}))
|
|
46
|
+
}))
|
|
47
|
+
}))
|
|
48
|
+
}))
|
|
49
|
+
}))
|
|
18
50
|
}));
|
|
19
|
-
}
|
|
20
|
-
process.env.NODE_ENV !== "production" ?
|
|
51
|
+
}
|
|
52
|
+
process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
|
|
21
53
|
// ----------------------------- Warning --------------------------------
|
|
22
54
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
23
55
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
24
56
|
// ----------------------------------------------------------------------
|
|
25
57
|
children: PropTypes.node,
|
|
26
|
-
className: PropTypes.string,
|
|
27
58
|
/**
|
|
28
59
|
* Color palette used to colorize multiple series.
|
|
29
60
|
* @default blueberryTwilightPalette
|
|
@@ -33,13 +64,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
33
64
|
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
34
65
|
*/
|
|
35
66
|
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
36
|
-
desc: PropTypes.string,
|
|
37
|
-
/**
|
|
38
|
-
* If `true`, the charts will not listen to the mouse move event.
|
|
39
|
-
* It might break interactive features, but will improve performance.
|
|
40
|
-
* @default false
|
|
41
|
-
*/
|
|
42
|
-
disableAxisListener: PropTypes.bool,
|
|
43
67
|
/**
|
|
44
68
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
45
69
|
*/
|
|
@@ -74,16 +98,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
74
98
|
* If not provided, the container supports line, bar, scatter and pie charts.
|
|
75
99
|
*/
|
|
76
100
|
plugins: PropTypes.arrayOf(PropTypes.object),
|
|
77
|
-
/**
|
|
78
|
-
* The chart will try to wait for the parent container to resolve its size
|
|
79
|
-
* before it renders for the first time.
|
|
80
|
-
*
|
|
81
|
-
* This can be useful in some scenarios where the chart appear to grow after
|
|
82
|
-
* the first render, like when used inside a grid.
|
|
83
|
-
*
|
|
84
|
-
* @default false
|
|
85
|
-
*/
|
|
86
|
-
resolveSizeBeforeRender: PropTypes.bool,
|
|
87
101
|
/**
|
|
88
102
|
* The array of series to display.
|
|
89
103
|
* Each type of series has its own specificity.
|
|
@@ -95,14 +109,6 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
95
109
|
* If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
|
|
96
110
|
*/
|
|
97
111
|
skipAnimation: PropTypes.bool,
|
|
98
|
-
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
99
|
-
title: PropTypes.string,
|
|
100
|
-
viewBox: PropTypes.shape({
|
|
101
|
-
height: PropTypes.number,
|
|
102
|
-
width: PropTypes.number,
|
|
103
|
-
x: PropTypes.number,
|
|
104
|
-
y: PropTypes.number
|
|
105
|
-
}),
|
|
106
112
|
/**
|
|
107
113
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
108
114
|
*/
|
|
@@ -241,4 +247,4 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainer.propTypes = {
|
|
|
241
247
|
min: PropTypes.number
|
|
242
248
|
}))
|
|
243
249
|
} : void 0;
|
|
244
|
-
export {
|
|
250
|
+
export { ChartDataProvider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ChartDataProvider.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useDefaultizeAxis } from "./useDefaultizeAxis.js";
|
|
4
|
+
export const useChartDataProviderProps = props => {
|
|
5
|
+
const {
|
|
6
|
+
width,
|
|
7
|
+
height,
|
|
8
|
+
series,
|
|
9
|
+
margin,
|
|
10
|
+
xAxis,
|
|
11
|
+
yAxis,
|
|
12
|
+
zAxis,
|
|
13
|
+
colors,
|
|
14
|
+
dataset,
|
|
15
|
+
highlightedItem,
|
|
16
|
+
onHighlightChange,
|
|
17
|
+
plugins,
|
|
18
|
+
children,
|
|
19
|
+
skipAnimation
|
|
20
|
+
} = props;
|
|
21
|
+
const [defaultizedXAxis, defaultizedYAxis] = useDefaultizeAxis(xAxis, yAxis, dataset);
|
|
22
|
+
const drawingAreaProviderProps = {
|
|
23
|
+
margin
|
|
24
|
+
};
|
|
25
|
+
const animationProviderProps = {
|
|
26
|
+
skipAnimation
|
|
27
|
+
};
|
|
28
|
+
const pluginProviderProps = {
|
|
29
|
+
plugins
|
|
30
|
+
};
|
|
31
|
+
const seriesProviderProps = {
|
|
32
|
+
series,
|
|
33
|
+
colors,
|
|
34
|
+
dataset
|
|
35
|
+
};
|
|
36
|
+
const cartesianProviderProps = {
|
|
37
|
+
xAxis: defaultizedXAxis,
|
|
38
|
+
yAxis: defaultizedYAxis,
|
|
39
|
+
dataset
|
|
40
|
+
};
|
|
41
|
+
const zAxisContextProps = {
|
|
42
|
+
zAxis,
|
|
43
|
+
dataset
|
|
44
|
+
};
|
|
45
|
+
const highlightedProviderProps = {
|
|
46
|
+
highlightedItem,
|
|
47
|
+
onHighlightChange
|
|
48
|
+
};
|
|
49
|
+
const sizeProviderProps = {
|
|
50
|
+
width,
|
|
51
|
+
height
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
children,
|
|
55
|
+
drawingAreaProviderProps,
|
|
56
|
+
seriesProviderProps,
|
|
57
|
+
cartesianProviderProps,
|
|
58
|
+
zAxisContextProps,
|
|
59
|
+
highlightedProviderProps,
|
|
60
|
+
pluginProviderProps,
|
|
61
|
+
animationProviderProps,
|
|
62
|
+
xAxis: defaultizedXAxis,
|
|
63
|
+
yAxis: defaultizedYAxis,
|
|
64
|
+
sizeProviderProps
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "
|
|
5
|
+
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "../../constants/index.js";
|
|
6
6
|
const defaultizeAxis = (inAxis, dataset, axisName) => {
|
|
7
7
|
const DEFAULT_AXIS_KEY = axisName === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
|
|
8
8
|
return [...(inAxis?.map((axis, index) => _extends({
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export const DrawingAreaContext = /*#__PURE__*/React.createContext({
|
|
5
|
+
top: 0,
|
|
6
|
+
left: 0,
|
|
7
|
+
bottom: 0,
|
|
8
|
+
right: 0,
|
|
9
|
+
height: 300,
|
|
10
|
+
width: 400,
|
|
11
|
+
chartId: '',
|
|
12
|
+
isPointInside: () => false
|
|
13
|
+
});
|
|
14
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
15
|
+
DrawingAreaContext.displayName = 'DrawingContext';
|
|
16
|
+
}
|
package/{context/DrawingProvider.js → modern/context/DrawingAreaProvider/DrawingAreaProvider.js}
RENAMED
|
@@ -3,42 +3,19 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import useId from '@mui/utils/useId';
|
|
6
|
-
import useChartDimensions from "
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* Defines the area in which it is possible to draw the charts.
|
|
10
|
-
*/
|
|
6
|
+
import useChartDimensions from "../../hooks/useChartDimensions.js";
|
|
7
|
+
import { DrawingAreaContext } from "./DrawingAreaContext.js";
|
|
8
|
+
import { useSize } from "../SizeProvider/index.js";
|
|
11
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
export
|
|
13
|
-
top: 0,
|
|
14
|
-
left: 0,
|
|
15
|
-
bottom: 0,
|
|
16
|
-
right: 0,
|
|
17
|
-
height: 300,
|
|
18
|
-
width: 400,
|
|
19
|
-
chartId: '',
|
|
20
|
-
isPointInside: () => false
|
|
21
|
-
});
|
|
22
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
23
|
-
DrawingContext.displayName = 'DrawingContext';
|
|
24
|
-
}
|
|
25
|
-
export const SvgContext = /*#__PURE__*/React.createContext({
|
|
26
|
-
isInitialized: false,
|
|
27
|
-
data: {
|
|
28
|
-
current: null
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
32
|
-
SvgContext.displayName = 'SvgContext';
|
|
33
|
-
}
|
|
34
|
-
export function DrawingProvider(props) {
|
|
10
|
+
export function DrawingAreaProvider(props) {
|
|
35
11
|
const {
|
|
36
|
-
width,
|
|
37
|
-
height,
|
|
38
12
|
margin,
|
|
39
|
-
svgRef,
|
|
40
13
|
children
|
|
41
14
|
} = props;
|
|
15
|
+
const {
|
|
16
|
+
width,
|
|
17
|
+
height
|
|
18
|
+
} = useSize();
|
|
42
19
|
const drawingArea = useChartDimensions(width, height, margin);
|
|
43
20
|
const chartId = useId();
|
|
44
21
|
const isPointInside = React.useCallback(({
|
|
@@ -64,15 +41,8 @@ export function DrawingProvider(props) {
|
|
|
64
41
|
}, drawingArea, {
|
|
65
42
|
isPointInside
|
|
66
43
|
}), [chartId, drawingArea, isPointInside]);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}), [svgRef]);
|
|
71
|
-
return /*#__PURE__*/_jsx(SvgContext.Provider, {
|
|
72
|
-
value: refValue,
|
|
73
|
-
children: /*#__PURE__*/_jsx(DrawingContext.Provider, {
|
|
74
|
-
value: value,
|
|
75
|
-
children: children
|
|
76
|
-
})
|
|
44
|
+
return /*#__PURE__*/_jsx(DrawingAreaContext.Provider, {
|
|
45
|
+
value: value,
|
|
46
|
+
children: children
|
|
77
47
|
});
|
|
78
48
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["highlighted", "faded"];
|
|
6
3
|
import * as React from 'react';
|
|
7
4
|
import PropTypes from 'prop-types';
|
|
8
5
|
import useControlled from '@mui/utils/useControlled';
|
|
@@ -11,18 +8,6 @@ import { createIsFaded } from "./createIsFaded.js";
|
|
|
11
8
|
import { createIsHighlighted } from "./createIsHighlighted.js";
|
|
12
9
|
import { useSeries } from "../../hooks/useSeries.js";
|
|
13
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
const mergeDeprecatedOptions = options => {
|
|
15
|
-
const _ref = options ?? {},
|
|
16
|
-
{
|
|
17
|
-
highlighted,
|
|
18
|
-
faded
|
|
19
|
-
} = _ref,
|
|
20
|
-
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
21
|
-
return _extends({
|
|
22
|
-
highlight: highlighted,
|
|
23
|
-
fade: faded
|
|
24
|
-
}, other);
|
|
25
|
-
};
|
|
26
11
|
function HighlightedProvider({
|
|
27
12
|
children,
|
|
28
13
|
highlightedItem: highlightedItemProps,
|
|
@@ -41,7 +26,7 @@ function HighlightedProvider({
|
|
|
41
26
|
const seriesData = series[seriesType];
|
|
42
27
|
Object.keys(seriesData?.series ?? {}).forEach(seriesId => {
|
|
43
28
|
const seriesItem = seriesData?.series[seriesId];
|
|
44
|
-
map.set(seriesId,
|
|
29
|
+
map.set(seriesId, seriesItem?.highlightScope);
|
|
45
30
|
});
|
|
46
31
|
});
|
|
47
32
|
return map;
|
|
@@ -1,77 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import * as React from 'react';
|
|
4
|
+
import { useCharts } from "../internals/useCharts.js";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
export const
|
|
7
|
-
item: null,
|
|
8
|
-
axis: {
|
|
9
|
-
x: null,
|
|
10
|
-
y: null
|
|
11
|
-
},
|
|
12
|
-
useVoronoiInteraction: false,
|
|
13
|
-
dispatch: () => null
|
|
14
|
-
});
|
|
6
|
+
export const ChartsContext = /*#__PURE__*/React.createContext(null);
|
|
15
7
|
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
-
|
|
8
|
+
ChartsContext.displayName = 'ChartsContext';
|
|
17
9
|
}
|
|
18
|
-
const dataReducer = (prevState, action) => {
|
|
19
|
-
switch (action.type) {
|
|
20
|
-
case 'enterItem':
|
|
21
|
-
return _extends({}, prevState, {
|
|
22
|
-
item: action.data
|
|
23
|
-
});
|
|
24
|
-
case 'exitChart':
|
|
25
|
-
if (prevState.item === null && prevState.axis.x === null && prevState.axis.y === null) {
|
|
26
|
-
return prevState;
|
|
27
|
-
}
|
|
28
|
-
return _extends({}, prevState, {
|
|
29
|
-
axis: {
|
|
30
|
-
x: null,
|
|
31
|
-
y: null
|
|
32
|
-
},
|
|
33
|
-
item: null
|
|
34
|
-
});
|
|
35
|
-
case 'updateVoronoiUsage':
|
|
36
|
-
return _extends({}, prevState, {
|
|
37
|
-
useVoronoiInteraction: action.useVoronoiInteraction
|
|
38
|
-
});
|
|
39
|
-
case 'leaveItem':
|
|
40
|
-
if (prevState.item === null || Object.keys(action.data).some(key => action.data[key] !== prevState.item[key])) {
|
|
41
|
-
// The item is already something else
|
|
42
|
-
return prevState;
|
|
43
|
-
}
|
|
44
|
-
return _extends({}, prevState, {
|
|
45
|
-
item: null
|
|
46
|
-
});
|
|
47
|
-
case 'updateAxis':
|
|
48
|
-
if (action.data.x === prevState.axis.x && action.data.y === prevState.axis.y) {
|
|
49
|
-
return prevState;
|
|
50
|
-
}
|
|
51
|
-
return _extends({}, prevState, {
|
|
52
|
-
axis: action.data
|
|
53
|
-
});
|
|
54
|
-
default:
|
|
55
|
-
return prevState;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
10
|
function InteractionProvider(props) {
|
|
59
11
|
const {
|
|
60
12
|
children
|
|
61
13
|
} = props;
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
useVoronoiInteraction: false
|
|
69
|
-
});
|
|
70
|
-
const value = React.useMemo(() => _extends({}, data, {
|
|
71
|
-
dispatch
|
|
72
|
-
}), [data]);
|
|
73
|
-
return /*#__PURE__*/_jsx(InteractionContext.Provider, {
|
|
74
|
-
value: value,
|
|
14
|
+
const {
|
|
15
|
+
contextValue
|
|
16
|
+
} = useCharts();
|
|
17
|
+
return /*#__PURE__*/_jsx(ChartsContext.Provider, {
|
|
18
|
+
value: contextValue,
|
|
75
19
|
children: children
|
|
76
20
|
});
|
|
77
21
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createSelector } from "../internals/plugins/utils/selectors.js";
|
|
2
|
+
function selectInteraction(state) {
|
|
3
|
+
return state.interaction;
|
|
4
|
+
}
|
|
5
|
+
export const selectorChartsInteractionItem = createSelector(selectInteraction, interaction => interaction.item);
|
|
6
|
+
export const selectorChartsInteractionAxis = createSelector(selectInteraction, interaction => interaction.axis);
|
|
7
|
+
export const selectorChartsInteractionXAxis = createSelector(selectInteraction, interaction => interaction.axis.x);
|
|
8
|
+
export const selectorChartsInteractionYAxis = createSelector(selectInteraction, interaction => interaction.axis.y);
|
|
9
|
+
export const selectorChartsInteractionItemIsDefined = createSelector(selectorChartsInteractionItem, item => item !== null);
|
|
10
|
+
export const selectorChartsInteractionXAxisIsDefined = createSelector(selectorChartsInteractionXAxis, x => x !== null);
|
|
11
|
+
export const selectorChartsInteractionYAxisIsDefined = createSelector(selectorChartsInteractionYAxis, y => y !== null);
|
|
12
|
+
export const selectorChartsInteractionIsVoronoiEnabled = createSelector(selectInteraction, interaction => interaction.isVoronoiEnabled);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export const SizeContext = /*#__PURE__*/React.createContext({
|
|
3
|
+
isInitialized: false,
|
|
4
|
+
data: {
|
|
5
|
+
hasIntrinsicSize: false,
|
|
6
|
+
containerRef: null,
|
|
7
|
+
height: 0,
|
|
8
|
+
width: 0
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
12
|
+
SizeContext.displayName = 'SizeContext';
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { SizeContext } from "./SizeContext.js";
|
|
5
|
+
import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The size provider.
|
|
9
|
+
*
|
|
10
|
+
* This differs from the DrawingProvider in that it provides the full size of the container.
|
|
11
|
+
*
|
|
12
|
+
* This provider is also responsible for resolving the size of the container before rendering and if the parent size changes.
|
|
13
|
+
*/
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
function SizeProvider(props) {
|
|
16
|
+
const dimensions = useChartContainerDimensions(props.width, props.height);
|
|
17
|
+
const value = React.useMemo(() => ({
|
|
18
|
+
isInitialized: true,
|
|
19
|
+
data: dimensions
|
|
20
|
+
}), [dimensions]);
|
|
21
|
+
return /*#__PURE__*/_jsx(SizeContext.Provider, {
|
|
22
|
+
value: value,
|
|
23
|
+
children: props.children
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { SizeProvider };
|
package/{ResponsiveChartContainer → modern/context/SizeProvider}/useChartContainerDimensions.js
RENAMED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
/* eslint-disable react-compiler/react-compiler */
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
6
|
import ownerWindow from '@mui/utils/ownerWindow';
|
|
6
|
-
|
|
7
|
+
const MAX_COMPUTE_RUN = 10;
|
|
8
|
+
export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
9
|
+
const hasInSize = inWidth !== undefined && inHeight !== undefined;
|
|
7
10
|
const stateRef = React.useRef({
|
|
8
11
|
displayError: false,
|
|
9
12
|
initialCompute: true,
|
|
@@ -40,7 +43,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
40
43
|
// https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
|
|
41
44
|
useEnhancedEffect(() => {
|
|
42
45
|
// computeRun is used to avoid infinite loops.
|
|
43
|
-
if (
|
|
46
|
+
if (hasInSize || !stateRef.current.initialCompute || stateRef.current.computeRun > MAX_COMPUTE_RUN) {
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
49
|
const computedSize = computeSize();
|
|
@@ -49,9 +52,9 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
49
52
|
} else if (stateRef.current.initialCompute) {
|
|
50
53
|
stateRef.current.initialCompute = false;
|
|
51
54
|
}
|
|
52
|
-
}, [width, height, computeSize,
|
|
55
|
+
}, [width, height, computeSize, hasInSize]);
|
|
53
56
|
useEnhancedEffect(() => {
|
|
54
|
-
if (
|
|
57
|
+
if (hasInSize) {
|
|
55
58
|
return () => {};
|
|
56
59
|
}
|
|
57
60
|
computeSize();
|
|
@@ -77,7 +80,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
77
80
|
observer.unobserve(elementToObserve);
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
|
-
}, [computeSize,
|
|
83
|
+
}, [computeSize, hasInSize]);
|
|
81
84
|
if (process.env.NODE_ENV !== 'production') {
|
|
82
85
|
if (stateRef.current.displayError && inWidth === undefined && width === 0) {
|
|
83
86
|
console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
|
|
@@ -88,9 +91,14 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
|
|
|
88
91
|
stateRef.current.displayError = false;
|
|
89
92
|
}
|
|
90
93
|
}
|
|
94
|
+
const finalWidth = inWidth ?? width;
|
|
95
|
+
const finalHeight = inHeight ?? height;
|
|
91
96
|
return {
|
|
92
97
|
containerRef: rootRef,
|
|
93
|
-
width:
|
|
94
|
-
height:
|
|
98
|
+
width: finalWidth,
|
|
99
|
+
height: finalHeight,
|
|
100
|
+
hasIntrinsicSize: finalWidth > 0 && finalHeight > 0,
|
|
101
|
+
inWidth,
|
|
102
|
+
inHeight
|
|
95
103
|
};
|
|
96
104
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { SizeContext } from "./SizeContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the size of the chart. And the ref of the container element that the chart is rendered in.
|
|
7
|
+
*/
|
|
8
|
+
export const useSize = () => {
|
|
9
|
+
const {
|
|
10
|
+
data
|
|
11
|
+
} = React.useContext(SizeContext);
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export const SvgRefContext = /*#__PURE__*/React.createContext({
|
|
5
|
+
isInitialized: false,
|
|
6
|
+
data: {
|
|
7
|
+
svgRef: {
|
|
8
|
+
current: null
|
|
9
|
+
},
|
|
10
|
+
surfaceRef: {
|
|
11
|
+
current: null
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
+
SvgRefContext.displayName = 'SvgRefContext';
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
5
|
+
import { SvgRefContext } from "./SvgRefContext.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export function SvgRefProvider(props) {
|
|
8
|
+
const {
|
|
9
|
+
children
|
|
10
|
+
} = props;
|
|
11
|
+
const svgRef = React.useRef(null);
|
|
12
|
+
const surfaceRef = useForkRef(svgRef);
|
|
13
|
+
const refValue = React.useMemo(() => ({
|
|
14
|
+
isInitialized: true,
|
|
15
|
+
data: {
|
|
16
|
+
svgRef,
|
|
17
|
+
surfaceRef
|
|
18
|
+
}
|
|
19
|
+
}), [svgRef, surfaceRef]);
|
|
20
|
+
return /*#__PURE__*/_jsx(SvgRefContext.Provider, {
|
|
21
|
+
value: refValue,
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { SvgRefContext } from "./SvgRefContext.js";
|
|
5
|
+
export function useSurfaceRef() {
|
|
6
|
+
const {
|
|
7
|
+
isInitialized,
|
|
8
|
+
data
|
|
9
|
+
} = React.useContext(SvgRefContext);
|
|
10
|
+
if (!isInitialized) {
|
|
11
|
+
throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
12
|
+
}
|
|
13
|
+
return data.surfaceRef;
|
|
14
|
+
}
|
package/modern/context/index.js
CHANGED