@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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSeriesHighlightedItem = getSeriesHighlightedItem;
|
|
7
|
+
exports.getSeriesUnfadedItem = getSeriesUnfadedItem;
|
|
8
|
+
exports.isSeriesFaded = isSeriesFaded;
|
|
9
|
+
exports.isSeriesHighlighted = isSeriesHighlighted;
|
|
10
|
+
function isSeriesHighlighted(scope, item, seriesId) {
|
|
11
|
+
return scope?.highlight === 'series' && item?.seriesId === seriesId;
|
|
12
|
+
}
|
|
13
|
+
function isSeriesFaded(scope, item, seriesId) {
|
|
14
|
+
if (isSeriesHighlighted(scope, item, seriesId)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return scope?.fade === 'global' && item != null || scope?.fade === 'series' && item?.seriesId === seriesId;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the data index of the highlighted item for a specific series.
|
|
22
|
+
* If the item is not highlighted, it returns `null`.
|
|
23
|
+
*/
|
|
24
|
+
function getSeriesHighlightedItem(scope, item, seriesId) {
|
|
25
|
+
return scope?.highlight === 'item' && item?.seriesId === seriesId ? item.dataIndex : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the data index of the "unfaded item" for a specific series.
|
|
30
|
+
* An "unfaded item" is the only item of a faded series that shouldn't be faded.
|
|
31
|
+
* If the series is not faded or if there is no highlighted item, it returns `null`.
|
|
32
|
+
*/
|
|
33
|
+
function getSeriesUnfadedItem(scope, item, seriesId) {
|
|
34
|
+
if (isSeriesHighlighted(scope, item, seriesId)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if (getSeriesHighlightedItem(scope, item, seriesId) === item?.dataIndex) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
return (scope?.fade === 'series' || scope?.fade === 'global') && item?.seriesId === seriesId ? item.dataIndex : null;
|
|
41
|
+
}
|
|
@@ -27,4 +27,8 @@ export declare const selectorChartsIsFadedCallback: import("reselect").Selector<
|
|
|
27
27
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
28
|
} & import("./useChartHighlight.types.js").UseChartHighlightState, (item: HighlightItemData | null) => boolean, any[]>;
|
|
29
29
|
export declare const selectorChartsIsHighlighted: import("reselect").Selector<any, boolean, [item: HighlightItemData | null]>;
|
|
30
|
+
export declare const selectorChartIsSeriesHighlighted: import("reselect").Selector<any, boolean, [seriesId: SeriesId]>;
|
|
31
|
+
export declare const selectorChartIsSeriesFaded: import("reselect").Selector<any, boolean, [seriesId: SeriesId]>;
|
|
32
|
+
export declare const selectorChartSeriesUnfadedItem: import("reselect").Selector<any, number | null | undefined, [seriesId: SeriesId]>;
|
|
33
|
+
export declare const selectorChartSeriesHighlightedItem: import("reselect").Selector<any, number | null | undefined, [seriesId: SeriesId]>;
|
|
30
34
|
export declare const selectorChartsIsFaded: import("reselect").Selector<any, boolean, [item: HighlightItemData | null]>;
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectorChartsIsHighlightedCallback = exports.selectorChartsIsHighlighted = exports.selectorChartsIsFadedCallback = exports.selectorChartsIsFaded = exports.selectorChartsHighlightedItem = exports.selectorChartsHighlightScopePerSeriesId = exports.selectorChartsHighlightScope = void 0;
|
|
6
|
+
exports.selectorChartsIsHighlightedCallback = exports.selectorChartsIsHighlighted = exports.selectorChartsIsFadedCallback = exports.selectorChartsIsFaded = exports.selectorChartsHighlightedItem = exports.selectorChartsHighlightScopePerSeriesId = exports.selectorChartsHighlightScope = exports.selectorChartSeriesUnfadedItem = exports.selectorChartSeriesHighlightedItem = exports.selectorChartIsSeriesHighlighted = exports.selectorChartIsSeriesFaded = void 0;
|
|
7
7
|
var _selectors = require("../../utils/selectors");
|
|
8
8
|
var _createIsHighlighted = require("./createIsHighlighted");
|
|
9
9
|
var _createIsFaded = require("./createIsFaded");
|
|
10
|
+
var _highlightStates = require("./highlightStates");
|
|
10
11
|
const selectHighlight = state => state.highlight;
|
|
11
12
|
const selectSeries = state => state.series;
|
|
12
13
|
const selectorChartsHighlightScopePerSeriesId = exports.selectorChartsHighlightScopePerSeriesId = (0, _selectors.createSelector)([selectSeries], series => {
|
|
@@ -38,6 +39,10 @@ const selectorChartsIsFadedCallback = exports.selectorChartsIsFadedCallback = (0
|
|
|
38
39
|
const selectorChartsIsHighlighted = exports.selectorChartsIsHighlighted = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
|
|
39
40
|
return (0, _createIsHighlighted.createIsHighlighted)(highlightScope, highlightedItem)(item);
|
|
40
41
|
});
|
|
42
|
+
const selectorChartIsSeriesHighlighted = exports.selectorChartIsSeriesHighlighted = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], _highlightStates.isSeriesHighlighted);
|
|
43
|
+
const selectorChartIsSeriesFaded = exports.selectorChartIsSeriesFaded = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], _highlightStates.isSeriesFaded);
|
|
44
|
+
const selectorChartSeriesUnfadedItem = exports.selectorChartSeriesUnfadedItem = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], _highlightStates.getSeriesUnfadedItem);
|
|
45
|
+
const selectorChartSeriesHighlightedItem = exports.selectorChartSeriesHighlightedItem = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], _highlightStates.getSeriesHighlightedItem);
|
|
41
46
|
const selectorChartsIsFaded = exports.selectorChartsIsFaded = (0, _selectors.createSelector)([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
|
|
42
47
|
return (0, _createIsFaded.createIsFaded)(highlightScope, highlightedItem)(item);
|
|
43
48
|
});
|
|
@@ -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,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
useChartKeyboardNavigation: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "useChartKeyboardNavigation", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _useChartKeyboardNavigation.useChartKeyboardNavigation;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation");
|
|
16
|
+
var _useChartKeyboardNavigation2 = require("./useChartKeyboardNavigation.selectors");
|
|
17
|
+
Object.keys(_useChartKeyboardNavigation2).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _useChartKeyboardNavigation2[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _useChartKeyboardNavigation2[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -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,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getNextSeriesWithData = getNextSeriesWithData;
|
|
7
|
+
exports.getPreviousSeriesWithData = getPreviousSeriesWithData;
|
|
8
|
+
exports.seriesHasData = seriesHasData;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the next series type and id that contains some data.
|
|
11
|
+
* Returns `null` if no other series have data.
|
|
12
|
+
*/
|
|
13
|
+
function getNextSeriesWithData(series, type, seriesId) {
|
|
14
|
+
const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
|
|
15
|
+
const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
|
|
16
|
+
const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
|
|
17
|
+
|
|
18
|
+
// Loop over all series types starting with the current seriesType
|
|
19
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
20
|
+
const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
|
|
21
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
22
|
+
|
|
23
|
+
// Edge case for the current series type: we don't loop on previous series of the same type.
|
|
24
|
+
const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
|
|
25
|
+
for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
|
|
26
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
27
|
+
return {
|
|
28
|
+
type: typesAvailable[typeIndex],
|
|
29
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// End looping on the initial type up to the initial series (excluded)
|
|
36
|
+
const typeIndex = startingTypeIndex;
|
|
37
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
38
|
+
const endingSeriesIndex = currentSeriesIndex;
|
|
39
|
+
for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
|
|
40
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
41
|
+
return {
|
|
42
|
+
type: typesAvailable[typeIndex],
|
|
43
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns the previous series type and id that contains some data.
|
|
52
|
+
* Returns `null` if no other series have data.
|
|
53
|
+
*/
|
|
54
|
+
function getPreviousSeriesWithData(series, type, seriesId) {
|
|
55
|
+
const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
|
|
56
|
+
const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
|
|
57
|
+
const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
|
|
58
|
+
|
|
59
|
+
// Loop over all series types starting with the current seriesType
|
|
60
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
61
|
+
const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
|
|
62
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
63
|
+
const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
|
|
64
|
+
for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
|
|
65
|
+
const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
|
|
66
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
67
|
+
return {
|
|
68
|
+
type: typesAvailable[typeIndex],
|
|
69
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// End looping on the initial type down to the initial series (excluded)
|
|
76
|
+
const typeIndex = startingTypeIndex;
|
|
77
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
78
|
+
const availableSeriesIds = seriesOfType.seriesOrder;
|
|
79
|
+
for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
|
|
80
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
81
|
+
return {
|
|
82
|
+
type: typesAvailable[typeIndex],
|
|
83
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
function seriesHasData(series, type, seriesId) {
|
|
90
|
+
// @ts-ignore snakey is not in MIT version
|
|
91
|
+
if (type === 'sankey') {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const data = series[type]?.series[seriesId]?.data;
|
|
95
|
+
return data && data.length > 0;
|
|
96
|
+
}
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.useChartKeyboardNavigation = void 0;
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
|
+
var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation.helpers");
|
|
15
|
+
const useChartKeyboardNavigation = ({
|
|
16
|
+
params,
|
|
17
|
+
store,
|
|
18
|
+
svgRef
|
|
19
|
+
}) => {
|
|
20
|
+
const focusNextItem = (0, _useEventCallback.default)(function focusNextItem() {
|
|
21
|
+
store.update(state => {
|
|
22
|
+
let {
|
|
23
|
+
type,
|
|
24
|
+
seriesId
|
|
25
|
+
} = state.keyboardNavigation.item ?? {};
|
|
26
|
+
if (type === undefined ||
|
|
27
|
+
// @ts-ignore sankey is not in MIT version
|
|
28
|
+
type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(state.series.processedSeries, type, seriesId)) {
|
|
29
|
+
const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(state.series.processedSeries, type, seriesId);
|
|
30
|
+
if (nextSeries === null) {
|
|
31
|
+
return (0, _extends2.default)({}, state, {
|
|
32
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
33
|
+
item: null // No series to move the focus too.
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
type = nextSeries.type;
|
|
38
|
+
seriesId = nextSeries.seriesId;
|
|
39
|
+
}
|
|
40
|
+
const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
|
|
41
|
+
return (0, _extends2.default)({}, state, {
|
|
42
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
43
|
+
item: {
|
|
44
|
+
type,
|
|
45
|
+
seriesId,
|
|
46
|
+
dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
const focusPreviousItem = (0, _useEventCallback.default)(function focusPreviousItem() {
|
|
53
|
+
store.update(state => {
|
|
54
|
+
let {
|
|
55
|
+
type,
|
|
56
|
+
seriesId
|
|
57
|
+
} = state.keyboardNavigation.item ?? {};
|
|
58
|
+
if (type === undefined ||
|
|
59
|
+
// @ts-ignore sankey is not in MIT version
|
|
60
|
+
type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(state.series.processedSeries, type, seriesId)) {
|
|
61
|
+
const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(state.series.processedSeries, type, seriesId);
|
|
62
|
+
if (previousSeries === null) {
|
|
63
|
+
return (0, _extends2.default)({}, state, {
|
|
64
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
65
|
+
item: null // No series to move the focus too.} };
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
type = previousSeries.type;
|
|
70
|
+
seriesId = previousSeries.seriesId;
|
|
71
|
+
}
|
|
72
|
+
const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
|
|
73
|
+
return (0, _extends2.default)({}, state, {
|
|
74
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
75
|
+
item: {
|
|
76
|
+
type,
|
|
77
|
+
seriesId,
|
|
78
|
+
dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
const focusPreviousSeries = (0, _useEventCallback.default)(function focusPreviousSeries() {
|
|
85
|
+
let setNewSeries = false;
|
|
86
|
+
store.update(state => {
|
|
87
|
+
let {
|
|
88
|
+
type,
|
|
89
|
+
seriesId
|
|
90
|
+
} = state.keyboardNavigation.item ?? {};
|
|
91
|
+
const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(state.series.processedSeries, type, seriesId);
|
|
92
|
+
if (previousSeries === null) {
|
|
93
|
+
return (0, _extends2.default)({}, state, {
|
|
94
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
95
|
+
item: null // No series to move the focus too.
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
type = previousSeries.type;
|
|
100
|
+
seriesId = previousSeries.seriesId;
|
|
101
|
+
const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
|
|
102
|
+
setNewSeries = true;
|
|
103
|
+
return (0, _extends2.default)({}, state, {
|
|
104
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
105
|
+
item: {
|
|
106
|
+
type,
|
|
107
|
+
seriesId,
|
|
108
|
+
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
return setNewSeries;
|
|
114
|
+
});
|
|
115
|
+
const focusNextSeries = (0, _useEventCallback.default)(function focusNextSeries() {
|
|
116
|
+
let setNewSeries = false;
|
|
117
|
+
store.update(state => {
|
|
118
|
+
let {
|
|
119
|
+
type,
|
|
120
|
+
seriesId
|
|
121
|
+
} = state.keyboardNavigation.item ?? {};
|
|
122
|
+
const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(state.series.processedSeries, type, seriesId);
|
|
123
|
+
if (nextSeries === null) {
|
|
124
|
+
return (0, _extends2.default)({}, state, {
|
|
125
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
126
|
+
item: null // No series to move the focus too.
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
type = nextSeries.type;
|
|
131
|
+
seriesId = nextSeries.seriesId;
|
|
132
|
+
const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
|
|
133
|
+
setNewSeries = true;
|
|
134
|
+
return (0, _extends2.default)({}, state, {
|
|
135
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
136
|
+
item: {
|
|
137
|
+
type,
|
|
138
|
+
seriesId,
|
|
139
|
+
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
return setNewSeries;
|
|
145
|
+
});
|
|
146
|
+
const removeFocus = (0, _useEventCallback.default)(function removeFocus() {
|
|
147
|
+
store.update(state => {
|
|
148
|
+
if (state.keyboardNavigation.item === null) {
|
|
149
|
+
return state;
|
|
150
|
+
}
|
|
151
|
+
return (0, _extends2.default)({}, state, {
|
|
152
|
+
keyboardNavigation: (0, _extends2.default)({}, state.keyboardNavigation, {
|
|
153
|
+
item: null
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
React.useEffect(() => {
|
|
159
|
+
const element = svgRef.current;
|
|
160
|
+
if (!element || !params.enableKeyboardNavigation) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
function keyboardHandler(event) {
|
|
164
|
+
switch (event.key) {
|
|
165
|
+
case 'ArrowRight':
|
|
166
|
+
focusNextItem();
|
|
167
|
+
break;
|
|
168
|
+
case 'ArrowLeft':
|
|
169
|
+
focusPreviousItem();
|
|
170
|
+
break;
|
|
171
|
+
case 'ArrowDown':
|
|
172
|
+
{
|
|
173
|
+
const updatedStore = focusPreviousSeries();
|
|
174
|
+
if (updatedStore) {
|
|
175
|
+
// prevents scrolling
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case 'ArrowUp':
|
|
181
|
+
{
|
|
182
|
+
const updatedStore = focusNextSeries();
|
|
183
|
+
if (updatedStore) {
|
|
184
|
+
// prevents scrolling
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
default:
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
element.addEventListener('keydown', keyboardHandler);
|
|
194
|
+
element.addEventListener('blur', removeFocus);
|
|
195
|
+
return () => {
|
|
196
|
+
element.removeEventListener('keydown', keyboardHandler);
|
|
197
|
+
element.removeEventListener('blur', removeFocus);
|
|
198
|
+
};
|
|
199
|
+
}, [svgRef, focusNextItem, focusPreviousItem, removeFocus, focusPreviousSeries, focusNextSeries, params.enableKeyboardNavigation]);
|
|
200
|
+
(0, _useEnhancedEffect.default)(() => store.update(prev => prev.keyboardNavigation.enableKeyboardNavigation === params.enableKeyboardNavigation ? prev : (0, _extends2.default)({}, prev, {
|
|
201
|
+
keyboardNavigation: (0, _extends2.default)({}, prev.keyboardNavigation, {
|
|
202
|
+
enableKeyboardNavigation: !!params.enableKeyboardNavigation
|
|
203
|
+
})
|
|
204
|
+
})), [store, params.enableKeyboardNavigation]);
|
|
205
|
+
return {
|
|
206
|
+
instance: {}
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
exports.useChartKeyboardNavigation = useChartKeyboardNavigation;
|
|
210
|
+
useChartKeyboardNavigation.getInitialState = params => ({
|
|
211
|
+
keyboardNavigation: {
|
|
212
|
+
item: null,
|
|
213
|
+
enableKeyboardNavigation: !!params.enableKeyboardNavigation
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
useChartKeyboardNavigation.params = {
|
|
217
|
+
enableKeyboardNavigation: true
|
|
218
|
+
};
|
|
@@ -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,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesId = exports.selectorChartsFocusedDataIndex = void 0;
|
|
7
|
+
var _selectors = require("../../utils/selectors");
|
|
8
|
+
const selectKeyboardNavigation = state => state.keyboardNavigation;
|
|
9
|
+
const selectorChartsHasFocusedItem = exports.selectorChartsHasFocusedItem = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item != null);
|
|
10
|
+
const selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesType = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.type);
|
|
11
|
+
const selectorChartsFocusedSeriesId = exports.selectorChartsFocusedSeriesId = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
|
|
12
|
+
const selectorChartsFocusedDataIndex = exports.selectorChartsFocusedDataIndex = (0, _selectors.createSelector)([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
|
|
13
|
+
const selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardNavigationEnabled = (0, _selectors.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 {};
|
|
@@ -19,6 +19,7 @@ var _getSVGPoint = require("../../../getSVGPoint");
|
|
|
19
19
|
var _coordinateTransformation = require("./coordinateTransformation");
|
|
20
20
|
var _getAxisIndex = require("./getAxisIndex");
|
|
21
21
|
var _useChartSeries = require("../../corePlugins/useChartSeries");
|
|
22
|
+
var _checkHasInteractionPlugin = require("../useChartInteraction/checkHasInteractionPlugin");
|
|
22
23
|
const useChartPolarAxis = ({
|
|
23
24
|
params,
|
|
24
25
|
store,
|
|
@@ -85,9 +86,10 @@ const useChartPolarAxis = ({
|
|
|
85
86
|
const mousePosition = React.useRef({
|
|
86
87
|
isInChart: false
|
|
87
88
|
});
|
|
89
|
+
const hasInteractionPlugin = (0, _checkHasInteractionPlugin.checkHasInteractionPlugin)(instance);
|
|
88
90
|
React.useEffect(() => {
|
|
89
91
|
const element = svgRef.current;
|
|
90
|
-
if (!isInteractionEnabled || element === null || params.disableAxisListener) {
|
|
92
|
+
if (!isInteractionEnabled || !hasInteractionPlugin || element === null || params.disableAxisListener) {
|
|
91
93
|
return () => {};
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -101,13 +103,13 @@ const useChartPolarAxis = ({
|
|
|
101
103
|
const panEndHandler = instance.addInteractionListener('panEnd', event => {
|
|
102
104
|
if (!event.detail.activeGestures.move) {
|
|
103
105
|
mousePosition.current.isInChart = false;
|
|
104
|
-
instance.cleanInteraction();
|
|
106
|
+
instance.cleanInteraction?.();
|
|
105
107
|
}
|
|
106
108
|
});
|
|
107
109
|
const pressEndHandler = instance.addInteractionListener('quickPressEnd', event => {
|
|
108
110
|
if (!event.detail.activeGestures.move && !event.detail.activeGestures.pan) {
|
|
109
111
|
mousePosition.current.isInChart = false;
|
|
110
|
-
instance.cleanInteraction();
|
|
112
|
+
instance.cleanInteraction?.();
|
|
111
113
|
}
|
|
112
114
|
});
|
|
113
115
|
const gestureHandler = event => {
|
|
@@ -119,12 +121,12 @@ const useChartPolarAxis = ({
|
|
|
119
121
|
const svgRect = element.getBoundingClientRect();
|
|
120
122
|
if (srcEvent.clientX < svgRect.left || srcEvent.clientX > svgRect.right || srcEvent.clientY < svgRect.top || srcEvent.clientY > svgRect.bottom) {
|
|
121
123
|
mousePosition.current.isInChart = false;
|
|
122
|
-
instance.cleanInteraction();
|
|
124
|
+
instance.cleanInteraction?.();
|
|
123
125
|
return;
|
|
124
126
|
}
|
|
125
127
|
const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, srcEvent);
|
|
126
128
|
mousePosition.current.isInChart = true;
|
|
127
|
-
instance.setPointerCoordinate(svgPoint);
|
|
129
|
+
instance.setPointerCoordinate?.(svgPoint);
|
|
128
130
|
return;
|
|
129
131
|
}
|
|
130
132
|
|
|
@@ -135,7 +137,7 @@ const useChartPolarAxis = ({
|
|
|
135
137
|
// Test if it's in the drawing area
|
|
136
138
|
if (!instance.isPointInside(svgPoint.x, svgPoint.y, event.detail.target)) {
|
|
137
139
|
if (mousePosition.current.isInChart) {
|
|
138
|
-
instance?.
|
|
140
|
+
instance.cleanInteraction?.();
|
|
139
141
|
mousePosition.current.isInChart = false;
|
|
140
142
|
}
|
|
141
143
|
return;
|
|
@@ -146,7 +148,7 @@ const useChartPolarAxis = ({
|
|
|
146
148
|
const maxRadius = radiusAxisWithScale[usedRadiusAxisId].scale.range()[1];
|
|
147
149
|
if (radiusSquare > maxRadius ** 2) {
|
|
148
150
|
if (mousePosition.current.isInChart) {
|
|
149
|
-
instance?.
|
|
151
|
+
instance.cleanInteraction?.();
|
|
150
152
|
mousePosition.current.isInChart = false;
|
|
151
153
|
}
|
|
152
154
|
return;
|
|
@@ -165,7 +167,7 @@ const useChartPolarAxis = ({
|
|
|
165
167
|
pressHandler.cleanup();
|
|
166
168
|
pressEndHandler.cleanup();
|
|
167
169
|
};
|
|
168
|
-
}, [svgRef, store, center, radiusAxisWithScale, usedRadiusAxisId, rotationAxisWithScale, usedRotationAxisId, instance, params.disableAxisListener, isInteractionEnabled, svg2rotation]);
|
|
170
|
+
}, [svgRef, store, center, radiusAxisWithScale, usedRadiusAxisId, rotationAxisWithScale, usedRotationAxisId, instance, params.disableAxisListener, isInteractionEnabled, svg2rotation, hasInteractionPlugin]);
|
|
169
171
|
React.useEffect(() => {
|
|
170
172
|
const element = svgRef.current;
|
|
171
173
|
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>;
|