@mui/x-charts 8.11.2 → 8.12.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 +2 -0
- package/BarChart/index.js +12 -0
- package/BarChart/useBarChartProps.d.ts +2 -2
- package/BarChart/useBarChartProps.js +4 -3
- package/CHANGELOG.md +231 -0
- package/ChartContainer/ChartContainer.js +4 -2
- package/ChartContainer/useChartContainerProps.js +4 -2
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
- package/ChartsLegend/ChartsLegend.js +2 -1
- package/ChartsLegend/ContinuousColorLegend.js +1 -0
- package/ChartsLegend/PiecewiseColorLegend.d.ts +2 -2
- package/ChartsLegend/PiecewiseColorLegend.js +33 -22
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +4 -0
- package/ChartsLegend/piecewiseColorLegendClasses.js +2 -2
- package/ChartsSurface/ChartsSurface.js +22 -2
- package/ChartsWrapper/ChartsWrapper.d.ts +5 -0
- package/ChartsWrapper/ChartsWrapper.js +87 -36
- package/ChartsXAxis/ChartsGroupedXAxisTicks.js +2 -2
- package/ChartsXAxis/ChartsXAxisImpl.js +3 -3
- package/ChartsXAxis/getVisibleLabels.js +5 -1
- package/ChartsXAxis/useAxisTicksProps.d.ts +3 -3
- package/ChartsYAxis/ChartsGroupedYAxisTicks.js +2 -2
- package/ChartsYAxis/ChartsYAxisImpl.js +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/useAreaPlotData.js +2 -2
- package/LineChart/useLineChartProps.d.ts +2 -2
- package/LineChart/useLineChartProps.js +2 -1
- package/LineChart/useLinePlotData.js +2 -2
- package/PieChart/PieArc.d.ts +1 -0
- package/PieChart/PieArc.js +7 -3
- package/PieChart/PieArcPlot.js +1 -0
- package/PieChart/PieChart.js +2 -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/RadarAxis/useRadarAxis.js +2 -2
- 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/RadarChart/useRadarChartProps.js +2 -1
- 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 +10 -6
- package/SparkLineChart/SparkLineChart.js +10 -5
- 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 +2 -0
- package/esm/BarChart/index.js +1 -0
- package/esm/BarChart/useBarChartProps.d.ts +2 -2
- package/esm/BarChart/useBarChartProps.js +4 -3
- package/esm/ChartContainer/ChartContainer.js +4 -2
- package/esm/ChartContainer/useChartContainerProps.js +4 -2
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +4 -4
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +4 -4
- package/esm/ChartsLegend/ChartsLegend.js +2 -1
- package/esm/ChartsLegend/ContinuousColorLegend.js +1 -0
- package/esm/ChartsLegend/PiecewiseColorLegend.d.ts +2 -2
- package/esm/ChartsLegend/PiecewiseColorLegend.js +33 -22
- package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +4 -0
- package/esm/ChartsLegend/piecewiseColorLegendClasses.js +2 -2
- package/esm/ChartsSurface/ChartsSurface.js +22 -2
- package/esm/ChartsWrapper/ChartsWrapper.d.ts +5 -0
- package/esm/ChartsWrapper/ChartsWrapper.js +87 -36
- package/esm/ChartsXAxis/ChartsGroupedXAxisTicks.js +2 -2
- package/esm/ChartsXAxis/ChartsXAxisImpl.js +3 -3
- package/esm/ChartsXAxis/getVisibleLabels.js +5 -1
- package/esm/ChartsXAxis/useAxisTicksProps.d.ts +3 -3
- package/esm/ChartsYAxis/ChartsGroupedYAxisTicks.js +2 -2
- package/esm/ChartsYAxis/ChartsYAxisImpl.js +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/useAreaPlotData.js +2 -2
- package/esm/LineChart/useLineChartProps.d.ts +2 -2
- package/esm/LineChart/useLineChartProps.js +2 -1
- package/esm/LineChart/useLinePlotData.js +2 -2
- package/esm/PieChart/PieArc.d.ts +1 -0
- package/esm/PieChart/PieArc.js +7 -3
- package/esm/PieChart/PieArcPlot.js +1 -0
- package/esm/PieChart/PieChart.js +2 -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/RadarAxis/useRadarAxis.js +2 -2
- 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/RadarChart/useRadarChartProps.js +2 -1
- 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 +10 -6
- package/esm/SparkLineChart/SparkLineChart.js +10 -5
- 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 +8 -2
- package/esm/hooks/useTicks.js +2 -2
- package/esm/hooks/useTicksGrouped.js +2 -2
- 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 +4 -3
- package/esm/internals/index.js +4 -3
- package/esm/internals/invertScale.js +2 -2
- package/esm/internals/plugins/allPlugins.d.ts +5 -4
- package/esm/internals/plugins/allPlugins.js +3 -2
- 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/{internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts → esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.d.ts} +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +24 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +63 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +123 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -3
- 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 +46 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +32 -21
- 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/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 +210 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +25 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +7 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +34 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +1 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +2 -2
- 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 +11 -0
- package/esm/internals/scaleGuards.js +9 -0
- 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/models/axis.d.ts +3 -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 +8 -2
- package/hooks/useTicks.js +2 -2
- package/hooks/useTicksGrouped.js +2 -2
- package/index.d.ts +1 -0
- package/index.js +13 -1
- package/internals/animation/Transition.js +0 -2
- package/internals/index.d.ts +4 -3
- package/internals/index.js +24 -12
- package/internals/invertScale.js +2 -2
- package/internals/plugins/allPlugins.d.ts +5 -4
- package/internals/plugins/allPlugins.js +3 -2
- 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/{esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.d.ts → internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.d.ts} +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +30 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +63 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +134 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -3
- 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 +47 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +33 -22
- 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/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 +218 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +25 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +13 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +34 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +5 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js +2 -2
- 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 +11 -0
- package/internals/scaleGuards.js +17 -0
- 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/models/axis.d.ts +3 -0
- package/package.json +4 -4
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +47 -0
- package/esm/internals/isBandScale.d.ts +0 -5
- package/esm/internals/isBandScale.js +0 -3
- 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/isBandScale.d.ts +0 -5
- package/internals/isBandScale.js +0 -9
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { timer, now, timeout
|
|
1
|
+
import { timer, now, timeout } from '@mui/x-charts-vendor/d3-timer';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A resumable transition class inspired by d3-transition.
|
|
@@ -50,7 +50,6 @@ export class Transition {
|
|
|
50
50
|
/* If we're resuming the transition, then subtract elapsed to continue the easing. */
|
|
51
51
|
const time = now() - this.elapsed;
|
|
52
52
|
this.timer = timer(elapsed => this.timerCallback(elapsed), 0, time);
|
|
53
|
-
timerFlush();
|
|
54
53
|
return this;
|
|
55
54
|
}
|
|
56
55
|
|
|
@@ -74,7 +73,6 @@ export class Transition {
|
|
|
74
73
|
finish() {
|
|
75
74
|
this.stop();
|
|
76
75
|
timeout(() => this.timerCallback(this.duration));
|
|
77
|
-
timerFlush();
|
|
78
76
|
return this;
|
|
79
77
|
}
|
|
80
78
|
}
|
package/esm/internals/index.d.ts
CHANGED
|
@@ -25,7 +25,8 @@ export * from "./plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
|
25
25
|
export * from "./plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
26
26
|
export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
27
27
|
export * from "./plugins/featurePlugins/useChartHighlight/index.js";
|
|
28
|
-
export * from "./plugins/featurePlugins/
|
|
28
|
+
export * from "./plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
29
|
+
export * from "./plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
29
30
|
export * from "./plugins/utils/selectors.js";
|
|
30
31
|
export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
|
|
31
32
|
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
|
@@ -52,9 +53,9 @@ export * from "./colorScale.js";
|
|
|
52
53
|
export * from "./ticks.js";
|
|
53
54
|
export * from "./dateHelpers.js";
|
|
54
55
|
export * from "./invertScale.js";
|
|
55
|
-
export * from "./
|
|
56
|
+
export * from "./scaleGuards.js";
|
|
56
57
|
export * from "./findMinMax.js";
|
|
57
|
-
export {
|
|
58
|
+
export { getAxisExtrema } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js";
|
|
58
59
|
export * from "../context/ChartProvider/index.js";
|
|
59
60
|
export * from "../context/ChartsSlotsContext.js";
|
|
60
61
|
export * from "../models/seriesType/config.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -30,7 +30,8 @@ export * from "./plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
|
30
30
|
export * from "./plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
31
31
|
export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
32
32
|
export * from "./plugins/featurePlugins/useChartHighlight/index.js";
|
|
33
|
-
export * from "./plugins/featurePlugins/
|
|
33
|
+
export * from "./plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
34
|
+
export * from "./plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
34
35
|
export * from "./plugins/utils/selectors.js";
|
|
35
36
|
export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
|
|
36
37
|
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
|
@@ -62,11 +63,11 @@ export * from "./colorScale.js";
|
|
|
62
63
|
export * from "./ticks.js";
|
|
63
64
|
export * from "./dateHelpers.js";
|
|
64
65
|
export * from "./invertScale.js";
|
|
65
|
-
export * from "./
|
|
66
|
+
export * from "./scaleGuards.js";
|
|
66
67
|
export * from "./findMinMax.js";
|
|
67
68
|
|
|
68
69
|
// contexts
|
|
69
|
-
export {
|
|
70
|
+
export { getAxisExtrema } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js";
|
|
70
71
|
export * from "../context/ChartProvider/index.js";
|
|
71
72
|
export * from "../context/ChartsSlotsContext.js";
|
|
72
73
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isOrdinalScale } from "./scaleGuards.js";
|
|
2
2
|
export function invertScale(scale, data, value) {
|
|
3
|
-
if (
|
|
3
|
+
if (isOrdinalScale(scale)) {
|
|
4
4
|
const dataIndex = scale.bandwidth() === 0 ? Math.floor((value - Math.min(...scale.range()) + scale.step() / 2) / scale.step()) : Math.floor((value - Math.min(...scale.range())) / scale.step());
|
|
5
5
|
return data[dataIndex];
|
|
6
6
|
}
|
|
@@ -2,9 +2,10 @@ import { ChartSeriesType } from "../../models/seriesType/config.js";
|
|
|
2
2
|
import { UseChartCartesianAxisSignature } from "./featurePlugins/useChartCartesianAxis/index.js";
|
|
3
3
|
import { UseChartHighlightSignature } from "./featurePlugins/useChartHighlight/index.js";
|
|
4
4
|
import { UseChartInteractionSignature } from "./featurePlugins/useChartInteraction/index.js";
|
|
5
|
+
import { UseChartKeyboardNavigationSignature } from "./featurePlugins/useChartKeyboardNavigation/index.js";
|
|
5
6
|
import { UseChartPolarAxisSignature } from "./featurePlugins/useChartPolarAxis/index.js";
|
|
6
|
-
import {
|
|
7
|
+
import { UseChartClosestPointSignature } from "./featurePlugins/useChartClosestPoint/index.js";
|
|
7
8
|
import { UseChartZAxisSignature } from "./featurePlugins/useChartZAxis/index.js";
|
|
8
|
-
export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature,
|
|
9
|
-
export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature,
|
|
10
|
-
export declare const DEFAULT_PLUGINS: readonly [import("./models/index.js").ChartPlugin<UseChartZAxisSignature>, import("./models/index.js").ChartPlugin<UseChartCartesianAxisSignature<any>>, import("./models/index.js").ChartPlugin<UseChartInteractionSignature>, import("./models/index.js").ChartPlugin<UseChartHighlightSignature>, import("./models/index.js").ChartPlugin<
|
|
9
|
+
export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
10
|
+
export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartCartesianAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
11
|
+
export declare const DEFAULT_PLUGINS: readonly [import("./models/index.js").ChartPlugin<UseChartZAxisSignature>, import("./models/index.js").ChartPlugin<UseChartCartesianAxisSignature<any>>, import("./models/index.js").ChartPlugin<UseChartInteractionSignature>, import("./models/index.js").ChartPlugin<UseChartHighlightSignature>, import("./models/index.js").ChartPlugin<UseChartClosestPointSignature>, import("./models/index.js").ChartPlugin<UseChartKeyboardNavigationSignature>];
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { useChartCartesianAxis } from "./featurePlugins/useChartCartesianAxis/index.js";
|
|
4
4
|
import { useChartHighlight } from "./featurePlugins/useChartHighlight/index.js";
|
|
5
5
|
import { useChartInteraction } from "./featurePlugins/useChartInteraction/index.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useChartKeyboardNavigation } from "./featurePlugins/useChartKeyboardNavigation/index.js";
|
|
7
|
+
import { useChartClosestPoint } from "./featurePlugins/useChartClosestPoint/index.js";
|
|
7
8
|
import { useChartZAxis } from "./featurePlugins/useChartZAxis/index.js";
|
|
8
|
-
export const DEFAULT_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight,
|
|
9
|
+
export const DEFAULT_PLUGINS = [useChartZAxis, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartClosestPoint, useChartKeyboardNavigation];
|
|
@@ -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,63 @@
|
|
|
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
|
+
};
|
|
17
|
+
export declare function getXAxesScales<T extends ChartSeriesType>({
|
|
18
|
+
drawingArea,
|
|
19
|
+
formattedSeries,
|
|
20
|
+
axis: axes,
|
|
21
|
+
seriesConfig,
|
|
22
|
+
zoomMap,
|
|
23
|
+
preferStrictDomainInLineCharts
|
|
24
|
+
}: GetAxesScalesParams<T> & {
|
|
25
|
+
axis?: DefaultedAxis[];
|
|
26
|
+
}): Record<AxisId, ScaleDefinition>;
|
|
27
|
+
export declare function getYAxesScales<T extends ChartSeriesType>({
|
|
28
|
+
drawingArea,
|
|
29
|
+
formattedSeries,
|
|
30
|
+
axis: axes,
|
|
31
|
+
seriesConfig,
|
|
32
|
+
zoomMap,
|
|
33
|
+
preferStrictDomainInLineCharts
|
|
34
|
+
}: GetAxesScalesParams<T> & {
|
|
35
|
+
axis?: DefaultedAxis[];
|
|
36
|
+
}): Record<AxisId, ScaleDefinition>;
|
|
37
|
+
export type ScaleDefinition = {
|
|
38
|
+
scale: D3ContinuousScale;
|
|
39
|
+
tickNumber: number;
|
|
40
|
+
} | {
|
|
41
|
+
scale: D3OrdinalScale;
|
|
42
|
+
tickNumber?: never;
|
|
43
|
+
};
|
|
44
|
+
type DomainLimit = 'nice' | 'strict' | ((min: number, max: number) => {
|
|
45
|
+
min: number;
|
|
46
|
+
max: number;
|
|
47
|
+
});
|
|
48
|
+
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) => {
|
|
49
|
+
min: number;
|
|
50
|
+
max: number;
|
|
51
|
+
});
|
|
52
|
+
export declare function applyDomainLimit(scale: D3ContinuousScale, axis: {
|
|
53
|
+
min?: number | Date;
|
|
54
|
+
max?: number | Date;
|
|
55
|
+
}, domainLimit: DomainLimit, rawTickNumber: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get the actual axis extrema considering the user defined min and max values.
|
|
58
|
+
* @param axisExtrema User defined axis extrema.
|
|
59
|
+
* @param minData Minimum value from the data.
|
|
60
|
+
* @param maxData Maximum value from the data.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getActualAxisExtrema(axisExtrema: Pick<AxisConfig, 'min' | 'max'>, minData: number, maxData: number): [number | Date, number | Date];
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
|
|
3
|
+
import { isBandScaleConfig, isPointScaleConfig, isSymlogScaleConfig } from "../../../../models/axis.js";
|
|
4
|
+
import { zoomScaleRange } from "./zoom.js";
|
|
5
|
+
import { getAxisDomainLimit } from "./getAxisDomainLimit.js";
|
|
6
|
+
import { getTickNumber } from "../../../ticks.js";
|
|
7
|
+
import { getScale } from "../../../getScale.js";
|
|
8
|
+
import { getAxisExtrema } from "./getAxisExtrema.js";
|
|
9
|
+
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
10
|
+
function getRange(drawingArea, axisDirection, axis) {
|
|
11
|
+
const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
12
|
+
return axis.reverse ? [range[1], range[0]] : range;
|
|
13
|
+
}
|
|
14
|
+
export function getXAxesScales({
|
|
15
|
+
drawingArea,
|
|
16
|
+
formattedSeries,
|
|
17
|
+
axis: axes = [],
|
|
18
|
+
seriesConfig,
|
|
19
|
+
zoomMap,
|
|
20
|
+
preferStrictDomainInLineCharts
|
|
21
|
+
}) {
|
|
22
|
+
const scales = {};
|
|
23
|
+
axes.forEach((eachAxis, axisIndex) => {
|
|
24
|
+
const axis = eachAxis;
|
|
25
|
+
const zoom = zoomMap?.get(axis.id);
|
|
26
|
+
scales[axis.id] = getAxisScale(axis, 'x', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
27
|
+
});
|
|
28
|
+
return scales;
|
|
29
|
+
}
|
|
30
|
+
export function getYAxesScales({
|
|
31
|
+
drawingArea,
|
|
32
|
+
formattedSeries,
|
|
33
|
+
axis: axes = [],
|
|
34
|
+
seriesConfig,
|
|
35
|
+
zoomMap,
|
|
36
|
+
preferStrictDomainInLineCharts
|
|
37
|
+
}) {
|
|
38
|
+
const scales = {};
|
|
39
|
+
axes.forEach((eachAxis, axisIndex) => {
|
|
40
|
+
const axis = eachAxis;
|
|
41
|
+
const zoom = zoomMap?.get(axis.id);
|
|
42
|
+
scales[axis.id] = getAxisScale(axis, 'y', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
43
|
+
});
|
|
44
|
+
return scales;
|
|
45
|
+
}
|
|
46
|
+
function getAxisScale(axis, axisDirection, zoom, drawingArea, seriesConfig, axisIndex, formattedSeries,
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
49
|
+
*/
|
|
50
|
+
preferStrictDomainInLineCharts) {
|
|
51
|
+
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
52
|
+
const range = getRange(drawingArea, axisDirection, axis);
|
|
53
|
+
if (isBandScaleConfig(axis)) {
|
|
54
|
+
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
55
|
+
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
56
|
+
const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
|
|
57
|
+
const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
|
|
58
|
+
return {
|
|
59
|
+
scale: scaleBand(axis.data, zoomedRange).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (isPointScaleConfig(axis)) {
|
|
63
|
+
const scaleRange = axisDirection === 'y' ? [...range].reverse() : range;
|
|
64
|
+
const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
|
|
65
|
+
return {
|
|
66
|
+
scale: scalePoint(axis.data, zoomedRange)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const scaleType = axis.scaleType ?? 'linear';
|
|
70
|
+
const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
71
|
+
const [minData, maxData] = getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries);
|
|
72
|
+
const axisExtrema = getActualAxisExtrema(axis, minData, maxData);
|
|
73
|
+
if (typeof domainLimit === 'function') {
|
|
74
|
+
const {
|
|
75
|
+
min,
|
|
76
|
+
max
|
|
77
|
+
} = domainLimit(minData, maxData);
|
|
78
|
+
axisExtrema[0] = min;
|
|
79
|
+
axisExtrema[1] = max;
|
|
80
|
+
}
|
|
81
|
+
const rawTickNumber = getTickNumber(_extends({}, axis, {
|
|
82
|
+
range,
|
|
83
|
+
domain: axisExtrema
|
|
84
|
+
}));
|
|
85
|
+
const zoomedRange = zoomScaleRange(range, zoomRange);
|
|
86
|
+
const scale = getScale(scaleType, axisExtrema, zoomedRange);
|
|
87
|
+
if (isSymlogScaleConfig(axis) && axis.constant != null) {
|
|
88
|
+
scale.constant(axis.constant);
|
|
89
|
+
}
|
|
90
|
+
applyDomainLimit(scale, axis, domainLimit, rawTickNumber);
|
|
91
|
+
return {
|
|
92
|
+
scale,
|
|
93
|
+
tickNumber: rawTickNumber
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts) {
|
|
97
|
+
return preferStrictDomainInLineCharts ? getAxisDomainLimit(axis, axisDirection, axisIndex, formattedSeries) : axis.domainLimit ?? 'nice';
|
|
98
|
+
}
|
|
99
|
+
export function applyDomainLimit(scale, axis, domainLimit, rawTickNumber) {
|
|
100
|
+
if (domainLimit === 'nice') {
|
|
101
|
+
scale.nice(rawTickNumber);
|
|
102
|
+
}
|
|
103
|
+
const [minDomain, maxDomain] = scale.domain();
|
|
104
|
+
scale.domain([axis.min ?? minDomain, axis.max ?? maxDomain]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get the actual axis extrema considering the user defined min and max values.
|
|
109
|
+
* @param axisExtrema User defined axis extrema.
|
|
110
|
+
* @param minData Minimum value from the data.
|
|
111
|
+
* @param maxData Maximum value from the data.
|
|
112
|
+
*/
|
|
113
|
+
export function getActualAxisExtrema(axisExtrema, minData, maxData) {
|
|
114
|
+
let min = minData;
|
|
115
|
+
let max = maxData;
|
|
116
|
+
if (axisExtrema.max != null && axisExtrema.max.valueOf() < minData) {
|
|
117
|
+
min = axisExtrema.max;
|
|
118
|
+
}
|
|
119
|
+
if (axisExtrema.min != null && axisExtrema.min.valueOf() > minData) {
|
|
120
|
+
max = axisExtrema.min;
|
|
121
|
+
}
|
|
122
|
+
return [axisExtrema.min ?? min, axisExtrema.max ?? max];
|
|
123
|
+
}
|