@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
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
+
const _excluded = ["trigger", "classes", "children"];
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import useLazyRef from '@mui/utils/useLazyRef';
|
|
9
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
10
|
+
import Popper from '@mui/material/Popper';
|
|
11
|
+
import NoSsr from '@mui/material/NoSsr';
|
|
12
|
+
import { useSvgRef } from "../hooks/useSvgRef.js";
|
|
13
|
+
import { usePointerType } from "./utils.js";
|
|
14
|
+
import { useSelector } from "../internals/useSelector.js";
|
|
15
|
+
import { useStore } from "../internals/useStore.js";
|
|
16
|
+
import { useXAxis } from "../hooks/index.js";
|
|
17
|
+
import { selectorChartsInteractionItemIsDefined, selectorChartsInteractionXAxisIsDefined, selectorChartsInteractionYAxisIsDefined } from "../context/InteractionSelectors.js";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
const ChartsTooltipRoot = styled(Popper, {
|
|
20
|
+
name: 'MuiChartsTooltip',
|
|
21
|
+
slot: 'Root',
|
|
22
|
+
overridesResolver: (_, styles) => styles.root
|
|
23
|
+
})(({
|
|
24
|
+
theme
|
|
25
|
+
}) => ({
|
|
26
|
+
pointerEvents: 'none',
|
|
27
|
+
zIndex: theme.zIndex.modal
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Demos:
|
|
32
|
+
*
|
|
33
|
+
* - [ChartsTooltip](https://mui.com/x/react-charts/tooltip/)
|
|
34
|
+
*
|
|
35
|
+
* API:
|
|
36
|
+
*
|
|
37
|
+
* - [ChartsTooltip API](https://mui.com/x/api/charts/charts-tool-tip/)
|
|
38
|
+
*/
|
|
39
|
+
function ChartsTooltipContainer(inProps) {
|
|
40
|
+
const props = useThemeProps({
|
|
41
|
+
props: inProps,
|
|
42
|
+
name: 'MuiChartsTooltipContainer'
|
|
43
|
+
});
|
|
44
|
+
const {
|
|
45
|
+
trigger = 'axis',
|
|
46
|
+
classes,
|
|
47
|
+
children
|
|
48
|
+
} = props,
|
|
49
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
50
|
+
const svgRef = useSvgRef();
|
|
51
|
+
const pointerType = usePointerType();
|
|
52
|
+
const xAxis = useXAxis();
|
|
53
|
+
const xAxisHasData = xAxis.data !== undefined && xAxis.data.length !== 0;
|
|
54
|
+
const popperRef = React.useRef(null);
|
|
55
|
+
const positionRef = useLazyRef(() => ({
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0
|
|
58
|
+
}));
|
|
59
|
+
const store = useStore();
|
|
60
|
+
const isOpen = useSelector(store,
|
|
61
|
+
// eslint-disable-next-line no-nested-ternary
|
|
62
|
+
trigger === 'axis' ? xAxisHasData ? selectorChartsInteractionXAxisIsDefined : selectorChartsInteractionYAxisIsDefined : selectorChartsInteractionItemIsDefined);
|
|
63
|
+
const popperOpen = pointerType !== null && isOpen; // tooltipHasData;
|
|
64
|
+
|
|
65
|
+
React.useEffect(() => {
|
|
66
|
+
const element = svgRef.current;
|
|
67
|
+
if (element === null) {
|
|
68
|
+
return () => {};
|
|
69
|
+
}
|
|
70
|
+
const handleMove = event => {
|
|
71
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
72
|
+
positionRef.current = {
|
|
73
|
+
x: event.clientX,
|
|
74
|
+
y: event.clientY
|
|
75
|
+
};
|
|
76
|
+
popperRef.current?.update();
|
|
77
|
+
};
|
|
78
|
+
element.addEventListener('pointermove', handleMove);
|
|
79
|
+
return () => {
|
|
80
|
+
element.removeEventListener('pointermove', handleMove);
|
|
81
|
+
};
|
|
82
|
+
}, [svgRef, positionRef]);
|
|
83
|
+
if (trigger === 'none') {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /*#__PURE__*/_jsx(NoSsr, {
|
|
87
|
+
children: popperOpen && /*#__PURE__*/_jsx(ChartsTooltipRoot, _extends({
|
|
88
|
+
className: classes?.root,
|
|
89
|
+
open: popperOpen,
|
|
90
|
+
placement: pointerType?.pointerType === 'mouse' ? 'right-start' : 'top',
|
|
91
|
+
popperRef: popperRef,
|
|
92
|
+
anchorEl: {
|
|
93
|
+
getBoundingClientRect: () => ({
|
|
94
|
+
x: positionRef.current.x,
|
|
95
|
+
y: positionRef.current.y,
|
|
96
|
+
top: positionRef.current.y,
|
|
97
|
+
left: positionRef.current.x,
|
|
98
|
+
right: positionRef.current.x,
|
|
99
|
+
bottom: positionRef.current.y,
|
|
100
|
+
width: 0,
|
|
101
|
+
height: 0,
|
|
102
|
+
toJSON: () => ''
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
modifiers: [{
|
|
106
|
+
name: 'offset',
|
|
107
|
+
options: {
|
|
108
|
+
offset: [0, pointerType?.pointerType === 'touch' ? 40 - pointerType.height : 0]
|
|
109
|
+
}
|
|
110
|
+
}]
|
|
111
|
+
}, other, {
|
|
112
|
+
children: children
|
|
113
|
+
}))
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
process.env.NODE_ENV !== "production" ? ChartsTooltipContainer.propTypes = {
|
|
117
|
+
// ----------------------------- Warning --------------------------------
|
|
118
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
119
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
120
|
+
// ----------------------------------------------------------------------
|
|
121
|
+
/**
|
|
122
|
+
* An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
|
|
123
|
+
* or a function that returns either.
|
|
124
|
+
* It's used to set the position of the popper.
|
|
125
|
+
* The return value will passed as the reference object of the Popper instance.
|
|
126
|
+
*/
|
|
127
|
+
anchorEl: PropTypes.oneOfType([(props, propName) => {
|
|
128
|
+
if (props[propName] == null) {
|
|
129
|
+
return new Error(`Prop '${propName}' is required but wasn't specified`);
|
|
130
|
+
}
|
|
131
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
132
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}, PropTypes.func, PropTypes.shape({
|
|
136
|
+
contextElement: (props, propName) => {
|
|
137
|
+
if (props[propName] == null) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
141
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
},
|
|
145
|
+
getBoundingClientRect: PropTypes.func.isRequired
|
|
146
|
+
})]),
|
|
147
|
+
/**
|
|
148
|
+
* Popper render function or node.
|
|
149
|
+
*/
|
|
150
|
+
children: PropTypes.node,
|
|
151
|
+
/**
|
|
152
|
+
* Override or extend the styles applied to the component.
|
|
153
|
+
*/
|
|
154
|
+
classes: PropTypes.object,
|
|
155
|
+
/**
|
|
156
|
+
* The component used for the root node.
|
|
157
|
+
* Either a string to use a HTML element or a component.
|
|
158
|
+
*/
|
|
159
|
+
component: PropTypes.elementType,
|
|
160
|
+
/**
|
|
161
|
+
* The components used for each slot inside the Popper.
|
|
162
|
+
* Either a string to use a HTML element or a component.
|
|
163
|
+
* @default {}
|
|
164
|
+
*/
|
|
165
|
+
components: PropTypes.shape({
|
|
166
|
+
Root: PropTypes.elementType
|
|
167
|
+
}),
|
|
168
|
+
/**
|
|
169
|
+
* The props used for each slot inside the Popper.
|
|
170
|
+
* @default {}
|
|
171
|
+
*/
|
|
172
|
+
componentsProps: PropTypes.shape({
|
|
173
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
174
|
+
}),
|
|
175
|
+
/**
|
|
176
|
+
* An HTML element or function that returns one.
|
|
177
|
+
* The `container` will have the portal children appended to it.
|
|
178
|
+
*
|
|
179
|
+
* You can also provide a callback, which is called in a React layout effect.
|
|
180
|
+
* This lets you set the container from a ref, and also makes server-side rendering possible.
|
|
181
|
+
*
|
|
182
|
+
* By default, it uses the body of the top-level document object,
|
|
183
|
+
* so it's simply `document.body` most of the time.
|
|
184
|
+
*/
|
|
185
|
+
container: PropTypes.oneOfType([(props, propName) => {
|
|
186
|
+
if (props[propName] == null) {
|
|
187
|
+
return new Error(`Prop '${propName}' is required but wasn't specified`);
|
|
188
|
+
}
|
|
189
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
190
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
191
|
+
}
|
|
192
|
+
return null;
|
|
193
|
+
}, PropTypes.func]),
|
|
194
|
+
/**
|
|
195
|
+
* The `children` will be under the DOM hierarchy of the parent component.
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
disablePortal: PropTypes.bool,
|
|
199
|
+
/**
|
|
200
|
+
* Always keep the children in the DOM.
|
|
201
|
+
* This prop can be useful in SEO situation or
|
|
202
|
+
* when you want to maximize the responsiveness of the Popper.
|
|
203
|
+
* @default false
|
|
204
|
+
*/
|
|
205
|
+
keepMounted: PropTypes.bool,
|
|
206
|
+
/**
|
|
207
|
+
* Popper.js is based on a "plugin-like" architecture,
|
|
208
|
+
* most of its features are fully encapsulated "modifiers".
|
|
209
|
+
*
|
|
210
|
+
* A modifier is a function that is called each time Popper.js needs to
|
|
211
|
+
* compute the position of the popper.
|
|
212
|
+
* For this reason, modifiers should be very performant to avoid bottlenecks.
|
|
213
|
+
* To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
|
|
214
|
+
*/
|
|
215
|
+
modifiers: PropTypes.arrayOf(PropTypes.shape({
|
|
216
|
+
data: PropTypes.object,
|
|
217
|
+
effect: PropTypes.func,
|
|
218
|
+
enabled: PropTypes.bool,
|
|
219
|
+
fn: PropTypes.func,
|
|
220
|
+
name: PropTypes.any,
|
|
221
|
+
options: PropTypes.object,
|
|
222
|
+
phase: PropTypes.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
|
|
223
|
+
requires: PropTypes.arrayOf(PropTypes.string),
|
|
224
|
+
requiresIfExists: PropTypes.arrayOf(PropTypes.string)
|
|
225
|
+
})),
|
|
226
|
+
/**
|
|
227
|
+
* If `true`, the component is shown.
|
|
228
|
+
*/
|
|
229
|
+
open: PropTypes.bool,
|
|
230
|
+
/**
|
|
231
|
+
* Popper placement.
|
|
232
|
+
* @default 'bottom'
|
|
233
|
+
*/
|
|
234
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
235
|
+
/**
|
|
236
|
+
* Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
|
|
237
|
+
* @default {}
|
|
238
|
+
*/
|
|
239
|
+
popperOptions: PropTypes.shape({
|
|
240
|
+
modifiers: PropTypes.array,
|
|
241
|
+
onFirstUpdate: PropTypes.func,
|
|
242
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
243
|
+
strategy: PropTypes.oneOf(['absolute', 'fixed'])
|
|
244
|
+
}),
|
|
245
|
+
/**
|
|
246
|
+
* A ref that points to the used popper instance.
|
|
247
|
+
*/
|
|
248
|
+
popperRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
249
|
+
current: PropTypes.shape({
|
|
250
|
+
destroy: PropTypes.func.isRequired,
|
|
251
|
+
forceUpdate: PropTypes.func.isRequired,
|
|
252
|
+
setOptions: PropTypes.func.isRequired,
|
|
253
|
+
state: PropTypes.shape({
|
|
254
|
+
attributes: PropTypes.object.isRequired,
|
|
255
|
+
elements: PropTypes.object.isRequired,
|
|
256
|
+
modifiersData: PropTypes.object.isRequired,
|
|
257
|
+
options: PropTypes.object.isRequired,
|
|
258
|
+
orderedModifiers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
259
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']).isRequired,
|
|
260
|
+
rects: PropTypes.object.isRequired,
|
|
261
|
+
reset: PropTypes.bool.isRequired,
|
|
262
|
+
scrollParents: PropTypes.object.isRequired,
|
|
263
|
+
strategy: PropTypes.oneOf(['absolute', 'fixed']).isRequired,
|
|
264
|
+
styles: PropTypes.object.isRequired
|
|
265
|
+
}).isRequired,
|
|
266
|
+
update: PropTypes.func.isRequired
|
|
267
|
+
})
|
|
268
|
+
})]),
|
|
269
|
+
/**
|
|
270
|
+
* The props used for each slot inside the Popper.
|
|
271
|
+
* @default {}
|
|
272
|
+
*/
|
|
273
|
+
slotProps: PropTypes.object,
|
|
274
|
+
/**
|
|
275
|
+
* The components used for each slot inside the Popper.
|
|
276
|
+
* Either a string to use a HTML element or a component.
|
|
277
|
+
* @default {}
|
|
278
|
+
*/
|
|
279
|
+
slots: PropTypes.object,
|
|
280
|
+
/**
|
|
281
|
+
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
282
|
+
*/
|
|
283
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
284
|
+
/**
|
|
285
|
+
* Help supporting a react-transition-group/Transition component.
|
|
286
|
+
* @default false
|
|
287
|
+
*/
|
|
288
|
+
transition: PropTypes.bool,
|
|
289
|
+
/**
|
|
290
|
+
* Select the kind of tooltip to display
|
|
291
|
+
* - 'item': Shows data about the item below the mouse.
|
|
292
|
+
* - 'axis': Shows values associated with the hovered x value
|
|
293
|
+
* - 'none': Does not display tooltip
|
|
294
|
+
* @default 'axis'
|
|
295
|
+
*/
|
|
296
|
+
trigger: PropTypes.oneOf(['axis', 'item', 'none'])
|
|
297
|
+
} : void 0;
|
|
298
|
+
export { ChartsTooltipContainer };
|
|
@@ -21,3 +21,4 @@ export interface ChartsTooltipClasses {
|
|
|
21
21
|
export type ChartsTooltipClassKey = keyof Omit<ChartsTooltipClasses, 'markCell' | 'labelCell' | 'valueCell'>;
|
|
22
22
|
export declare function getChartsTooltipUtilityClass(slot: string): string;
|
|
23
23
|
export declare const chartsTooltipClasses: ChartsTooltipClasses;
|
|
24
|
+
export declare const useUtilityClasses: (classes?: Partial<ChartsTooltipClasses>) => Record<"cell" | "table" | "row" | "mark" | "root" | "paper" | "markCell" | "labelCell" | "valueCell", string>;
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
2
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
3
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
2
4
|
export function getChartsTooltipUtilityClass(slot) {
|
|
3
5
|
return generateUtilityClass('MuiChartsTooltip', slot);
|
|
4
6
|
}
|
|
5
|
-
export const chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'paper', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell']);
|
|
7
|
+
export const chartsTooltipClasses = generateUtilityClasses('MuiChartsTooltip', ['root', 'paper', 'table', 'row', 'cell', 'mark', 'markCell', 'labelCell', 'valueCell']);
|
|
8
|
+
export const useUtilityClasses = classes => {
|
|
9
|
+
const slots = {
|
|
10
|
+
root: ['root'],
|
|
11
|
+
paper: ['paper'],
|
|
12
|
+
table: ['table'],
|
|
13
|
+
row: ['row'],
|
|
14
|
+
cell: ['cell'],
|
|
15
|
+
mark: ['mark'],
|
|
16
|
+
markCell: ['markCell'],
|
|
17
|
+
labelCell: ['labelCell'],
|
|
18
|
+
valueCell: ['valueCell']
|
|
19
|
+
};
|
|
20
|
+
return composeClasses(slots, getChartsTooltipUtilityClass, classes);
|
|
21
|
+
};
|
package/ChartsTooltip/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export * from './ChartsTooltip';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './ChartsTooltipContainer';
|
|
3
|
+
export type { ChartsTooltipClasses, ChartsTooltipClassKey } from './chartsTooltipClasses';
|
|
4
|
+
export { getChartsTooltipUtilityClass, chartsTooltipClasses } from './chartsTooltipClasses';
|
|
3
5
|
export * from './ChartsAxisTooltipContent';
|
|
4
6
|
export * from './ChartsItemTooltipContent';
|
|
5
|
-
export * from './DefaultChartsAxisTooltipContent';
|
|
6
|
-
export * from './DefaultChartsItemTooltipContent';
|
|
7
7
|
export * from './ChartsTooltipTable';
|
|
8
8
|
export * from './useItemTooltip';
|
|
9
9
|
export * from './useAxisTooltip';
|
package/ChartsTooltip/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export * from "./ChartsTooltip.js";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./ChartsTooltipContainer.js";
|
|
3
|
+
export { getChartsTooltipUtilityClass, chartsTooltipClasses } from "./chartsTooltipClasses.js";
|
|
3
4
|
export * from "./ChartsAxisTooltipContent.js";
|
|
4
5
|
export * from "./ChartsItemTooltipContent.js";
|
|
5
|
-
export * from "./DefaultChartsAxisTooltipContent.js";
|
|
6
|
-
export * from "./DefaultChartsItemTooltipContent.js";
|
|
7
6
|
export * from "./ChartsTooltipTable.js";
|
|
8
7
|
export * from "./useItemTooltip.js";
|
|
9
8
|
export * from "./useAxisTooltip.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AxisInteractionData } from '../context/InteractionProvider';
|
|
2
1
|
import { SeriesId } from '../models/seriesType/common';
|
|
3
2
|
import { CartesianChartSeriesType, ChartsSeriesConfig } from '../models/seriesType/config';
|
|
4
3
|
export interface UseAxisTooltipReturnValue<SeriesT extends CartesianChartSeriesType = CartesianChartSeriesType, AxisValueT extends string | number | Date = string | number | Date> {
|
|
5
|
-
|
|
4
|
+
axisDirection: 'x' | 'y';
|
|
5
|
+
dataIndex: number;
|
|
6
6
|
seriesItems: SeriesItem<SeriesT>[];
|
|
7
7
|
axisValue: AxisValueT;
|
|
8
8
|
axisFormattedValue: string;
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
5
4
|
import { useSeries } from "../hooks/useSeries.js";
|
|
6
5
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
7
6
|
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
8
7
|
import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
|
|
8
|
+
import { useStore } from "../internals/useStore.js";
|
|
9
|
+
import { useSelector } from "../internals/useSelector.js";
|
|
9
10
|
import { getLabel } from "../internals/getLabel.js";
|
|
10
11
|
import { isCartesianSeriesType } from "../internals/isCartesian.js";
|
|
11
12
|
import { utcFormatter } from "./utils.js";
|
|
13
|
+
import { useXAxis, useYAxis } from "../hooks/useAxis.js";
|
|
14
|
+
import { selectorChartsInteractionXAxis, selectorChartsInteractionYAxis } from "../context/InteractionSelectors.js";
|
|
12
15
|
export function useAxisTooltip() {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const defaultXAxis = useXAxis();
|
|
17
|
+
const defaultYAxis = useYAxis();
|
|
18
|
+
const xAxisHasData = defaultXAxis.data !== undefined && defaultXAxis.data.length !== 0;
|
|
19
|
+
const store = useStore();
|
|
20
|
+
const axisData = useSelector(store, xAxisHasData ? selectorChartsInteractionXAxis : selectorChartsInteractionYAxis);
|
|
16
21
|
const series = useSeries();
|
|
17
22
|
const {
|
|
18
23
|
xAxis,
|
|
19
|
-
yAxis
|
|
20
|
-
xAxisIds,
|
|
21
|
-
yAxisIds
|
|
24
|
+
yAxis
|
|
22
25
|
} = useCartesianContext();
|
|
23
26
|
const {
|
|
24
27
|
zAxis,
|
|
25
28
|
zAxisIds
|
|
26
29
|
} = React.useContext(ZAxisContext);
|
|
27
30
|
const colorProcessors = useColorProcessor();
|
|
28
|
-
|
|
29
|
-
// By default use the x-axis
|
|
30
|
-
const isXaxis = axis.x !== null && axis.x.index !== -1;
|
|
31
|
-
const axisData = isXaxis ? axis.x && axis.x : axis.y && axis.y;
|
|
32
31
|
if (axisData === null) {
|
|
33
32
|
return null;
|
|
34
33
|
}
|
|
@@ -36,8 +35,8 @@ export function useAxisTooltip() {
|
|
|
36
35
|
index: dataIndex,
|
|
37
36
|
value: axisValue
|
|
38
37
|
} = axisData;
|
|
39
|
-
const USED_AXIS_ID =
|
|
40
|
-
const usedAxis =
|
|
38
|
+
const USED_AXIS_ID = xAxisHasData ? defaultXAxis.id : defaultYAxis.id;
|
|
39
|
+
const usedAxis = xAxisHasData ? defaultXAxis : defaultYAxis;
|
|
41
40
|
const relevantSeries = Object.keys(series).filter(isCartesianSeriesType).flatMap(seriesType => {
|
|
42
41
|
const seriesOfType = series[seriesType];
|
|
43
42
|
if (!seriesOfType) {
|
|
@@ -45,16 +44,16 @@ export function useAxisTooltip() {
|
|
|
45
44
|
}
|
|
46
45
|
return seriesOfType.seriesOrder.map(seriesId => {
|
|
47
46
|
const seriesToAdd = seriesOfType.series[seriesId];
|
|
48
|
-
const providedXAxisId = seriesToAdd.xAxisId
|
|
49
|
-
const providedYAxisId = seriesToAdd.yAxisId
|
|
50
|
-
const axisKey =
|
|
47
|
+
const providedXAxisId = seriesToAdd.xAxisId;
|
|
48
|
+
const providedYAxisId = seriesToAdd.yAxisId;
|
|
49
|
+
const axisKey = xAxisHasData ? providedXAxisId : providedYAxisId;
|
|
51
50
|
|
|
52
51
|
// Test if the series uses the default axis
|
|
53
52
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
54
|
-
const xAxisId = providedXAxisId ??
|
|
55
|
-
const yAxisId = providedYAxisId ??
|
|
56
|
-
const zAxisId =
|
|
57
|
-
const color = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId
|
|
53
|
+
const xAxisId = providedXAxisId ?? defaultXAxis.id;
|
|
54
|
+
const yAxisId = providedYAxisId ?? defaultYAxis.id;
|
|
55
|
+
const zAxisId = 'zAxisId' in seriesToAdd ? seriesToAdd.zAxisId : zAxisIds[0];
|
|
56
|
+
const color = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId ? zAxis[zAxisId] : undefined)(dataIndex) ?? '';
|
|
58
57
|
const value = seriesToAdd.data[dataIndex] ?? null;
|
|
59
58
|
const formattedValue = seriesToAdd.valueFormatter(value, {
|
|
60
59
|
dataIndex
|
|
@@ -76,7 +75,8 @@ export function useAxisTooltip() {
|
|
|
76
75
|
location: 'tooltip'
|
|
77
76
|
});
|
|
78
77
|
return {
|
|
79
|
-
|
|
78
|
+
axisDirection: xAxisHasData ? 'x' : 'y',
|
|
79
|
+
dataIndex,
|
|
80
80
|
seriesItems: relevantSeries,
|
|
81
81
|
axisValue,
|
|
82
82
|
axisFormattedValue
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ItemInteractionData } from '../context/InteractionProvider';
|
|
2
1
|
import { ChartSeriesType, ChartsSeriesConfig } from '../models/seriesType/config';
|
|
2
|
+
import { ItemInteractionData } from '../internals/plugins/models';
|
|
3
3
|
export interface UseItemTooltipReturnValue<T extends ChartSeriesType> {
|
|
4
4
|
identifier: ItemInteractionData<T>;
|
|
5
5
|
color: string;
|
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { InteractionContext } from "../context/InteractionProvider.js";
|
|
6
5
|
import { useSeries } from "../hooks/useSeries.js";
|
|
7
6
|
import { useCartesianContext } from "../context/CartesianProvider/index.js";
|
|
8
7
|
import { ZAxisContext } from "../context/ZAxisContextProvider.js";
|
|
9
8
|
import { useColorProcessor } from "../context/PluginProvider/useColorProcessor.js";
|
|
10
9
|
import { getLabel } from "../internals/getLabel.js";
|
|
10
|
+
import { selectorChartsInteractionItem } from "../context/InteractionSelectors.js";
|
|
11
|
+
import { useSelector } from "../internals/useSelector.js";
|
|
12
|
+
import { useStore } from "../internals/useStore.js";
|
|
11
13
|
export function useItemTooltip() {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
} = React.useContext(InteractionContext);
|
|
14
|
+
const store = useStore();
|
|
15
|
+
const item = useSelector(store, selectorChartsInteractionItem);
|
|
15
16
|
const series = useSeries();
|
|
16
17
|
const {
|
|
17
18
|
xAxis,
|
|
@@ -24,9 +25,9 @@ export function useItemTooltip() {
|
|
|
24
25
|
zAxisIds
|
|
25
26
|
} = React.useContext(ZAxisContext);
|
|
26
27
|
const colorProcessors = useColorProcessor();
|
|
27
|
-
const xAxisId = series.xAxisId ??
|
|
28
|
-
const yAxisId = series.yAxisId ??
|
|
29
|
-
const zAxisId = series.zAxisId ??
|
|
28
|
+
const xAxisId = series.xAxisId ?? xAxisIds[0];
|
|
29
|
+
const yAxisId = series.yAxisId ?? yAxisIds[0];
|
|
30
|
+
const zAxisId = series.zAxisId ?? zAxisIds[0];
|
|
30
31
|
if (!item || item.dataIndex === undefined) {
|
|
31
32
|
return null;
|
|
32
33
|
}
|
package/ChartsTooltip/utils.d.ts
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
import { AxisInteractionData, ItemInteractionData } from '../context/InteractionProvider';
|
|
2
|
-
import { ChartSeriesType } from '../models/seriesType/config';
|
|
3
1
|
type MousePosition = {
|
|
4
2
|
x: number;
|
|
5
3
|
y: number;
|
|
6
4
|
pointerType: 'mouse' | 'touch' | 'pen';
|
|
7
5
|
height: number;
|
|
8
6
|
};
|
|
9
|
-
export declare function generateVirtualElement(mousePosition: MousePosition | null): {
|
|
10
|
-
getBoundingClientRect: () => {
|
|
11
|
-
width: number;
|
|
12
|
-
height: number;
|
|
13
|
-
x: number;
|
|
14
|
-
y: number;
|
|
15
|
-
top: number;
|
|
16
|
-
right: number;
|
|
17
|
-
bottom: number;
|
|
18
|
-
left: number;
|
|
19
|
-
toJSON: () => string;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
7
|
export type UseMouseTrackerReturnValue = null | MousePosition;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated We recommend using vanilla JS to let popper track mouse position.
|
|
10
|
+
*/
|
|
23
11
|
export declare function useMouseTracker(): UseMouseTrackerReturnValue;
|
|
12
|
+
type PointerType = Pick<MousePosition, 'height' | 'pointerType'>;
|
|
13
|
+
export declare function usePointerType(): null | PointerType;
|
|
24
14
|
export type TriggerOptions = 'item' | 'axis' | 'none';
|
|
25
|
-
export declare function getTooltipHasData(trigger: TriggerOptions, displayedData: null | AxisInteractionData | ItemInteractionData<ChartSeriesType>): boolean;
|
|
26
15
|
export declare function utcFormatter(v: string | number | Date): string;
|
|
27
16
|
export {};
|
package/ChartsTooltip/utils.js
CHANGED
|
@@ -1,42 +1,8 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { useSvgRef } from "../hooks/index.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
getBoundingClientRect: () => ({
|
|
8
|
-
width: 0,
|
|
9
|
-
height: 0,
|
|
10
|
-
x: 0,
|
|
11
|
-
y: 0,
|
|
12
|
-
top: 0,
|
|
13
|
-
right: 0,
|
|
14
|
-
bottom: 0,
|
|
15
|
-
left: 0,
|
|
16
|
-
toJSON: () => ''
|
|
17
|
-
})
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
const {
|
|
21
|
-
x,
|
|
22
|
-
y
|
|
23
|
-
} = mousePosition;
|
|
24
|
-
const boundingBox = {
|
|
25
|
-
width: 0,
|
|
26
|
-
height: 0,
|
|
27
|
-
x,
|
|
28
|
-
y,
|
|
29
|
-
top: y,
|
|
30
|
-
right: x,
|
|
31
|
-
bottom: y,
|
|
32
|
-
left: x
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
35
|
-
getBoundingClientRect: () => _extends({}, boundingBox, {
|
|
36
|
-
toJSON: () => JSON.stringify(boundingBox)
|
|
37
|
-
})
|
|
38
|
-
};
|
|
39
|
-
}
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated We recommend using vanilla JS to let popper track mouse position.
|
|
5
|
+
*/
|
|
40
6
|
export function useMouseTracker() {
|
|
41
7
|
const svgRef = useSvgRef();
|
|
42
8
|
|
|
@@ -47,6 +13,7 @@ export function useMouseTracker() {
|
|
|
47
13
|
if (element === null) {
|
|
48
14
|
return () => {};
|
|
49
15
|
}
|
|
16
|
+
const controller = new AbortController();
|
|
50
17
|
const handleOut = event => {
|
|
51
18
|
if (event.pointerType !== 'mouse') {
|
|
52
19
|
setMousePosition(null);
|
|
@@ -60,24 +27,52 @@ export function useMouseTracker() {
|
|
|
60
27
|
pointerType: event.pointerType
|
|
61
28
|
});
|
|
62
29
|
};
|
|
63
|
-
element.addEventListener('pointerdown', handleMove
|
|
64
|
-
|
|
65
|
-
|
|
30
|
+
element.addEventListener('pointerdown', handleMove, {
|
|
31
|
+
signal: controller.signal
|
|
32
|
+
});
|
|
33
|
+
element.addEventListener('pointermove', handleMove, {
|
|
34
|
+
signal: controller.signal
|
|
35
|
+
});
|
|
36
|
+
element.addEventListener('pointerup', handleOut, {
|
|
37
|
+
signal: controller.signal
|
|
38
|
+
});
|
|
66
39
|
return () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
40
|
+
// Calling `.abort()` removes ALL event listeners
|
|
41
|
+
// For more info, see https://kettanaito.com/blog/dont-sleep-on-abort-controller
|
|
42
|
+
controller.abort();
|
|
70
43
|
};
|
|
71
44
|
}, [svgRef]);
|
|
72
45
|
return mousePosition;
|
|
73
46
|
}
|
|
74
|
-
export function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
47
|
+
export function usePointerType() {
|
|
48
|
+
const svgRef = useSvgRef();
|
|
49
|
+
|
|
50
|
+
// Use a ref to avoid rerendering on every mousemove event.
|
|
51
|
+
const [pointerType, setPointerType] = React.useState(null);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
const element = svgRef.current;
|
|
54
|
+
if (element === null) {
|
|
55
|
+
return () => {};
|
|
56
|
+
}
|
|
57
|
+
const handleOut = event => {
|
|
58
|
+
if (event.pointerType !== 'mouse') {
|
|
59
|
+
setPointerType(null);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const handleEnter = event => {
|
|
63
|
+
setPointerType({
|
|
64
|
+
height: event.height,
|
|
65
|
+
pointerType: event.pointerType
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
element.addEventListener('pointerenter', handleEnter);
|
|
69
|
+
element.addEventListener('pointerup', handleOut);
|
|
70
|
+
return () => {
|
|
71
|
+
element.removeEventListener('pointerenter', handleEnter);
|
|
72
|
+
element.removeEventListener('pointerup', handleOut);
|
|
73
|
+
};
|
|
74
|
+
}, [svgRef]);
|
|
75
|
+
return pointerType;
|
|
81
76
|
}
|
|
82
77
|
export function utcFormatter(v) {
|
|
83
78
|
if (v instanceof Date) {
|