@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
|
@@ -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>;
|
|
@@ -6,17 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.computeAxisValue = computeAxisValue;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
|
|
10
9
|
var _defaultValueFormatters = require("../../../defaultValueFormatters");
|
|
11
10
|
var _axis = require("../../../../models/axis");
|
|
12
11
|
var _colorScale = require("../../../colorScale");
|
|
13
12
|
var _ticks = require("../../../ticks");
|
|
14
13
|
var _getScale = require("../../../getScale");
|
|
15
14
|
var _dateHelpers = require("../../../dateHelpers");
|
|
16
|
-
var
|
|
17
|
-
var _getAxisExtremum = require("./getAxisExtremum");
|
|
15
|
+
var _getAxisExtrema = require("./getAxisExtrema");
|
|
18
16
|
var _getAxisTriggerTooltip = require("./getAxisTriggerTooltip");
|
|
19
|
-
var
|
|
17
|
+
var _getAxisScale = require("./getAxisScale");
|
|
18
|
+
var _scaleGuards = require("../../../scaleGuards");
|
|
20
19
|
function getRange(drawingArea, axisDirection,
|
|
21
20
|
// | 'rotation' | 'radius',
|
|
22
21
|
reverse) {
|
|
@@ -26,6 +25,7 @@ reverse) {
|
|
|
26
25
|
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
27
26
|
const DEFAULT_BAR_GAP_RATIO = 0.1;
|
|
28
27
|
function computeAxisValue({
|
|
28
|
+
scales,
|
|
29
29
|
drawingArea,
|
|
30
30
|
formattedSeries,
|
|
31
31
|
axis: allAxis,
|
|
@@ -46,97 +46,91 @@ function computeAxisValue({
|
|
|
46
46
|
const completeAxis = {};
|
|
47
47
|
allAxis.forEach((eachAxis, axisIndex) => {
|
|
48
48
|
const axis = eachAxis;
|
|
49
|
+
const scaleDefinition = scales[axis.id];
|
|
50
|
+
let scale = scaleDefinition.scale;
|
|
49
51
|
const zoomOption = zoomOptions?.[axis.id];
|
|
50
52
|
const zoom = zoomMap?.get(axis.id);
|
|
51
53
|
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
52
54
|
const range = getRange(drawingArea, axisDirection, axis.reverse ?? false);
|
|
53
|
-
const [minData, maxData] = (0, _getAxisExtremum.getAxisExtremum)(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, zoom === undefined && !zoomOption ? getFilters : undefined // Do not apply filtering if zoom is already defined.
|
|
54
|
-
);
|
|
55
55
|
const triggerTooltip = !axis.ignoreTooltip && axisIdsTriggeringTooltip.has(axis.id);
|
|
56
56
|
const data = axis.data ?? [];
|
|
57
|
-
if ((0,
|
|
58
|
-
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
59
|
-
const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
57
|
+
if ((0, _scaleGuards.isOrdinalScale)(scale)) {
|
|
60
58
|
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
61
59
|
const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
if ((0, _scaleGuards.isBandScale)(scale) && (0, _axis.isBandScaleConfig)(axis)) {
|
|
61
|
+
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
62
|
+
const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
|
|
63
|
+
completeAxis[axis.id] = (0, _extends2.default)({
|
|
64
|
+
offset: 0,
|
|
65
|
+
height: 0,
|
|
66
|
+
categoryGapRatio,
|
|
67
|
+
barGapRatio,
|
|
68
|
+
triggerTooltip
|
|
69
|
+
}, axis, {
|
|
70
|
+
data,
|
|
71
|
+
scale,
|
|
72
|
+
tickNumber: axis.data.length,
|
|
73
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? (0, _colorScale.getOrdinalColorScale)((0, _extends2.default)({
|
|
74
|
+
values: axis.data
|
|
75
|
+
}, axis.colorMap)) : (0, _colorScale.getColorScale)(axis.colorMap))
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if ((0, _axis.isPointScaleConfig)(axis)) {
|
|
79
|
+
completeAxis[axis.id] = (0, _extends2.default)({
|
|
80
|
+
offset: 0,
|
|
81
|
+
height: 0,
|
|
82
|
+
triggerTooltip
|
|
83
|
+
}, axis, {
|
|
84
|
+
data,
|
|
85
|
+
scale,
|
|
86
|
+
tickNumber: axis.data.length,
|
|
87
|
+
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? (0, _colorScale.getOrdinalColorScale)((0, _extends2.default)({
|
|
88
|
+
values: axis.data
|
|
89
|
+
}, axis.colorMap)) : (0, _colorScale.getColorScale)(axis.colorMap))
|
|
90
|
+
});
|
|
80
91
|
}
|
|
81
|
-
}
|
|
82
|
-
if ((0, _axis.isPointScaleConfig)(axis)) {
|
|
83
|
-
const scaleRange = axisDirection === 'y' ? [...range].reverse() : range;
|
|
84
|
-
const zoomedRange = (0, _zoom.zoomScaleRange)(scaleRange, zoomRange);
|
|
85
|
-
completeAxis[axis.id] = (0, _extends2.default)({
|
|
86
|
-
offset: 0,
|
|
87
|
-
height: 0,
|
|
88
|
-
triggerTooltip
|
|
89
|
-
}, axis, {
|
|
90
|
-
data,
|
|
91
|
-
scale: (0, _d3Scale.scalePoint)(axis.data, zoomedRange),
|
|
92
|
-
tickNumber: axis.data.length,
|
|
93
|
-
colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? (0, _colorScale.getOrdinalColorScale)((0, _extends2.default)({
|
|
94
|
-
values: axis.data
|
|
95
|
-
}, axis.colorMap)) : (0, _colorScale.getColorScale)(axis.colorMap))
|
|
96
|
-
});
|
|
97
92
|
if ((0, _dateHelpers.isDateData)(axis.data)) {
|
|
98
93
|
const dateFormatter = (0, _dateHelpers.createDateFormatter)(axis.data, scaleRange, axis.tickNumber);
|
|
99
94
|
completeAxis[axis.id].valueFormatter = axis.valueFormatter ?? dateFormatter;
|
|
100
95
|
}
|
|
96
|
+
return;
|
|
101
97
|
}
|
|
102
98
|
if (axis.scaleType === 'band' || axis.scaleType === 'point') {
|
|
103
99
|
// Could be merged with the two previous "if conditions" but then TS does not get that `axis.scaleType` can't be `band` or `point`.
|
|
104
100
|
return;
|
|
105
101
|
}
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
if (typeof domainLimit === 'function') {
|
|
110
|
-
const {
|
|
111
|
-
min,
|
|
112
|
-
max
|
|
113
|
-
} = domainLimit(minData, maxData);
|
|
114
|
-
axisExtremums[0] = min;
|
|
115
|
-
axisExtremums[1] = max;
|
|
116
|
-
}
|
|
117
|
-
const rawTickNumber = (0, _ticks.getTickNumber)((0, _extends2.default)({}, axis, {
|
|
118
|
-
range,
|
|
119
|
-
domain: axisExtremums
|
|
120
|
-
}));
|
|
102
|
+
const rawTickNumber = scaleDefinition.tickNumber;
|
|
103
|
+
const continuousAxis = axis;
|
|
104
|
+
const scaleType = continuousAxis.scaleType ?? 'linear';
|
|
121
105
|
const tickNumber = (0, _ticks.scaleTickNumberByRange)(rawTickNumber, zoomRange);
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
scale.
|
|
106
|
+
const filter = zoom === undefined && !zoomOption ? getFilters : undefined; // Do not apply filtering if zoom is already defined.
|
|
107
|
+
if (filter) {
|
|
108
|
+
const [minData, maxData] = (0, _getAxisExtrema.getAxisExtrema)(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, filter);
|
|
109
|
+
scale = scale.copy();
|
|
110
|
+
scale.domain([minData, maxData]);
|
|
111
|
+
const domainLimit = (0, _getAxisScale.getDomainLimit)(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
112
|
+
const axisExtrema = (0, _getAxisScale.getActualAxisExtrema)(axis, minData, maxData);
|
|
113
|
+
if (typeof domainLimit === 'function') {
|
|
114
|
+
const {
|
|
115
|
+
min,
|
|
116
|
+
max
|
|
117
|
+
} = domainLimit(minData, maxData);
|
|
118
|
+
axisExtrema[0] = min;
|
|
119
|
+
axisExtrema[1] = max;
|
|
120
|
+
}
|
|
121
|
+
scale.domain(axisExtrema);
|
|
122
|
+
(0, _getAxisScale.applyDomainLimit)(scale, axis, domainLimit, rawTickNumber);
|
|
126
123
|
}
|
|
127
|
-
const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
|
|
128
|
-
const [minDomain, maxDomain] = finalScale.domain();
|
|
129
|
-
const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
|
|
130
124
|
completeAxis[axis.id] = (0, _extends2.default)({
|
|
131
125
|
offset: 0,
|
|
132
126
|
height: 0,
|
|
133
127
|
triggerTooltip
|
|
134
|
-
},
|
|
128
|
+
}, continuousAxis, {
|
|
135
129
|
data,
|
|
136
|
-
scaleType
|
|
137
|
-
scale
|
|
130
|
+
scaleType,
|
|
131
|
+
scale,
|
|
138
132
|
tickNumber,
|
|
139
|
-
colorScale:
|
|
133
|
+
colorScale: continuousAxis.colorMap && (0, _colorScale.getSequentialColorScale)(continuousAxis.colorMap),
|
|
140
134
|
valueFormatter: axis.valueFormatter ?? (0, _defaultValueFormatters.createScalarFormatter)(tickNumber, (0, _getScale.getScale)(scaleType, range.map(v => scale.invert(v)), range))
|
|
141
135
|
});
|
|
142
136
|
});
|
|
@@ -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;
|
|
@@ -8,30 +8,22 @@ exports.createContinuousScaleGetAxisFilter = createContinuousScaleGetAxisFilter;
|
|
|
8
8
|
exports.createDiscreteScaleGetAxisFilter = createDiscreteScaleGetAxisFilter;
|
|
9
9
|
exports.createGetAxisFilters = void 0;
|
|
10
10
|
var _isDefined = require("../../../isDefined");
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
zoomOptions,
|
|
16
|
-
seriesConfig,
|
|
17
|
-
formattedSeries,
|
|
18
|
-
direction
|
|
19
|
-
}) {
|
|
20
|
-
return (axis, axisIndex) => {
|
|
21
|
-
const zoomOption = zoomOptions[axis.id];
|
|
11
|
+
var _scaleGuards = require("../../../scaleGuards");
|
|
12
|
+
function createAxisFilterMapper(zoomMap, zoomOptions, direction) {
|
|
13
|
+
return (axisId, axisData, scale) => {
|
|
14
|
+
const zoomOption = zoomOptions[axisId];
|
|
22
15
|
if (!zoomOption || zoomOption.filterMode !== 'discard') {
|
|
23
16
|
return null;
|
|
24
17
|
}
|
|
25
|
-
const zoom = zoomMap?.get(
|
|
18
|
+
const zoom = zoomMap?.get(axisId);
|
|
26
19
|
if (zoom === undefined || zoom.start <= 0 && zoom.end >= 100) {
|
|
27
20
|
// No zoom, or zoom with all data visible
|
|
28
21
|
return null;
|
|
29
22
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return createDiscreteScaleGetAxisFilter(axis.data, zoom.start, zoom.end, direction);
|
|
23
|
+
if ((0, _scaleGuards.isOrdinalScale)(scale)) {
|
|
24
|
+
return createDiscreteScaleGetAxisFilter(axisData, zoom.start, zoom.end, direction);
|
|
33
25
|
}
|
|
34
|
-
return createContinuousScaleGetAxisFilter(
|
|
26
|
+
return createContinuousScaleGetAxisFilter(scale, zoom.start, zoom.end, direction, axisData);
|
|
35
27
|
};
|
|
36
28
|
}
|
|
37
29
|
function createDiscreteScaleGetAxisFilter(axisData, zoomStart, zoomEnd, direction) {
|
|
@@ -47,10 +39,10 @@ function createDiscreteScaleGetAxisFilter(axisData, zoomStart, zoomEnd, directio
|
|
|
47
39
|
return dataIndex >= minVal && dataIndex < maxVal;
|
|
48
40
|
};
|
|
49
41
|
}
|
|
50
|
-
function createContinuousScaleGetAxisFilter(
|
|
42
|
+
function createContinuousScaleGetAxisFilter(scale, zoomStart, zoomEnd, direction, axisData) {
|
|
51
43
|
let min;
|
|
52
44
|
let max;
|
|
53
|
-
[min, max] =
|
|
45
|
+
[min, max] = scale.domain();
|
|
54
46
|
min = min instanceof Date ? min.getTime() : min;
|
|
55
47
|
max = max instanceof Date ? max.getTime() : max;
|
|
56
48
|
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,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAxisExtrema = getAxisExtrema;
|
|
7
|
+
var _isCartesian = require("../../../isCartesian");
|
|
8
|
+
const axisExtremumCallback = (chartType, axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters) => {
|
|
9
|
+
const getter = axisDirection === 'x' ? seriesConfig[chartType].xExtremumGetter : seriesConfig[chartType].yExtremumGetter;
|
|
10
|
+
const series = formattedSeries[chartType]?.series ?? {};
|
|
11
|
+
return getter?.({
|
|
12
|
+
series,
|
|
13
|
+
axis,
|
|
14
|
+
axisIndex,
|
|
15
|
+
isDefaultAxis: axisIndex === 0,
|
|
16
|
+
getFilters
|
|
17
|
+
}) ?? [Infinity, -Infinity];
|
|
18
|
+
};
|
|
19
|
+
function getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters) {
|
|
20
|
+
const cartesianChartTypes = Object.keys(seriesConfig).filter(_isCartesian.isCartesianSeriesType);
|
|
21
|
+
let extrema = [Infinity, -Infinity];
|
|
22
|
+
for (const chartType of cartesianChartTypes) {
|
|
23
|
+
const [min, max] = axisExtremumCallback(chartType, axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters);
|
|
24
|
+
extrema = [Math.min(extrema[0], min), Math.max(extrema[1], max)];
|
|
25
|
+
}
|
|
26
|
+
if (Number.isNaN(extrema[0]) || Number.isNaN(extrema[1])) {
|
|
27
|
+
return [Infinity, -Infinity];
|
|
28
|
+
}
|
|
29
|
+
return extrema;
|
|
30
|
+
}
|
|
@@ -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 {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyDomainLimit = applyDomainLimit;
|
|
7
|
+
exports.getActualAxisExtrema = getActualAxisExtrema;
|
|
8
|
+
exports.getDomainLimit = getDomainLimit;
|
|
9
|
+
exports.getXAxesScales = getXAxesScales;
|
|
10
|
+
exports.getYAxesScales = getYAxesScales;
|
|
11
|
+
var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
|
|
12
|
+
var _axis = require("../../../../models/axis");
|
|
13
|
+
var _zoom = require("./zoom");
|
|
14
|
+
var _getAxisDomainLimit = require("./getAxisDomainLimit");
|
|
15
|
+
var _ticks = require("../../../ticks");
|
|
16
|
+
var _getScale = require("../../../getScale");
|
|
17
|
+
var _getAxisExtrema = require("./getAxisExtrema");
|
|
18
|
+
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
19
|
+
function getRange(drawingArea, axisDirection, axis) {
|
|
20
|
+
const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
21
|
+
return axis.reverse ? [range[1], range[0]] : range;
|
|
22
|
+
}
|
|
23
|
+
function getXAxesScales({
|
|
24
|
+
drawingArea,
|
|
25
|
+
formattedSeries,
|
|
26
|
+
axis: axes = [],
|
|
27
|
+
seriesConfig,
|
|
28
|
+
zoomMap,
|
|
29
|
+
preferStrictDomainInLineCharts,
|
|
30
|
+
defaultTickNumber
|
|
31
|
+
}) {
|
|
32
|
+
const scales = {};
|
|
33
|
+
axes.forEach((eachAxis, axisIndex) => {
|
|
34
|
+
const axis = eachAxis;
|
|
35
|
+
const zoom = zoomMap?.get(axis.id);
|
|
36
|
+
scales[axis.id] = getAxisScale(axis, 'x', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts, defaultTickNumber);
|
|
37
|
+
});
|
|
38
|
+
return scales;
|
|
39
|
+
}
|
|
40
|
+
function getYAxesScales({
|
|
41
|
+
drawingArea,
|
|
42
|
+
formattedSeries,
|
|
43
|
+
axis: axes = [],
|
|
44
|
+
seriesConfig,
|
|
45
|
+
zoomMap,
|
|
46
|
+
preferStrictDomainInLineCharts,
|
|
47
|
+
defaultTickNumber
|
|
48
|
+
}) {
|
|
49
|
+
const scales = {};
|
|
50
|
+
axes.forEach((eachAxis, axisIndex) => {
|
|
51
|
+
const axis = eachAxis;
|
|
52
|
+
const zoom = zoomMap?.get(axis.id);
|
|
53
|
+
scales[axis.id] = getAxisScale(axis, 'y', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts, defaultTickNumber);
|
|
54
|
+
});
|
|
55
|
+
return scales;
|
|
56
|
+
}
|
|
57
|
+
function getAxisScale(axis, axisDirection, zoom, drawingArea, seriesConfig, axisIndex, formattedSeries,
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
60
|
+
*/
|
|
61
|
+
preferStrictDomainInLineCharts, defaultTickNumber) {
|
|
62
|
+
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
63
|
+
const range = getRange(drawingArea, axisDirection, axis);
|
|
64
|
+
if ((0, _axis.isBandScaleConfig)(axis)) {
|
|
65
|
+
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
66
|
+
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
67
|
+
const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
|
|
68
|
+
const zoomedRange = (0, _zoom.zoomScaleRange)(scaleRange, zoomRange);
|
|
69
|
+
return {
|
|
70
|
+
scale: (0, _d3Scale.scaleBand)(axis.data, zoomedRange).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if ((0, _axis.isPointScaleConfig)(axis)) {
|
|
74
|
+
const scaleRange = axisDirection === 'y' ? [...range].reverse() : range;
|
|
75
|
+
const zoomedRange = (0, _zoom.zoomScaleRange)(scaleRange, zoomRange);
|
|
76
|
+
return {
|
|
77
|
+
scale: (0, _d3Scale.scalePoint)(axis.data, zoomedRange)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const scaleType = axis.scaleType ?? 'linear';
|
|
81
|
+
const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
82
|
+
const [minData, maxData] = (0, _getAxisExtrema.getAxisExtrema)(axis, axisDirection, seriesConfig, axisIndex, formattedSeries);
|
|
83
|
+
const axisExtrema = getActualAxisExtrema(axis, minData, maxData);
|
|
84
|
+
if (typeof domainLimit === 'function') {
|
|
85
|
+
const {
|
|
86
|
+
min,
|
|
87
|
+
max
|
|
88
|
+
} = domainLimit(minData, maxData);
|
|
89
|
+
axisExtrema[0] = min;
|
|
90
|
+
axisExtrema[1] = max;
|
|
91
|
+
}
|
|
92
|
+
const rawTickNumber = (0, _ticks.getTickNumber)(axis, axisExtrema, defaultTickNumber);
|
|
93
|
+
const zoomedRange = (0, _zoom.zoomScaleRange)(range, zoomRange);
|
|
94
|
+
const scale = (0, _getScale.getScale)(scaleType, axisExtrema, zoomedRange);
|
|
95
|
+
if ((0, _axis.isSymlogScaleConfig)(axis) && axis.constant != null) {
|
|
96
|
+
scale.constant(axis.constant);
|
|
97
|
+
}
|
|
98
|
+
applyDomainLimit(scale, axis, domainLimit, rawTickNumber);
|
|
99
|
+
return {
|
|
100
|
+
scale,
|
|
101
|
+
tickNumber: rawTickNumber
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts) {
|
|
105
|
+
return preferStrictDomainInLineCharts ? (0, _getAxisDomainLimit.getAxisDomainLimit)(axis, axisDirection, axisIndex, formattedSeries) : axis.domainLimit ?? 'nice';
|
|
106
|
+
}
|
|
107
|
+
function applyDomainLimit(scale, axis, domainLimit, rawTickNumber) {
|
|
108
|
+
if (domainLimit === 'nice') {
|
|
109
|
+
scale.nice(rawTickNumber);
|
|
110
|
+
}
|
|
111
|
+
const [minDomain, maxDomain] = scale.domain();
|
|
112
|
+
scale.domain([axis.min ?? minDomain, axis.max ?? maxDomain]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get the actual axis extrema considering the user defined min and max values.
|
|
117
|
+
* @param axisExtrema User defined axis extrema.
|
|
118
|
+
* @param minData Minimum value from the data.
|
|
119
|
+
* @param maxData Maximum value from the data.
|
|
120
|
+
*/
|
|
121
|
+
function getActualAxisExtrema(axisExtrema, minData, maxData) {
|
|
122
|
+
let min = minData;
|
|
123
|
+
let max = maxData;
|
|
124
|
+
if (axisExtrema.max != null && axisExtrema.max.valueOf() < minData) {
|
|
125
|
+
min = axisExtrema.max;
|
|
126
|
+
}
|
|
127
|
+
if (axisExtrema.min != null && axisExtrema.min.valueOf() > minData) {
|
|
128
|
+
max = axisExtrema.min;
|
|
129
|
+
}
|
|
130
|
+
return [axisExtrema.min ?? min, axisExtrema.max ?? max];
|
|
131
|
+
}
|
|
@@ -23,6 +23,7 @@ var _getSVGPoint = require("../../../getSVGPoint");
|
|
|
23
23
|
var _useChartInteraction = require("../useChartInteraction");
|
|
24
24
|
var _useChartCartesianInteraction = require("./useChartCartesianInteraction.selectors");
|
|
25
25
|
var _useLazySelectorEffect = require("../../utils/useLazySelectorEffect");
|
|
26
|
+
var _checkHasInteractionPlugin = require("../useChartInteraction/checkHasInteractionPlugin");
|
|
26
27
|
const useChartCartesianAxis = ({
|
|
27
28
|
params,
|
|
28
29
|
store,
|
|
@@ -106,26 +107,27 @@ const useChartCartesianAxis = ({
|
|
|
106
107
|
onHighlightedAxisChange(nextAxisInteraction);
|
|
107
108
|
}
|
|
108
109
|
}, !onHighlightedAxisChange);
|
|
110
|
+
const hasInteractionPlugin = (0, _checkHasInteractionPlugin.checkHasInteractionPlugin)(instance);
|
|
109
111
|
React.useEffect(() => {
|
|
110
112
|
const element = svgRef.current;
|
|
111
|
-
if (!isInteractionEnabled || !element || params.disableAxisListener) {
|
|
113
|
+
if (!isInteractionEnabled || !hasInteractionPlugin || !element || params.disableAxisListener) {
|
|
112
114
|
return () => {};
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
// Clean the interaction when the mouse leaves the chart.
|
|
116
118
|
const moveEndHandler = instance.addInteractionListener('moveEnd', event => {
|
|
117
119
|
if (!event.detail.activeGestures.pan) {
|
|
118
|
-
instance.cleanInteraction
|
|
120
|
+
instance.cleanInteraction();
|
|
119
121
|
}
|
|
120
122
|
});
|
|
121
123
|
const panEndHandler = instance.addInteractionListener('panEnd', event => {
|
|
122
124
|
if (!event.detail.activeGestures.move) {
|
|
123
|
-
instance.cleanInteraction
|
|
125
|
+
instance.cleanInteraction();
|
|
124
126
|
}
|
|
125
127
|
});
|
|
126
128
|
const pressEndHandler = instance.addInteractionListener('quickPressEnd', event => {
|
|
127
129
|
if (!event.detail.activeGestures.move && !event.detail.activeGestures.pan) {
|
|
128
|
-
instance.cleanInteraction
|
|
130
|
+
instance.cleanInteraction();
|
|
129
131
|
}
|
|
130
132
|
});
|
|
131
133
|
const gestureHandler = event => {
|
|
@@ -142,7 +144,7 @@ const useChartCartesianAxis = ({
|
|
|
142
144
|
instance.cleanInteraction?.();
|
|
143
145
|
return;
|
|
144
146
|
}
|
|
145
|
-
instance.setPointerCoordinate
|
|
147
|
+
instance.setPointerCoordinate(svgPoint);
|
|
146
148
|
};
|
|
147
149
|
const moveHandler = instance.addInteractionListener('move', gestureHandler);
|
|
148
150
|
const panHandler = instance.addInteractionListener('pan', gestureHandler);
|
|
@@ -155,7 +157,7 @@ const useChartCartesianAxis = ({
|
|
|
155
157
|
pressHandler.cleanup();
|
|
156
158
|
pressEndHandler.cleanup();
|
|
157
159
|
};
|
|
158
|
-
}, [svgRef, store, xAxisWithScale, usedXAxis, yAxisWithScale, usedYAxis, instance, params.disableAxisListener, isInteractionEnabled]);
|
|
160
|
+
}, [svgRef, store, xAxisWithScale, usedXAxis, yAxisWithScale, usedYAxis, instance, params.disableAxisListener, isInteractionEnabled, hasInteractionPlugin]);
|
|
159
161
|
React.useEffect(() => {
|
|
160
162
|
const element = svgRef.current;
|
|
161
163
|
const onAxisClick = params.onAxisClick;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { AxisId } from "../../../../models/axis.js";
|
|
2
|
+
export declare const selectorChartPreviewXScales: import("reselect").Selector<any, Record<AxisId, import("./getAxisScale.js").ScaleDefinition>, [axisId: AxisId]>;
|
|
2
3
|
export declare const selectorChartPreviewComputedXAxis: import("reselect").Selector<any, import("./useChartCartesianAxis.types.js").ComputedAxisConfig<import("../../../index.js").ChartsXAxisProps>, [axisId: AxisId]>;
|
|
4
|
+
export declare const selectorChartPreviewYScales: import("reselect").Selector<any, Record<AxisId, import("./getAxisScale.js").ScaleDefinition>, [axisId: AxisId]>;
|
|
3
5
|
export declare const selectorChartPreviewComputedYAxis: import("reselect").Selector<any, import("./useChartCartesianAxis.types.js").ComputedAxisConfig<import("../../../index.js").ChartsYAxisProps>, [axisId: AxisId]>;
|