@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,63 @@
|
|
|
1
|
+
import { AxisConfig, AxisId, D3ContinuousScale, D3OrdinalScale, DefaultedAxis } from "../../../../models/axis.js";
|
|
2
|
+
import { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
|
+
import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
import { ChartSeriesConfig } from "../../models/index.js";
|
|
5
|
+
import { ZoomData } from "./zoom.types.js";
|
|
6
|
+
import { ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
|
|
7
|
+
type GetAxesScalesParams<T extends ChartSeriesType = ChartSeriesType> = {
|
|
8
|
+
drawingArea: ChartDrawingArea;
|
|
9
|
+
formattedSeries: ProcessedSeries<T>;
|
|
10
|
+
seriesConfig: ChartSeriesConfig<T>;
|
|
11
|
+
zoomMap?: Map<AxisId, ZoomData>;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
14
|
+
*/
|
|
15
|
+
preferStrictDomainInLineCharts?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare function getXAxesScales<T extends ChartSeriesType>({
|
|
18
|
+
drawingArea,
|
|
19
|
+
formattedSeries,
|
|
20
|
+
axis: axes,
|
|
21
|
+
seriesConfig,
|
|
22
|
+
zoomMap,
|
|
23
|
+
preferStrictDomainInLineCharts
|
|
24
|
+
}: GetAxesScalesParams<T> & {
|
|
25
|
+
axis?: DefaultedAxis[];
|
|
26
|
+
}): Record<AxisId, ScaleDefinition>;
|
|
27
|
+
export declare function getYAxesScales<T extends ChartSeriesType>({
|
|
28
|
+
drawingArea,
|
|
29
|
+
formattedSeries,
|
|
30
|
+
axis: axes,
|
|
31
|
+
seriesConfig,
|
|
32
|
+
zoomMap,
|
|
33
|
+
preferStrictDomainInLineCharts
|
|
34
|
+
}: GetAxesScalesParams<T> & {
|
|
35
|
+
axis?: DefaultedAxis[];
|
|
36
|
+
}): Record<AxisId, ScaleDefinition>;
|
|
37
|
+
export type ScaleDefinition = {
|
|
38
|
+
scale: D3ContinuousScale;
|
|
39
|
+
tickNumber: number;
|
|
40
|
+
} | {
|
|
41
|
+
scale: D3OrdinalScale;
|
|
42
|
+
tickNumber?: never;
|
|
43
|
+
};
|
|
44
|
+
type DomainLimit = 'nice' | 'strict' | ((min: number, max: number) => {
|
|
45
|
+
min: number;
|
|
46
|
+
max: number;
|
|
47
|
+
});
|
|
48
|
+
export declare function getDomainLimit(axis: Pick<DefaultedAxis, 'id' | 'domainLimit'>, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, preferStrictDomainInLineCharts: boolean | undefined): "nice" | "strict" | ((min: number, max: number) => {
|
|
49
|
+
min: number;
|
|
50
|
+
max: number;
|
|
51
|
+
});
|
|
52
|
+
export declare function applyDomainLimit(scale: D3ContinuousScale, axis: {
|
|
53
|
+
min?: number | Date;
|
|
54
|
+
max?: number | Date;
|
|
55
|
+
}, domainLimit: DomainLimit, rawTickNumber: number): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get the actual axis extrema considering the user defined min and max values.
|
|
58
|
+
* @param axisExtrema User defined axis extrema.
|
|
59
|
+
* @param minData Minimum value from the data.
|
|
60
|
+
* @param maxData Maximum value from the data.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getActualAxisExtrema(axisExtrema: Pick<AxisConfig, 'min' | 'max'>, minData: number, maxData: number): [number | Date, number | Date];
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
|
|
3
|
+
import { isBandScaleConfig, isPointScaleConfig, isSymlogScaleConfig } from "../../../../models/axis.js";
|
|
4
|
+
import { zoomScaleRange } from "./zoom.js";
|
|
5
|
+
import { getAxisDomainLimit } from "./getAxisDomainLimit.js";
|
|
6
|
+
import { getTickNumber } from "../../../ticks.js";
|
|
7
|
+
import { getScale } from "../../../getScale.js";
|
|
8
|
+
import { getAxisExtrema } from "./getAxisExtrema.js";
|
|
9
|
+
const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
|
|
10
|
+
function getRange(drawingArea, axisDirection, axis) {
|
|
11
|
+
const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
|
|
12
|
+
return axis.reverse ? [range[1], range[0]] : range;
|
|
13
|
+
}
|
|
14
|
+
export function getXAxesScales({
|
|
15
|
+
drawingArea,
|
|
16
|
+
formattedSeries,
|
|
17
|
+
axis: axes = [],
|
|
18
|
+
seriesConfig,
|
|
19
|
+
zoomMap,
|
|
20
|
+
preferStrictDomainInLineCharts
|
|
21
|
+
}) {
|
|
22
|
+
const scales = {};
|
|
23
|
+
axes.forEach((eachAxis, axisIndex) => {
|
|
24
|
+
const axis = eachAxis;
|
|
25
|
+
const zoom = zoomMap?.get(axis.id);
|
|
26
|
+
scales[axis.id] = getAxisScale(axis, 'x', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
27
|
+
});
|
|
28
|
+
return scales;
|
|
29
|
+
}
|
|
30
|
+
export function getYAxesScales({
|
|
31
|
+
drawingArea,
|
|
32
|
+
formattedSeries,
|
|
33
|
+
axis: axes = [],
|
|
34
|
+
seriesConfig,
|
|
35
|
+
zoomMap,
|
|
36
|
+
preferStrictDomainInLineCharts
|
|
37
|
+
}) {
|
|
38
|
+
const scales = {};
|
|
39
|
+
axes.forEach((eachAxis, axisIndex) => {
|
|
40
|
+
const axis = eachAxis;
|
|
41
|
+
const zoom = zoomMap?.get(axis.id);
|
|
42
|
+
scales[axis.id] = getAxisScale(axis, 'y', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
43
|
+
});
|
|
44
|
+
return scales;
|
|
45
|
+
}
|
|
46
|
+
function getAxisScale(axis, axisDirection, zoom, drawingArea, seriesConfig, axisIndex, formattedSeries,
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
49
|
+
*/
|
|
50
|
+
preferStrictDomainInLineCharts) {
|
|
51
|
+
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
52
|
+
const range = getRange(drawingArea, axisDirection, axis);
|
|
53
|
+
if (isBandScaleConfig(axis)) {
|
|
54
|
+
const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
|
|
55
|
+
// Reverse range because ordinal scales are presented from top to bottom on y-axis
|
|
56
|
+
const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
|
|
57
|
+
const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
|
|
58
|
+
return {
|
|
59
|
+
scale: scaleBand(axis.data, zoomedRange).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (isPointScaleConfig(axis)) {
|
|
63
|
+
const scaleRange = axisDirection === 'y' ? [...range].reverse() : range;
|
|
64
|
+
const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
|
|
65
|
+
return {
|
|
66
|
+
scale: scalePoint(axis.data, zoomedRange)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const scaleType = axis.scaleType ?? 'linear';
|
|
70
|
+
const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
71
|
+
const [minData, maxData] = getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries);
|
|
72
|
+
const axisExtrema = getActualAxisExtrema(axis, minData, maxData);
|
|
73
|
+
if (typeof domainLimit === 'function') {
|
|
74
|
+
const {
|
|
75
|
+
min,
|
|
76
|
+
max
|
|
77
|
+
} = domainLimit(minData, maxData);
|
|
78
|
+
axisExtrema[0] = min;
|
|
79
|
+
axisExtrema[1] = max;
|
|
80
|
+
}
|
|
81
|
+
const rawTickNumber = getTickNumber(_extends({}, axis, {
|
|
82
|
+
range,
|
|
83
|
+
domain: axisExtrema
|
|
84
|
+
}));
|
|
85
|
+
const zoomedRange = zoomScaleRange(range, zoomRange);
|
|
86
|
+
const scale = getScale(scaleType, axisExtrema, zoomedRange);
|
|
87
|
+
if (isSymlogScaleConfig(axis) && axis.constant != null) {
|
|
88
|
+
scale.constant(axis.constant);
|
|
89
|
+
}
|
|
90
|
+
applyDomainLimit(scale, axis, domainLimit, rawTickNumber);
|
|
91
|
+
return {
|
|
92
|
+
scale,
|
|
93
|
+
tickNumber: rawTickNumber
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts) {
|
|
97
|
+
return preferStrictDomainInLineCharts ? getAxisDomainLimit(axis, axisDirection, axisIndex, formattedSeries) : axis.domainLimit ?? 'nice';
|
|
98
|
+
}
|
|
99
|
+
export function applyDomainLimit(scale, axis, domainLimit, rawTickNumber) {
|
|
100
|
+
if (domainLimit === 'nice') {
|
|
101
|
+
scale.nice(rawTickNumber);
|
|
102
|
+
}
|
|
103
|
+
const [minDomain, maxDomain] = scale.domain();
|
|
104
|
+
scale.domain([axis.min ?? minDomain, axis.max ?? maxDomain]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get the actual axis extrema considering the user defined min and max values.
|
|
109
|
+
* @param axisExtrema User defined axis extrema.
|
|
110
|
+
* @param minData Minimum value from the data.
|
|
111
|
+
* @param maxData Maximum value from the data.
|
|
112
|
+
*/
|
|
113
|
+
export function getActualAxisExtrema(axisExtrema, minData, maxData) {
|
|
114
|
+
let min = minData;
|
|
115
|
+
let max = maxData;
|
|
116
|
+
if (axisExtrema.max != null && axisExtrema.max.valueOf() < minData) {
|
|
117
|
+
min = axisExtrema.max;
|
|
118
|
+
}
|
|
119
|
+
if (axisExtrema.min != null && axisExtrema.min.valueOf() > minData) {
|
|
120
|
+
max = axisExtrema.min;
|
|
121
|
+
}
|
|
122
|
+
return [axisExtrema.min ?? min, axisExtrema.max ?? max];
|
|
123
|
+
}
|
|
@@ -16,6 +16,7 @@ import { getSVGPoint } from "../../../getSVGPoint.js";
|
|
|
16
16
|
import { selectorChartsInteractionIsInitialized } from "../useChartInteraction/index.js";
|
|
17
17
|
import { selectorChartAxisInteraction } from "./useChartCartesianInteraction.selectors.js";
|
|
18
18
|
import { useLazySelectorEffect } from "../../utils/useLazySelectorEffect.js";
|
|
19
|
+
import { checkHasInteractionPlugin } from "../useChartInteraction/checkHasInteractionPlugin.js";
|
|
19
20
|
export const useChartCartesianAxis = ({
|
|
20
21
|
params,
|
|
21
22
|
store,
|
|
@@ -99,26 +100,27 @@ export const useChartCartesianAxis = ({
|
|
|
99
100
|
onHighlightedAxisChange(nextAxisInteraction);
|
|
100
101
|
}
|
|
101
102
|
}, !onHighlightedAxisChange);
|
|
103
|
+
const hasInteractionPlugin = checkHasInteractionPlugin(instance);
|
|
102
104
|
React.useEffect(() => {
|
|
103
105
|
const element = svgRef.current;
|
|
104
|
-
if (!isInteractionEnabled || !element || params.disableAxisListener) {
|
|
106
|
+
if (!isInteractionEnabled || !hasInteractionPlugin || !element || params.disableAxisListener) {
|
|
105
107
|
return () => {};
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
// Clean the interaction when the mouse leaves the chart.
|
|
109
111
|
const moveEndHandler = instance.addInteractionListener('moveEnd', event => {
|
|
110
112
|
if (!event.detail.activeGestures.pan) {
|
|
111
|
-
instance.cleanInteraction
|
|
113
|
+
instance.cleanInteraction();
|
|
112
114
|
}
|
|
113
115
|
});
|
|
114
116
|
const panEndHandler = instance.addInteractionListener('panEnd', event => {
|
|
115
117
|
if (!event.detail.activeGestures.move) {
|
|
116
|
-
instance.cleanInteraction
|
|
118
|
+
instance.cleanInteraction();
|
|
117
119
|
}
|
|
118
120
|
});
|
|
119
121
|
const pressEndHandler = instance.addInteractionListener('quickPressEnd', event => {
|
|
120
122
|
if (!event.detail.activeGestures.move && !event.detail.activeGestures.pan) {
|
|
121
|
-
instance.cleanInteraction
|
|
123
|
+
instance.cleanInteraction();
|
|
122
124
|
}
|
|
123
125
|
});
|
|
124
126
|
const gestureHandler = event => {
|
|
@@ -135,7 +137,7 @@ export const useChartCartesianAxis = ({
|
|
|
135
137
|
instance.cleanInteraction?.();
|
|
136
138
|
return;
|
|
137
139
|
}
|
|
138
|
-
instance.setPointerCoordinate
|
|
140
|
+
instance.setPointerCoordinate(svgPoint);
|
|
139
141
|
};
|
|
140
142
|
const moveHandler = instance.addInteractionListener('move', gestureHandler);
|
|
141
143
|
const panHandler = instance.addInteractionListener('pan', gestureHandler);
|
|
@@ -148,7 +150,7 @@ export const useChartCartesianAxis = ({
|
|
|
148
150
|
pressHandler.cleanup();
|
|
149
151
|
pressEndHandler.cleanup();
|
|
150
152
|
};
|
|
151
|
-
}, [svgRef, store, xAxisWithScale, usedXAxis, yAxisWithScale, usedYAxis, instance, params.disableAxisListener, isInteractionEnabled]);
|
|
153
|
+
}, [svgRef, store, xAxisWithScale, usedXAxis, yAxisWithScale, usedYAxis, instance, params.disableAxisListener, isInteractionEnabled, hasInteractionPlugin]);
|
|
152
154
|
React.useEffect(() => {
|
|
153
155
|
const element = svgRef.current;
|
|
154
156
|
const onAxisClick = params.onAxisClick;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { AxisId } from "../../../../models/axis.js";
|
|
2
|
+
export declare const selectorChartPreviewXScales: import("reselect").Selector<any, Record<AxisId, import("./getAxisScale.js").ScaleDefinition>, [axisId: AxisId]>;
|
|
2
3
|
export declare const selectorChartPreviewComputedXAxis: import("reselect").Selector<any, import("./useChartCartesianAxis.types.js").ComputedAxisConfig<import("../../../index.js").ChartsXAxisProps>, [axisId: AxisId]>;
|
|
4
|
+
export declare const selectorChartPreviewYScales: import("reselect").Selector<any, Record<AxisId, import("./getAxisScale.js").ScaleDefinition>, [axisId: AxisId]>;
|
|
3
5
|
export declare const selectorChartPreviewComputedYAxis: import("reselect").Selector<any, import("./useChartCartesianAxis.types.js").ComputedAxisConfig<import("../../../index.js").ChartsYAxisProps>, [axisId: AxisId]>;
|
|
@@ -5,6 +5,8 @@ import { computeAxisValue } from "./computeAxisValue.js";
|
|
|
5
5
|
import { selectorChartZoomAxisFilters, selectorChartZoomOptionsLookup } from "./useChartCartesianAxisRendering.selectors.js";
|
|
6
6
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/index.js";
|
|
7
7
|
import { ZOOM_SLIDER_PREVIEW_SIZE } from "../../../constants.js";
|
|
8
|
+
import { selectorPreferStrictDomainInLineCharts } from "../../corePlugins/useChartExperimentalFeature/index.js";
|
|
9
|
+
import { getXAxesScales, getYAxesScales } from "./getAxisScale.js";
|
|
8
10
|
function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
|
|
9
11
|
return axisDirection === 'x' ? {
|
|
10
12
|
left: 0,
|
|
@@ -22,7 +24,25 @@ function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
|
|
|
22
24
|
bottom: mainChartDrawingArea.height
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
|
-
export const
|
|
27
|
+
export const selectorChartPreviewXScales = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorPreferStrictDomainInLineCharts, (_, axisId) => axisId], function selectorChartPreviewXScales(xAxes, chartDrawingArea, formattedSeries, seriesConfig, zoomOptions, preferStrictDomainInLineCharts, axisId) {
|
|
28
|
+
const hasAxis = xAxes?.some(axis => axis.id === axisId);
|
|
29
|
+
const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
|
|
30
|
+
const options = zoomOptions[axisId];
|
|
31
|
+
const zoomMap = new Map([[axisId, {
|
|
32
|
+
axisId,
|
|
33
|
+
start: options.minStart,
|
|
34
|
+
end: options.maxEnd
|
|
35
|
+
}]]);
|
|
36
|
+
return getXAxesScales({
|
|
37
|
+
drawingArea,
|
|
38
|
+
formattedSeries,
|
|
39
|
+
axis: xAxes,
|
|
40
|
+
seriesConfig,
|
|
41
|
+
zoomMap,
|
|
42
|
+
preferStrictDomainInLineCharts
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
export const selectorChartPreviewComputedXAxis = createSelector([selectorChartRawXAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorChartDrawingArea, selectorPreferStrictDomainInLineCharts, selectorChartPreviewXScales, (_, axisId) => axisId], (xAxes, formattedSeries, seriesConfig, zoomOptions, getFilters, chartDrawingArea, preferStrictDomainInLineCharts, scales, axisId) => {
|
|
26
46
|
const hasAxis = xAxes?.some(axis => axis.id === axisId);
|
|
27
47
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
|
|
28
48
|
const options = zoomOptions[axisId];
|
|
@@ -32,6 +52,7 @@ export const selectorChartPreviewComputedXAxis = createSelector([selectorChartRa
|
|
|
32
52
|
end: options.maxEnd
|
|
33
53
|
}]]);
|
|
34
54
|
const computedAxes = computeAxisValue({
|
|
55
|
+
scales,
|
|
35
56
|
drawingArea,
|
|
36
57
|
formattedSeries,
|
|
37
58
|
axis: xAxes,
|
|
@@ -39,7 +60,8 @@ export const selectorChartPreviewComputedXAxis = createSelector([selectorChartRa
|
|
|
39
60
|
axisDirection: 'x',
|
|
40
61
|
zoomMap,
|
|
41
62
|
zoomOptions,
|
|
42
|
-
getFilters
|
|
63
|
+
getFilters,
|
|
64
|
+
preferStrictDomainInLineCharts
|
|
43
65
|
});
|
|
44
66
|
if (computedAxes.axis[axisId]) {
|
|
45
67
|
return {
|
|
@@ -48,7 +70,25 @@ export const selectorChartPreviewComputedXAxis = createSelector([selectorChartRa
|
|
|
48
70
|
}
|
|
49
71
|
return computedAxes.axis;
|
|
50
72
|
});
|
|
51
|
-
export const
|
|
73
|
+
export const selectorChartPreviewYScales = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorPreferStrictDomainInLineCharts, (_, axisId) => axisId], function selectorChartPreviewYScales(yAxes, chartDrawingArea, formattedSeries, seriesConfig, zoomOptions, preferStrictDomainInLineCharts, axisId) {
|
|
74
|
+
const hasAxis = yAxes?.some(axis => axis.id === axisId);
|
|
75
|
+
const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
|
|
76
|
+
const options = zoomOptions[axisId];
|
|
77
|
+
const zoomMap = new Map([[axisId, {
|
|
78
|
+
axisId,
|
|
79
|
+
start: options.minStart,
|
|
80
|
+
end: options.maxEnd
|
|
81
|
+
}]]);
|
|
82
|
+
return getYAxesScales({
|
|
83
|
+
drawingArea,
|
|
84
|
+
formattedSeries,
|
|
85
|
+
axis: yAxes,
|
|
86
|
+
seriesConfig,
|
|
87
|
+
zoomMap,
|
|
88
|
+
preferStrictDomainInLineCharts
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
export const selectorChartPreviewComputedYAxis = createSelector([selectorChartRawYAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorChartDrawingArea, selectorPreferStrictDomainInLineCharts, selectorChartPreviewYScales, (_, axisId) => axisId], (yAxes, formattedSeries, seriesConfig, zoomOptions, getFilters, chartDrawingArea, preferStrictDomainInLineCharts, scales, axisId) => {
|
|
52
92
|
const hasAxis = yAxes?.some(axis => axis.id === axisId);
|
|
53
93
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
|
|
54
94
|
const options = zoomOptions[axisId];
|
|
@@ -58,6 +98,7 @@ export const selectorChartPreviewComputedYAxis = createSelector([selectorChartRa
|
|
|
58
98
|
end: options.maxEnd
|
|
59
99
|
}]]);
|
|
60
100
|
const computedAxes = computeAxisValue({
|
|
101
|
+
scales,
|
|
61
102
|
drawingArea,
|
|
62
103
|
formattedSeries,
|
|
63
104
|
axis: yAxes,
|
|
@@ -65,7 +106,8 @@ export const selectorChartPreviewComputedYAxis = createSelector([selectorChartRa
|
|
|
65
106
|
axisDirection: 'y',
|
|
66
107
|
zoomMap,
|
|
67
108
|
zoomOptions,
|
|
68
|
-
getFilters
|
|
109
|
+
getFilters,
|
|
110
|
+
preferStrictDomainInLineCharts
|
|
69
111
|
});
|
|
70
112
|
if (computedAxes.axis[axisId]) {
|
|
71
113
|
return {
|
|
@@ -23,6 +23,16 @@ export declare const selectorChartZoomOptionsLookup: import("reselect").Selector
|
|
|
23
23
|
[x: number]: import("./useChartCartesianAxis.types.js").DefaultizedZoomOptions;
|
|
24
24
|
}, []>;
|
|
25
25
|
export declare const selectorChartAxisZoomOptionsLookup: import("reselect").Selector<any, import("./useChartCartesianAxis.types.js").DefaultizedZoomOptions, [axisId: AxisId]>;
|
|
26
|
+
export declare const selectorChartXScales: 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("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
|
|
27
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
|
+
} & Partial<{}> & {
|
|
29
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
30
|
+
}, Record<AxisId, import("./getAxisScale.js").ScaleDefinition>, []>;
|
|
31
|
+
export declare const selectorChartYScales: 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("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
|
|
32
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
33
|
+
} & Partial<{}> & {
|
|
34
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
35
|
+
}, Record<AxisId, import("./getAxisScale.js").ScaleDefinition>, []>;
|
|
26
36
|
export declare const selectorChartZoomAxisFilters: 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("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
|
|
27
37
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
38
|
} & {
|
|
@@ -7,6 +7,7 @@ import { createAxisFilterMapper, createGetAxisFilters } from "./createAxisFilter
|
|
|
7
7
|
import { createZoomLookup } from "./createZoomLookup.js";
|
|
8
8
|
import { selectorChartRawXAxis, selectorChartRawYAxis } from "./useChartCartesianAxisLayout.selectors.js";
|
|
9
9
|
import { selectorPreferStrictDomainInLineCharts } from "../../corePlugins/useChartExperimentalFeature/index.js";
|
|
10
|
+
import { getXAxesScales, getYAxesScales } from "./getAxisScale.js";
|
|
10
11
|
export const createZoomMap = zoom => {
|
|
11
12
|
const zoomItemMap = new Map();
|
|
12
13
|
zoom.forEach(zoomItem => {
|
|
@@ -24,34 +25,42 @@ export const selectorChartZoomIsInteracting = createSelector([selectorChartZoomS
|
|
|
24
25
|
export const selectorChartZoomMap = createSelector([selectorChartZoomState], zoom => zoom?.zoomData && createZoomMap(zoom?.zoomData));
|
|
25
26
|
export const selectorChartZoomOptionsLookup = createSelector([selectorChartRawXAxis, selectorChartRawYAxis], (xAxis, yAxis) => _extends({}, createZoomLookup('x')(xAxis), createZoomLookup('y')(yAxis)));
|
|
26
27
|
export const selectorChartAxisZoomOptionsLookup = createSelector([selectorChartZoomOptionsLookup, (_, axisId) => axisId], (axisLookup, axisId) => axisLookup[axisId]);
|
|
27
|
-
const selectorChartXFilter = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
const selectorChartXFilter = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup], (zoomMap, zoomOptions) => zoomMap && zoomOptions && createAxisFilterMapper(zoomMap, zoomOptions, 'x'));
|
|
29
|
+
const selectorChartYFilter = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup], (zoomMap, zoomOptions) => zoomMap && zoomOptions && createAxisFilterMapper(zoomMap, zoomOptions, 'y'));
|
|
30
|
+
export const selectorChartXScales = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorPreferStrictDomainInLineCharts], function selectorChartXScales(axis, drawingArea, formattedSeries, seriesConfig, zoomMap, preferStrictDomainInLineCharts) {
|
|
31
|
+
return getXAxesScales({
|
|
32
|
+
drawingArea,
|
|
33
|
+
formattedSeries,
|
|
34
|
+
axis,
|
|
35
|
+
seriesConfig,
|
|
36
|
+
zoomMap,
|
|
37
|
+
preferStrictDomainInLineCharts
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
export const selectorChartYScales = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorPreferStrictDomainInLineCharts], function selectorChartYScales(axis, drawingArea, formattedSeries, seriesConfig, zoomMap, preferStrictDomainInLineCharts) {
|
|
41
|
+
return getYAxesScales({
|
|
42
|
+
drawingArea,
|
|
43
|
+
formattedSeries,
|
|
44
|
+
axis,
|
|
45
|
+
seriesConfig,
|
|
46
|
+
zoomMap,
|
|
47
|
+
preferStrictDomainInLineCharts
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
export const selectorChartZoomAxisFilters = createSelector([selectorChartXFilter, selectorChartYFilter, selectorChartRawXAxis, selectorChartRawYAxis, selectorChartXScales, selectorChartYScales], (xMapper, yMapper, xAxis, yAxis, xScales, yScales) => {
|
|
42
51
|
if (xMapper === undefined || yMapper === undefined) {
|
|
43
52
|
// Early return if there is no zoom.
|
|
44
53
|
return undefined;
|
|
45
54
|
}
|
|
46
|
-
const xFilters = xAxis?.reduce((acc, axis
|
|
47
|
-
const filter = xMapper(axis,
|
|
55
|
+
const xFilters = xAxis?.reduce((acc, axis) => {
|
|
56
|
+
const filter = xMapper(axis.id, axis.data, xScales[axis.id].scale);
|
|
48
57
|
if (filter !== null) {
|
|
49
58
|
acc[axis.id] = filter;
|
|
50
59
|
}
|
|
51
60
|
return acc;
|
|
52
61
|
}, {});
|
|
53
|
-
const yFilters = yAxis?.reduce((acc, axis
|
|
54
|
-
const filter = yMapper(axis,
|
|
62
|
+
const yFilters = yAxis?.reduce((acc, axis) => {
|
|
63
|
+
const filter = yMapper(axis.id, axis.data, yScales[axis.id].scale);
|
|
55
64
|
if (filter !== null) {
|
|
56
65
|
acc[axis.id] = filter;
|
|
57
66
|
}
|
|
@@ -67,7 +76,8 @@ export const selectorChartZoomAxisFilters = createSelector([selectorChartXFilter
|
|
|
67
76
|
* The only interesting selectors that merge axis data and zoom if provided.
|
|
68
77
|
*/
|
|
69
78
|
|
|
70
|
-
export const selectorChartXAxis = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorPreferStrictDomainInLineCharts], (axis, drawingArea, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts) => computeAxisValue({
|
|
79
|
+
export const selectorChartXAxis = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorPreferStrictDomainInLineCharts, selectorChartXScales], (axis, drawingArea, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts, scales) => computeAxisValue({
|
|
80
|
+
scales,
|
|
71
81
|
drawingArea,
|
|
72
82
|
formattedSeries,
|
|
73
83
|
axis,
|
|
@@ -78,7 +88,8 @@ export const selectorChartXAxis = createSelector([selectorChartRawXAxis, selecto
|
|
|
78
88
|
getFilters,
|
|
79
89
|
preferStrictDomainInLineCharts
|
|
80
90
|
}));
|
|
81
|
-
export const selectorChartYAxis = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorPreferStrictDomainInLineCharts], (axis, drawingArea, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts) => computeAxisValue({
|
|
91
|
+
export const selectorChartYAxis = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorPreferStrictDomainInLineCharts, selectorChartYScales], (axis, drawingArea, formattedSeries, seriesConfig, zoomMap, zoomOptions, getFilters, preferStrictDomainInLineCharts, scales) => computeAxisValue({
|
|
92
|
+
scales,
|
|
82
93
|
drawingArea,
|
|
83
94
|
formattedSeries,
|
|
84
95
|
axis,
|
|
@@ -11,7 +11,7 @@ import { useSelector } from "../../../store/useSelector.js";
|
|
|
11
11
|
import { selectorChartXAxis, selectorChartYAxis, selectorChartZoomIsInteracting } from "../useChartCartesianAxis/index.js";
|
|
12
12
|
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
13
13
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/index.js";
|
|
14
|
-
export const
|
|
14
|
+
export const useChartClosestPoint = ({
|
|
15
15
|
svgRef,
|
|
16
16
|
params,
|
|
17
17
|
store,
|
|
@@ -86,7 +86,8 @@ export const useChartVoronoi = ({
|
|
|
86
86
|
seriesId,
|
|
87
87
|
seriesIndexes,
|
|
88
88
|
startIndex: points.length,
|
|
89
|
-
endIndex: points.length + seriesPoints.length
|
|
89
|
+
endIndex: points.length + seriesPoints.length,
|
|
90
|
+
markerSize: series[seriesId].markerSize
|
|
90
91
|
};
|
|
91
92
|
points = points.concat(seriesPoints);
|
|
92
93
|
});
|
|
@@ -123,11 +124,12 @@ export const useChartVoronoi = ({
|
|
|
123
124
|
// The point index in the series with id=closestSeries.seriesId.
|
|
124
125
|
const seriesPointIndex = (2 * closestPointIndex - voronoiRef.current[closestSeries.seriesId].startIndex) / 2;
|
|
125
126
|
const dataIndex = voronoiRef.current[closestSeries.seriesId].seriesIndexes[seriesPointIndex];
|
|
126
|
-
|
|
127
|
+
const maxRadius = voronoiMaxRadius === 'item' ? closestSeries.markerSize : voronoiMaxRadius;
|
|
128
|
+
if (maxRadius !== undefined) {
|
|
127
129
|
const pointX = delauneyRef.current.points[2 * closestPointIndex];
|
|
128
130
|
const pointY = delauneyRef.current.points[2 * closestPointIndex + 1];
|
|
129
131
|
const dist2 = (pointX - svgPoint.x) ** 2 + (pointY - svgPoint.y) ** 2;
|
|
130
|
-
if (dist2 >
|
|
132
|
+
if (dist2 > maxRadius ** 2) {
|
|
131
133
|
// The closest point is too far to be considered.
|
|
132
134
|
return 'outside-voronoi-max-radius';
|
|
133
135
|
}
|
|
@@ -233,17 +235,17 @@ export const useChartVoronoi = ({
|
|
|
233
235
|
}
|
|
234
236
|
};
|
|
235
237
|
};
|
|
236
|
-
|
|
238
|
+
useChartClosestPoint.getDefaultizedParams = ({
|
|
237
239
|
params
|
|
238
240
|
}) => _extends({}, params, {
|
|
239
241
|
disableVoronoi: params.disableVoronoi ?? !params.series.some(item => item.type === 'scatter')
|
|
240
242
|
});
|
|
241
|
-
|
|
243
|
+
useChartClosestPoint.getInitialState = params => ({
|
|
242
244
|
voronoi: {
|
|
243
245
|
isVoronoiEnabled: !params.disableVoronoi
|
|
244
246
|
}
|
|
245
247
|
});
|
|
246
|
-
|
|
248
|
+
useChartClosestPoint.params = {
|
|
247
249
|
disableVoronoi: true,
|
|
248
250
|
voronoiMaxRadius: true,
|
|
249
251
|
onItemClick: true
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const selectorChartsIsVoronoiEnabled: 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 & import("./useChartClosestPoint.types.js").UseChartVoronoiState & Partial<{}> & {
|
|
2
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
3
|
+
} & {
|
|
4
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
5
|
+
}, boolean | undefined, any[]>;
|
|
@@ -29,10 +29,11 @@ export interface UseChartVoronoiParameters {
|
|
|
29
29
|
*/
|
|
30
30
|
disableVoronoi?: boolean;
|
|
31
31
|
/**
|
|
32
|
-
* Defines the
|
|
32
|
+
* Defines the maximum distance between a scatter point and the pointer that triggers the interaction.
|
|
33
|
+
* If set to `'item'`, the radius is the `markerSize`.
|
|
33
34
|
* If `undefined`, the radius is assumed to be infinite.
|
|
34
35
|
*/
|
|
35
|
-
voronoiMaxRadius?: number | undefined;
|
|
36
|
+
voronoiMaxRadius?: 'item' | number | undefined;
|
|
36
37
|
/**
|
|
37
38
|
* Callback fired when clicking close to an item.
|
|
38
39
|
* This is only available for scatter plot for now.
|
|
@@ -41,10 +42,13 @@ export interface UseChartVoronoiParameters {
|
|
|
41
42
|
*/
|
|
42
43
|
onItemClick?: (event: MouseEvent, scatterItemIdentifier: ScatterItemIdentifier) => void;
|
|
43
44
|
}
|
|
44
|
-
export type UseChartVoronoiDefaultizedParameters = UseChartVoronoiParameters & {
|
|
45
|
+
export type UseChartVoronoiDefaultizedParameters = Pick<UseChartVoronoiParameters, 'voronoiMaxRadius' | 'onItemClick'> & {
|
|
46
|
+
/**
|
|
47
|
+
* If true, the voronoi plugin is disabled.
|
|
48
|
+
*/
|
|
45
49
|
disableVoronoi: boolean;
|
|
46
50
|
};
|
|
47
|
-
export type
|
|
51
|
+
export type UseChartClosestPointSignature = ChartPluginSignature<{
|
|
48
52
|
instance: UseChartVoronoiInstance;
|
|
49
53
|
state: UseChartVoronoiState;
|
|
50
54
|
params: UseChartVoronoiParameters;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HighlightItemData } from "./useChartHighlight.types.js";
|
|
2
|
+
import { HighlightScope } from "./highlightConfig.types.js";
|
|
3
|
+
import { SeriesId } from "../../../../models/seriesType/common.js";
|
|
4
|
+
export declare function isSeriesHighlighted(scope: Partial<HighlightScope> | null, item: HighlightItemData | null, seriesId: SeriesId): boolean;
|
|
5
|
+
export declare function isSeriesFaded(scope: Partial<HighlightScope> | null, item: HighlightItemData | null, seriesId: SeriesId): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the data index of the highlighted item for a specific series.
|
|
8
|
+
* If the item is not highlighted, it returns `null`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSeriesHighlightedItem(scope: Partial<HighlightScope> | null, item: HighlightItemData | null, seriesId: SeriesId): number | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the data index of the "unfaded item" for a specific series.
|
|
13
|
+
* An "unfaded item" is the only item of a faded series that shouldn't be faded.
|
|
14
|
+
* If the series is not faded or if there is no highlighted item, it returns `null`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSeriesUnfadedItem(scope: Partial<HighlightScope> | null, item: HighlightItemData | null, seriesId: SeriesId): number | null | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function isSeriesHighlighted(scope, item, seriesId) {
|
|
2
|
+
return scope?.highlight === 'series' && item?.seriesId === seriesId;
|
|
3
|
+
}
|
|
4
|
+
export function isSeriesFaded(scope, item, seriesId) {
|
|
5
|
+
if (isSeriesHighlighted(scope, item, seriesId)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return scope?.fade === 'global' && item != null || scope?.fade === 'series' && item?.seriesId === seriesId;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns the data index of the highlighted item for a specific series.
|
|
13
|
+
* If the item is not highlighted, it returns `null`.
|
|
14
|
+
*/
|
|
15
|
+
export function getSeriesHighlightedItem(scope, item, seriesId) {
|
|
16
|
+
return scope?.highlight === 'item' && item?.seriesId === seriesId ? item.dataIndex : null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the data index of the "unfaded item" for a specific series.
|
|
21
|
+
* An "unfaded item" is the only item of a faded series that shouldn't be faded.
|
|
22
|
+
* If the series is not faded or if there is no highlighted item, it returns `null`.
|
|
23
|
+
*/
|
|
24
|
+
export function getSeriesUnfadedItem(scope, item, seriesId) {
|
|
25
|
+
if (isSeriesHighlighted(scope, item, seriesId)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (getSeriesHighlightedItem(scope, item, seriesId) === item?.dataIndex) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return (scope?.fade === 'series' || scope?.fade === 'global') && item?.seriesId === seriesId ? item.dataIndex : null;
|
|
32
|
+
}
|
package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts
CHANGED
|
@@ -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]>;
|