@mui/x-charts 8.11.3 → 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 +1 -0
- package/BarChart/index.js +12 -0
- package/BarChart/useBarChartProps.d.ts +2 -2
- package/CHANGELOG.md +151 -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 +21 -2
- 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 +1 -0
- package/PieChart/PieArc.js +7 -3
- package/PieChart/PieArcPlot.js +1 -0
- 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 +21 -2
- 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 +1 -0
- package/esm/PieChart/PieArc.js +7 -3
- package/esm/PieChart/PieArcPlot.js +1 -0
- 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/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 +63 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +123 -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 +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/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/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/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 +63 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +134 -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 +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/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/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 +4 -4
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +47 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -22
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -2
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -29
- package/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
- package/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -27
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -9
- /package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
- /package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createSelector } from "../../utils/selectors.js";
|
|
2
2
|
import { createIsHighlighted } from "./createIsHighlighted.js";
|
|
3
3
|
import { createIsFaded } from "./createIsFaded.js";
|
|
4
|
+
import { getSeriesHighlightedItem, getSeriesUnfadedItem, isSeriesFaded, isSeriesHighlighted } from "./highlightStates.js";
|
|
4
5
|
const selectHighlight = state => state.highlight;
|
|
5
6
|
const selectSeries = state => state.series;
|
|
6
7
|
export const selectorChartsHighlightScopePerSeriesId = createSelector([selectSeries], series => {
|
|
@@ -32,6 +33,10 @@ export const selectorChartsIsFadedCallback = createSelector([selectorChartsHighl
|
|
|
32
33
|
export const selectorChartsIsHighlighted = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
|
|
33
34
|
return createIsHighlighted(highlightScope, highlightedItem)(item);
|
|
34
35
|
});
|
|
36
|
+
export const selectorChartIsSeriesHighlighted = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], isSeriesHighlighted);
|
|
37
|
+
export const selectorChartIsSeriesFaded = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], isSeriesFaded);
|
|
38
|
+
export const selectorChartSeriesUnfadedItem = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], getSeriesUnfadedItem);
|
|
39
|
+
export const selectorChartSeriesHighlightedItem = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], getSeriesHighlightedItem);
|
|
35
40
|
export const selectorChartsIsFaded = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
|
|
36
41
|
return createIsFaded(highlightScope, highlightedItem)(item);
|
|
37
42
|
});
|
package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ChartAnyPluginSignature, ChartUsedInstance } from "../../models/plugin.js";
|
|
2
|
+
import { UseChartInteractionInstance } from "./useChartInteraction.types.js";
|
|
3
|
+
export declare function checkHasInteractionPlugin<T extends ChartAnyPluginSignature>(instance: ChartUsedInstance<T>): instance is ChartUsedInstance<T> & UseChartInteractionInstance;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChartSeriesType, ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
|
|
2
|
+
import { SeriesId } from "../../../../models/seriesType/common.js";
|
|
3
|
+
import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the next series type and id that contains some data.
|
|
6
|
+
* Returns `null` if no other series have data.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getNextSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: ChartSeriesType, seriesId?: SeriesId): {
|
|
9
|
+
type: Exclude<ChartSeriesType, 'sankey'>;
|
|
10
|
+
seriesId: SeriesId;
|
|
11
|
+
} | null;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the previous series type and id that contains some data.
|
|
14
|
+
* Returns `null` if no other series have data.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getPreviousSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: ChartSeriesType, seriesId?: SeriesId): {
|
|
17
|
+
type: Exclude<ChartSeriesType, 'sankey'>;
|
|
18
|
+
seriesId: SeriesId;
|
|
19
|
+
} | null;
|
|
20
|
+
export declare function seriesHasData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type: ChartSeriesType, seriesId: SeriesId): boolean | undefined;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the next series type and id that contains some data.
|
|
3
|
+
* Returns `null` if no other series have data.
|
|
4
|
+
*/
|
|
5
|
+
export function getNextSeriesWithData(series, type, seriesId) {
|
|
6
|
+
const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
|
|
7
|
+
const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
|
|
8
|
+
const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
|
|
9
|
+
|
|
10
|
+
// Loop over all series types starting with the current seriesType
|
|
11
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
12
|
+
const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
|
|
13
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
14
|
+
|
|
15
|
+
// Edge case for the current series type: we don't loop on previous series of the same type.
|
|
16
|
+
const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
|
|
17
|
+
for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
|
|
18
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
19
|
+
return {
|
|
20
|
+
type: typesAvailable[typeIndex],
|
|
21
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// End looping on the initial type up to the initial series (excluded)
|
|
28
|
+
const typeIndex = startingTypeIndex;
|
|
29
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
30
|
+
const endingSeriesIndex = currentSeriesIndex;
|
|
31
|
+
for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
|
|
32
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
33
|
+
return {
|
|
34
|
+
type: typesAvailable[typeIndex],
|
|
35
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the previous series type and id that contains some data.
|
|
44
|
+
* Returns `null` if no other series have data.
|
|
45
|
+
*/
|
|
46
|
+
export function getPreviousSeriesWithData(series, type, seriesId) {
|
|
47
|
+
const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
|
|
48
|
+
const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
|
|
49
|
+
const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
|
|
50
|
+
|
|
51
|
+
// Loop over all series types starting with the current seriesType
|
|
52
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
53
|
+
const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
|
|
54
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
55
|
+
const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
|
|
56
|
+
for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
|
|
57
|
+
const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
|
|
58
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
59
|
+
return {
|
|
60
|
+
type: typesAvailable[typeIndex],
|
|
61
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// End looping on the initial type down to the initial series (excluded)
|
|
68
|
+
const typeIndex = startingTypeIndex;
|
|
69
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
70
|
+
const availableSeriesIds = seriesOfType.seriesOrder;
|
|
71
|
+
for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
|
|
72
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
73
|
+
return {
|
|
74
|
+
type: typesAvailable[typeIndex],
|
|
75
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
export function seriesHasData(series, type, seriesId) {
|
|
82
|
+
// @ts-ignore snakey is not in MIT version
|
|
83
|
+
if (type === 'sankey') {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
const data = series[type]?.series[seriesId]?.data;
|
|
87
|
+
return data && data.length > 0;
|
|
88
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
|
+
import { getNextSeriesWithData, getPreviousSeriesWithData, seriesHasData } from "./useChartKeyboardNavigation.helpers.js";
|
|
8
|
+
export const useChartKeyboardNavigation = ({
|
|
9
|
+
params,
|
|
10
|
+
store,
|
|
11
|
+
svgRef
|
|
12
|
+
}) => {
|
|
13
|
+
const focusNextItem = useEventCallback(function focusNextItem() {
|
|
14
|
+
store.update(state => {
|
|
15
|
+
let {
|
|
16
|
+
type,
|
|
17
|
+
seriesId
|
|
18
|
+
} = state.keyboardNavigation.item ?? {};
|
|
19
|
+
if (type === undefined ||
|
|
20
|
+
// @ts-ignore sankey is not in MIT version
|
|
21
|
+
type === 'sankey' || seriesId === undefined || !seriesHasData(state.series.processedSeries, type, seriesId)) {
|
|
22
|
+
const nextSeries = getNextSeriesWithData(state.series.processedSeries, type, seriesId);
|
|
23
|
+
if (nextSeries === null) {
|
|
24
|
+
return _extends({}, state, {
|
|
25
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
26
|
+
item: null // No series to move the focus too.
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
type = nextSeries.type;
|
|
31
|
+
seriesId = nextSeries.seriesId;
|
|
32
|
+
}
|
|
33
|
+
const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
|
|
34
|
+
return _extends({}, state, {
|
|
35
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
36
|
+
item: {
|
|
37
|
+
type,
|
|
38
|
+
seriesId,
|
|
39
|
+
dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
const focusPreviousItem = useEventCallback(function focusPreviousItem() {
|
|
46
|
+
store.update(state => {
|
|
47
|
+
let {
|
|
48
|
+
type,
|
|
49
|
+
seriesId
|
|
50
|
+
} = state.keyboardNavigation.item ?? {};
|
|
51
|
+
if (type === undefined ||
|
|
52
|
+
// @ts-ignore sankey is not in MIT version
|
|
53
|
+
type === 'sankey' || seriesId === undefined || !seriesHasData(state.series.processedSeries, type, seriesId)) {
|
|
54
|
+
const previousSeries = getPreviousSeriesWithData(state.series.processedSeries, type, seriesId);
|
|
55
|
+
if (previousSeries === null) {
|
|
56
|
+
return _extends({}, state, {
|
|
57
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
58
|
+
item: null // No series to move the focus too.} };
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
type = previousSeries.type;
|
|
63
|
+
seriesId = previousSeries.seriesId;
|
|
64
|
+
}
|
|
65
|
+
const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
|
|
66
|
+
return _extends({}, state, {
|
|
67
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
68
|
+
item: {
|
|
69
|
+
type,
|
|
70
|
+
seriesId,
|
|
71
|
+
dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
const focusPreviousSeries = useEventCallback(function focusPreviousSeries() {
|
|
78
|
+
let setNewSeries = false;
|
|
79
|
+
store.update(state => {
|
|
80
|
+
let {
|
|
81
|
+
type,
|
|
82
|
+
seriesId
|
|
83
|
+
} = state.keyboardNavigation.item ?? {};
|
|
84
|
+
const previousSeries = getPreviousSeriesWithData(state.series.processedSeries, type, seriesId);
|
|
85
|
+
if (previousSeries === null) {
|
|
86
|
+
return _extends({}, state, {
|
|
87
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
88
|
+
item: null // No series to move the focus too.
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
type = previousSeries.type;
|
|
93
|
+
seriesId = previousSeries.seriesId;
|
|
94
|
+
const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
|
|
95
|
+
setNewSeries = true;
|
|
96
|
+
return _extends({}, state, {
|
|
97
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
98
|
+
item: {
|
|
99
|
+
type,
|
|
100
|
+
seriesId,
|
|
101
|
+
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return setNewSeries;
|
|
107
|
+
});
|
|
108
|
+
const focusNextSeries = useEventCallback(function focusNextSeries() {
|
|
109
|
+
let setNewSeries = false;
|
|
110
|
+
store.update(state => {
|
|
111
|
+
let {
|
|
112
|
+
type,
|
|
113
|
+
seriesId
|
|
114
|
+
} = state.keyboardNavigation.item ?? {};
|
|
115
|
+
const nextSeries = getNextSeriesWithData(state.series.processedSeries, type, seriesId);
|
|
116
|
+
if (nextSeries === null) {
|
|
117
|
+
return _extends({}, state, {
|
|
118
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
119
|
+
item: null // No series to move the focus too.
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
type = nextSeries.type;
|
|
124
|
+
seriesId = nextSeries.seriesId;
|
|
125
|
+
const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
|
|
126
|
+
setNewSeries = true;
|
|
127
|
+
return _extends({}, state, {
|
|
128
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
129
|
+
item: {
|
|
130
|
+
type,
|
|
131
|
+
seriesId,
|
|
132
|
+
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
return setNewSeries;
|
|
138
|
+
});
|
|
139
|
+
const removeFocus = useEventCallback(function removeFocus() {
|
|
140
|
+
store.update(state => {
|
|
141
|
+
if (state.keyboardNavigation.item === null) {
|
|
142
|
+
return state;
|
|
143
|
+
}
|
|
144
|
+
return _extends({}, state, {
|
|
145
|
+
keyboardNavigation: _extends({}, state.keyboardNavigation, {
|
|
146
|
+
item: null
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
React.useEffect(() => {
|
|
152
|
+
const element = svgRef.current;
|
|
153
|
+
if (!element || !params.enableKeyboardNavigation) {
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
156
|
+
function keyboardHandler(event) {
|
|
157
|
+
switch (event.key) {
|
|
158
|
+
case 'ArrowRight':
|
|
159
|
+
focusNextItem();
|
|
160
|
+
break;
|
|
161
|
+
case 'ArrowLeft':
|
|
162
|
+
focusPreviousItem();
|
|
163
|
+
break;
|
|
164
|
+
case 'ArrowDown':
|
|
165
|
+
{
|
|
166
|
+
const updatedStore = focusPreviousSeries();
|
|
167
|
+
if (updatedStore) {
|
|
168
|
+
// prevents scrolling
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case 'ArrowUp':
|
|
174
|
+
{
|
|
175
|
+
const updatedStore = focusNextSeries();
|
|
176
|
+
if (updatedStore) {
|
|
177
|
+
// prevents scrolling
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
default:
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
element.addEventListener('keydown', keyboardHandler);
|
|
187
|
+
element.addEventListener('blur', removeFocus);
|
|
188
|
+
return () => {
|
|
189
|
+
element.removeEventListener('keydown', keyboardHandler);
|
|
190
|
+
element.removeEventListener('blur', removeFocus);
|
|
191
|
+
};
|
|
192
|
+
}, [svgRef, focusNextItem, focusPreviousItem, removeFocus, focusPreviousSeries, focusNextSeries, params.enableKeyboardNavigation]);
|
|
193
|
+
useEnhancedEffect(() => store.update(prev => prev.keyboardNavigation.enableKeyboardNavigation === params.enableKeyboardNavigation ? prev : _extends({}, prev, {
|
|
194
|
+
keyboardNavigation: _extends({}, prev.keyboardNavigation, {
|
|
195
|
+
enableKeyboardNavigation: !!params.enableKeyboardNavigation
|
|
196
|
+
})
|
|
197
|
+
})), [store, params.enableKeyboardNavigation]);
|
|
198
|
+
return {
|
|
199
|
+
instance: {}
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
useChartKeyboardNavigation.getInitialState = params => ({
|
|
203
|
+
keyboardNavigation: {
|
|
204
|
+
item: null,
|
|
205
|
+
enableKeyboardNavigation: !!params.enableKeyboardNavigation
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
useChartKeyboardNavigation.params = {
|
|
209
|
+
enableKeyboardNavigation: true
|
|
210
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const selectorChartsHasFocusedItem: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
2
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
3
|
+
} & {
|
|
4
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
5
|
+
}, boolean, any[]>;
|
|
6
|
+
export declare const selectorChartsFocusedSeriesType: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
7
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
8
|
+
} & {
|
|
9
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
10
|
+
}, keyof import("../../../index.js").ChartsSeriesConfig | undefined, any[]>;
|
|
11
|
+
export declare const selectorChartsFocusedSeriesId: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
12
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
13
|
+
} & {
|
|
14
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
15
|
+
}, import("../../../index.js").SeriesId | undefined, any[]>;
|
|
16
|
+
export declare const selectorChartsFocusedDataIndex: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
17
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
18
|
+
} & {
|
|
19
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
20
|
+
}, number | undefined, any[]>;
|
|
21
|
+
export declare const selectorChartsIsKeyboardNavigationEnabled: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
22
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
23
|
+
} & {
|
|
24
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
25
|
+
}, boolean, any[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createSelector } from "../../utils/selectors.js";
|
|
2
|
+
const selectKeyboardNavigation = state => state.keyboardNavigation;
|
|
3
|
+
export const selectorChartsHasFocusedItem = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item != null);
|
|
4
|
+
export const selectorChartsFocusedSeriesType = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.type);
|
|
5
|
+
export const selectorChartsFocusedSeriesId = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
|
|
6
|
+
export const selectorChartsFocusedDataIndex = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
|
|
7
|
+
export const selectorChartsIsKeyboardNavigationEnabled = createSelector([selectKeyboardNavigation], keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ChartPluginSignature } from "../../models/index.js";
|
|
2
|
+
import { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
|
+
import { SeriesId } from "../../../../models/seriesType/common.js";
|
|
4
|
+
export interface UseChartKeyboardNavigationInstance {}
|
|
5
|
+
type SeriesItemIdentifier = {
|
|
6
|
+
/**
|
|
7
|
+
* The type of the series
|
|
8
|
+
*/
|
|
9
|
+
type: ChartSeriesType;
|
|
10
|
+
/**
|
|
11
|
+
* The id of the series with focus.
|
|
12
|
+
*/
|
|
13
|
+
seriesId: SeriesId;
|
|
14
|
+
/**
|
|
15
|
+
* The index of the data point with focus.
|
|
16
|
+
*/
|
|
17
|
+
dataIndex: number;
|
|
18
|
+
};
|
|
19
|
+
export interface UseChartKeyboardNavigationState {
|
|
20
|
+
keyboardNavigation: {
|
|
21
|
+
item: null | SeriesItemIdentifier;
|
|
22
|
+
enableKeyboardNavigation: boolean;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
type UseChartKeyboardNavigationParameters = {
|
|
26
|
+
enableKeyboardNavigation?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type UseChartKeyboardNavigationSignature = ChartPluginSignature<{
|
|
29
|
+
params: UseChartKeyboardNavigationParameters;
|
|
30
|
+
defaultizedParams: UseChartKeyboardNavigationParameters;
|
|
31
|
+
instance: UseChartKeyboardNavigationInstance;
|
|
32
|
+
state: UseChartKeyboardNavigationState;
|
|
33
|
+
}>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -12,6 +12,7 @@ import { getSVGPoint } from "../../../getSVGPoint.js";
|
|
|
12
12
|
import { generatePolar2svg, generateSvg2polar, generateSvg2rotation } from "./coordinateTransformation.js";
|
|
13
13
|
import { getAxisIndex } from "./getAxisIndex.js";
|
|
14
14
|
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
15
|
+
import { checkHasInteractionPlugin } from "../useChartInteraction/checkHasInteractionPlugin.js";
|
|
15
16
|
export const useChartPolarAxis = ({
|
|
16
17
|
params,
|
|
17
18
|
store,
|
|
@@ -78,9 +79,10 @@ export const useChartPolarAxis = ({
|
|
|
78
79
|
const mousePosition = React.useRef({
|
|
79
80
|
isInChart: false
|
|
80
81
|
});
|
|
82
|
+
const hasInteractionPlugin = checkHasInteractionPlugin(instance);
|
|
81
83
|
React.useEffect(() => {
|
|
82
84
|
const element = svgRef.current;
|
|
83
|
-
if (!isInteractionEnabled || element === null || params.disableAxisListener) {
|
|
85
|
+
if (!isInteractionEnabled || !hasInteractionPlugin || element === null || params.disableAxisListener) {
|
|
84
86
|
return () => {};
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -94,13 +96,13 @@ export const useChartPolarAxis = ({
|
|
|
94
96
|
const panEndHandler = instance.addInteractionListener('panEnd', event => {
|
|
95
97
|
if (!event.detail.activeGestures.move) {
|
|
96
98
|
mousePosition.current.isInChart = false;
|
|
97
|
-
instance.cleanInteraction();
|
|
99
|
+
instance.cleanInteraction?.();
|
|
98
100
|
}
|
|
99
101
|
});
|
|
100
102
|
const pressEndHandler = instance.addInteractionListener('quickPressEnd', event => {
|
|
101
103
|
if (!event.detail.activeGestures.move && !event.detail.activeGestures.pan) {
|
|
102
104
|
mousePosition.current.isInChart = false;
|
|
103
|
-
instance.cleanInteraction();
|
|
105
|
+
instance.cleanInteraction?.();
|
|
104
106
|
}
|
|
105
107
|
});
|
|
106
108
|
const gestureHandler = event => {
|
|
@@ -112,12 +114,12 @@ export const useChartPolarAxis = ({
|
|
|
112
114
|
const svgRect = element.getBoundingClientRect();
|
|
113
115
|
if (srcEvent.clientX < svgRect.left || srcEvent.clientX > svgRect.right || srcEvent.clientY < svgRect.top || srcEvent.clientY > svgRect.bottom) {
|
|
114
116
|
mousePosition.current.isInChart = false;
|
|
115
|
-
instance.cleanInteraction();
|
|
117
|
+
instance.cleanInteraction?.();
|
|
116
118
|
return;
|
|
117
119
|
}
|
|
118
120
|
const svgPoint = getSVGPoint(element, srcEvent);
|
|
119
121
|
mousePosition.current.isInChart = true;
|
|
120
|
-
instance.setPointerCoordinate(svgPoint);
|
|
122
|
+
instance.setPointerCoordinate?.(svgPoint);
|
|
121
123
|
return;
|
|
122
124
|
}
|
|
123
125
|
|
|
@@ -128,7 +130,7 @@ export const useChartPolarAxis = ({
|
|
|
128
130
|
// Test if it's in the drawing area
|
|
129
131
|
if (!instance.isPointInside(svgPoint.x, svgPoint.y, event.detail.target)) {
|
|
130
132
|
if (mousePosition.current.isInChart) {
|
|
131
|
-
instance?.
|
|
133
|
+
instance.cleanInteraction?.();
|
|
132
134
|
mousePosition.current.isInChart = false;
|
|
133
135
|
}
|
|
134
136
|
return;
|
|
@@ -139,7 +141,7 @@ export const useChartPolarAxis = ({
|
|
|
139
141
|
const maxRadius = radiusAxisWithScale[usedRadiusAxisId].scale.range()[1];
|
|
140
142
|
if (radiusSquare > maxRadius ** 2) {
|
|
141
143
|
if (mousePosition.current.isInChart) {
|
|
142
|
-
instance?.
|
|
144
|
+
instance.cleanInteraction?.();
|
|
143
145
|
mousePosition.current.isInChart = false;
|
|
144
146
|
}
|
|
145
147
|
return;
|
|
@@ -158,7 +160,7 @@ export const useChartPolarAxis = ({
|
|
|
158
160
|
pressHandler.cleanup();
|
|
159
161
|
pressEndHandler.cleanup();
|
|
160
162
|
};
|
|
161
|
-
}, [svgRef, store, center, radiusAxisWithScale, usedRadiusAxisId, rotationAxisWithScale, usedRotationAxisId, instance, params.disableAxisListener, isInteractionEnabled, svg2rotation]);
|
|
163
|
+
}, [svgRef, store, center, radiusAxisWithScale, usedRadiusAxisId, rotationAxisWithScale, usedRotationAxisId, instance, params.disableAxisListener, isInteractionEnabled, svg2rotation, hasInteractionPlugin]);
|
|
162
164
|
React.useEffect(() => {
|
|
163
165
|
const element = svgRef.current;
|
|
164
166
|
const onAxisClick = params.onAxisClick;
|
|
@@ -69,5 +69,6 @@ export type UseChartPolarAxisSignature<SeriesType extends ChartSeriesType = Char
|
|
|
69
69
|
defaultizedParams: UseChartPolarAxisDefaultizedParameters;
|
|
70
70
|
state: UseChartPolarAxisState;
|
|
71
71
|
instance: UseChartPolarAxisInstance;
|
|
72
|
-
dependencies: [
|
|
72
|
+
dependencies: [UseChartSeriesSignature<SeriesType>];
|
|
73
|
+
optionalDependencies: [UseChartInteractionSignature];
|
|
73
74
|
}>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ChartSeries, ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
2
2
|
import type { AllSeriesType } from "../../../../models/seriesType/index.js";
|
|
3
|
-
export type GetSeriesWithDefaultValues<T extends ChartSeriesType> = (series: AllSeriesType<T>, seriesIndex: number, colors: string[]) => ChartSeries<T>;
|
|
3
|
+
export type GetSeriesWithDefaultValues<T extends ChartSeriesType> = (series: AllSeriesType<T>, seriesIndex: number, colors: readonly string[]) => ChartSeries<T>;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import type { ScaleBand } from '@mui/x-charts-vendor/d3-scale';
|
|
1
2
|
import { D3OrdinalScale, D3Scale } from "../models/axis.js";
|
|
2
3
|
export declare function isOrdinalScale<T extends {
|
|
3
4
|
toString(): string;
|
|
5
|
+
}>(scale: D3Scale<T>): scale is D3OrdinalScale<T>;
|
|
6
|
+
export declare function isBandScale<T extends {
|
|
7
|
+
toString(): string;
|
|
8
|
+
}>(scale: D3Scale<T>): scale is ScaleBand<T>;
|
|
9
|
+
export declare function isPointScale<T extends {
|
|
10
|
+
toString(): string;
|
|
4
11
|
}>(scale: D3Scale<T>): scale is D3OrdinalScale<T>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
export function isOrdinalScale(scale) {
|
|
2
2
|
return scale.bandwidth !== undefined;
|
|
3
|
+
}
|
|
4
|
+
export function isBandScale(scale) {
|
|
5
|
+
return isOrdinalScale(scale) && scale.paddingOuter !== undefined;
|
|
6
|
+
}
|
|
7
|
+
export function isPointScale(scale) {
|
|
8
|
+
return isOrdinalScale(scale) && !('paddingOuter' in scale);
|
|
3
9
|
}
|