@mui/x-charts 7.13.0 → 7.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +180 -183
- package/BarChart/BarClipPath.js +17 -25
- package/BarChart/BarElement.js +33 -43
- package/BarChart/BarLabel/BarLabel.d.ts +1 -1
- package/BarChart/BarLabel/BarLabel.js +25 -34
- package/BarChart/BarLabel/BarLabel.types.js +1 -5
- package/BarChart/BarLabel/BarLabelItem.js +31 -39
- package/BarChart/BarLabel/BarLabelPlot.js +13 -21
- package/BarChart/BarLabel/barLabelClasses.d.ts +1 -1
- package/BarChart/BarLabel/barLabelClasses.js +9 -19
- package/BarChart/BarLabel/getBarLabel.js +2 -9
- package/BarChart/BarLabel/index.js +2 -25
- package/BarChart/BarPlot.js +39 -46
- package/BarChart/checkScaleErrors.js +6 -12
- package/BarChart/extremums.js +45 -18
- package/BarChart/formatter.js +9 -16
- package/BarChart/getColor.js +1 -7
- package/BarChart/getRadius.js +2 -9
- package/BarChart/index.js +4 -49
- package/BarChart/legend.js +3 -9
- package/BarChart/package.json +2 -2
- package/BarChart/plugin.js +8 -15
- package/BarChart/types.js +1 -5
- package/BarChart/useBarChartProps.js +17 -25
- package/CHANGELOG.md +151 -2
- package/ChartContainer/ChartContainer.js +164 -172
- package/ChartContainer/index.js +1 -16
- package/ChartContainer/package.json +2 -2
- package/ChartContainer/useChartContainerProps.d.ts +8 -8
- package/ChartContainer/useChartContainerProps.js +13 -23
- package/ChartContainer/useDefaultizeAxis.d.ts +6 -5
- package/ChartContainer/useDefaultizeAxis.js +22 -21
- package/ChartsAxis/ChartsAxis.js +24 -32
- package/ChartsAxis/axisClasses.js +4 -11
- package/ChartsAxis/index.js +2 -27
- package/ChartsAxis/package.json +2 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +55 -51
- package/ChartsAxisHighlight/index.js +1 -16
- package/ChartsAxisHighlight/package.json +2 -2
- package/ChartsClipPath/ChartsClipPath.js +17 -25
- package/ChartsClipPath/index.js +1 -16
- package/ChartsClipPath/package.json +2 -2
- package/ChartsGrid/ChartsGrid.d.ts +1 -1
- package/ChartsGrid/ChartsGrid.js +38 -44
- package/ChartsGrid/chartsGridClasses.js +5 -13
- package/ChartsGrid/index.js +2 -27
- package/ChartsGrid/package.json +2 -2
- package/ChartsLegend/ChartsLegend.js +33 -41
- package/ChartsLegend/ContinuousColorLegend.js +66 -73
- package/ChartsLegend/DefaultChartsLegend.js +38 -46
- package/ChartsLegend/LegendPerItem.js +30 -39
- package/ChartsLegend/PiecewiseColorLegend.js +36 -44
- package/ChartsLegend/chartsLegend.types.js +1 -5
- package/ChartsLegend/chartsLegendClasses.js +4 -11
- package/ChartsLegend/index.js +6 -71
- package/ChartsLegend/legend.types.js +1 -5
- package/ChartsLegend/legendItemsPlacement.js +6 -13
- package/ChartsLegend/package.json +2 -2
- package/ChartsLegend/useAxis.js +6 -14
- package/ChartsLegend/utils.js +9 -16
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +15 -23
- package/ChartsOnAxisClickHandler/index.js +1 -16
- package/ChartsOnAxisClickHandler/package.json +2 -2
- package/ChartsOverlay/ChartsLoadingOverlay.js +12 -21
- package/ChartsOverlay/ChartsNoDataOverlay.js +12 -21
- package/ChartsOverlay/ChartsOverlay.js +13 -23
- package/ChartsOverlay/index.js +3 -26
- package/ChartsOverlay/package.json +2 -2
- package/ChartsReferenceLine/ChartsReferenceLine.js +21 -29
- package/ChartsReferenceLine/ChartsXReferenceLine.js +22 -31
- package/ChartsReferenceLine/ChartsYReferenceLine.js +22 -31
- package/ChartsReferenceLine/chartsReferenceLineClasses.js +5 -13
- package/ChartsReferenceLine/common.js +6 -13
- package/ChartsReferenceLine/index.js +2 -27
- package/ChartsReferenceLine/package.json +2 -2
- package/{modern → ChartsSurface}/ChartsSurface.js +7 -3
- package/ChartsSurface/index.d.ts +1 -0
- package/ChartsSurface/index.js +1 -0
- package/ChartsSurface/package.json +6 -0
- package/ChartsText/ChartsText.js +18 -26
- package/ChartsText/index.js +1 -12
- package/ChartsText/package.json +2 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.js +22 -30
- package/ChartsTooltip/ChartsItemTooltipContent.js +18 -26
- package/ChartsTooltip/ChartsTooltip.js +34 -42
- package/ChartsTooltip/ChartsTooltipTable.js +11 -16
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +44 -52
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +32 -40
- package/ChartsTooltip/chartsTooltipClasses.js +4 -11
- package/ChartsTooltip/index.js +7 -82
- package/ChartsTooltip/package.json +2 -2
- package/ChartsTooltip/utils.js +9 -21
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +29 -37
- package/ChartsVoronoiHandler/index.js +1 -16
- package/ChartsVoronoiHandler/package.json +2 -2
- package/ChartsXAxis/ChartsXAxis.js +90 -87
- package/ChartsXAxis/index.js +1 -16
- package/ChartsXAxis/package.json +2 -2
- package/ChartsYAxis/ChartsYAxis.js +78 -79
- package/ChartsYAxis/index.js +1 -16
- package/ChartsYAxis/package.json +2 -2
- package/Gauge/Gauge.js +52 -60
- package/Gauge/GaugeContainer.js +51 -59
- package/Gauge/GaugeProvider.js +17 -28
- package/Gauge/GaugeReferenceArc.js +11 -20
- package/Gauge/GaugeValueArc.js +11 -20
- package/Gauge/GaugeValueText.js +18 -26
- package/Gauge/gaugeClasses.js +6 -14
- package/Gauge/index.js +7 -87
- package/Gauge/package.json +2 -2
- package/Gauge/utils.js +2 -9
- package/LineChart/AnimatedArea.js +35 -44
- package/LineChart/AnimatedLine.js +36 -45
- package/LineChart/AreaElement.js +33 -43
- package/LineChart/AreaPlot.js +30 -38
- package/LineChart/LineChart.js +185 -188
- package/LineChart/LineElement.js +33 -43
- package/LineChart/LineHighlightElement.js +20 -30
- package/LineChart/LineHighlightPlot.js +28 -36
- package/LineChart/LinePlot.js +30 -38
- package/LineChart/MarkElement.js +40 -48
- package/LineChart/MarkPlot.js +33 -41
- package/LineChart/extremums.js +23 -15
- package/LineChart/formatter.js +9 -16
- package/LineChart/getColor.js +1 -7
- package/LineChart/index.js +11 -126
- package/LineChart/legend.js +3 -9
- package/LineChart/package.json +2 -2
- package/LineChart/plugin.js +8 -15
- package/LineChart/useLineChartProps.js +14 -22
- package/PieChart/PieArc.js +34 -44
- package/PieChart/PieArcLabel.js +30 -40
- package/PieChart/PieArcLabelPlot.js +59 -67
- package/PieChart/PieArcPlot.js +56 -64
- package/PieChart/PieChart.js +180 -183
- package/PieChart/PiePlot.js +29 -37
- package/PieChart/dataTransform/transition.js +2 -8
- package/PieChart/dataTransform/useTransformData.js +7 -16
- package/PieChart/formatter.js +10 -17
- package/PieChart/getColor.js +1 -7
- package/PieChart/getPieCoordinates.js +4 -10
- package/PieChart/index.js +7 -82
- package/PieChart/legend.js +3 -9
- package/PieChart/package.json +2 -2
- package/PieChart/plugin.js +5 -12
- package/ResponsiveChartContainer/ResizableContainer.js +2 -8
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +151 -159
- package/ResponsiveChartContainer/index.js +1 -16
- package/ResponsiveChartContainer/package.json +2 -2
- package/ResponsiveChartContainer/useChartContainerDimensions.js +7 -17
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +8 -16
- package/ScatterChart/Scatter.js +26 -34
- package/ScatterChart/ScatterChart.js +198 -201
- package/ScatterChart/ScatterPlot.js +21 -29
- package/ScatterChart/extremums.js +29 -21
- package/ScatterChart/formatter.js +3 -9
- package/ScatterChart/getColor.js +1 -7
- package/ScatterChart/index.js +3 -38
- package/ScatterChart/legend.js +3 -9
- package/ScatterChart/package.json +2 -2
- package/ScatterChart/plugin.js +8 -15
- package/ScatterChart/useScatterChartProps.js +10 -18
- package/SparkLineChart/SparkLineChart.js +163 -171
- package/SparkLineChart/index.js +1 -16
- package/SparkLineChart/package.json +2 -2
- package/colorPalettes/colorPalettes.js +9 -18
- package/colorPalettes/index.js +1 -16
- package/colorPalettes/package.json +2 -2
- package/constants/package.json +6 -0
- package/context/CartesianProvider/Cartesian.types.d.ts +59 -0
- package/context/CartesianProvider/CartesianContext.d.ts +1 -22
- package/context/CartesianProvider/CartesianContext.js +2 -10
- package/context/CartesianProvider/CartesianProvider.d.ts +1 -21
- package/context/CartesianProvider/CartesianProvider.js +19 -29
- package/context/CartesianProvider/computeValue.d.ts +18 -31
- package/context/CartesianProvider/computeValue.js +42 -52
- package/context/CartesianProvider/defaultizeAxis.d.ts +4 -4
- package/context/CartesianProvider/defaultizeAxis.js +6 -14
- package/context/CartesianProvider/getAxisExtremum.d.ts +3 -2
- package/context/CartesianProvider/getAxisExtremum.js +12 -13
- package/context/CartesianProvider/index.d.ts +1 -0
- package/context/CartesianProvider/index.js +8 -48
- package/context/CartesianProvider/useCartesianContext.d.ts +1 -1
- package/context/CartesianProvider/useCartesianContext.js +5 -14
- package/context/CartesianProvider/zoom.d.ts +10 -0
- package/context/CartesianProvider/zoom.js +19 -0
- package/context/DrawingProvider.d.ts +7 -2
- package/context/DrawingProvider.js +24 -27
- package/context/HighlightedProvider/HighlightedContext.js +2 -9
- package/context/HighlightedProvider/HighlightedProvider.js +24 -32
- package/context/HighlightedProvider/createIsFaded.js +2 -9
- package/context/HighlightedProvider/createIsHighlighted.js +2 -9
- package/context/HighlightedProvider/index.js +4 -49
- package/context/HighlightedProvider/useHighlighted.js +4 -11
- package/context/HighlightedProvider/useItemHighlighted.js +3 -9
- package/context/InteractionProvider.d.ts +2 -2
- package/context/InteractionProvider.js +13 -22
- package/context/PluginProvider/ColorProcessor.types.js +1 -5
- package/context/PluginProvider/ExtremumGetter.types.d.ts +11 -1
- package/context/PluginProvider/ExtremumGetter.types.js +1 -5
- package/context/PluginProvider/Plugin.types.js +1 -5
- package/context/PluginProvider/PluginContext.js +2 -10
- package/context/PluginProvider/PluginProvider.js +8 -15
- package/context/PluginProvider/SeriesFormatter.types.js +1 -5
- package/context/PluginProvider/index.js +10 -115
- package/context/PluginProvider/mergePlugins.d.ts +6 -6
- package/context/PluginProvider/mergePlugins.js +6 -13
- package/context/PluginProvider/useColorProcessor.js +4 -12
- package/context/PluginProvider/useSeriesFormatter.js +4 -12
- package/context/PluginProvider/useXExtremumGetter.js +4 -12
- package/context/PluginProvider/useYExtremumGetter.js +4 -12
- package/context/SeriesProvider/Series.types.js +1 -5
- package/context/SeriesProvider/SeriesContext.js +2 -10
- package/context/SeriesProvider/SeriesProvider.js +14 -21
- package/context/SeriesProvider/index.js +7 -48
- package/context/SeriesProvider/processSeries.js +6 -14
- package/context/ZAxisContextProvider.js +36 -45
- package/context/context.types.js +1 -5
- package/context/index.js +2 -27
- package/context/package.json +2 -2
- package/hooks/index.js +7 -115
- package/hooks/package.json +2 -2
- package/hooks/useAxis.js +5 -12
- package/hooks/useAxisEvents.js +20 -26
- package/hooks/useChartDimensions.js +5 -14
- package/hooks/useChartId.js +4 -12
- package/hooks/useColorScale.js +9 -19
- package/hooks/useDrawingArea.js +4 -12
- package/hooks/useInteractionItemProps.js +7 -16
- package/hooks/useMounted.js +4 -13
- package/hooks/useReducedMotion.js +6 -12
- package/hooks/useScale.js +8 -15
- package/hooks/useSeries.js +8 -19
- package/hooks/useSvgRef.js +4 -12
- package/hooks/useTicks.js +7 -16
- package/index.js +27 -292
- package/internals/SlotComponentPropsFromProps.js +1 -5
- package/internals/cleanId.js +1 -7
- package/internals/colorScale.js +8 -16
- package/internals/components/AxisSharedComponents.js +8 -15
- package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +17 -27
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +7 -15
- package/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +7 -15
- package/internals/components/ChartsAxesGradients/index.js +1 -16
- package/internals/configInit.js +1 -7
- package/internals/defaultizeColor.d.ts +16 -16
- package/internals/defaultizeColor.js +5 -12
- package/internals/defaultizeValueFormatter.js +3 -10
- package/internals/domUtils.d.ts +2 -0
- package/internals/domUtils.js +19 -15
- package/internals/geometry.js +1 -7
- package/internals/getCurve.js +11 -17
- package/internals/getLabel.js +1 -7
- package/internals/getPercentageValue.js +1 -7
- package/internals/getSVGPoint.js +1 -7
- package/internals/getScale.js +8 -14
- package/internals/getSymbol.js +1 -7
- package/internals/getWordsByLines.js +5 -12
- package/internals/index.d.ts +3 -0
- package/internals/index.js +40 -306
- package/internals/isBandScale.js +1 -7
- package/internals/isCartesian.js +4 -11
- package/internals/isDefined.js +1 -7
- package/internals/isInfinity.js +1 -7
- package/internals/notNull.js +1 -7
- package/internals/package.json +2 -2
- package/internals/stackSeries.js +16 -23
- package/internals/ts-generic.js +1 -5
- package/internals/useAnimatedPath.d.ts +1 -1
- package/internals/useAnimatedPath.js +21 -26
- package/internals/warning.js +2 -9
- package/models/axis.d.ts +4 -0
- package/models/axis.js +6 -8
- package/models/colorMapping.js +1 -5
- package/models/helpers.js +1 -5
- package/models/index.js +4 -38
- package/models/layout.js +1 -5
- package/models/package.json +2 -2
- package/models/seriesType/bar.js +1 -5
- package/models/seriesType/common.js +1 -5
- package/models/seriesType/config.js +1 -5
- package/models/seriesType/index.js +6 -61
- package/models/seriesType/line.js +1 -5
- package/models/seriesType/pie.js +1 -5
- package/models/seriesType/scatter.js +1 -5
- package/models/stacking.js +1 -5
- package/models/z-axis.js +1 -5
- package/modern/BarChart/BarChart.js +6 -1
- package/modern/BarChart/BarLabel/BarLabel.js +4 -4
- package/modern/BarChart/BarPlot.js +4 -3
- package/modern/BarChart/extremums.js +42 -7
- package/modern/ChartContainer/useChartContainerProps.js +1 -1
- package/modern/ChartContainer/useDefaultizeAxis.js +16 -5
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +23 -9
- package/modern/ChartsGrid/ChartsGrid.js +12 -10
- package/modern/ChartsLegend/ContinuousColorLegend.js +3 -2
- package/modern/ChartsLegend/LegendPerItem.js +5 -4
- package/{esm → modern/ChartsSurface}/ChartsSurface.js +7 -3
- package/modern/ChartsSurface/index.js +1 -0
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +1 -1
- package/modern/ChartsXAxis/ChartsXAxis.js +14 -3
- package/modern/ChartsYAxis/ChartsYAxis.js +11 -4
- package/modern/LineChart/LineChart.js +6 -1
- package/modern/LineChart/MarkElement.js +4 -2
- package/modern/LineChart/extremums.js +20 -4
- package/modern/PieChart/PieChart.js +10 -5
- package/modern/ScatterChart/ScatterChart.js +6 -1
- package/modern/ScatterChart/extremums.js +26 -10
- package/modern/context/CartesianProvider/CartesianProvider.js +2 -5
- package/modern/context/CartesianProvider/computeValue.js +20 -23
- package/modern/context/CartesianProvider/getAxisExtremum.js +11 -5
- package/modern/context/CartesianProvider/index.js +1 -0
- package/modern/context/CartesianProvider/zoom.js +19 -0
- package/modern/context/DrawingProvider.js +11 -3
- package/modern/hooks/useAxisEvents.js +5 -2
- package/modern/index.js +1 -1
- package/modern/internals/domUtils.js +16 -3
- package/modern/internals/index.js +4 -0
- package/modern/internals/useAnimatedPath.js +17 -13
- package/modern/models/axis.js +5 -0
- package/modern/tests/firePointerEvent.js +35 -0
- package/node/BarChart/BarChart.js +356 -0
- package/node/BarChart/BarClipPath.js +50 -0
- package/node/BarChart/BarElement.js +119 -0
- package/node/BarChart/BarLabel/BarLabel.js +60 -0
- package/node/BarChart/BarLabel/BarLabel.types.js +5 -0
- package/node/BarChart/BarLabel/BarLabelItem.js +127 -0
- package/node/BarChart/BarLabel/BarLabelPlot.js +83 -0
- package/node/BarChart/BarLabel/barLabelClasses.js +29 -0
- package/{esm → node}/BarChart/BarLabel/getBarLabel.js +9 -2
- package/node/BarChart/BarLabel/index.js +25 -0
- package/{esm → node}/BarChart/BarPlot.js +47 -38
- package/{esm → node}/BarChart/checkScaleErrors.js +12 -6
- package/node/BarChart/extremums.js +83 -0
- package/{esm → node}/BarChart/formatter.js +16 -9
- package/{esm → node}/BarChart/getColor.js +7 -1
- package/{esm → node}/BarChart/getRadius.js +9 -2
- package/node/BarChart/index.js +49 -0
- package/{esm/LineChart → node/BarChart}/legend.js +9 -3
- package/node/BarChart/plugin.js +17 -0
- package/node/BarChart/types.js +5 -0
- package/{esm → node}/BarChart/useBarChartProps.js +25 -17
- package/node/ChartContainer/ChartContainer.js +258 -0
- package/node/ChartContainer/index.js +16 -0
- package/node/ChartContainer/useChartContainerProps.js +92 -0
- package/node/ChartContainer/useDefaultizeAxis.js +40 -0
- package/{esm → node}/ChartsAxis/ChartsAxis.js +32 -24
- package/node/ChartsAxis/axisClasses.js +12 -0
- package/node/ChartsAxis/index.js +27 -0
- package/node/ChartsAxisHighlight/ChartsAxisHighlight.js +144 -0
- package/node/ChartsAxisHighlight/index.js +16 -0
- package/node/ChartsClipPath/ChartsClipPath.js +59 -0
- package/node/ChartsClipPath/index.js +16 -0
- package/node/ChartsGrid/ChartsGrid.js +141 -0
- package/node/ChartsGrid/chartsGridClasses.js +14 -0
- package/node/ChartsGrid/index.js +27 -0
- package/node/ChartsLegend/ChartsLegend.js +114 -0
- package/{esm → node}/ChartsLegend/ContinuousColorLegend.js +74 -65
- package/node/ChartsLegend/DefaultChartsLegend.js +105 -0
- package/{esm → node}/ChartsLegend/LegendPerItem.js +40 -29
- package/{esm → node}/ChartsLegend/PiecewiseColorLegend.js +44 -36
- package/node/ChartsLegend/chartsLegend.types.js +5 -0
- package/node/ChartsLegend/chartsLegendClasses.js +12 -0
- package/node/ChartsLegend/index.js +71 -0
- package/node/ChartsLegend/legend.types.js +5 -0
- package/{esm → node}/ChartsLegend/legendItemsPlacement.js +13 -6
- package/node/ChartsLegend/useAxis.js +47 -0
- package/node/ChartsLegend/utils.js +23 -0
- package/{esm → node}/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +23 -15
- package/node/ChartsOnAxisClickHandler/index.js +16 -0
- package/node/ChartsOverlay/ChartsLoadingOverlay.js +43 -0
- package/node/ChartsOverlay/ChartsNoDataOverlay.js +43 -0
- package/node/ChartsOverlay/ChartsOverlay.js +41 -0
- package/node/ChartsOverlay/index.js +26 -0
- package/node/ChartsReferenceLine/ChartsReferenceLine.js +82 -0
- package/node/ChartsReferenceLine/ChartsXReferenceLine.js +109 -0
- package/node/ChartsReferenceLine/ChartsYReferenceLine.js +109 -0
- package/node/ChartsReferenceLine/chartsReferenceLineClasses.js +14 -0
- package/node/ChartsReferenceLine/common.js +27 -0
- package/node/ChartsReferenceLine/index.js +27 -0
- package/{ChartsSurface.js → node/ChartsSurface/ChartsSurface.js} +6 -2
- package/node/ChartsSurface/index.js +16 -0
- package/{esm → node}/ChartsText/ChartsText.js +26 -18
- package/node/ChartsText/index.js +12 -0
- package/node/ChartsTooltip/ChartsAxisTooltipContent.js +88 -0
- package/node/ChartsTooltip/ChartsItemTooltipContent.js +60 -0
- package/node/ChartsTooltip/ChartsTooltip.js +162 -0
- package/{esm → node}/ChartsTooltip/ChartsTooltipTable.js +16 -11
- package/node/ChartsTooltip/DefaultChartsAxisTooltipContent.js +129 -0
- package/node/ChartsTooltip/DefaultChartsItemTooltipContent.js +98 -0
- package/node/ChartsTooltip/chartsTooltipClasses.js +12 -0
- package/node/ChartsTooltip/index.js +82 -0
- package/{esm → node}/ChartsTooltip/utils.js +21 -9
- package/{esm → node}/ChartsVoronoiHandler/ChartsVoronoiHandler.js +37 -29
- package/node/ChartsVoronoiHandler/index.js +16 -0
- package/{esm → node}/ChartsXAxis/ChartsXAxis.js +98 -79
- package/node/ChartsXAxis/index.js +16 -0
- package/{esm → node}/ChartsYAxis/ChartsYAxis.js +86 -71
- package/node/ChartsYAxis/index.js +16 -0
- package/node/Gauge/Gauge.js +157 -0
- package/{esm → node}/Gauge/GaugeContainer.js +59 -51
- package/node/Gauge/GaugeProvider.js +99 -0
- package/node/Gauge/GaugeReferenceArc.js +44 -0
- package/node/Gauge/GaugeValueArc.js +51 -0
- package/node/Gauge/GaugeValueText.js +77 -0
- package/node/Gauge/gaugeClasses.js +15 -0
- package/node/Gauge/index.js +87 -0
- package/{esm → node}/Gauge/utils.js +9 -2
- package/node/LineChart/AnimatedArea.js +112 -0
- package/node/LineChart/AnimatedLine.js +115 -0
- package/node/LineChart/AreaElement.js +119 -0
- package/{esm → node}/LineChart/AreaPlot.js +38 -30
- package/node/LineChart/LineChart.js +357 -0
- package/node/LineChart/LineElement.js +119 -0
- package/node/LineChart/LineHighlightElement.js +90 -0
- package/node/LineChart/LineHighlightPlot.js +126 -0
- package/{esm → node}/LineChart/LinePlot.js +38 -30
- package/node/LineChart/MarkElement.js +140 -0
- package/{esm → node}/LineChart/MarkPlot.js +41 -33
- package/{esm → node}/LineChart/extremums.js +31 -7
- package/{esm → node}/LineChart/formatter.js +16 -9
- package/{esm → node}/LineChart/getColor.js +7 -1
- package/node/LineChart/index.js +126 -0
- package/{esm/BarChart → node/LineChart}/legend.js +9 -3
- package/node/LineChart/plugin.js +17 -0
- package/{esm → node}/LineChart/useLineChartProps.js +22 -14
- package/node/PieChart/PieArc.js +117 -0
- package/node/PieChart/PieArcLabel.js +117 -0
- package/node/PieChart/PieArcLabelPlot.js +202 -0
- package/node/PieChart/PieArcPlot.js +184 -0
- package/node/PieChart/PieChart.js +401 -0
- package/{esm → node}/PieChart/PiePlot.js +37 -29
- package/{esm → node}/PieChart/dataTransform/transition.js +8 -2
- package/{esm → node}/PieChart/dataTransform/useTransformData.js +16 -7
- package/node/PieChart/formatter.js +53 -0
- package/node/PieChart/getColor.js +12 -0
- package/node/PieChart/getPieCoordinates.js +25 -0
- package/node/PieChart/index.js +82 -0
- package/{esm → node}/PieChart/legend.js +9 -3
- package/node/PieChart/plugin.js +14 -0
- package/{esm → node}/ResponsiveChartContainer/ResizableContainer.js +8 -2
- package/node/ResponsiveChartContainer/ResponsiveChartContainer.js +233 -0
- package/node/ResponsiveChartContainer/index.js +16 -0
- package/{esm → node}/ResponsiveChartContainer/useChartContainerDimensions.js +17 -7
- package/{esm → node}/ResponsiveChartContainer/useResponsiveChartContainerProps.js +16 -8
- package/{esm → node}/ScatterChart/Scatter.js +34 -26
- package/node/ScatterChart/ScatterChart.js +363 -0
- package/node/ScatterChart/ScatterPlot.js +107 -0
- package/node/ScatterChart/extremums.js +63 -0
- package/node/ScatterChart/formatter.js +17 -0
- package/{esm → node}/ScatterChart/getColor.js +7 -1
- package/node/ScatterChart/index.js +38 -0
- package/{esm → node}/ScatterChart/legend.js +9 -3
- package/node/ScatterChart/plugin.js +17 -0
- package/{esm → node}/ScatterChart/useScatterChartProps.js +18 -10
- package/node/SparkLineChart/SparkLineChart.js +356 -0
- package/node/SparkLineChart/index.js +16 -0
- package/node/colorPalettes/colorPalettes.js +18 -0
- package/node/colorPalettes/index.js +16 -0
- package/node/context/CartesianProvider/Cartesian.types.js +5 -0
- package/node/context/CartesianProvider/CartesianContext.js +21 -0
- package/node/context/CartesianProvider/CartesianProvider.js +54 -0
- package/{esm → node}/context/CartesianProvider/computeValue.js +49 -45
- package/node/context/CartesianProvider/defaultizeAxis.js +21 -0
- package/node/context/CartesianProvider/getAxisExtremum.js +27 -0
- package/node/context/CartesianProvider/index.js +61 -0
- package/node/context/CartesianProvider/useCartesianContext.js +17 -0
- package/node/context/CartesianProvider/zoom.js +26 -0
- package/node/context/DrawingProvider.js +87 -0
- package/node/context/HighlightedProvider/HighlightedContext.js +39 -0
- package/node/context/HighlightedProvider/HighlightedProvider.js +100 -0
- package/{esm → node}/context/HighlightedProvider/createIsFaded.js +9 -2
- package/{esm → node}/context/HighlightedProvider/createIsHighlighted.js +9 -2
- package/node/context/HighlightedProvider/index.js +49 -0
- package/node/context/HighlightedProvider/useHighlighted.js +27 -0
- package/{esm → node}/context/HighlightedProvider/useItemHighlighted.js +9 -3
- package/node/context/InteractionProvider.js +85 -0
- package/node/context/PluginProvider/ColorProcessor.types.js +5 -0
- package/node/context/PluginProvider/ExtremumGetter.types.js +5 -0
- package/node/context/PluginProvider/Plugin.types.js +5 -0
- package/node/context/PluginProvider/PluginContext.js +21 -0
- package/node/context/PluginProvider/PluginProvider.js +26 -0
- package/node/context/PluginProvider/SeriesFormatter.types.js +5 -0
- package/node/context/PluginProvider/index.js +115 -0
- package/{esm → node}/context/PluginProvider/mergePlugins.js +13 -6
- package/node/context/PluginProvider/useColorProcessor.js +23 -0
- package/node/context/PluginProvider/useSeriesFormatter.js +23 -0
- package/node/context/PluginProvider/useXExtremumGetter.js +23 -0
- package/node/context/PluginProvider/useYExtremumGetter.js +23 -0
- package/node/context/SeriesProvider/Series.types.js +5 -0
- package/node/context/SeriesProvider/SeriesContext.js +16 -0
- package/node/context/SeriesProvider/SeriesProvider.js +38 -0
- package/node/context/SeriesProvider/index.js +49 -0
- package/{esm → node}/context/SeriesProvider/processSeries.js +14 -6
- package/node/context/ZAxisContextProvider.js +103 -0
- package/node/context/context.types.js +5 -0
- package/node/context/index.js +27 -0
- package/node/hooks/index.js +115 -0
- package/node/hooks/useAxis.js +24 -0
- package/{esm → node}/hooks/useAxisEvents.js +29 -17
- package/node/hooks/useChartDimensions.js +25 -0
- package/node/hooks/useChartId.js +16 -0
- package/node/hooks/useColorScale.js +37 -0
- package/node/hooks/useDrawingArea.js +30 -0
- package/node/hooks/useInteractionItemProps.js +55 -0
- package/node/hooks/useMounted.js +25 -0
- package/{esm → node}/hooks/useReducedMotion.js +12 -6
- package/node/hooks/useScale.js +30 -0
- package/{esm → node}/hooks/useSeries.js +19 -8
- package/node/hooks/useSvgRef.js +20 -0
- package/{esm → node}/hooks/useTicks.js +16 -7
- package/node/index.js +298 -0
- package/node/internals/SlotComponentPropsFromProps.js +5 -0
- package/node/internals/cleanId.js +12 -0
- package/node/internals/colorScale.js +24 -0
- package/node/internals/components/AxisSharedComponents.js +33 -0
- package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +105 -0
- package/node/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +64 -0
- package/node/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +48 -0
- package/node/internals/components/ChartsAxesGradients/index.js +16 -0
- package/{esm → node}/internals/configInit.js +7 -1
- package/node/internals/defaultizeColor.js +21 -0
- package/node/internals/defaultizeValueFormatter.js +17 -0
- package/{esm → node}/internals/domUtils.js +30 -7
- package/{esm → node}/internals/geometry.js +7 -1
- package/node/internals/getCurve.js +45 -0
- package/node/internals/getLabel.js +9 -0
- package/{esm → node}/internals/getPercentageValue.js +7 -1
- package/{esm → node}/internals/getSVGPoint.js +7 -1
- package/node/internals/getScale.js +23 -0
- package/{esm → node}/internals/getSymbol.js +7 -1
- package/node/internals/getWordsByLines.js +21 -0
- package/node/internals/index.js +335 -0
- package/node/internals/isBandScale.js +9 -0
- package/node/internals/isCartesian.js +14 -0
- package/node/internals/isDefined.js +9 -0
- package/node/internals/isInfinity.js +9 -0
- package/node/internals/notNull.js +9 -0
- package/{esm → node}/internals/stackSeries.js +23 -16
- package/node/internals/ts-generic.js +5 -0
- package/node/internals/useAnimatedPath.js +42 -0
- package/{esm → node}/internals/warning.js +9 -2
- package/node/models/axis.js +18 -0
- package/node/models/colorMapping.js +5 -0
- package/node/models/helpers.js +5 -0
- package/node/models/index.js +38 -0
- package/node/models/layout.js +5 -0
- package/node/models/seriesType/bar.js +5 -0
- package/node/models/seriesType/common.js +5 -0
- package/node/models/seriesType/config.js +5 -0
- package/node/models/seriesType/index.js +71 -0
- package/node/models/seriesType/line.js +5 -0
- package/node/models/seriesType/pie.js +5 -0
- package/node/models/seriesType/scatter.js +5 -0
- package/node/models/stacking.js +5 -0
- package/node/models/z-axis.js +5 -0
- package/node/tests/firePointerEvent.js +42 -0
- package/node/themeAugmentation/index.js +38 -0
- package/package.json +8 -8
- package/tests/firePointerEvent.js +35 -0
- package/themeAugmentation/components.d.ts +2 -12
- package/themeAugmentation/index.js +3 -38
- package/themeAugmentation/overrides.d.ts +6 -7
- package/themeAugmentation/package.json +2 -2
- package/themeAugmentation/props.d.ts +3 -14
- package/context/CartesianProvider/normalizeAxis.d.ts +0 -5
- package/context/CartesianProvider/normalizeAxis.js +0 -23
- package/esm/BarChart/BarChart.js +0 -343
- package/esm/BarChart/BarClipPath.js +0 -42
- package/esm/BarChart/BarElement.js +0 -109
- package/esm/BarChart/BarLabel/BarLabel.js +0 -51
- package/esm/BarChart/BarLabel/BarLabelItem.js +0 -119
- package/esm/BarChart/BarLabel/BarLabelPlot.js +0 -75
- package/esm/BarChart/BarLabel/barLabelClasses.js +0 -19
- package/esm/BarChart/BarLabel/index.js +0 -2
- package/esm/BarChart/extremums.js +0 -40
- package/esm/BarChart/index.js +0 -4
- package/esm/BarChart/plugin.js +0 -10
- package/esm/ChartContainer/ChartContainer.js +0 -250
- package/esm/ChartContainer/index.js +0 -1
- package/esm/ChartContainer/useChartContainerProps.js +0 -82
- package/esm/ChartContainer/useDefaultizeAxis.js +0 -19
- package/esm/ChartsAxis/axisClasses.js +0 -5
- package/esm/ChartsAxis/index.js +0 -2
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +0 -120
- package/esm/ChartsAxisHighlight/index.js +0 -1
- package/esm/ChartsClipPath/ChartsClipPath.js +0 -51
- package/esm/ChartsClipPath/index.js +0 -1
- package/esm/ChartsGrid/ChartsGrid.js +0 -131
- package/esm/ChartsGrid/chartsGridClasses.js +0 -6
- package/esm/ChartsGrid/index.js +0 -2
- package/esm/ChartsLegend/ChartsLegend.js +0 -106
- package/esm/ChartsLegend/DefaultChartsLegend.js +0 -97
- package/esm/ChartsLegend/chartsLegend.types.js +0 -1
- package/esm/ChartsLegend/chartsLegendClasses.js +0 -5
- package/esm/ChartsLegend/index.js +0 -6
- package/esm/ChartsLegend/legend.types.js +0 -1
- package/esm/ChartsLegend/useAxis.js +0 -39
- package/esm/ChartsLegend/utils.js +0 -16
- package/esm/ChartsOnAxisClickHandler/index.js +0 -1
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +0 -34
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +0 -34
- package/esm/ChartsOverlay/ChartsOverlay.js +0 -31
- package/esm/ChartsOverlay/index.js +0 -3
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +0 -74
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +0 -100
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +0 -100
- package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +0 -6
- package/esm/ChartsReferenceLine/common.js +0 -20
- package/esm/ChartsReferenceLine/index.js +0 -2
- package/esm/ChartsText/index.js +0 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +0 -80
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +0 -52
- package/esm/ChartsTooltip/ChartsTooltip.js +0 -154
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -121
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -90
- package/esm/ChartsTooltip/chartsTooltipClasses.js +0 -5
- package/esm/ChartsTooltip/index.js +0 -7
- package/esm/ChartsVoronoiHandler/index.js +0 -1
- package/esm/ChartsXAxis/index.js +0 -1
- package/esm/ChartsYAxis/index.js +0 -1
- package/esm/Gauge/Gauge.js +0 -149
- package/esm/Gauge/GaugeProvider.js +0 -88
- package/esm/Gauge/GaugeReferenceArc.js +0 -35
- package/esm/Gauge/GaugeValueArc.js +0 -42
- package/esm/Gauge/GaugeValueText.js +0 -69
- package/esm/Gauge/gaugeClasses.js +0 -7
- package/esm/Gauge/index.js +0 -7
- package/esm/LineChart/AnimatedArea.js +0 -103
- package/esm/LineChart/AnimatedLine.js +0 -106
- package/esm/LineChart/AreaElement.js +0 -109
- package/esm/LineChart/LineChart.js +0 -344
- package/esm/LineChart/LineElement.js +0 -109
- package/esm/LineChart/LineHighlightElement.js +0 -80
- package/esm/LineChart/LineHighlightPlot.js +0 -118
- package/esm/LineChart/MarkElement.js +0 -128
- package/esm/LineChart/index.js +0 -11
- package/esm/LineChart/plugin.js +0 -10
- package/esm/PieChart/PieArc.js +0 -107
- package/esm/PieChart/PieArcLabel.js +0 -107
- package/esm/PieChart/PieArcLabelPlot.js +0 -194
- package/esm/PieChart/PieArcPlot.js +0 -176
- package/esm/PieChart/PieChart.js +0 -388
- package/esm/PieChart/formatter.js +0 -46
- package/esm/PieChart/getColor.js +0 -6
- package/esm/PieChart/getPieCoordinates.js +0 -19
- package/esm/PieChart/index.js +0 -7
- package/esm/PieChart/plugin.js +0 -7
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -225
- package/esm/ResponsiveChartContainer/index.js +0 -1
- package/esm/ScatterChart/ScatterChart.js +0 -350
- package/esm/ScatterChart/ScatterPlot.js +0 -99
- package/esm/ScatterChart/extremums.js +0 -39
- package/esm/ScatterChart/formatter.js +0 -11
- package/esm/ScatterChart/index.js +0 -3
- package/esm/ScatterChart/plugin.js +0 -10
- package/esm/SparkLineChart/SparkLineChart.js +0 -348
- package/esm/SparkLineChart/index.js +0 -1
- package/esm/colorPalettes/colorPalettes.js +0 -9
- package/esm/colorPalettes/index.js +0 -1
- package/esm/context/CartesianProvider/CartesianContext.js +0 -13
- package/esm/context/CartesianProvider/CartesianProvider.js +0 -50
- package/esm/context/CartesianProvider/defaultizeAxis.js +0 -13
- package/esm/context/CartesianProvider/getAxisExtremum.js +0 -14
- package/esm/context/CartesianProvider/index.js +0 -8
- package/esm/context/CartesianProvider/normalizeAxis.js +0 -15
- package/esm/context/CartesianProvider/useCartesianContext.js +0 -8
- package/esm/context/DrawingProvider.js +0 -68
- package/esm/context/HighlightedProvider/HighlightedContext.js +0 -32
- package/esm/context/HighlightedProvider/HighlightedProvider.js +0 -92
- package/esm/context/HighlightedProvider/index.js +0 -4
- package/esm/context/HighlightedProvider/useHighlighted.js +0 -20
- package/esm/context/InteractionProvider.js +0 -76
- package/esm/context/PluginProvider/ColorProcessor.types.js +0 -1
- package/esm/context/PluginProvider/ExtremumGetter.types.js +0 -1
- package/esm/context/PluginProvider/Plugin.types.js +0 -1
- package/esm/context/PluginProvider/PluginContext.js +0 -13
- package/esm/context/PluginProvider/PluginProvider.js +0 -19
- package/esm/context/PluginProvider/SeriesFormatter.types.js +0 -1
- package/esm/context/PluginProvider/index.js +0 -10
- package/esm/context/PluginProvider/useColorProcessor.js +0 -15
- package/esm/context/PluginProvider/useSeriesFormatter.js +0 -15
- package/esm/context/PluginProvider/useXExtremumGetter.js +0 -15
- package/esm/context/PluginProvider/useYExtremumGetter.js +0 -15
- package/esm/context/SeriesProvider/Series.types.js +0 -1
- package/esm/context/SeriesProvider/SeriesContext.js +0 -8
- package/esm/context/SeriesProvider/SeriesProvider.js +0 -31
- package/esm/context/SeriesProvider/index.js +0 -8
- package/esm/context/ZAxisContextProvider.js +0 -94
- package/esm/context/context.types.js +0 -1
- package/esm/context/index.js +0 -2
- package/esm/hooks/index.js +0 -7
- package/esm/hooks/useAxis.js +0 -17
- package/esm/hooks/useChartDimensions.js +0 -16
- package/esm/hooks/useChartId.js +0 -8
- package/esm/hooks/useColorScale.js +0 -27
- package/esm/hooks/useDrawingArea.js +0 -22
- package/esm/hooks/useInteractionItemProps.js +0 -46
- package/esm/hooks/useMounted.js +0 -16
- package/esm/hooks/useScale.js +0 -23
- package/esm/hooks/useSvgRef.js +0 -12
- package/esm/index.js +0 -26
- package/esm/internals/SlotComponentPropsFromProps.js +0 -1
- package/esm/internals/cleanId.js +0 -6
- package/esm/internals/colorScale.js +0 -16
- package/esm/internals/components/AxisSharedComponents.js +0 -26
- package/esm/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +0 -95
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +0 -56
- package/esm/internals/components/ChartsAxesGradients/ChartsPiecewiseGradient.js +0 -40
- package/esm/internals/components/ChartsAxesGradients/index.js +0 -1
- package/esm/internals/defaultizeColor.js +0 -14
- package/esm/internals/defaultizeValueFormatter.js +0 -10
- package/esm/internals/getCurve.js +0 -39
- package/esm/internals/getLabel.js +0 -3
- package/esm/internals/getScale.js +0 -17
- package/esm/internals/getWordsByLines.js +0 -14
- package/esm/internals/index.js +0 -37
- package/esm/internals/isBandScale.js +0 -3
- package/esm/internals/isCartesian.js +0 -7
- package/esm/internals/isDefined.js +0 -3
- package/esm/internals/isInfinity.js +0 -3
- package/esm/internals/notNull.js +0 -3
- package/esm/internals/ts-generic.js +0 -1
- package/esm/internals/useAnimatedPath.js +0 -29
- package/esm/internals/useIsRTL.js +0 -5
- package/esm/models/axis.js +0 -6
- package/esm/models/colorMapping.js +0 -1
- package/esm/models/helpers.js +0 -1
- package/esm/models/index.js +0 -4
- package/esm/models/layout.js +0 -1
- package/esm/models/seriesType/bar.js +0 -1
- package/esm/models/seriesType/common.js +0 -1
- package/esm/models/seriesType/config.js +0 -1
- package/esm/models/seriesType/index.js +0 -16
- package/esm/models/seriesType/line.js +0 -1
- package/esm/models/seriesType/pie.js +0 -1
- package/esm/models/seriesType/scatter.js +0 -1
- package/esm/models/stacking.js +0 -1
- package/esm/models/z-axis.js +0 -1
- package/esm/themeAugmentation/index.js +0 -3
- package/internals/useIsRTL.d.ts +0 -1
- package/internals/useIsRTL.js +0 -12
- package/modern/context/CartesianProvider/normalizeAxis.js +0 -15
- package/modern/internals/useIsRTL.js +0 -5
- /package/{ChartsSurface.d.ts → ChartsSurface/ChartsSurface.d.ts} +0 -0
- /package/{constants.d.ts → constants/index.d.ts} +0 -0
- /package/{esm/constants.js → constants/index.js} +0 -0
- /package/{esm/BarChart/BarLabel/BarLabel.types.js → context/CartesianProvider/Cartesian.types.js} +0 -0
- /package/modern/{constants.js → constants/index.js} +0 -0
- /package/{esm/BarChart/types.js → modern/context/CartesianProvider/Cartesian.types.js} +0 -0
- /package/{constants.js → node/constants/index.js} +0 -0
|
@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
9
10
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
10
11
|
import { useTicks } from '../hooks/useTicks';
|
|
11
12
|
import { useDrawingArea } from '../hooks/useDrawingArea';
|
|
@@ -84,7 +85,7 @@ function ChartsYAxis(inProps) {
|
|
|
84
85
|
sx
|
|
85
86
|
} = defaultizedProps;
|
|
86
87
|
const theme = useTheme();
|
|
87
|
-
const
|
|
88
|
+
const isRtl = useRtl();
|
|
88
89
|
const classes = useUtilityClasses(_extends({}, defaultizedProps, {
|
|
89
90
|
theme
|
|
90
91
|
}));
|
|
@@ -92,7 +93,8 @@ function ChartsYAxis(inProps) {
|
|
|
92
93
|
left,
|
|
93
94
|
top,
|
|
94
95
|
width,
|
|
95
|
-
height
|
|
96
|
+
height,
|
|
97
|
+
isPointInside
|
|
96
98
|
} = useDrawingArea();
|
|
97
99
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
98
100
|
const yTicks = useTicks({
|
|
@@ -112,7 +114,7 @@ function ChartsYAxis(inProps) {
|
|
|
112
114
|
const Tick = slots?.axisTick ?? 'line';
|
|
113
115
|
const TickLabel = slots?.axisTickLabel ?? ChartsText;
|
|
114
116
|
const Label = slots?.axisLabel ?? ChartsText;
|
|
115
|
-
const revertAnchor = !
|
|
117
|
+
const revertAnchor = !isRtl && position === 'right' || isRtl && position !== 'right';
|
|
116
118
|
const axisTickLabelProps = useSlotProps({
|
|
117
119
|
elementType: TickLabel,
|
|
118
120
|
externalSlotProps: slotProps?.axisTickLabel,
|
|
@@ -172,7 +174,12 @@ function ChartsYAxis(inProps) {
|
|
|
172
174
|
const xTickLabel = positionSign * (tickSize + 2);
|
|
173
175
|
const yTickLabel = labelOffset;
|
|
174
176
|
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
175
|
-
const showLabel =
|
|
177
|
+
const showLabel = isPointInside({
|
|
178
|
+
x: -1,
|
|
179
|
+
y: offset
|
|
180
|
+
}, {
|
|
181
|
+
direction: 'y'
|
|
182
|
+
});
|
|
176
183
|
if (!showLabel) {
|
|
177
184
|
return null;
|
|
178
185
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import { useThemeProps } from '@mui/material/styles';
|
|
4
5
|
import { AreaPlot } from './AreaPlot';
|
|
5
6
|
import { LinePlot } from './LinePlot';
|
|
6
7
|
import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
@@ -26,7 +27,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
26
27
|
*
|
|
27
28
|
* - [LineChart API](https://mui.com/x/api/charts/line-chart/)
|
|
28
29
|
*/
|
|
29
|
-
const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(
|
|
30
|
+
const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(inProps, ref) {
|
|
31
|
+
const props = useThemeProps({
|
|
32
|
+
props: inProps,
|
|
33
|
+
name: 'MuiLineChart'
|
|
34
|
+
});
|
|
30
35
|
const {
|
|
31
36
|
chartContainerProps,
|
|
32
37
|
axisClickHandlerProps,
|
|
@@ -6,9 +6,18 @@ export const getExtremumX = params => {
|
|
|
6
6
|
const maxX = Math.max(...(axis.data ?? []));
|
|
7
7
|
return [minX, maxX];
|
|
8
8
|
};
|
|
9
|
-
function getSeriesExtremums(getValues, stackedData) {
|
|
10
|
-
return stackedData.reduce((seriesAcc, stackedValue) => {
|
|
9
|
+
function getSeriesExtremums(getValues, stackedData, filter) {
|
|
10
|
+
return stackedData.reduce((seriesAcc, stackedValue, index) => {
|
|
11
11
|
const [base, value] = getValues(stackedValue);
|
|
12
|
+
if (filter && (!filter({
|
|
13
|
+
y: base,
|
|
14
|
+
x: null
|
|
15
|
+
}, index) || !filter({
|
|
16
|
+
y: value,
|
|
17
|
+
x: null
|
|
18
|
+
}, index))) {
|
|
19
|
+
return seriesAcc;
|
|
20
|
+
}
|
|
12
21
|
return [Math.min(base, value, seriesAcc[0]), Math.max(base, value, seriesAcc[1])];
|
|
13
22
|
}, [Infinity, -Infinity]);
|
|
14
23
|
}
|
|
@@ -16,7 +25,8 @@ export const getExtremumY = params => {
|
|
|
16
25
|
const {
|
|
17
26
|
series,
|
|
18
27
|
axis,
|
|
19
|
-
isDefaultAxis
|
|
28
|
+
isDefaultAxis,
|
|
29
|
+
getFilters
|
|
20
30
|
} = params;
|
|
21
31
|
return Object.keys(series).filter(seriesId => {
|
|
22
32
|
const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
|
|
@@ -27,10 +37,16 @@ export const getExtremumY = params => {
|
|
|
27
37
|
stackedData
|
|
28
38
|
} = series[seriesId];
|
|
29
39
|
const isArea = area !== undefined;
|
|
40
|
+
const filter = getFilters?.({
|
|
41
|
+
currentAxisId: axis.id,
|
|
42
|
+
isDefaultAxis,
|
|
43
|
+
seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
|
|
44
|
+
seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey
|
|
45
|
+
});
|
|
30
46
|
|
|
31
47
|
// Since this series is not used to display an area, we do not consider the base (the d[0]).
|
|
32
48
|
const getValues = isArea && axis.scaleType !== 'log' && typeof series[seriesId].baseline !== 'string' ? d => d : d => [d[1], d[1]];
|
|
33
|
-
const seriesExtremums = getSeriesExtremums(getValues, stackedData);
|
|
49
|
+
const seriesExtremums = getSeriesExtremums(getValues, stackedData, filter);
|
|
34
50
|
const [seriesMin, seriesMax] = seriesExtremums;
|
|
35
51
|
return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
|
|
36
52
|
}, [Infinity, -Infinity]);
|
|
@@ -3,6 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "sx", "tooltip", "axisHighlight", "skipAnimation", "legend", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "onItemClick", "loading", "highlightedItem", "onHighlightChange", "className"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
7
|
+
import { useThemeProps } from '@mui/material/styles';
|
|
6
8
|
import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
7
9
|
import { ChartsAxis } from '../ChartsAxis/ChartsAxis';
|
|
8
10
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
@@ -10,7 +12,6 @@ import { ChartsTooltip } from '../ChartsTooltip';
|
|
|
10
12
|
import { ChartsLegend } from '../ChartsLegend';
|
|
11
13
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
12
14
|
import { PiePlot } from './PiePlot';
|
|
13
|
-
import { useIsRTL } from '../internals/useIsRTL';
|
|
14
15
|
import { ChartsOverlay } from '../ChartsOverlay';
|
|
15
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
const defaultMargin = {
|
|
@@ -36,7 +37,11 @@ const defaultRTLMargin = {
|
|
|
36
37
|
*
|
|
37
38
|
* - [PieChart API](https://mui.com/x/api/charts/pie-chart/)
|
|
38
39
|
*/
|
|
39
|
-
const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(
|
|
40
|
+
const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(inProps, ref) {
|
|
41
|
+
const props = useThemeProps({
|
|
42
|
+
props: inProps,
|
|
43
|
+
name: 'MuiPieChart'
|
|
44
|
+
});
|
|
40
45
|
const {
|
|
41
46
|
xAxis,
|
|
42
47
|
yAxis,
|
|
@@ -69,13 +74,13 @@ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(props, ref) {
|
|
|
69
74
|
className
|
|
70
75
|
} = props,
|
|
71
76
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
72
|
-
const
|
|
73
|
-
const margin = _extends({},
|
|
77
|
+
const isRtl = useRtl();
|
|
78
|
+
const margin = _extends({}, isRtl ? defaultRTLMargin : defaultMargin, marginProps);
|
|
74
79
|
const legend = _extends({
|
|
75
80
|
direction: 'column',
|
|
76
81
|
position: {
|
|
77
82
|
vertical: 'middle',
|
|
78
|
-
horizontal:
|
|
83
|
+
horizontal: isRtl ? 'left' : 'right'
|
|
79
84
|
}
|
|
80
85
|
}, legendProps);
|
|
81
86
|
return /*#__PURE__*/_jsxs(ResponsiveChartContainer, _extends({}, other, {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import { useThemeProps } from '@mui/material/styles';
|
|
4
5
|
import { ScatterPlot } from './ScatterPlot';
|
|
5
6
|
import { ResponsiveChartContainer } from '../ResponsiveChartContainer';
|
|
6
7
|
import { ChartsAxis } from '../ChartsAxis';
|
|
@@ -23,7 +24,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
23
24
|
*
|
|
24
25
|
* - [ScatterChart API](https://mui.com/x/api/charts/scatter-chart/)
|
|
25
26
|
*/
|
|
26
|
-
const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(
|
|
27
|
+
const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(inProps, ref) {
|
|
28
|
+
const props = useThemeProps({
|
|
29
|
+
props: inProps,
|
|
30
|
+
name: 'MuiScatterChart'
|
|
31
|
+
});
|
|
27
32
|
const {
|
|
28
33
|
chartContainerProps,
|
|
29
34
|
zAxisProps,
|
|
@@ -5,16 +5,24 @@ export const getExtremumX = params => {
|
|
|
5
5
|
const {
|
|
6
6
|
series,
|
|
7
7
|
axis,
|
|
8
|
-
isDefaultAxis
|
|
8
|
+
isDefaultAxis,
|
|
9
|
+
getFilters
|
|
9
10
|
} = params;
|
|
10
11
|
return Object.keys(series).filter(seriesId => {
|
|
11
12
|
const axisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey;
|
|
12
13
|
return axisId === axis.id || axisId === undefined && isDefaultAxis;
|
|
13
14
|
}).reduce((acc, seriesId) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const filter = getFilters?.({
|
|
16
|
+
currentAxisId: axis.id,
|
|
17
|
+
isDefaultAxis,
|
|
18
|
+
seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
|
|
19
|
+
seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey
|
|
20
|
+
});
|
|
21
|
+
const seriesMinMax = series[seriesId].data.reduce((accSeries, d, dataIndex) => {
|
|
22
|
+
if (filter && !filter(d, dataIndex)) {
|
|
23
|
+
return accSeries;
|
|
24
|
+
}
|
|
25
|
+
return mergeMinMax(accSeries, [d.x, d.x]);
|
|
18
26
|
}, [Infinity, -Infinity]);
|
|
19
27
|
return mergeMinMax(acc, seriesMinMax);
|
|
20
28
|
}, [Infinity, -Infinity]);
|
|
@@ -23,16 +31,24 @@ export const getExtremumY = params => {
|
|
|
23
31
|
const {
|
|
24
32
|
series,
|
|
25
33
|
axis,
|
|
26
|
-
isDefaultAxis
|
|
34
|
+
isDefaultAxis,
|
|
35
|
+
getFilters
|
|
27
36
|
} = params;
|
|
28
37
|
return Object.keys(series).filter(seriesId => {
|
|
29
38
|
const axisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
|
|
30
39
|
return axisId === axis.id || axisId === undefined && isDefaultAxis;
|
|
31
40
|
}).reduce((acc, seriesId) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
const filter = getFilters?.({
|
|
42
|
+
currentAxisId: axis.id,
|
|
43
|
+
isDefaultAxis,
|
|
44
|
+
seriesXAxisId: series[seriesId].xAxisId ?? series[seriesId].xAxisKey,
|
|
45
|
+
seriesYAxisId: series[seriesId].yAxisId ?? series[seriesId].yAxisKey
|
|
46
|
+
});
|
|
47
|
+
const seriesMinMax = series[seriesId].data.reduce((accSeries, d, dataIndex) => {
|
|
48
|
+
if (filter && !filter(d, dataIndex)) {
|
|
49
|
+
return accSeries;
|
|
50
|
+
}
|
|
51
|
+
return mergeMinMax(accSeries, [d.y, d.y]);
|
|
36
52
|
}, [Infinity, -Infinity]);
|
|
37
53
|
return mergeMinMax(acc, seriesMinMax);
|
|
38
54
|
}, [Infinity, -Infinity]);
|
|
@@ -10,7 +10,6 @@ function CartesianProvider(props) {
|
|
|
10
10
|
const {
|
|
11
11
|
xAxis,
|
|
12
12
|
yAxis,
|
|
13
|
-
dataset,
|
|
14
13
|
children
|
|
15
14
|
} = props;
|
|
16
15
|
const formattedSeries = useSeries();
|
|
@@ -22,17 +21,15 @@ function CartesianProvider(props) {
|
|
|
22
21
|
formattedSeries,
|
|
23
22
|
axis: xAxis,
|
|
24
23
|
extremumGetters: xExtremumGetters,
|
|
25
|
-
dataset,
|
|
26
24
|
axisDirection: 'x'
|
|
27
|
-
}), [drawingArea, formattedSeries, xAxis, xExtremumGetters
|
|
25
|
+
}), [drawingArea, formattedSeries, xAxis, xExtremumGetters]);
|
|
28
26
|
const yValues = React.useMemo(() => computeValue({
|
|
29
27
|
drawingArea,
|
|
30
28
|
formattedSeries,
|
|
31
29
|
axis: yAxis,
|
|
32
30
|
extremumGetters: yExtremumGetters,
|
|
33
|
-
dataset,
|
|
34
31
|
axisDirection: 'y'
|
|
35
|
-
}), [drawingArea, formattedSeries, yAxis, yExtremumGetters
|
|
32
|
+
}), [drawingArea, formattedSeries, yAxis, yExtremumGetters]);
|
|
36
33
|
const value = React.useMemo(() => ({
|
|
37
34
|
isInitialized: true,
|
|
38
35
|
data: {
|
|
@@ -4,22 +4,12 @@ import { isBandScaleConfig, isPointScaleConfig } from '../../models/axis';
|
|
|
4
4
|
import { getColorScale, getOrdinalColorScale } from '../../internals/colorScale';
|
|
5
5
|
import { getTickNumber } from '../../hooks/useTicks';
|
|
6
6
|
import { getScale } from '../../internals/getScale';
|
|
7
|
+
import { zoomScaleRange } from './zoom';
|
|
7
8
|
import { getAxisExtremum } from './getAxisExtremum';
|
|
8
|
-
import { normalizeAxis } from './normalizeAxis';
|
|
9
9
|
const getRange = (drawingArea, axisDirection, isReverse) => {
|
|
10
10
|
const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
11
11
|
return isReverse ? range.reverse() : range;
|
|
12
12
|
};
|
|
13
|
-
const zoomedScaleRange = (scaleRange, zoomRange) => {
|
|
14
|
-
const rangeGap = scaleRange[1] - scaleRange[0];
|
|
15
|
-
const zoomGap = zoomRange[1] - zoomRange[0];
|
|
16
|
-
|
|
17
|
-
// If current zoom show the scale between p1 and p2 percents
|
|
18
|
-
// The range should be extended by adding [0, p1] and [p2, 100] segments
|
|
19
|
-
const min = scaleRange[0] - zoomRange[0] * rangeGap / zoomGap;
|
|
20
|
-
const max = scaleRange[1] + (100 - zoomRange[1]) * rangeGap / zoomGap;
|
|
21
|
-
return [min, max];
|
|
22
|
-
};
|
|
23
13
|
const isDateData = data => data?.[0] instanceof Date;
|
|
24
14
|
function createDateFormatter(axis, range) {
|
|
25
15
|
const timeScale = scaleTime(axis.data, range);
|
|
@@ -32,32 +22,37 @@ const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
|
32
22
|
export function computeValue({
|
|
33
23
|
drawingArea,
|
|
34
24
|
formattedSeries,
|
|
35
|
-
axis:
|
|
25
|
+
axis: allAxis,
|
|
36
26
|
extremumGetters,
|
|
37
|
-
dataset,
|
|
38
27
|
axisDirection,
|
|
39
|
-
zoomData
|
|
28
|
+
zoomData,
|
|
29
|
+
zoomOptions,
|
|
30
|
+
getFilters
|
|
40
31
|
}) {
|
|
41
|
-
const allAxis = normalizeAxis(inAxis, dataset, axisDirection);
|
|
42
32
|
const completeAxis = {};
|
|
43
|
-
allAxis.forEach((
|
|
33
|
+
allAxis.forEach((eachAxis, axisIndex) => {
|
|
34
|
+
const axis = eachAxis;
|
|
44
35
|
const isDefaultAxis = axisIndex === 0;
|
|
45
|
-
const
|
|
36
|
+
const zoomOption = zoomOptions?.[axis.id];
|
|
46
37
|
const zoom = zoomData?.find(({
|
|
47
38
|
axisId
|
|
48
39
|
}) => axisId === axis.id);
|
|
49
40
|
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
50
41
|
const range = getRange(drawingArea, axisDirection, axis.reverse);
|
|
42
|
+
const [minData, maxData] = getAxisExtremum(axis, extremumGetters, isDefaultAxis, formattedSeries, zoom === undefined && !zoomOption ? getFilters : undefined // Do not apply filtering if zoom is already defined.
|
|
43
|
+
);
|
|
44
|
+
const data = axis.data ?? [];
|
|
51
45
|
if (isBandScaleConfig(axis)) {
|
|
52
46
|
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
53
47
|
const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
54
48
|
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
55
49
|
const scaleRange = axisDirection === 'x' ? range : [range[1], range[0]];
|
|
56
|
-
const zoomedRange =
|
|
50
|
+
const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
|
|
57
51
|
completeAxis[axis.id] = _extends({
|
|
58
52
|
categoryGapRatio,
|
|
59
53
|
barGapRatio
|
|
60
54
|
}, axis, {
|
|
55
|
+
data,
|
|
61
56
|
scale: scaleBand(axis.data, zoomedRange).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
|
|
62
57
|
tickNumber: axis.data.length,
|
|
63
58
|
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
@@ -71,8 +66,9 @@ export function computeValue({
|
|
|
71
66
|
}
|
|
72
67
|
if (isPointScaleConfig(axis)) {
|
|
73
68
|
const scaleRange = axisDirection === 'x' ? range : [...range].reverse();
|
|
74
|
-
const zoomedRange =
|
|
69
|
+
const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
|
|
75
70
|
completeAxis[axis.id] = _extends({}, axis, {
|
|
71
|
+
data,
|
|
76
72
|
scale: scalePoint(axis.data, zoomedRange),
|
|
77
73
|
tickNumber: axis.data.length,
|
|
78
74
|
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
@@ -89,19 +85,20 @@ export function computeValue({
|
|
|
89
85
|
return;
|
|
90
86
|
}
|
|
91
87
|
const scaleType = axis.scaleType ?? 'linear';
|
|
92
|
-
const
|
|
88
|
+
const axisExtremums = [axis.min ?? minData, axis.max ?? maxData];
|
|
93
89
|
const rawTickNumber = getTickNumber(_extends({}, axis, {
|
|
94
90
|
range,
|
|
95
|
-
domain:
|
|
91
|
+
domain: axisExtremums
|
|
96
92
|
}));
|
|
97
93
|
const tickNumber = rawTickNumber / ((zoomRange[1] - zoomRange[0]) / 100);
|
|
98
|
-
const zoomedRange =
|
|
94
|
+
const zoomedRange = zoomScaleRange(range, zoomRange);
|
|
99
95
|
|
|
100
96
|
// TODO: move nice to prop? Disable when there is zoom?
|
|
101
|
-
const scale = getScale(scaleType,
|
|
97
|
+
const scale = getScale(scaleType, axisExtremums, zoomedRange).nice(rawTickNumber);
|
|
102
98
|
const [minDomain, maxDomain] = scale.domain();
|
|
103
99
|
const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
|
|
104
100
|
completeAxis[axis.id] = _extends({}, axis, {
|
|
101
|
+
data,
|
|
105
102
|
scaleType: scaleType,
|
|
106
103
|
scale: scale.domain(domain),
|
|
107
104
|
tickNumber,
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis, formattedSeries) => {
|
|
1
|
+
const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis, formattedSeries, getFilters) => {
|
|
2
2
|
const getter = getters[chartType];
|
|
3
3
|
const series = formattedSeries[chartType]?.series ?? {};
|
|
4
4
|
const [minChartTypeData, maxChartTypeData] = getter?.({
|
|
5
5
|
series,
|
|
6
6
|
axis,
|
|
7
|
-
isDefaultAxis
|
|
7
|
+
isDefaultAxis,
|
|
8
|
+
getFilters
|
|
8
9
|
}) ?? [Infinity, -Infinity];
|
|
9
|
-
|
|
10
|
+
const [minData, maxData] = acc;
|
|
11
|
+
return [Math.min(minChartTypeData, minData), Math.max(maxChartTypeData, maxData)];
|
|
10
12
|
};
|
|
11
|
-
export const getAxisExtremum = (axis, getters, isDefaultAxis, formattedSeries) => {
|
|
13
|
+
export const getAxisExtremum = (axis, getters, isDefaultAxis, formattedSeries, getFilters) => {
|
|
12
14
|
const charTypes = Object.keys(getters);
|
|
13
|
-
|
|
15
|
+
const extremums = charTypes.reduce((acc, charType) => axisExtremumCallback(acc, charType, axis, getters, isDefaultAxis, formattedSeries, getFilters), [Infinity, -Infinity]);
|
|
16
|
+
if (Number.isNaN(extremums[0]) || Number.isNaN(extremums[1])) {
|
|
17
|
+
return [Infinity, -Infinity];
|
|
18
|
+
}
|
|
19
|
+
return extremums;
|
|
14
20
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies the zoom into the scale range.
|
|
3
|
+
* It changes the screen coordinates that the scale covers.
|
|
4
|
+
* Not the data that is displayed.
|
|
5
|
+
*
|
|
6
|
+
* @param scaleRange the original range in real screen coordinates.
|
|
7
|
+
* @param zoomRange the zoom range in percentage.
|
|
8
|
+
* @returns zoomed range in real screen coordinates.
|
|
9
|
+
*/
|
|
10
|
+
export const zoomScaleRange = (scaleRange, zoomRange) => {
|
|
11
|
+
const rangeGap = scaleRange[1] - scaleRange[0];
|
|
12
|
+
const zoomGap = zoomRange[1] - zoomRange[0];
|
|
13
|
+
|
|
14
|
+
// If current zoom show the scale between p1 and p2 percents
|
|
15
|
+
// The range should be extended by adding [0, p1] and [p2, 100] segments
|
|
16
|
+
const min = scaleRange[0] - zoomRange[0] * rangeGap / zoomGap;
|
|
17
|
+
const max = scaleRange[1] + (100 - zoomRange[1]) * rangeGap / zoomGap;
|
|
18
|
+
return [min, max];
|
|
19
|
+
};
|
|
@@ -42,12 +42,20 @@ export function DrawingProvider(props) {
|
|
|
42
42
|
const isPointInside = React.useCallback(({
|
|
43
43
|
x,
|
|
44
44
|
y
|
|
45
|
-
},
|
|
45
|
+
}, options) => {
|
|
46
46
|
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
47
|
-
if (targetElement && targetElement.closest('[data-drawing-container]')) {
|
|
47
|
+
if (options?.targetElement && options?.targetElement.closest('[data-drawing-container]')) {
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
const isInsideX = x >= drawingArea.left - 1 && x <= drawingArea.left + drawingArea.width;
|
|
51
|
+
const isInsideY = y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height;
|
|
52
|
+
if (options?.direction === 'x') {
|
|
53
|
+
return isInsideX;
|
|
54
|
+
}
|
|
55
|
+
if (options?.direction === 'y') {
|
|
56
|
+
return isInsideY;
|
|
57
|
+
}
|
|
58
|
+
return isInsideX && isInsideY;
|
|
51
59
|
}, [drawingArea]);
|
|
52
60
|
const value = React.useMemo(() => _extends({
|
|
53
61
|
chartId: chartId ?? ''
|
|
@@ -44,7 +44,8 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
44
44
|
const value = scale.invert(mouseValue);
|
|
45
45
|
if (axisData === undefined) {
|
|
46
46
|
return {
|
|
47
|
-
value
|
|
47
|
+
value,
|
|
48
|
+
index: -1
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
const valueAsNumber = getAsANumber(value);
|
|
@@ -98,7 +99,9 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
98
99
|
const svgPoint = getSVGPoint(element, target);
|
|
99
100
|
mousePosition.current.x = svgPoint.x;
|
|
100
101
|
mousePosition.current.y = svgPoint.y;
|
|
101
|
-
if (!drawingArea.isPointInside(svgPoint,
|
|
102
|
+
if (!drawingArea.isPointInside(svgPoint, {
|
|
103
|
+
targetElement: event.target
|
|
104
|
+
})) {
|
|
102
105
|
if (mousePosition.current.isInChart) {
|
|
103
106
|
dispatch({
|
|
104
107
|
type: 'exitChart'
|
package/modern/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const SPAN_STYLE = {
|
|
|
20
20
|
whiteSpace: 'pre'
|
|
21
21
|
};
|
|
22
22
|
const STYLE_LIST = ['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom'];
|
|
23
|
-
const MEASUREMENT_SPAN_ID = 'mui_measurement_span';
|
|
23
|
+
export const MEASUREMENT_SPAN_ID = 'mui_measurement_span';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
*
|
|
@@ -57,7 +57,7 @@ function camelToMiddleLine(text) {
|
|
|
57
57
|
* @returns CSS styling string
|
|
58
58
|
*/
|
|
59
59
|
export const getStyleString = style => Object.keys(style).sort().reduce((result, s) => `${result}${camelToMiddleLine(s)}:${autoCompleteStyle(s, style[s])};`, '');
|
|
60
|
-
|
|
60
|
+
let domCleanTimeout;
|
|
61
61
|
/**
|
|
62
62
|
*
|
|
63
63
|
* @param text The string to estimate
|
|
@@ -105,6 +105,13 @@ export const getStringSize = (text, style = {}) => {
|
|
|
105
105
|
} else {
|
|
106
106
|
stringCache.cacheCount += 1;
|
|
107
107
|
}
|
|
108
|
+
if (domCleanTimeout) {
|
|
109
|
+
clearTimeout(domCleanTimeout);
|
|
110
|
+
}
|
|
111
|
+
domCleanTimeout = setTimeout(() => {
|
|
112
|
+
// Limit node cleaning to once per render cycle
|
|
113
|
+
measurementSpan.textContent = '';
|
|
114
|
+
}, 0);
|
|
108
115
|
return result;
|
|
109
116
|
} catch (e) {
|
|
110
117
|
return {
|
|
@@ -112,4 +119,10 @@ export const getStringSize = (text, style = {}) => {
|
|
|
112
119
|
height: 0
|
|
113
120
|
};
|
|
114
121
|
}
|
|
115
|
-
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
125
|
+
export function unstable_cleanupDOM() {
|
|
126
|
+
// const measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
|
|
127
|
+
// measurementSpan?.remove();
|
|
128
|
+
}
|
|
@@ -20,6 +20,8 @@ export * from './configInit';
|
|
|
20
20
|
export * from './getLabel';
|
|
21
21
|
export * from './getSVGPoint';
|
|
22
22
|
export * from './isDefined';
|
|
23
|
+
export { unstable_cleanupDOM } from './domUtils';
|
|
24
|
+
export * from './getScale';
|
|
23
25
|
|
|
24
26
|
// contexts
|
|
25
27
|
|
|
@@ -29,6 +31,8 @@ export * from '../context/InteractionProvider';
|
|
|
29
31
|
export * from '../context/SeriesProvider';
|
|
30
32
|
export * from '../context/ZAxisContextProvider';
|
|
31
33
|
export * from '../context/PluginProvider';
|
|
34
|
+
export { getAxisExtremum } from '../context/CartesianProvider/getAxisExtremum';
|
|
35
|
+
|
|
32
36
|
// series configuration
|
|
33
37
|
export * from '../models/seriesType/config';
|
|
34
38
|
export * from '../models/seriesType/common';
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { interpolateString } from '@mui/x-charts-vendor/d3-interpolate';
|
|
3
|
-
import { useSpring
|
|
3
|
+
import { useSpring } from '@react-spring/web';
|
|
4
4
|
function usePrevious(value) {
|
|
5
|
-
const ref = React.useRef(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
5
|
+
const ref = React.useRef({
|
|
6
|
+
currentPath: value,
|
|
7
|
+
previousPath: undefined
|
|
8
|
+
});
|
|
9
|
+
if (ref.current.currentPath !== value) {
|
|
10
|
+
ref.current = {
|
|
11
|
+
currentPath: value,
|
|
12
|
+
previousPath: ref.current.currentPath
|
|
13
|
+
};
|
|
14
|
+
}
|
|
9
15
|
return ref.current;
|
|
10
16
|
}
|
|
11
|
-
|
|
12
|
-
// Taken from Nivo
|
|
13
17
|
export const useAnimatedPath = (path, skipAnimation) => {
|
|
14
|
-
const
|
|
15
|
-
const interpolator = React.useMemo(() => previousPath ? interpolateString(previousPath,
|
|
16
|
-
const {
|
|
18
|
+
const memoryRef = usePrevious(path);
|
|
19
|
+
const interpolator = React.useMemo(() => memoryRef.previousPath ? interpolateString(memoryRef.previousPath, memoryRef.currentPath) : () => memoryRef.currentPath, [memoryRef.currentPath, memoryRef.previousPath]);
|
|
20
|
+
const [{
|
|
17
21
|
value
|
|
18
|
-
} = useSpring({
|
|
22
|
+
}] = useSpring({
|
|
19
23
|
from: {
|
|
20
24
|
value: 0
|
|
21
25
|
},
|
|
@@ -24,6 +28,6 @@ export const useAnimatedPath = (path, skipAnimation) => {
|
|
|
24
28
|
},
|
|
25
29
|
reset: true,
|
|
26
30
|
immediate: skipAnimation
|
|
27
|
-
});
|
|
28
|
-
return to(
|
|
31
|
+
}, [memoryRef.currentPath]);
|
|
32
|
+
return value.to(interpolator);
|
|
29
33
|
};
|
package/modern/models/axis.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { fireEvent } from '@mui/internal-test-utils';
|
|
3
|
+
export function firePointerEvent(target, type, options) {
|
|
4
|
+
const originalGetBoundingClientRect = target.getBoundingClientRect;
|
|
5
|
+
target.getBoundingClientRect = () => ({
|
|
6
|
+
x: 0,
|
|
7
|
+
y: 0,
|
|
8
|
+
bottom: 0,
|
|
9
|
+
height: 0,
|
|
10
|
+
left: 0,
|
|
11
|
+
right: 0,
|
|
12
|
+
top: 0,
|
|
13
|
+
width: 0,
|
|
14
|
+
toJSON() {
|
|
15
|
+
return {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
bottom: 0,
|
|
19
|
+
height: 0,
|
|
20
|
+
left: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
top: 0,
|
|
23
|
+
width: 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const event = new window.PointerEvent(type, _extends({
|
|
28
|
+
bubbles: true,
|
|
29
|
+
cancelable: true,
|
|
30
|
+
composed: true,
|
|
31
|
+
isPrimary: true
|
|
32
|
+
}, options));
|
|
33
|
+
fireEvent(target, event);
|
|
34
|
+
target.getBoundingClientRect = originalGetBoundingClientRect;
|
|
35
|
+
}
|