@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
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
4
|
import * as React from 'react';
|
|
4
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
5
5
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
6
6
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
7
7
|
import { getSVGPoint } from "../internals/getSVGPoint.js";
|
|
8
8
|
import { useSvgRef } from "./useSvgRef.js";
|
|
9
9
|
import { useDrawingArea } from "./useDrawingArea.js";
|
|
10
|
+
import { useStore } from "../internals/useStore.js";
|
|
10
11
|
function getAsANumber(value) {
|
|
11
12
|
return value instanceof Date ? value.getTime() : value;
|
|
12
13
|
}
|
|
@@ -19,9 +20,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
19
20
|
xAxisIds,
|
|
20
21
|
yAxisIds
|
|
21
22
|
} = useCartesianContext();
|
|
22
|
-
const
|
|
23
|
-
dispatch
|
|
24
|
-
} = React.useContext(InteractionContext);
|
|
23
|
+
const store = useStore(disableAxisListener);
|
|
25
24
|
const usedXAxis = xAxisIds[0];
|
|
26
25
|
const usedYAxis = yAxisIds[0];
|
|
27
26
|
|
|
@@ -33,7 +32,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
33
32
|
});
|
|
34
33
|
React.useEffect(() => {
|
|
35
34
|
const element = svgRef.current;
|
|
36
|
-
if (element === null || disableAxisListener) {
|
|
35
|
+
if (element === null || disableAxisListener || !store) {
|
|
37
36
|
return () => {};
|
|
38
37
|
}
|
|
39
38
|
function getNewAxisState(axisConfig, mouseValue) {
|
|
@@ -92,9 +91,15 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
92
91
|
x: -1,
|
|
93
92
|
y: -1
|
|
94
93
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
store.update(prev => _extends({}, prev, {
|
|
95
|
+
interaction: {
|
|
96
|
+
item: null,
|
|
97
|
+
axis: {
|
|
98
|
+
x: null,
|
|
99
|
+
y: null
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
98
103
|
};
|
|
99
104
|
const handleMove = event => {
|
|
100
105
|
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
@@ -105,9 +110,15 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
105
110
|
targetElement: event.target
|
|
106
111
|
})) {
|
|
107
112
|
if (mousePosition.current.isInChart) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
store.update(prev => _extends({}, prev, {
|
|
114
|
+
interaction: {
|
|
115
|
+
item: null,
|
|
116
|
+
axis: {
|
|
117
|
+
x: null,
|
|
118
|
+
y: null
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
111
122
|
mousePosition.current.isInChart = false;
|
|
112
123
|
}
|
|
113
124
|
return;
|
|
@@ -115,13 +126,15 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
115
126
|
mousePosition.current.isInChart = true;
|
|
116
127
|
const newStateX = getNewAxisState(xAxis[usedXAxis], svgPoint.x);
|
|
117
128
|
const newStateY = getNewAxisState(yAxis[usedYAxis], svgPoint.y);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
store.update(prev => _extends({}, prev, {
|
|
130
|
+
interaction: _extends({}, prev.interaction, {
|
|
131
|
+
axis: _extends({}, prev.interaction.axis, prev.interaction.axis.x?.index !== newStateX?.index || prev.interaction.axis.x?.value !== newStateX?.value ? {
|
|
132
|
+
x: newStateX
|
|
133
|
+
} : {}, prev.interaction.axis.y?.index !== newStateY?.index || prev.interaction.axis.y?.value !== newStateY?.value ? {
|
|
134
|
+
y: newStateY
|
|
135
|
+
} : {})
|
|
136
|
+
})
|
|
137
|
+
}));
|
|
125
138
|
};
|
|
126
139
|
const handleDown = event => {
|
|
127
140
|
const target = event.currentTarget;
|
|
@@ -144,5 +157,5 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
144
157
|
element.removeEventListener('pointercancel', handleOut);
|
|
145
158
|
element.removeEventListener('pointerleave', handleOut);
|
|
146
159
|
};
|
|
147
|
-
}, [svgRef,
|
|
160
|
+
}, [svgRef, store, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, drawingArea]);
|
|
148
161
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { DrawingAreaContext } from "../context/DrawingAreaProvider/index.js";
|
|
5
5
|
export function useChartId() {
|
|
6
6
|
const {
|
|
7
7
|
chartId
|
|
8
|
-
} = React.useContext(
|
|
8
|
+
} = React.useContext(DrawingAreaContext);
|
|
9
9
|
return React.useMemo(() => chartId, [chartId]);
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { DrawingAreaContext } from "../context/DrawingAreaProvider/index.js";
|
|
5
5
|
export function useDrawingArea() {
|
|
6
6
|
const {
|
|
7
7
|
left,
|
|
@@ -11,7 +11,7 @@ export function useDrawingArea() {
|
|
|
11
11
|
bottom,
|
|
12
12
|
right,
|
|
13
13
|
isPointInside
|
|
14
|
-
} = React.useContext(
|
|
14
|
+
} = React.useContext(DrawingAreaContext);
|
|
15
15
|
return React.useMemo(() => ({
|
|
16
16
|
left,
|
|
17
17
|
top,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
4
|
import { useHighlighted } from "../context/index.js";
|
|
5
|
+
import { useStore } from "../internals/useStore.js";
|
|
6
6
|
export const useInteractionItemProps = skip => {
|
|
7
|
-
const
|
|
8
|
-
dispatch: dispatchInteraction
|
|
9
|
-
} = React.useContext(InteractionContext);
|
|
7
|
+
const store = useStore();
|
|
10
8
|
const {
|
|
11
9
|
setHighlighted,
|
|
12
10
|
clearHighlighted
|
|
@@ -21,10 +19,11 @@ export const useInteractionItemProps = skip => {
|
|
|
21
19
|
}
|
|
22
20
|
};
|
|
23
21
|
const onPointerEnter = () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
store.update(prev => _extends({}, prev, {
|
|
23
|
+
interaction: _extends({}, prev.interaction, {
|
|
24
|
+
item: data
|
|
25
|
+
})
|
|
26
|
+
}));
|
|
28
27
|
setHighlighted({
|
|
29
28
|
seriesId: data.seriesId,
|
|
30
29
|
dataIndex: data.dataIndex
|
|
@@ -32,9 +31,17 @@ export const useInteractionItemProps = skip => {
|
|
|
32
31
|
};
|
|
33
32
|
const onPointerLeave = event => {
|
|
34
33
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
data
|
|
34
|
+
store.update(prev => {
|
|
35
|
+
const prevItem = prev.interaction.item;
|
|
36
|
+
if (prevItem === null || Object.keys(data).some(key => data[key] !== prevItem[key])) {
|
|
37
|
+
// The item is already something else, no need to clean it.
|
|
38
|
+
return prev;
|
|
39
|
+
}
|
|
40
|
+
return _extends({}, prev, {
|
|
41
|
+
interaction: _extends({}, prev.interaction, {
|
|
42
|
+
item: null
|
|
43
|
+
})
|
|
44
|
+
});
|
|
38
45
|
});
|
|
39
46
|
clearHighlighted();
|
|
40
47
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { SvgRefContext } from "../context/SvgRefProvider/index.js";
|
|
5
5
|
export function useSvgRef() {
|
|
6
6
|
const {
|
|
7
7
|
isInitialized,
|
|
8
8
|
data
|
|
9
|
-
} = React.useContext(
|
|
9
|
+
} = React.useContext(SvgRefContext);
|
|
10
10
|
if (!isInitialized) {
|
|
11
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
12
|
}
|
|
13
|
-
return data;
|
|
13
|
+
return data.svgRef;
|
|
14
14
|
}
|
package/modern/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts
|
|
2
|
+
* @mui/x-charts v8.0.0-alpha.1
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -28,6 +28,5 @@ export * from "./PieChart/index.js";
|
|
|
28
28
|
export * from "./ScatterChart/index.js";
|
|
29
29
|
export * from "./SparkLineChart/index.js";
|
|
30
30
|
export * from "./Gauge/index.js";
|
|
31
|
-
export * from "./ChartContainer/index.js";
|
|
32
31
|
export * from "./ChartsSurface/index.js";
|
|
33
|
-
export * from "./
|
|
32
|
+
export * from "./ChartContainer/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useCartesianContext } from "../../../context/CartesianProvider/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { DrawingAreaContext } from "../../../context/DrawingAreaProvider/index.js";
|
|
4
4
|
import { useDrawingArea } from "../../../hooks/index.js";
|
|
5
5
|
import ChartsPiecewiseGradient from "./ChartsPiecewiseGradient.js";
|
|
6
6
|
import ChartsContinuousGradient from "./ChartsContinuousGradient.js";
|
|
@@ -8,7 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
export function useChartGradient() {
|
|
9
9
|
const {
|
|
10
10
|
chartId
|
|
11
|
-
} = React.useContext(
|
|
11
|
+
} = React.useContext(DrawingAreaContext);
|
|
12
12
|
return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
|
|
13
13
|
}
|
|
14
14
|
export function ChartsAxesGradients() {
|
|
@@ -29,8 +29,13 @@ export function ChartsAxesGradients() {
|
|
|
29
29
|
yAxisIds,
|
|
30
30
|
yAxis
|
|
31
31
|
} = useCartesianContext();
|
|
32
|
+
const filteredYAxisIds = yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined);
|
|
33
|
+
const filteredXAxisIds = xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined);
|
|
34
|
+
if (filteredYAxisIds.length === 0 && filteredXAxisIds.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
32
37
|
return /*#__PURE__*/_jsxs("defs", {
|
|
33
|
-
children: [
|
|
38
|
+
children: [filteredYAxisIds.map(axisId => {
|
|
34
39
|
const gradientId = getGradientId(axisId, 'y');
|
|
35
40
|
const {
|
|
36
41
|
colorMap,
|
|
@@ -60,7 +65,7 @@ export function ChartsAxesGradients() {
|
|
|
60
65
|
}, gradientId);
|
|
61
66
|
}
|
|
62
67
|
return null;
|
|
63
|
-
}),
|
|
68
|
+
}), filteredXAxisIds.map(axisId => {
|
|
64
69
|
const gradientId = getGradientId(axisId, 'x');
|
|
65
70
|
const {
|
|
66
71
|
colorMap,
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
// Returns the index of a defined shape
|
|
2
1
|
export function getSymbol(shape) {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
switch (shape) {
|
|
4
|
+
case 'circle':
|
|
5
|
+
return 0;
|
|
6
|
+
case 'cross':
|
|
7
|
+
return 1;
|
|
8
|
+
case 'diamond':
|
|
9
|
+
return 2;
|
|
10
|
+
case 'square':
|
|
11
|
+
return 3;
|
|
12
|
+
case 'star':
|
|
13
|
+
return 4;
|
|
14
|
+
case 'triangle':
|
|
15
|
+
return 5;
|
|
16
|
+
case 'wye':
|
|
17
|
+
return 6;
|
|
18
|
+
default:
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
5
21
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Components
|
|
2
2
|
export * from "./components/ChartsAxesGradients/index.js";
|
|
3
|
-
export * from "../
|
|
4
|
-
export * from "../ResponsiveChartContainer/ResizableContainer.js";
|
|
3
|
+
export * from "../ChartContainer/ResizableContainer.js";
|
|
5
4
|
|
|
6
5
|
// hooks
|
|
7
6
|
export { useSeries } from "../hooks/useSeries.js";
|
|
@@ -10,8 +9,8 @@ export { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
|
10
9
|
export { useScatterChartProps } from "../ScatterChart/useScatterChartProps.js";
|
|
11
10
|
export { useLineChartProps } from "../LineChart/useLineChartProps.js";
|
|
12
11
|
export { useBarChartProps } from "../BarChart/useBarChartProps.js";
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export * from "../ChartContainer/useChartContainerProps.js";
|
|
13
|
+
export * from "../context/ChartDataProvider/useChartDataProviderProps.js";
|
|
15
14
|
|
|
16
15
|
// utils
|
|
17
16
|
export * from "./defaultizeValueFormatter.js";
|
|
@@ -26,17 +25,19 @@ export * from "./computeAxisValue.js";
|
|
|
26
25
|
// contexts
|
|
27
26
|
|
|
28
27
|
export * from "../context/CartesianProvider/index.js";
|
|
29
|
-
export * from "../context/
|
|
28
|
+
export * from "../context/DrawingAreaProvider/index.js";
|
|
30
29
|
export * from "../context/InteractionProvider.js";
|
|
31
30
|
export * from "../context/SeriesProvider/index.js";
|
|
32
31
|
export * from "../context/ZAxisContextProvider.js";
|
|
33
32
|
export * from "../context/PluginProvider/index.js";
|
|
34
33
|
export * from "../context/AnimationProvider/index.js";
|
|
35
34
|
export { getAxisExtremum } from "../context/CartesianProvider/getAxisExtremum.js";
|
|
35
|
+
export * from "../context/ChartDataProvider/index.js";
|
|
36
|
+
export * from "../context/SizeProvider/index.js";
|
|
37
|
+
export * from "../context/SvgRefProvider/index.js";
|
|
36
38
|
|
|
37
39
|
// series configuration
|
|
38
40
|
export * from "../models/seriesType/config.js";
|
|
39
41
|
export * from "../models/seriesType/common.js";
|
|
40
|
-
export * from "../models/helpers.js";
|
|
41
42
|
export * from "../models/z-axis.js";
|
|
42
43
|
export * from "../models/axis.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// For now this is fixed. Will need to support generic if we add plugins
|
|
2
|
+
|
|
3
|
+
export class ChartStore {
|
|
4
|
+
constructor(value) {
|
|
5
|
+
this.value = void 0;
|
|
6
|
+
this.listeners = void 0;
|
|
7
|
+
this.subscribe = fn => {
|
|
8
|
+
this.listeners.add(fn);
|
|
9
|
+
return () => {
|
|
10
|
+
this.listeners.delete(fn);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
this.getSnapshot = () => {
|
|
14
|
+
return this.value;
|
|
15
|
+
};
|
|
16
|
+
this.update = updater => {
|
|
17
|
+
const newState = updater(this.value);
|
|
18
|
+
if (newState !== this.value) {
|
|
19
|
+
this.value = newState;
|
|
20
|
+
this.listeners.forEach(l => l(newState));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
this.value = value;
|
|
24
|
+
this.listeners = new Set();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// For now this is fixed. Will need to support generic if we add plugins
|
|
2
|
+
|
|
3
|
+
export class ChartsStore {
|
|
4
|
+
constructor(value) {
|
|
5
|
+
this.value = void 0;
|
|
6
|
+
this.listeners = void 0;
|
|
7
|
+
this.subscribe = fn => {
|
|
8
|
+
this.listeners.add(fn);
|
|
9
|
+
return () => {
|
|
10
|
+
this.listeners.delete(fn);
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
this.getSnapshot = () => {
|
|
14
|
+
return this.value;
|
|
15
|
+
};
|
|
16
|
+
this.update = updater => {
|
|
17
|
+
const newState = updater(this.value);
|
|
18
|
+
if (newState !== this.value) {
|
|
19
|
+
this.value = newState;
|
|
20
|
+
this.listeners.forEach(l => l(newState));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
this.value = value;
|
|
24
|
+
this.listeners = new Set();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { lruMemoize, createSelectorCreator } from 'reselect';
|
|
2
|
+
const reselectCreateSelector = createSelectorCreator({
|
|
3
|
+
memoize: lruMemoize,
|
|
4
|
+
memoizeOptions: {
|
|
5
|
+
maxSize: 1,
|
|
6
|
+
equalityCheck: Object.is
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
const cache = new WeakMap();
|
|
10
|
+
/**
|
|
11
|
+
* Method wrapping reselect's createSelector to provide caching for chart instances.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export const createSelector = (...createSelectorArgs) => {
|
|
15
|
+
const selector = (state, selectorArgs) => {
|
|
16
|
+
const cacheKey = state.cacheKey;
|
|
17
|
+
|
|
18
|
+
// If there is no cache for the current chart instance, create one.
|
|
19
|
+
let cacheForCurrentChartInstance = cache.get(cacheKey);
|
|
20
|
+
if (!cacheForCurrentChartInstance) {
|
|
21
|
+
cacheForCurrentChartInstance = new Map();
|
|
22
|
+
cache.set(cacheKey, cacheForCurrentChartInstance);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// If there is a cached selector, execute it.
|
|
26
|
+
const cachedSelector = cacheForCurrentChartInstance.get(createSelectorArgs);
|
|
27
|
+
if (cachedSelector) {
|
|
28
|
+
return cachedSelector(state, selectorArgs);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Otherwise, create a new selector and cache it and execute it.
|
|
32
|
+
const fn = reselectCreateSelector(...createSelectorArgs);
|
|
33
|
+
cacheForCurrentChartInstance.set(createSelectorArgs, fn);
|
|
34
|
+
return fn(state, selectorArgs);
|
|
35
|
+
};
|
|
36
|
+
return selector;
|
|
37
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartStore } from "./plugins/utils/ChartStore.js";
|
|
3
|
+
let globalId = 0;
|
|
4
|
+
export function useCharts() {
|
|
5
|
+
const storeRef = React.useRef(null);
|
|
6
|
+
if (storeRef.current == null) {
|
|
7
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
8
|
+
globalId += 1;
|
|
9
|
+
const initialState = {
|
|
10
|
+
interaction: {
|
|
11
|
+
item: null,
|
|
12
|
+
axis: {
|
|
13
|
+
x: null,
|
|
14
|
+
y: null
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
cacheKey: {
|
|
18
|
+
id: globalId
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
storeRef.current = new ChartStore(initialState);
|
|
22
|
+
}
|
|
23
|
+
const contextValue = React.useMemo(() => ({
|
|
24
|
+
store: storeRef.current
|
|
25
|
+
}), []);
|
|
26
|
+
return {
|
|
27
|
+
contextValue
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector';
|
|
2
|
+
const defaultCompare = Object.is;
|
|
3
|
+
export const useSelector = (store, selector, args = undefined, equals = defaultCompare) => {
|
|
4
|
+
const selectorWithArgs = state => selector(state, args);
|
|
5
|
+
return useSyncExternalStoreWithSelector(store.subscribe, store.getSnapshot, store.getSnapshot, selectorWithArgs, equals);
|
|
6
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartsContext } from "../context/InteractionProvider.js";
|
|
3
|
+
export function useStore(skipError) {
|
|
4
|
+
const charts = React.useContext(ChartsContext);
|
|
5
|
+
if (skipError) {
|
|
6
|
+
// TODO: Remove once store is used by all charts.
|
|
7
|
+
// This line is only for `useAxisEvents` which is in the surface of the Gauge.
|
|
8
|
+
// But the Gauge don't have store yet because it does not need the interaction provider.
|
|
9
|
+
// Will be fixed when every thing move to the store since every component will have access to it.
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
return charts?.store;
|
|
12
|
+
}
|
|
13
|
+
if (!charts) {
|
|
14
|
+
throw new Error(['MUI X: Could not find the charts context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
15
|
+
}
|
|
16
|
+
return charts.store;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.AnimatedBarElement = AnimatedBarElement;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _web = require("@react-spring/web");
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
const _excluded = ["ownerState"];
|
|
16
|
+
/**
|
|
17
|
+
* @ignore - internal component.
|
|
18
|
+
*/
|
|
19
|
+
function AnimatedBarElement(props) {
|
|
20
|
+
const {
|
|
21
|
+
ownerState
|
|
22
|
+
} = props,
|
|
23
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_web.animated.rect, (0, _extends2.default)({}, other, {
|
|
25
|
+
filter: ownerState.isHighlighted ? 'brightness(120%)' : undefined,
|
|
26
|
+
opacity: ownerState.isFaded ? 0.3 : 1
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
@@ -12,7 +12,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
var _styles = require("@mui/material/styles");
|
|
14
14
|
var _BarPlot = require("./BarPlot");
|
|
15
|
-
var
|
|
15
|
+
var _ChartContainer = require("../ChartContainer");
|
|
16
16
|
var _ChartsAxis = require("../ChartsAxis");
|
|
17
17
|
var _ChartsTooltip = require("../ChartsTooltip");
|
|
18
18
|
var _ChartsLegend = require("../ChartsLegend");
|
|
@@ -50,15 +50,15 @@ const BarChart = exports.BarChart = /*#__PURE__*/React.forwardRef(function BarCh
|
|
|
50
50
|
chartsAxisProps,
|
|
51
51
|
axisHighlightProps,
|
|
52
52
|
legendProps,
|
|
53
|
-
tooltipProps,
|
|
54
53
|
children
|
|
55
54
|
} = (0, _useBarChartProps.useBarChartProps)(props);
|
|
56
|
-
|
|
55
|
+
const Tooltip = props.slots?.tooltip ?? _ChartsTooltip.ChartsTooltip;
|
|
56
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartContainer.ChartContainer, (0, _extends2.default)({
|
|
57
57
|
ref: ref
|
|
58
58
|
}, chartContainerProps, {
|
|
59
59
|
children: [props.onAxisClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOnAxisClickHandler.ChartsOnAxisClickHandler, (0, _extends2.default)({}, axisClickHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", (0, _extends2.default)({}, clipPathGroupProps, {
|
|
60
60
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_BarPlot.BarPlot, (0, _extends2.default)({}, barPlotProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps))]
|
|
61
|
-
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
61
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), !props.hideLegend && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tooltip, (0, _extends2.default)({}, props.slotProps?.tooltip)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsClipPath.ChartsClipPath, (0, _extends2.default)({}, clipPathProps)), children]
|
|
62
62
|
}));
|
|
63
63
|
});
|
|
64
64
|
process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
@@ -70,7 +70,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
70
70
|
* The configuration of axes highlight.
|
|
71
71
|
* Default is set to 'band' in the bar direction.
|
|
72
72
|
* Depends on `layout` prop.
|
|
73
|
-
* @see See {@link https://mui.com/x/react-charts/highlighting highlighting docs} for more details.
|
|
73
|
+
* @see See {@link https://mui.com/x/react-charts/highlighting/ highlighting docs} for more details.
|
|
74
74
|
*/
|
|
75
75
|
axisHighlight: _propTypes.default.shape({
|
|
76
76
|
x: _propTypes.default.oneOf(['band', 'line', 'none']),
|
|
@@ -123,6 +123,10 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
123
123
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
124
124
|
*/
|
|
125
125
|
height: _propTypes.default.number,
|
|
126
|
+
/**
|
|
127
|
+
* If `true`, the legend is not rendered.
|
|
128
|
+
*/
|
|
129
|
+
hideLegend: _propTypes.default.bool,
|
|
126
130
|
/**
|
|
127
131
|
* The item currently highlighted. Turns highlighting into a controlled prop.
|
|
128
132
|
*/
|
|
@@ -141,32 +145,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
141
145
|
* @default yAxisIds[0] The id of the first provided axis
|
|
142
146
|
*/
|
|
143
147
|
leftAxis: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string]),
|
|
144
|
-
/**
|
|
145
|
-
* @deprecated Consider using `slotProps.legend` instead.
|
|
146
|
-
*/
|
|
147
|
-
legend: _propTypes.default.shape({
|
|
148
|
-
classes: _propTypes.default.object,
|
|
149
|
-
direction: _propTypes.default.oneOf(['column', 'row']),
|
|
150
|
-
hidden: _propTypes.default.bool,
|
|
151
|
-
itemGap: _propTypes.default.number,
|
|
152
|
-
itemMarkHeight: _propTypes.default.number,
|
|
153
|
-
itemMarkWidth: _propTypes.default.number,
|
|
154
|
-
labelStyle: _propTypes.default.object,
|
|
155
|
-
markGap: _propTypes.default.number,
|
|
156
|
-
onItemClick: _propTypes.default.func,
|
|
157
|
-
padding: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
|
|
158
|
-
bottom: _propTypes.default.number,
|
|
159
|
-
left: _propTypes.default.number,
|
|
160
|
-
right: _propTypes.default.number,
|
|
161
|
-
top: _propTypes.default.number
|
|
162
|
-
})]),
|
|
163
|
-
position: _propTypes.default.shape({
|
|
164
|
-
horizontal: _propTypes.default.oneOf(['left', 'middle', 'right']).isRequired,
|
|
165
|
-
vertical: _propTypes.default.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
166
|
-
}),
|
|
167
|
-
slotProps: _propTypes.default.object,
|
|
168
|
-
slots: _propTypes.default.object
|
|
169
|
-
}),
|
|
170
148
|
/**
|
|
171
149
|
* If `true`, a loading overlay is displayed.
|
|
172
150
|
* @default false
|
|
@@ -203,16 +181,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
203
181
|
* @param {BarItemIdentifier} barItemIdentifier The bar item identifier.
|
|
204
182
|
*/
|
|
205
183
|
onItemClick: _propTypes.default.func,
|
|
206
|
-
/**
|
|
207
|
-
* The chart will try to wait for the parent container to resolve its size
|
|
208
|
-
* before it renders for the first time.
|
|
209
|
-
*
|
|
210
|
-
* This can be useful in some scenarios where the chart appear to grow after
|
|
211
|
-
* the first render, like when used inside a grid.
|
|
212
|
-
*
|
|
213
|
-
* @default false
|
|
214
|
-
*/
|
|
215
|
-
resolveSizeBeforeRender: _propTypes.default.bool,
|
|
216
184
|
/**
|
|
217
185
|
* Indicate which axis to display the right of the charts.
|
|
218
186
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -241,30 +209,12 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
241
209
|
slots: _propTypes.default.object,
|
|
242
210
|
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
243
211
|
title: _propTypes.default.string,
|
|
244
|
-
/**
|
|
245
|
-
* The configuration of the tooltip.
|
|
246
|
-
* @see See {@link https://mui.com/x/react-charts/tooltip/ tooltip docs} for more details.
|
|
247
|
-
*/
|
|
248
|
-
tooltip: _propTypes.default.shape({
|
|
249
|
-
axisContent: _propTypes.default.elementType,
|
|
250
|
-
classes: _propTypes.default.object,
|
|
251
|
-
itemContent: _propTypes.default.elementType,
|
|
252
|
-
slotProps: _propTypes.default.object,
|
|
253
|
-
slots: _propTypes.default.object,
|
|
254
|
-
trigger: _propTypes.default.oneOf(['axis', 'item', 'none'])
|
|
255
|
-
}),
|
|
256
212
|
/**
|
|
257
213
|
* Indicate which axis to display the top of the charts.
|
|
258
214
|
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
259
215
|
* @default null
|
|
260
216
|
*/
|
|
261
217
|
topAxis: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.string]),
|
|
262
|
-
viewBox: _propTypes.default.shape({
|
|
263
|
-
height: _propTypes.default.number,
|
|
264
|
-
width: _propTypes.default.number,
|
|
265
|
-
x: _propTypes.default.number,
|
|
266
|
-
y: _propTypes.default.number
|
|
267
|
-
}),
|
|
268
218
|
/**
|
|
269
219
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
270
220
|
*/
|