@mui/x-charts 8.11.3 → 8.13.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.d.ts +2 -2
- package/BarChart/BarChart.js +1 -0
- package/BarChart/BarChart.plugins.d.ts +3 -2
- package/BarChart/BarChart.plugins.js +2 -1
- package/BarChart/BarElement.js +10 -2
- package/BarChart/index.d.ts +1 -0
- package/BarChart/index.js +12 -0
- package/BarChart/useBarChartProps.d.ts +2 -2
- package/CHANGELOG.md +296 -6
- package/ChartContainer/ChartContainer.js +4 -2
- package/ChartContainer/useChartContainerProps.js +4 -2
- package/ChartsLegend/ContinuousColorLegend.js +1 -0
- package/ChartsLegend/PiecewiseColorLegend.js +1 -0
- package/ChartsSurface/ChartsSurface.js +23 -3
- package/ChartsWrapper/ChartsWrapper.d.ts +2 -1
- package/ChartsWrapper/ChartsWrapper.js +49 -46
- package/ChartsXAxis/useAxisTicksProps.d.ts +3 -3
- package/ChartsYAxis/useAxisTicksProps.d.ts +3 -3
- package/LineChart/FocusedMark.d.ts +2 -0
- package/LineChart/FocusedMark.js +44 -0
- package/LineChart/LineChart.d.ts +2 -2
- package/LineChart/LineChart.js +3 -1
- package/LineChart/LineChart.plugins.d.ts +3 -2
- package/LineChart/LineChart.plugins.js +2 -1
- package/LineChart/index.d.ts +1 -0
- package/LineChart/index.js +12 -0
- package/LineChart/useLineChartProps.d.ts +2 -2
- package/PieChart/PieArc.d.ts +4 -0
- package/PieChart/PieArc.js +16 -11
- package/PieChart/PieArcPlot.js +28 -3
- package/PieChart/PieChart.js +1 -0
- package/PieChart/PieChart.plugins.d.ts +2 -1
- package/PieChart/PieChart.plugins.js +2 -1
- package/PieChart/dataTransform/useTransformData.d.ts +1 -0
- package/PieChart/dataTransform/useTransformData.js +9 -1
- package/PieChart/index.d.ts +1 -0
- package/PieChart/index.js +12 -0
- package/RadarChart/RadarChart.plugins.d.ts +1 -1
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -3
- package/RadarChart/index.d.ts +2 -1
- package/RadarChart/index.js +12 -0
- package/RadarChart/useRadarChartProps.d.ts +2 -2
- package/ScatterChart/BatchScatter.d.ts +32 -0
- package/ScatterChart/BatchScatter.js +171 -0
- package/ScatterChart/Scatter.js +13 -5
- package/ScatterChart/ScatterChart.d.ts +4 -4
- package/ScatterChart/ScatterChart.js +13 -2
- package/ScatterChart/ScatterChart.plugins.d.ts +4 -3
- package/ScatterChart/ScatterChart.plugins.js +3 -2
- package/ScatterChart/ScatterPlot.d.ts +10 -0
- package/ScatterChart/ScatterPlot.js +14 -2
- package/ScatterChart/index.d.ts +1 -0
- package/ScatterChart/index.js +12 -0
- package/ScatterChart/useScatterChartProps.d.ts +2 -2
- package/ScatterChart/useScatterChartProps.js +8 -5
- package/SparkLineChart/SparkLineChart.js +10 -5
- package/Toolbar/Toolbar.js +1 -2
- package/colorPalettes/types.d.ts +1 -1
- package/context/ChartApi.d.ts +6 -6
- package/esm/BarChart/BarChart.d.ts +2 -2
- package/esm/BarChart/BarChart.js +1 -0
- package/esm/BarChart/BarChart.plugins.d.ts +3 -2
- package/esm/BarChart/BarChart.plugins.js +2 -1
- package/esm/BarChart/BarElement.js +10 -2
- package/esm/BarChart/index.d.ts +1 -0
- package/esm/BarChart/index.js +1 -0
- package/esm/BarChart/useBarChartProps.d.ts +2 -2
- package/esm/ChartContainer/ChartContainer.js +4 -2
- package/esm/ChartContainer/useChartContainerProps.js +4 -2
- package/esm/ChartsLegend/ContinuousColorLegend.js +1 -0
- package/esm/ChartsLegend/PiecewiseColorLegend.js +1 -0
- package/esm/ChartsSurface/ChartsSurface.js +23 -3
- package/esm/ChartsWrapper/ChartsWrapper.d.ts +2 -1
- package/esm/ChartsWrapper/ChartsWrapper.js +49 -46
- package/esm/ChartsXAxis/useAxisTicksProps.d.ts +3 -3
- package/esm/ChartsYAxis/useAxisTicksProps.d.ts +3 -3
- package/esm/LineChart/FocusedMark.d.ts +2 -0
- package/esm/LineChart/FocusedMark.js +38 -0
- package/esm/LineChart/LineChart.d.ts +2 -2
- package/esm/LineChart/LineChart.js +3 -1
- package/esm/LineChart/LineChart.plugins.d.ts +3 -2
- package/esm/LineChart/LineChart.plugins.js +2 -1
- package/esm/LineChart/index.d.ts +1 -0
- package/esm/LineChart/index.js +1 -0
- package/esm/LineChart/useLineChartProps.d.ts +2 -2
- package/esm/PieChart/PieArc.d.ts +4 -0
- package/esm/PieChart/PieArc.js +17 -12
- package/esm/PieChart/PieArcPlot.js +30 -5
- package/esm/PieChart/PieChart.js +1 -0
- package/esm/PieChart/PieChart.plugins.d.ts +2 -1
- package/esm/PieChart/PieChart.plugins.js +2 -1
- package/esm/PieChart/dataTransform/useTransformData.d.ts +1 -0
- package/esm/PieChart/dataTransform/useTransformData.js +9 -1
- package/esm/PieChart/index.d.ts +1 -0
- package/esm/PieChart/index.js +1 -0
- package/esm/RadarChart/RadarChart.plugins.d.ts +1 -1
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -3
- package/esm/RadarChart/index.d.ts +2 -1
- package/esm/RadarChart/index.js +2 -1
- package/esm/RadarChart/useRadarChartProps.d.ts +2 -2
- package/esm/ScatterChart/BatchScatter.d.ts +32 -0
- package/esm/ScatterChart/BatchScatter.js +165 -0
- package/esm/ScatterChart/Scatter.js +13 -5
- package/esm/ScatterChart/ScatterChart.d.ts +4 -4
- package/esm/ScatterChart/ScatterChart.js +13 -2
- package/esm/ScatterChart/ScatterChart.plugins.d.ts +4 -3
- package/esm/ScatterChart/ScatterChart.plugins.js +3 -2
- package/esm/ScatterChart/ScatterPlot.d.ts +10 -0
- package/esm/ScatterChart/ScatterPlot.js +14 -2
- package/esm/ScatterChart/index.d.ts +1 -0
- package/esm/ScatterChart/index.js +1 -0
- package/esm/ScatterChart/useScatterChartProps.d.ts +2 -2
- package/esm/ScatterChart/useScatterChartProps.js +8 -5
- package/esm/SparkLineChart/SparkLineChart.js +10 -5
- package/esm/Toolbar/Toolbar.js +1 -2
- package/esm/colorPalettes/types.d.ts +1 -1
- package/esm/context/ChartApi.d.ts +6 -6
- package/esm/hooks/useAxis.d.ts +5 -5
- package/esm/hooks/useDrawingArea.d.ts +20 -2
- package/esm/hooks/useFocusedItem.d.ts +15 -0
- package/esm/hooks/useFocusedItem.js +20 -0
- package/esm/hooks/useIsItemFocused.d.ts +12 -0
- package/esm/hooks/useIsItemFocused.js +15 -0
- package/esm/hooks/useIsItemFocusedGetter.d.ts +8 -0
- package/esm/hooks/useIsItemFocusedGetter.js +14 -0
- package/esm/hooks/useScale.js +6 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -1
- package/esm/internals/animation/Transition.js +1 -3
- package/esm/internals/index.d.ts +3 -2
- package/esm/internals/index.js +3 -2
- package/esm/internals/plugins/allPlugins.d.ts +5 -4
- package/esm/internals/plugins/allPlugins.js +3 -2
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +60 -32
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +19 -5
- package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +66 -72
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -19
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +10 -18
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/{getAxisExtremum.d.ts → getAxisExtrema.d.ts} +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +24 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +66 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +121 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +49 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +20 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +41 -21
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +30 -7
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/index.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/index.js +2 -0
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.js → useChartClosestPoint/useChartClosestPoint.js} +9 -7
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.d.ts +5 -0
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +3 -0
- package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.d.ts → useChartClosestPoint/useChartClosestPoint.types.d.ts} +8 -4
- package/esm/internals/plugins/featurePlugins/useChartHighlight/highlightStates.d.ts +16 -0
- package/esm/internals/plugins/featurePlugins/useChartHighlight/highlightStates.js +32 -0
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -0
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +5 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.js +3 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +6 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +2 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +6 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +2 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +20 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +88 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +170 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +37 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +33 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +36 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +1 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +10 -8
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +2 -1
- package/esm/internals/plugins/models/seriesConfig/getSeriesWithDefaultValues.types.d.ts +1 -1
- package/esm/internals/scaleGuards.d.ts +7 -0
- package/esm/internals/scaleGuards.js +6 -0
- package/esm/internals/ticks.d.ts +3 -5
- package/esm/internals/ticks.js +6 -5
- package/esm/locales/elGR.d.ts +96 -0
- package/esm/locales/elGR.js +100 -0
- package/esm/locales/enUS.d.ts +96 -0
- package/esm/locales/enUS.js +99 -1
- package/esm/locales/frFR.d.ts +96 -0
- package/esm/locales/frFR.js +100 -2
- package/esm/locales/ptBR.d.ts +96 -0
- package/esm/locales/ptBR.js +100 -0
- package/esm/locales/ptPT.d.ts +96 -0
- package/esm/locales/ptPT.js +100 -0
- package/esm/locales/svSE.d.ts +97 -1
- package/esm/locales/svSE.js +100 -0
- package/esm/locales/utils/chartsLocaleTextApi.d.ts +384 -0
- package/esm/locales/utils/getChartsLocalization.d.ts +96 -0
- package/esm/plugins/index.d.ts +6 -0
- package/esm/plugins/index.js +12 -0
- package/hooks/useAxis.d.ts +5 -5
- package/hooks/useDrawingArea.d.ts +20 -2
- package/hooks/useFocusedItem.d.ts +15 -0
- package/hooks/useFocusedItem.js +26 -0
- package/hooks/useIsItemFocused.d.ts +12 -0
- package/hooks/useIsItemFocused.js +20 -0
- package/hooks/useIsItemFocusedGetter.d.ts +8 -0
- package/hooks/useIsItemFocusedGetter.js +18 -0
- package/hooks/useScale.js +6 -0
- package/index.d.ts +1 -0
- package/index.js +13 -1
- package/internals/animation/Transition.js +0 -2
- package/internals/index.d.ts +3 -2
- package/internals/index.js +20 -8
- package/internals/plugins/allPlugins.d.ts +5 -4
- package/internals/plugins/allPlugins.js +3 -2
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +59 -31
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +19 -5
- package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +2 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +63 -69
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -19
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +10 -18
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/{getAxisExtremum.d.ts → getAxisExtrema.d.ts} +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +30 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +66 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +131 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +49 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +20 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +42 -22
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +30 -7
- package/internals/plugins/featurePlugins/useChartClosestPoint/index.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/index.js +27 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.d.ts +3 -0
- package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.js → useChartClosestPoint/useChartClosestPoint.js} +11 -9
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.d.ts +5 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +9 -0
- package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.d.ts → useChartClosestPoint/useChartClosestPoint.types.d.ts} +8 -4
- package/internals/plugins/featurePlugins/useChartHighlight/highlightStates.d.ts +16 -0
- package/internals/plugins/featurePlugins/useChartHighlight/highlightStates.js +41 -0
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -0
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +6 -1
- package/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.js +9 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +6 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +3 -2
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +6 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +27 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +20 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +96 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +178 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +37 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +39 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +36 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +5 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -4
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +10 -8
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +2 -1
- package/internals/plugins/models/seriesConfig/getSeriesWithDefaultValues.types.d.ts +1 -1
- package/internals/scaleGuards.d.ts +7 -0
- package/internals/scaleGuards.js +8 -0
- package/internals/ticks.d.ts +3 -5
- package/internals/ticks.js +7 -5
- package/locales/elGR.d.ts +96 -0
- package/locales/elGR.js +100 -0
- package/locales/enUS.d.ts +96 -0
- package/locales/enUS.js +99 -1
- package/locales/frFR.d.ts +96 -0
- package/locales/frFR.js +100 -2
- package/locales/ptBR.d.ts +96 -0
- package/locales/ptBR.js +100 -0
- package/locales/ptPT.d.ts +96 -0
- package/locales/ptPT.js +100 -0
- package/locales/svSE.d.ts +97 -1
- package/locales/svSE.js +100 -0
- package/locales/utils/chartsLocaleTextApi.d.ts +384 -0
- package/locales/utils/getChartsLocalization.d.ts +96 -0
- package/package.json +5 -5
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +47 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -22
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -2
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -29
- package/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
- package/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -27
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -9
- /package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
- /package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js
CHANGED
|
@@ -1,48 +1,67 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { GestureManager, MoveGesture, PanGesture, PinchGesture, PressGesture, TapGesture, TurnWheelGesture } from '@mui/x-internal-gestures/core';
|
|
4
|
+
import { GestureManager, MoveGesture, PanGesture, PinchGesture, PressGesture, TapAndDragGesture, TapGesture, TurnWheelGesture } from '@mui/x-internal-gestures/core';
|
|
5
5
|
const preventDefault = event => event.preventDefault();
|
|
6
6
|
export const useChartInteractionListener = ({
|
|
7
7
|
svgRef
|
|
8
8
|
}) => {
|
|
9
|
+
const gestureManagerRef = React.useRef(null);
|
|
9
10
|
React.useEffect(() => {
|
|
10
11
|
const svg = svgRef.current;
|
|
11
|
-
if (!
|
|
12
|
+
if (!gestureManagerRef.current) {
|
|
13
|
+
gestureManagerRef.current = new GestureManager({
|
|
14
|
+
gestures: [
|
|
15
|
+
// We separate the zoom gestures from the gestures that are not zoom related
|
|
16
|
+
// This allows us to configure the zoom gestures based on the zoom configuration.
|
|
17
|
+
new PanGesture({
|
|
18
|
+
name: 'pan',
|
|
19
|
+
threshold: 0,
|
|
20
|
+
maxPointers: 1
|
|
21
|
+
}), new PanGesture({
|
|
22
|
+
name: 'zoomPan',
|
|
23
|
+
threshold: 0,
|
|
24
|
+
maxPointers: 1,
|
|
25
|
+
preventIf: ['zoomTapAndDrag']
|
|
26
|
+
}), new MoveGesture({
|
|
27
|
+
name: 'move',
|
|
28
|
+
preventIf: ['pan', 'zoomPinch', 'zoomPan'] // Prevent move gesture when pan is active
|
|
29
|
+
}), new PinchGesture({
|
|
30
|
+
name: 'zoomPinch',
|
|
31
|
+
threshold: 5,
|
|
32
|
+
preventIf: ['pan', 'zoomPan']
|
|
33
|
+
}), new TurnWheelGesture({
|
|
34
|
+
name: 'zoomTurnWheel',
|
|
35
|
+
sensitivity: 0.01,
|
|
36
|
+
initialDelta: 1
|
|
37
|
+
}), new TapGesture({
|
|
38
|
+
name: 'tap',
|
|
39
|
+
maxDistance: 10,
|
|
40
|
+
preventIf: ['pan', 'zoomPan', 'zoomPinch']
|
|
41
|
+
}), new PressGesture({
|
|
42
|
+
name: 'quickPress',
|
|
43
|
+
duration: 50,
|
|
44
|
+
maxDistance: 10
|
|
45
|
+
}), new TapAndDragGesture({
|
|
46
|
+
name: 'zoomTapAndDrag',
|
|
47
|
+
tapMaxDistance: 10,
|
|
48
|
+
dragThreshold: 10,
|
|
49
|
+
dragTimeout: 1000
|
|
50
|
+
})]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Assign gesture manager after initialization
|
|
55
|
+
const gestureManager = gestureManagerRef.current;
|
|
56
|
+
if (!svg || !gestureManager) {
|
|
12
57
|
return undefined;
|
|
13
58
|
}
|
|
14
|
-
|
|
15
|
-
gestures: [new PanGesture({
|
|
16
|
-
name: 'pan',
|
|
17
|
-
threshold: 0,
|
|
18
|
-
maxPointers: 1
|
|
19
|
-
}), new MoveGesture({
|
|
20
|
-
name: 'move',
|
|
21
|
-
preventIf: ['pan', 'pinch'] // Prevent move gesture when pan is active
|
|
22
|
-
}), new PinchGesture({
|
|
23
|
-
name: 'pinch',
|
|
24
|
-
threshold: 5,
|
|
25
|
-
preventIf: ['pan']
|
|
26
|
-
}), new TurnWheelGesture({
|
|
27
|
-
name: 'turnWheel',
|
|
28
|
-
sensitivity: 0.01,
|
|
29
|
-
initialDelta: 1
|
|
30
|
-
}), new TapGesture({
|
|
31
|
-
name: 'tap',
|
|
32
|
-
maxDistance: 10,
|
|
33
|
-
preventIf: ['pan', 'pinch']
|
|
34
|
-
}), new PressGesture({
|
|
35
|
-
name: 'quickPress',
|
|
36
|
-
duration: 50,
|
|
37
|
-
maxDistance: 10
|
|
38
|
-
})]
|
|
39
|
-
});
|
|
40
|
-
gestureManager.registerElement(['pan', 'move', 'pinch', 'turnWheel', 'tap', 'quickPress'], svg);
|
|
59
|
+
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag'], svg);
|
|
41
60
|
return () => {
|
|
42
61
|
// Cleanup gesture manager
|
|
43
|
-
gestureManager.
|
|
62
|
+
gestureManager.unregisterAllGestures(svg);
|
|
44
63
|
};
|
|
45
|
-
}, [svgRef]);
|
|
64
|
+
}, [svgRef, gestureManagerRef]);
|
|
46
65
|
const addInteractionListener = React.useCallback((interaction, callback, options) => {
|
|
47
66
|
// Forcefully cast the svgRef to any, it is annoying to fix the types.
|
|
48
67
|
const svg = svgRef.current;
|
|
@@ -51,6 +70,14 @@ export const useChartInteractionListener = ({
|
|
|
51
70
|
cleanup: () => svg?.removeEventListener(interaction, callback)
|
|
52
71
|
};
|
|
53
72
|
}, [svgRef]);
|
|
73
|
+
const updateZoomInteractionListeners = React.useCallback((interaction, options) => {
|
|
74
|
+
const svg = svgRef.current;
|
|
75
|
+
const gestureManager = gestureManagerRef.current;
|
|
76
|
+
if (!gestureManager || !svg) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
gestureManager.setGestureOptions(interaction, svg, options ?? {});
|
|
80
|
+
}, [svgRef, gestureManagerRef]);
|
|
54
81
|
React.useEffect(() => {
|
|
55
82
|
const svg = svgRef.current;
|
|
56
83
|
|
|
@@ -67,7 +94,8 @@ export const useChartInteractionListener = ({
|
|
|
67
94
|
}, [svgRef]);
|
|
68
95
|
return {
|
|
69
96
|
instance: {
|
|
70
|
-
addInteractionListener
|
|
97
|
+
addInteractionListener,
|
|
98
|
+
updateZoomInteractionListeners
|
|
71
99
|
}
|
|
72
100
|
};
|
|
73
101
|
};
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { MoveEvent, PanEvent, PinchEvent, PressEvent, TapEvent, TurnWheelEvent } from '@mui/x-internal-gestures/core';
|
|
1
|
+
import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type TapAndDragEvent, type TapAndDragGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
|
|
2
2
|
import { ChartPluginSignature } from "../../models/index.js";
|
|
3
|
-
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | '
|
|
3
|
+
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'move' | 'moveStart' | 'moveEnd' | 'quickPress' | 'quickPressEnd' | 'zoomTurnWheel' | 'tap';
|
|
4
4
|
export type InteractionListenerResult = {
|
|
5
5
|
cleanup: () => void;
|
|
6
6
|
};
|
|
7
7
|
export type AddInteractionListener = {
|
|
8
|
-
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
9
|
-
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: '
|
|
10
|
-
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: '
|
|
8
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
9
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd', callback: (event: PinchEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
10
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTurnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
11
11
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'move' | 'moveStart' | 'moveEnd', callback: (event: MoveEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
12
12
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'tap', callback: (event: TapEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
13
13
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'quickPress' | 'quickPressEnd', callback: (event: PressEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
14
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd', callback: (event: TapAndDragEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
15
|
+
};
|
|
16
|
+
export type UpdateZoomInteractionListeners = {
|
|
17
|
+
(interaction: 'zoomPan', options?: Omit<PanGestureOptions<'zoomPan'>, 'name'>): void;
|
|
18
|
+
(interaction: 'zoomPinch', options?: Omit<PinchGestureOptions<'zoomPinch'>, 'name'>): void;
|
|
19
|
+
(interaction: 'zoomTurnWheel', options?: Omit<TurnWheelGestureOptions<'zoomTurnWheel'>, 'name'>): void;
|
|
20
|
+
(interaction: 'zoomTapAndDrag', options?: Omit<TapAndDragGestureOptions<'zoomTapAndDrag'>, 'name'>): void;
|
|
14
21
|
};
|
|
15
22
|
export interface UseChartInteractionListenerParameters {}
|
|
16
23
|
export interface UseChartInteractionListenerState {}
|
|
@@ -22,6 +29,13 @@ export interface UseChartInteractionListenerInstance {
|
|
|
22
29
|
* @param callback The callback to call when the interaction occurs.
|
|
23
30
|
*/
|
|
24
31
|
addInteractionListener: AddInteractionListener;
|
|
32
|
+
/**
|
|
33
|
+
* Updates the zoom interaction listeners with the provided options.
|
|
34
|
+
*
|
|
35
|
+
* @param interaction The interaction to update.
|
|
36
|
+
* @param options The options to apply to the interaction.
|
|
37
|
+
*/
|
|
38
|
+
updateZoomInteractionListeners: UpdateZoomInteractionListeners;
|
|
25
39
|
}
|
|
26
40
|
export type UseChartInteractionListenerSignature = ChartPluginSignature<{
|
|
27
41
|
params: UseChartInteractionListenerParameters;
|
|
@@ -17,7 +17,7 @@ export declare const preprocessSeries: <TSeriesType extends ChartSeriesType>({
|
|
|
17
17
|
dataset
|
|
18
18
|
}: {
|
|
19
19
|
series: Readonly<AllSeriesType<TSeriesType>[]>;
|
|
20
|
-
colors: string[];
|
|
20
|
+
colors: readonly string[];
|
|
21
21
|
seriesConfig: ChartSeriesConfig<TSeriesType>;
|
|
22
22
|
dataset?: Readonly<DatasetType>;
|
|
23
23
|
}) => { [type in TSeriesType]?: SeriesProcessorResult<TSeriesType> | undefined };
|
|
@@ -5,11 +5,13 @@ import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
|
|
|
5
5
|
import { ComputedAxisConfig, DefaultizedZoomOptions } from "./useChartCartesianAxis.types.js";
|
|
6
6
|
import { ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.js";
|
|
7
7
|
import { GetZoomAxisFilters, ZoomData } from "./zoom.types.js";
|
|
8
|
+
import { ScaleDefinition } from "./getAxisScale.js";
|
|
8
9
|
export type ComputeResult<T extends ChartsAxisProps> = {
|
|
9
10
|
axis: ComputedAxisConfig<T>;
|
|
10
11
|
axisIds: AxisId[];
|
|
11
12
|
};
|
|
12
13
|
type ComputeCommonParams<T extends ChartSeriesType = ChartSeriesType> = {
|
|
14
|
+
scales: Record<AxisId, ScaleDefinition>;
|
|
13
15
|
drawingArea: ChartDrawingArea;
|
|
14
16
|
formattedSeries: ProcessedSeries<T>;
|
|
15
17
|
seriesConfig: ChartSeriesConfig<T>;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
|
|
3
2
|
import { createScalarFormatter } from "../../../defaultValueFormatters.js";
|
|
4
|
-
import { isBandScaleConfig, isPointScaleConfig
|
|
5
|
-
import { getColorScale, getOrdinalColorScale } from "../../../colorScale.js";
|
|
6
|
-
import {
|
|
3
|
+
import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.js";
|
|
4
|
+
import { getColorScale, getOrdinalColorScale, getSequentialColorScale } from "../../../colorScale.js";
|
|
5
|
+
import { scaleTickNumberByRange } from "../../../ticks.js";
|
|
7
6
|
import { getScale } from "../../../getScale.js";
|
|
8
7
|
import { isDateData, createDateFormatter } from "../../../dateHelpers.js";
|
|
9
|
-
import {
|
|
10
|
-
import { getAxisExtremum } from "./getAxisExtremum.js";
|
|
8
|
+
import { getAxisExtrema } from "./getAxisExtrema.js";
|
|
11
9
|
import { getAxisTriggerTooltip } from "./getAxisTriggerTooltip.js";
|
|
12
|
-
import {
|
|
10
|
+
import { applyDomainLimit, getActualAxisExtrema, getDomainLimit } from "./getAxisScale.js";
|
|
11
|
+
import { isBandScale, isOrdinalScale } from "../../../scaleGuards.js";
|
|
13
12
|
function getRange(drawingArea, axisDirection,
|
|
14
13
|
// | 'rotation' | 'radius',
|
|
15
14
|
reverse) {
|
|
@@ -19,6 +18,7 @@ reverse) {
|
|
|
19
18
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
20
19
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
21
20
|
export function computeAxisValue({
|
|
21
|
+
scales,
|
|
22
22
|
drawingArea,
|
|
23
23
|
formattedSeries,
|
|
24
24
|
axis: allAxis,
|
|
@@ -39,97 +39,91 @@ export function computeAxisValue({
|
|
|
39
39
|
const completeAxis = {};
|
|
40
40
|
allAxis.forEach((eachAxis, axisIndex) => {
|
|
41
41
|
const axis = eachAxis;
|
|
42
|
+
const scaleDefinition = scales[axis.id];
|
|
43
|
+
let scale = scaleDefinition.scale;
|
|
42
44
|
const zoomOption = zoomOptions?.[axis.id];
|
|
43
45
|
const zoom = zoomMap?.get(axis.id);
|
|
44
46
|
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
45
47
|
const range = getRange(drawingArea, axisDirection, axis.reverse ?? false);
|
|
46
|
-
const [minData, maxData] = getAxisExtremum(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, zoom === undefined && !zoomOption ? getFilters : undefined // Do not apply filtering if zoom is already defined.
|
|
47
|
-
);
|
|
48
48
|
const triggerTooltip = !axis.ignoreTooltip && axisIdsTriggeringTooltip.has(axis.id);
|
|
49
49
|
const data = axis.data ?? [];
|
|
50
|
-
if (
|
|
51
|
-
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
52
|
-
const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
50
|
+
if (isOrdinalScale(scale)) {
|
|
53
51
|
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
54
52
|
const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
if (isBandScale(scale) && isBandScaleConfig(axis)) {
|
|
54
|
+
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
55
|
+
const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
56
|
+
completeAxis[axis.id] = _extends({
|
|
57
|
+
offset: 0,
|
|
58
|
+
height: 0,
|
|
59
|
+
categoryGapRatio,
|
|
60
|
+
barGapRatio,
|
|
61
|
+
triggerTooltip
|
|
62
|
+
}, axis, {
|
|
63
|
+
data,
|
|
64
|
+
scale,
|
|
65
|
+
tickNumber: axis.data.length,
|
|
66
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
67
|
+
values: axis.data
|
|
68
|
+
}, axis.colorMap)) : getColorScale(axis.colorMap))
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (isPointScaleConfig(axis)) {
|
|
72
|
+
completeAxis[axis.id] = _extends({
|
|
73
|
+
offset: 0,
|
|
74
|
+
height: 0,
|
|
75
|
+
triggerTooltip
|
|
76
|
+
}, axis, {
|
|
77
|
+
data,
|
|
78
|
+
scale,
|
|
79
|
+
tickNumber: axis.data.length,
|
|
80
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
81
|
+
values: axis.data
|
|
82
|
+
}, axis.colorMap)) : getColorScale(axis.colorMap))
|
|
83
|
+
});
|
|
73
84
|
}
|
|
74
|
-
}
|
|
75
|
-
if (isPointScaleConfig(axis)) {
|
|
76
|
-
const scaleRange = axisDirection === 'y' ? [...range].reverse() : range;
|
|
77
|
-
const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
|
|
78
|
-
completeAxis[axis.id] = _extends({
|
|
79
|
-
offset: 0,
|
|
80
|
-
height: 0,
|
|
81
|
-
triggerTooltip
|
|
82
|
-
}, axis, {
|
|
83
|
-
data,
|
|
84
|
-
scale: scalePoint(axis.data, zoomedRange),
|
|
85
|
-
tickNumber: axis.data.length,
|
|
86
|
-
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
|
|
87
|
-
values: axis.data
|
|
88
|
-
}, axis.colorMap)) : getColorScale(axis.colorMap))
|
|
89
|
-
});
|
|
90
85
|
if (isDateData(axis.data)) {
|
|
91
86
|
const dateFormatter = createDateFormatter(axis.data, scaleRange, axis.tickNumber);
|
|
92
87
|
completeAxis[axis.id].valueFormatter = axis.valueFormatter ?? dateFormatter;
|
|
93
88
|
}
|
|
89
|
+
return;
|
|
94
90
|
}
|
|
95
91
|
if (axis.scaleType === 'band' || axis.scaleType === 'point') {
|
|
96
92
|
// Could be merged with the two previous "if conditions" but then TS does not get that `axis.scaleType` can't be `band` or `point`.
|
|
97
93
|
return;
|
|
98
94
|
}
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
if (typeof domainLimit === 'function') {
|
|
103
|
-
const {
|
|
104
|
-
min,
|
|
105
|
-
max
|
|
106
|
-
} = domainLimit(minData, maxData);
|
|
107
|
-
axisExtremums[0] = min;
|
|
108
|
-
axisExtremums[1] = max;
|
|
109
|
-
}
|
|
110
|
-
const rawTickNumber = getTickNumber(_extends({}, axis, {
|
|
111
|
-
range,
|
|
112
|
-
domain: axisExtremums
|
|
113
|
-
}));
|
|
95
|
+
const rawTickNumber = scaleDefinition.tickNumber;
|
|
96
|
+
const continuousAxis = axis;
|
|
97
|
+
const scaleType = continuousAxis.scaleType ?? 'linear';
|
|
114
98
|
const tickNumber = scaleTickNumberByRange(rawTickNumber, zoomRange);
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
scale.
|
|
99
|
+
const filter = zoom === undefined && !zoomOption ? getFilters : undefined; // Do not apply filtering if zoom is already defined.
|
|
100
|
+
if (filter) {
|
|
101
|
+
const [minData, maxData] = getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, filter);
|
|
102
|
+
scale = scale.copy();
|
|
103
|
+
scale.domain([minData, maxData]);
|
|
104
|
+
const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
105
|
+
const axisExtrema = getActualAxisExtrema(axis, minData, maxData);
|
|
106
|
+
if (typeof domainLimit === 'function') {
|
|
107
|
+
const {
|
|
108
|
+
min,
|
|
109
|
+
max
|
|
110
|
+
} = domainLimit(minData, maxData);
|
|
111
|
+
axisExtrema[0] = min;
|
|
112
|
+
axisExtrema[1] = max;
|
|
113
|
+
}
|
|
114
|
+
scale.domain(axisExtrema);
|
|
115
|
+
applyDomainLimit(scale, axis, domainLimit, rawTickNumber);
|
|
119
116
|
}
|
|
120
|
-
const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
|
|
121
|
-
const [minDomain, maxDomain] = finalScale.domain();
|
|
122
|
-
const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
|
|
123
117
|
completeAxis[axis.id] = _extends({
|
|
124
118
|
offset: 0,
|
|
125
119
|
height: 0,
|
|
126
120
|
triggerTooltip
|
|
127
|
-
},
|
|
121
|
+
}, continuousAxis, {
|
|
128
122
|
data,
|
|
129
|
-
scaleType
|
|
130
|
-
scale
|
|
123
|
+
scaleType,
|
|
124
|
+
scale,
|
|
131
125
|
tickNumber,
|
|
132
|
-
colorScale:
|
|
126
|
+
colorScale: continuousAxis.colorMap && getSequentialColorScale(continuousAxis.colorMap),
|
|
133
127
|
valueFormatter: axis.valueFormatter ?? createScalarFormatter(tickNumber, getScale(scaleType, range.map(v => scale.invert(v)), range))
|
|
134
128
|
});
|
|
135
129
|
});
|
package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import { AxisId,
|
|
2
|
-
import { CartesianChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
|
-
import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
1
|
+
import { AxisId, D3ContinuousScale, D3Scale } from "../../../../models/axis.js";
|
|
4
2
|
import { AxisConfig } from "../../../../models/index.js";
|
|
5
|
-
import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
|
|
6
3
|
import { DefaultizedZoomOptions, ExtremumFilter } from "./useChartCartesianAxis.types.js";
|
|
7
4
|
import { GetZoomAxisFilters, ZoomAxisFilters, ZoomData } from "./zoom.types.js";
|
|
8
|
-
export declare function createAxisFilterMapper(
|
|
9
|
-
zoomMap: Map<AxisId, ZoomData>;
|
|
10
|
-
zoomOptions: Record<AxisId, DefaultizedZoomOptions>;
|
|
11
|
-
seriesConfig: ChartSeriesConfig<CartesianChartSeriesType>;
|
|
12
|
-
formattedSeries: ProcessedSeries;
|
|
13
|
-
direction: 'x';
|
|
14
|
-
}): (axis: AxisConfig<ScaleName, any, ChartsXAxisProps>, axisIndex: number) => ExtremumFilter | null;
|
|
15
|
-
export declare function createAxisFilterMapper(params: {
|
|
16
|
-
zoomMap: Map<AxisId, ZoomData>;
|
|
17
|
-
zoomOptions: Record<AxisId, DefaultizedZoomOptions>;
|
|
18
|
-
seriesConfig: ChartSeriesConfig<CartesianChartSeriesType>;
|
|
19
|
-
formattedSeries: ProcessedSeries;
|
|
20
|
-
direction: 'y';
|
|
21
|
-
}): (axis: AxisConfig<ScaleName, any, ChartsYAxisProps>, axisIndex: number) => ExtremumFilter | null;
|
|
5
|
+
export declare function createAxisFilterMapper(zoomMap: Map<AxisId, ZoomData>, zoomOptions: Record<AxisId, DefaultizedZoomOptions>, direction: 'x' | 'y'): (axisId: AxisId, axisData: AxisConfig['data'], scale: D3Scale) => ExtremumFilter | null;
|
|
22
6
|
export declare function createDiscreteScaleGetAxisFilter(axisData: AxisConfig['data'], zoomStart: number, zoomEnd: number, direction: 'x' | 'y'): ExtremumFilter;
|
|
23
|
-
export declare function createContinuousScaleGetAxisFilter(
|
|
7
|
+
export declare function createContinuousScaleGetAxisFilter(scale: D3ContinuousScale, zoomStart: number, zoomEnd: number, direction: 'x' | 'y', axisData: AxisConfig['data']): ExtremumFilter;
|
|
24
8
|
export declare const createGetAxisFilters: (filters: ZoomAxisFilters) => GetZoomAxisFilters;
|
package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
import { isDefined } from "../../../isDefined.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
zoomOptions,
|
|
7
|
-
seriesConfig,
|
|
8
|
-
formattedSeries,
|
|
9
|
-
direction
|
|
10
|
-
}) {
|
|
11
|
-
return (axis, axisIndex) => {
|
|
12
|
-
const zoomOption = zoomOptions[axis.id];
|
|
2
|
+
import { isOrdinalScale } from "../../../scaleGuards.js";
|
|
3
|
+
export function createAxisFilterMapper(zoomMap, zoomOptions, direction) {
|
|
4
|
+
return (axisId, axisData, scale) => {
|
|
5
|
+
const zoomOption = zoomOptions[axisId];
|
|
13
6
|
if (!zoomOption || zoomOption.filterMode !== 'discard') {
|
|
14
7
|
return null;
|
|
15
8
|
}
|
|
16
|
-
const zoom = zoomMap?.get(
|
|
9
|
+
const zoom = zoomMap?.get(axisId);
|
|
17
10
|
if (zoom === undefined || zoom.start <= 0 && zoom.end >= 100) {
|
|
18
11
|
// No zoom, or zoom with all data visible
|
|
19
12
|
return null;
|
|
20
13
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return createDiscreteScaleGetAxisFilter(axis.data, zoom.start, zoom.end, direction);
|
|
14
|
+
if (isOrdinalScale(scale)) {
|
|
15
|
+
return createDiscreteScaleGetAxisFilter(axisData, zoom.start, zoom.end, direction);
|
|
24
16
|
}
|
|
25
|
-
return createContinuousScaleGetAxisFilter(
|
|
17
|
+
return createContinuousScaleGetAxisFilter(scale, zoom.start, zoom.end, direction, axisData);
|
|
26
18
|
};
|
|
27
19
|
}
|
|
28
20
|
export function createDiscreteScaleGetAxisFilter(axisData, zoomStart, zoomEnd, direction) {
|
|
@@ -38,10 +30,10 @@ export function createDiscreteScaleGetAxisFilter(axisData, zoomStart, zoomEnd, d
|
|
|
38
30
|
return dataIndex >= minVal && dataIndex < maxVal;
|
|
39
31
|
};
|
|
40
32
|
}
|
|
41
|
-
export function createContinuousScaleGetAxisFilter(
|
|
33
|
+
export function createContinuousScaleGetAxisFilter(scale, zoomStart, zoomEnd, direction, axisData) {
|
|
42
34
|
let min;
|
|
43
35
|
let max;
|
|
44
|
-
[min, max] =
|
|
36
|
+
[min, max] = scale.domain();
|
|
45
37
|
min = min instanceof Date ? min.getTime() : min;
|
|
46
38
|
max = max instanceof Date ? max.getTime() : max;
|
|
47
39
|
const minVal = min + zoomStart * (max - min) / 100;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxisConfig } from "../../../../models/axis.js";
|
|
2
2
|
import { CartesianChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
3
|
import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
-
export declare const getAxisDomainLimit: <T extends CartesianChartSeriesType>(axis: AxisConfig, axisDirection: "x" | "y", axisIndex: number, formattedSeries: ProcessedSeries<T | "line">) => "nice" | "strict" | ((min: number, max: number) => {
|
|
4
|
+
export declare const getAxisDomainLimit: <T extends CartesianChartSeriesType>(axis: Pick<AxisConfig, "id" | "domainLimit">, axisDirection: "x" | "y", axisIndex: number, formattedSeries: ProcessedSeries<T | "line">) => "nice" | "strict" | ((min: number, max: number) => {
|
|
5
5
|
min: number;
|
|
6
6
|
max: number;
|
|
7
7
|
});
|
|
@@ -3,4 +3,4 @@ import { CartesianChartSeriesType } from "../../../../models/seriesType/config.j
|
|
|
3
3
|
import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
|
|
4
4
|
import { ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.js";
|
|
5
5
|
import { GetZoomAxisFilters } from "./zoom.types.js";
|
|
6
|
-
export declare
|
|
6
|
+
export declare function getAxisExtrema<T extends CartesianChartSeriesType>(axis: AxisConfig, axisDirection: 'x' | 'y', seriesConfig: ChartSeriesConfig<T>, axisIndex: number, formattedSeries: ProcessedSeries<T>, getFilters?: GetZoomAxisFilters): [number, number];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isCartesianSeriesType } from "../../../isCartesian.js";
|
|
2
|
+
const axisExtremumCallback = (chartType, axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters) => {
|
|
3
|
+
const getter = axisDirection === 'x' ? seriesConfig[chartType].xExtremumGetter : seriesConfig[chartType].yExtremumGetter;
|
|
4
|
+
const series = formattedSeries[chartType]?.series ?? {};
|
|
5
|
+
return getter?.({
|
|
6
|
+
series,
|
|
7
|
+
axis,
|
|
8
|
+
axisIndex,
|
|
9
|
+
isDefaultAxis: axisIndex === 0,
|
|
10
|
+
getFilters
|
|
11
|
+
}) ?? [Infinity, -Infinity];
|
|
12
|
+
};
|
|
13
|
+
export function getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters) {
|
|
14
|
+
const cartesianChartTypes = Object.keys(seriesConfig).filter(isCartesianSeriesType);
|
|
15
|
+
let extrema = [Infinity, -Infinity];
|
|
16
|
+
for (const chartType of cartesianChartTypes) {
|
|
17
|
+
const [min, max] = axisExtremumCallback(chartType, axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters);
|
|
18
|
+
extrema = [Math.min(extrema[0], min), Math.max(extrema[1], max)];
|
|
19
|
+
}
|
|
20
|
+
if (Number.isNaN(extrema[0]) || Number.isNaN(extrema[1])) {
|
|
21
|
+
return [Infinity, -Infinity];
|
|
22
|
+
}
|
|
23
|
+
return extrema;
|
|
24
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { AxisConfig, AxisId, D3ContinuousScale, D3OrdinalScale, DefaultedAxis } from "../../../../models/axis.js";
|
|
2
|
+
import { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
|
+
import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
import { ChartSeriesConfig } from "../../models/index.js";
|
|
5
|
+
import { ZoomData } from "./zoom.types.js";
|
|
6
|
+
import { ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
|
|
7
|
+
type GetAxesScalesParams<T extends ChartSeriesType = ChartSeriesType> = {
|
|
8
|
+
drawingArea: ChartDrawingArea;
|
|
9
|
+
formattedSeries: ProcessedSeries<T>;
|
|
10
|
+
seriesConfig: ChartSeriesConfig<T>;
|
|
11
|
+
zoomMap?: Map<AxisId, ZoomData>;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
14
|
+
*/
|
|
15
|
+
preferStrictDomainInLineCharts?: boolean;
|
|
16
|
+
defaultTickNumber: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function getXAxesScales<T extends ChartSeriesType>({
|
|
19
|
+
drawingArea,
|
|
20
|
+
formattedSeries,
|
|
21
|
+
axis: axes,
|
|
22
|
+
seriesConfig,
|
|
23
|
+
zoomMap,
|
|
24
|
+
preferStrictDomainInLineCharts,
|
|
25
|
+
defaultTickNumber
|
|
26
|
+
}: GetAxesScalesParams<T> & {
|
|
27
|
+
axis?: DefaultedAxis[];
|
|
28
|
+
}): Record<AxisId, ScaleDefinition>;
|
|
29
|
+
export declare function getYAxesScales<T extends ChartSeriesType>({
|
|
30
|
+
drawingArea,
|
|
31
|
+
formattedSeries,
|
|
32
|
+
axis: axes,
|
|
33
|
+
seriesConfig,
|
|
34
|
+
zoomMap,
|
|
35
|
+
preferStrictDomainInLineCharts,
|
|
36
|
+
defaultTickNumber
|
|
37
|
+
}: GetAxesScalesParams<T> & {
|
|
38
|
+
axis?: DefaultedAxis[];
|
|
39
|
+
}): Record<AxisId, ScaleDefinition>;
|
|
40
|
+
export type ScaleDefinition = {
|
|
41
|
+
scale: D3ContinuousScale;
|
|
42
|
+
tickNumber: number;
|
|
43
|
+
} | {
|
|
44
|
+
scale: D3OrdinalScale;
|
|
45
|
+
tickNumber?: never;
|
|
46
|
+
};
|
|
47
|
+
type DomainLimit = 'nice' | 'strict' | ((min: number, max: number) => {
|
|
48
|
+
min: number;
|
|
49
|
+
max: number;
|
|
50
|
+
});
|
|
51
|
+
export declare function getDomainLimit(axis: Pick<DefaultedAxis, 'id' | 'domainLimit'>, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, preferStrictDomainInLineCharts: boolean | undefined): "nice" | "strict" | ((min: number, max: number) => {
|
|
52
|
+
min: number;
|
|
53
|
+
max: number;
|
|
54
|
+
});
|
|
55
|
+
export declare function applyDomainLimit(scale: D3ContinuousScale, axis: {
|
|
56
|
+
min?: number | Date;
|
|
57
|
+
max?: number | Date;
|
|
58
|
+
}, domainLimit: DomainLimit, rawTickNumber: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* Get the actual axis extrema considering the user defined min and max values.
|
|
61
|
+
* @param axisExtrema User defined axis extrema.
|
|
62
|
+
* @param minData Minimum value from the data.
|
|
63
|
+
* @param maxData Maximum value from the data.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getActualAxisExtrema(axisExtrema: Pick<AxisConfig, 'min' | 'max'>, minData: number, maxData: number): [number | Date, number | Date];
|
|
66
|
+
export {};
|