@mui/x-charts 8.12.0 → 8.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +145 -0
- package/ChartsSurface/ChartsSurface.js +4 -3
- package/PieChart/PieArc.d.ts +3 -0
- package/PieChart/PieArc.js +13 -12
- package/PieChart/PieArcPlot.js +27 -3
- package/esm/ChartsSurface/ChartsSurface.js +4 -3
- package/esm/PieChart/PieArc.d.ts +3 -0
- package/esm/PieChart/PieArc.js +14 -13
- package/esm/PieChart/PieArcPlot.js +29 -5
- package/esm/index.js +1 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +60 -32
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +19 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +5 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +8 -10
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +7 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +13 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +30 -7
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +6 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +2 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +6 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +115 -155
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +14 -2
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +27 -1
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -5
- package/esm/internals/ticks.d.ts +3 -5
- package/esm/internals/ticks.js +6 -5
- package/index.js +1 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +59 -31
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +19 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +5 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +8 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +6 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +14 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +30 -7
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +6 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +3 -2
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +6 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +115 -155
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +14 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +28 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +2 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -4
- package/internals/ticks.d.ts +3 -5
- package/internals/ticks.js +7 -5
- package/package.json +4 -4
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { MoveEvent, PanEvent, PinchEvent, PressEvent, TapEvent, TurnWheelEvent } from '@mui/x-internal-gestures/core';
|
|
1
|
+
import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type TapAndDragEvent, type TapAndDragGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
|
|
2
2
|
import { ChartPluginSignature } from "../../models/index.js";
|
|
3
|
-
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | '
|
|
3
|
+
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'move' | 'moveStart' | 'moveEnd' | 'quickPress' | 'quickPressEnd' | 'zoomTurnWheel' | 'tap';
|
|
4
4
|
export type InteractionListenerResult = {
|
|
5
5
|
cleanup: () => void;
|
|
6
6
|
};
|
|
7
7
|
export type AddInteractionListener = {
|
|
8
|
-
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
9
|
-
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: '
|
|
10
|
-
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: '
|
|
8
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
9
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd', callback: (event: PinchEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
10
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTurnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
11
11
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'move' | 'moveStart' | 'moveEnd', callback: (event: MoveEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
12
12
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'tap', callback: (event: TapEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
13
13
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'quickPress' | 'quickPressEnd', callback: (event: PressEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
14
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd', callback: (event: TapAndDragEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
15
|
+
};
|
|
16
|
+
export type UpdateZoomInteractionListeners = {
|
|
17
|
+
(interaction: 'zoomPan', options?: Omit<PanGestureOptions<'zoomPan'>, 'name'>): void;
|
|
18
|
+
(interaction: 'zoomPinch', options?: Omit<PinchGestureOptions<'zoomPinch'>, 'name'>): void;
|
|
19
|
+
(interaction: 'zoomTurnWheel', options?: Omit<TurnWheelGestureOptions<'zoomTurnWheel'>, 'name'>): void;
|
|
20
|
+
(interaction: 'zoomTapAndDrag', options?: Omit<TapAndDragGestureOptions<'zoomTapAndDrag'>, 'name'>): void;
|
|
14
21
|
};
|
|
15
22
|
export interface UseChartInteractionListenerParameters {}
|
|
16
23
|
export interface UseChartInteractionListenerState {}
|
|
@@ -22,6 +29,13 @@ export interface UseChartInteractionListenerInstance {
|
|
|
22
29
|
* @param callback The callback to call when the interaction occurs.
|
|
23
30
|
*/
|
|
24
31
|
addInteractionListener: AddInteractionListener;
|
|
32
|
+
/**
|
|
33
|
+
* Updates the zoom interaction listeners with the provided options.
|
|
34
|
+
*
|
|
35
|
+
* @param interaction The interaction to update.
|
|
36
|
+
* @param options The options to apply to the interaction.
|
|
37
|
+
*/
|
|
38
|
+
updateZoomInteractionListeners: UpdateZoomInteractionListeners;
|
|
25
39
|
}
|
|
26
40
|
export type UseChartInteractionListenerSignature = ChartPluginSignature<{
|
|
27
41
|
params: UseChartInteractionListenerParameters;
|
|
@@ -13,6 +13,7 @@ type GetAxesScalesParams<T extends ChartSeriesType = ChartSeriesType> = {
|
|
|
13
13
|
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
14
14
|
*/
|
|
15
15
|
preferStrictDomainInLineCharts?: boolean;
|
|
16
|
+
defaultTickNumber: number;
|
|
16
17
|
};
|
|
17
18
|
export declare function getXAxesScales<T extends ChartSeriesType>({
|
|
18
19
|
drawingArea,
|
|
@@ -20,7 +21,8 @@ export declare function getXAxesScales<T extends ChartSeriesType>({
|
|
|
20
21
|
axis: axes,
|
|
21
22
|
seriesConfig,
|
|
22
23
|
zoomMap,
|
|
23
|
-
preferStrictDomainInLineCharts
|
|
24
|
+
preferStrictDomainInLineCharts,
|
|
25
|
+
defaultTickNumber
|
|
24
26
|
}: GetAxesScalesParams<T> & {
|
|
25
27
|
axis?: DefaultedAxis[];
|
|
26
28
|
}): Record<AxisId, ScaleDefinition>;
|
|
@@ -30,7 +32,8 @@ export declare function getYAxesScales<T extends ChartSeriesType>({
|
|
|
30
32
|
axis: axes,
|
|
31
33
|
seriesConfig,
|
|
32
34
|
zoomMap,
|
|
33
|
-
preferStrictDomainInLineCharts
|
|
35
|
+
preferStrictDomainInLineCharts,
|
|
36
|
+
defaultTickNumber
|
|
34
37
|
}: GetAxesScalesParams<T> & {
|
|
35
38
|
axis?: DefaultedAxis[];
|
|
36
39
|
}): Record<AxisId, ScaleDefinition>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
|
|
3
2
|
import { isBandScaleConfig, isPointScaleConfig, isSymlogScaleConfig } from "../../../../models/axis.js";
|
|
4
3
|
import { zoomScaleRange } from "./zoom.js";
|
|
@@ -17,13 +16,14 @@ export function getXAxesScales({
|
|
|
17
16
|
axis: axes = [],
|
|
18
17
|
seriesConfig,
|
|
19
18
|
zoomMap,
|
|
20
|
-
preferStrictDomainInLineCharts
|
|
19
|
+
preferStrictDomainInLineCharts,
|
|
20
|
+
defaultTickNumber
|
|
21
21
|
}) {
|
|
22
22
|
const scales = {};
|
|
23
23
|
axes.forEach((eachAxis, axisIndex) => {
|
|
24
24
|
const axis = eachAxis;
|
|
25
25
|
const zoom = zoomMap?.get(axis.id);
|
|
26
|
-
scales[axis.id] = getAxisScale(axis, 'x', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
26
|
+
scales[axis.id] = getAxisScale(axis, 'x', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts, defaultTickNumber);
|
|
27
27
|
});
|
|
28
28
|
return scales;
|
|
29
29
|
}
|
|
@@ -33,13 +33,14 @@ export function getYAxesScales({
|
|
|
33
33
|
axis: axes = [],
|
|
34
34
|
seriesConfig,
|
|
35
35
|
zoomMap,
|
|
36
|
-
preferStrictDomainInLineCharts
|
|
36
|
+
preferStrictDomainInLineCharts,
|
|
37
|
+
defaultTickNumber
|
|
37
38
|
}) {
|
|
38
39
|
const scales = {};
|
|
39
40
|
axes.forEach((eachAxis, axisIndex) => {
|
|
40
41
|
const axis = eachAxis;
|
|
41
42
|
const zoom = zoomMap?.get(axis.id);
|
|
42
|
-
scales[axis.id] = getAxisScale(axis, 'y', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
|
|
43
|
+
scales[axis.id] = getAxisScale(axis, 'y', zoom, drawingArea, seriesConfig, axisIndex, formattedSeries, preferStrictDomainInLineCharts, defaultTickNumber);
|
|
43
44
|
});
|
|
44
45
|
return scales;
|
|
45
46
|
}
|
|
@@ -47,7 +48,7 @@ function getAxisScale(axis, axisDirection, zoom, drawingArea, seriesConfig, axis
|
|
|
47
48
|
/**
|
|
48
49
|
* @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
|
|
49
50
|
*/
|
|
50
|
-
preferStrictDomainInLineCharts) {
|
|
51
|
+
preferStrictDomainInLineCharts, defaultTickNumber) {
|
|
51
52
|
const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
|
|
52
53
|
const range = getRange(drawingArea, axisDirection, axis);
|
|
53
54
|
if (isBandScaleConfig(axis)) {
|
|
@@ -78,10 +79,7 @@ preferStrictDomainInLineCharts) {
|
|
|
78
79
|
axisExtrema[0] = min;
|
|
79
80
|
axisExtrema[1] = max;
|
|
80
81
|
}
|
|
81
|
-
const rawTickNumber = getTickNumber(
|
|
82
|
-
range,
|
|
83
|
-
domain: axisExtrema
|
|
84
|
-
}));
|
|
82
|
+
const rawTickNumber = getTickNumber(axis, axisExtrema, defaultTickNumber);
|
|
85
83
|
const zoomedRange = zoomScaleRange(range, zoomRange);
|
|
86
84
|
const scale = getScale(scaleType, axisExtrema, zoomedRange);
|
|
87
85
|
if (isSymlogScaleConfig(axis) && axis.constant != null) {
|
|
@@ -2,7 +2,7 @@ import { createSelector } from "../../utils/selectors.js";
|
|
|
2
2
|
import { selectorChartRawXAxis, selectorChartRawYAxis } from "./useChartCartesianAxisLayout.selectors.js";
|
|
3
3
|
import { selectorChartSeriesConfig, selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
4
4
|
import { computeAxisValue } from "./computeAxisValue.js";
|
|
5
|
-
import { selectorChartZoomAxisFilters, selectorChartZoomOptionsLookup } from "./useChartCartesianAxisRendering.selectors.js";
|
|
5
|
+
import { selectorChartZoomAxisFilters, selectorChartZoomOptionsLookup, selectorDefaultXAxisTickNumber, selectorDefaultYAxisTickNumber } from "./useChartCartesianAxisRendering.selectors.js";
|
|
6
6
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/index.js";
|
|
7
7
|
import { ZOOM_SLIDER_PREVIEW_SIZE } from "../../../constants.js";
|
|
8
8
|
import { selectorPreferStrictDomainInLineCharts } from "../../corePlugins/useChartExperimentalFeature/index.js";
|
|
@@ -24,7 +24,7 @@ function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
|
|
|
24
24
|
bottom: mainChartDrawingArea.height
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
export const selectorChartPreviewXScales = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorPreferStrictDomainInLineCharts, (_, axisId) => axisId], function selectorChartPreviewXScales(xAxes, chartDrawingArea, formattedSeries, seriesConfig, zoomOptions, preferStrictDomainInLineCharts, axisId) {
|
|
27
|
+
export const selectorChartPreviewXScales = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorPreferStrictDomainInLineCharts, selectorDefaultXAxisTickNumber, (_, axisId) => axisId], function selectorChartPreviewXScales(xAxes, chartDrawingArea, formattedSeries, seriesConfig, zoomOptions, preferStrictDomainInLineCharts, defaultTickNumber, axisId) {
|
|
28
28
|
const hasAxis = xAxes?.some(axis => axis.id === axisId);
|
|
29
29
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
|
|
30
30
|
const options = zoomOptions[axisId];
|
|
@@ -39,7 +39,8 @@ export const selectorChartPreviewXScales = createSelector([selectorChartRawXAxis
|
|
|
39
39
|
axis: xAxes,
|
|
40
40
|
seriesConfig,
|
|
41
41
|
zoomMap,
|
|
42
|
-
preferStrictDomainInLineCharts
|
|
42
|
+
preferStrictDomainInLineCharts,
|
|
43
|
+
defaultTickNumber
|
|
43
44
|
});
|
|
44
45
|
});
|
|
45
46
|
export const selectorChartPreviewComputedXAxis = createSelector([selectorChartRawXAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorChartDrawingArea, selectorPreferStrictDomainInLineCharts, selectorChartPreviewXScales, (_, axisId) => axisId], (xAxes, formattedSeries, seriesConfig, zoomOptions, getFilters, chartDrawingArea, preferStrictDomainInLineCharts, scales, axisId) => {
|
|
@@ -70,7 +71,7 @@ export const selectorChartPreviewComputedXAxis = createSelector([selectorChartRa
|
|
|
70
71
|
}
|
|
71
72
|
return computedAxes.axis;
|
|
72
73
|
});
|
|
73
|
-
export const selectorChartPreviewYScales = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorPreferStrictDomainInLineCharts, (_, axisId) => axisId], function selectorChartPreviewYScales(yAxes, chartDrawingArea, formattedSeries, seriesConfig, zoomOptions, preferStrictDomainInLineCharts, axisId) {
|
|
74
|
+
export const selectorChartPreviewYScales = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorPreferStrictDomainInLineCharts, selectorDefaultYAxisTickNumber, (_, axisId) => axisId], function selectorChartPreviewYScales(yAxes, chartDrawingArea, formattedSeries, seriesConfig, zoomOptions, preferStrictDomainInLineCharts, defaultTickNumber, axisId) {
|
|
74
75
|
const hasAxis = yAxes?.some(axis => axis.id === axisId);
|
|
75
76
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
|
|
76
77
|
const options = zoomOptions[axisId];
|
|
@@ -85,7 +86,8 @@ export const selectorChartPreviewYScales = createSelector([selectorChartRawYAxis
|
|
|
85
86
|
axis: yAxes,
|
|
86
87
|
seriesConfig,
|
|
87
88
|
zoomMap,
|
|
88
|
-
preferStrictDomainInLineCharts
|
|
89
|
+
preferStrictDomainInLineCharts,
|
|
90
|
+
defaultTickNumber
|
|
89
91
|
});
|
|
90
92
|
});
|
|
91
93
|
export const selectorChartPreviewComputedYAxis = createSelector([selectorChartRawYAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartZoomAxisFilters, selectorChartDrawingArea, selectorPreferStrictDomainInLineCharts, selectorChartPreviewYScales, (_, axisId) => axisId], (yAxes, formattedSeries, seriesConfig, zoomOptions, getFilters, chartDrawingArea, preferStrictDomainInLineCharts, scales, axisId) => {
|
|
@@ -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 selectorDefaultXAxisTickNumber: 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<{}> & {
|
|
27
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
|
+
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
|
|
29
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
30
|
+
}, number, []>;
|
|
31
|
+
export declare const selectorDefaultYAxisTickNumber: 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<{}> & {
|
|
32
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
33
|
+
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
|
|
34
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
35
|
+
}, number, []>;
|
|
26
36
|
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
37
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
38
|
} & Partial<{}> & {
|
|
@@ -8,6 +8,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
10
|
import { getXAxesScales, getYAxesScales } from "./getAxisScale.js";
|
|
11
|
+
import { getDefaultTickNumber } from "../../../ticks.js";
|
|
11
12
|
export const createZoomMap = zoom => {
|
|
12
13
|
const zoomItemMap = new Map();
|
|
13
14
|
zoom.forEach(zoomItem => {
|
|
@@ -27,24 +28,32 @@ export const selectorChartZoomOptionsLookup = createSelector([selectorChartRawXA
|
|
|
27
28
|
export const selectorChartAxisZoomOptionsLookup = createSelector([selectorChartZoomOptionsLookup, (_, axisId) => axisId], (axisLookup, axisId) => axisLookup[axisId]);
|
|
28
29
|
const selectorChartXFilter = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup], (zoomMap, zoomOptions) => zoomMap && zoomOptions && createAxisFilterMapper(zoomMap, zoomOptions, 'x'));
|
|
29
30
|
const selectorChartYFilter = createSelector([selectorChartZoomMap, selectorChartZoomOptionsLookup], (zoomMap, zoomOptions) => zoomMap && zoomOptions && createAxisFilterMapper(zoomMap, zoomOptions, 'y'));
|
|
30
|
-
export const
|
|
31
|
+
export const selectorDefaultXAxisTickNumber = createSelector([selectorChartDrawingArea], function selectorDefaultXAxisTickNumber(drawingArea) {
|
|
32
|
+
return getDefaultTickNumber(drawingArea.width);
|
|
33
|
+
});
|
|
34
|
+
export const selectorDefaultYAxisTickNumber = createSelector([selectorChartDrawingArea], function selectorDefaultYAxisTickNumber(drawingArea) {
|
|
35
|
+
return getDefaultTickNumber(drawingArea.height);
|
|
36
|
+
});
|
|
37
|
+
export const selectorChartXScales = createSelector([selectorChartRawXAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorPreferStrictDomainInLineCharts, selectorDefaultXAxisTickNumber], function selectorChartXScales(axis, drawingArea, formattedSeries, seriesConfig, zoomMap, preferStrictDomainInLineCharts, defaultTickNumber) {
|
|
31
38
|
return getXAxesScales({
|
|
32
39
|
drawingArea,
|
|
33
40
|
formattedSeries,
|
|
34
41
|
axis,
|
|
35
42
|
seriesConfig,
|
|
36
43
|
zoomMap,
|
|
37
|
-
preferStrictDomainInLineCharts
|
|
44
|
+
preferStrictDomainInLineCharts,
|
|
45
|
+
defaultTickNumber
|
|
38
46
|
});
|
|
39
47
|
});
|
|
40
|
-
export const selectorChartYScales = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorPreferStrictDomainInLineCharts], function selectorChartYScales(axis, drawingArea, formattedSeries, seriesConfig, zoomMap, preferStrictDomainInLineCharts) {
|
|
48
|
+
export const selectorChartYScales = createSelector([selectorChartRawYAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomMap, selectorPreferStrictDomainInLineCharts, selectorDefaultYAxisTickNumber], function selectorChartYScales(axis, drawingArea, formattedSeries, seriesConfig, zoomMap, preferStrictDomainInLineCharts, defaultTickNumber) {
|
|
41
49
|
return getYAxesScales({
|
|
42
50
|
drawingArea,
|
|
43
51
|
formattedSeries,
|
|
44
52
|
axis,
|
|
45
53
|
seriesConfig,
|
|
46
54
|
zoomMap,
|
|
47
|
-
preferStrictDomainInLineCharts
|
|
55
|
+
preferStrictDomainInLineCharts,
|
|
56
|
+
defaultTickNumber
|
|
48
57
|
});
|
|
49
58
|
});
|
|
50
59
|
export const selectorChartZoomAxisFilters = createSelector([selectorChartXFilter, selectorChartYFilter, selectorChartRawXAxis, selectorChartRawYAxis, selectorChartXScales, selectorChartYScales], (xMapper, yMapper, xAxis, yAxis, xScales, yScales) => {
|
|
@@ -13,7 +13,7 @@ export declare const selectorChartsHighlightXAxisValue: import("reselect").Selec
|
|
|
13
13
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
14
14
|
} & {
|
|
15
15
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
16
|
-
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}>, {
|
|
16
|
+
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, {
|
|
17
17
|
value: any;
|
|
18
18
|
axisId: import("../../../index.js").AxisId;
|
|
19
19
|
dataIndex: number;
|
|
@@ -26,7 +26,7 @@ export declare const selectorChartsHighlightYAxisValue: import("reselect").Selec
|
|
|
26
26
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
27
27
|
} & {
|
|
28
28
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
29
|
-
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}>, {
|
|
29
|
+
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, {
|
|
30
30
|
value: any;
|
|
31
31
|
axisId: import("../../../index.js").AxisId;
|
|
32
32
|
dataIndex: number;
|
|
@@ -2,6 +2,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { createSelector } from "../../utils/selectors.js";
|
|
3
3
|
import { selectorChartXAxis, selectorChartYAxis } from "./useChartCartesianAxisRendering.selectors.js";
|
|
4
4
|
import { selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue, selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue } from "./useChartCartesianInteraction.selectors.js";
|
|
5
|
+
import { selectorChartsKeyboardXAxisIndex, selectorChartsKeyboardYAxisIndex } from "../useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js";
|
|
6
|
+
import { selectorChartsLastInteraction } from "../useChartInteraction/useChartInteraction.selectors.js";
|
|
5
7
|
const selectorChartControlledCartesianAxisHighlight = state => state.controlledCartesianAxisHighlight;
|
|
6
8
|
const selectAxisHighlight = (computedIndex, axis, axisItems) => {
|
|
7
9
|
if (axisItems !== undefined) {
|
|
@@ -14,22 +16,43 @@ const selectAxisHighlight = (computedIndex, axis, axisItems) => {
|
|
|
14
16
|
};
|
|
15
17
|
export const selectorChartsHighlightXAxisIndex = createSelector([selectorChartsInteractionXAxisIndex, selectorChartXAxis, selectorChartControlledCartesianAxisHighlight], selectAxisHighlight);
|
|
16
18
|
export const selectorChartsHighlightYAxisIndex = createSelector([selectorChartsInteractionYAxisIndex, selectorChartYAxis, selectorChartControlledCartesianAxisHighlight], selectAxisHighlight);
|
|
17
|
-
const selectAxisHighlightWithValue = (computedIndex, computedValue, axis,
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
19
|
+
const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, controlledAxisItems, keyboardAxisItem, lastInteractionUpdate) => {
|
|
20
|
+
if (controlledAxisItems !== undefined) {
|
|
21
|
+
return controlledAxisItems.map(item => _extends({}, item, {
|
|
20
22
|
value: axis.axis[item.axisId]?.data?.[item.dataIndex]
|
|
21
23
|
})).filter(({
|
|
22
24
|
value
|
|
23
25
|
}) => value !== undefined);
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
const pointerHighlight = computedValue !== null && {
|
|
26
28
|
axisId: axis.axisIds[0],
|
|
27
29
|
dataIndex: computedIndex,
|
|
28
30
|
value: computedValue
|
|
29
|
-
}
|
|
31
|
+
};
|
|
32
|
+
const keyboardValue = keyboardAxisItem && axis.axis[keyboardAxisItem.axisId]?.data?.[keyboardAxisItem.dataIndex];
|
|
33
|
+
const keyboardHighlight = keyboardAxisItem && keyboardValue != null && _extends({}, keyboardAxisItem, {
|
|
34
|
+
value: keyboardValue
|
|
35
|
+
});
|
|
36
|
+
if (lastInteractionUpdate === 'pointer') {
|
|
37
|
+
if (pointerHighlight) {
|
|
38
|
+
return [pointerHighlight];
|
|
39
|
+
}
|
|
40
|
+
if (keyboardHighlight) {
|
|
41
|
+
return [keyboardHighlight];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (lastInteractionUpdate === 'keyboard') {
|
|
45
|
+
if (keyboardHighlight) {
|
|
46
|
+
return [keyboardHighlight];
|
|
47
|
+
}
|
|
48
|
+
if (pointerHighlight) {
|
|
49
|
+
return [pointerHighlight];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return [];
|
|
30
53
|
};
|
|
31
|
-
export const selectorChartsHighlightXAxisValue = createSelector([selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue, selectorChartXAxis, selectorChartControlledCartesianAxisHighlight], selectAxisHighlightWithValue);
|
|
32
|
-
export const selectorChartsHighlightYAxisValue = createSelector([selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue, selectorChartYAxis, selectorChartControlledCartesianAxisHighlight], selectAxisHighlightWithValue);
|
|
54
|
+
export const selectorChartsHighlightXAxisValue = createSelector([selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue, selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, selectorChartsKeyboardXAxisIndex, selectorChartsLastInteraction], selectAxisHighlightWithValue);
|
|
55
|
+
export const selectorChartsHighlightYAxisValue = createSelector([selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue, selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, selectorChartsKeyboardYAxisIndex, selectorChartsLastInteraction], selectAxisHighlightWithValue);
|
|
33
56
|
|
|
34
57
|
/**
|
|
35
58
|
* Get the scale of the axis with highlight if controlled. The default axis otherwise.
|
|
@@ -7,10 +7,10 @@ export const useChartInteraction = ({
|
|
|
7
7
|
const cleanInteraction = useEventCallback(function cleanInteraction() {
|
|
8
8
|
store.update(prev => {
|
|
9
9
|
return _extends({}, prev, {
|
|
10
|
-
interaction: {
|
|
10
|
+
interaction: _extends({}, prev.interaction, {
|
|
11
11
|
pointer: null,
|
|
12
12
|
item: null
|
|
13
|
-
}
|
|
13
|
+
})
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -51,7 +51,8 @@ export const useChartInteraction = ({
|
|
|
51
51
|
const setPointerCoordinate = useEventCallback(function setPointerCoordinate(coordinate) {
|
|
52
52
|
store.update(prev => _extends({}, prev, {
|
|
53
53
|
interaction: _extends({}, prev.interaction, {
|
|
54
|
-
pointer: coordinate
|
|
54
|
+
pointer: coordinate,
|
|
55
|
+
lastUpdate: coordinate !== null ? 'pointer' : prev.interaction.lastUpdate
|
|
55
56
|
})
|
|
56
57
|
}));
|
|
57
58
|
});
|
|
@@ -67,7 +68,8 @@ export const useChartInteraction = ({
|
|
|
67
68
|
useChartInteraction.getInitialState = () => ({
|
|
68
69
|
interaction: {
|
|
69
70
|
item: null,
|
|
70
|
-
pointer: null
|
|
71
|
+
pointer: null,
|
|
72
|
+
lastUpdate: 'pointer'
|
|
71
73
|
}
|
|
72
74
|
});
|
|
73
75
|
useChartInteraction.params = {};
|
package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts
CHANGED
|
@@ -27,4 +27,9 @@ export declare const selectorChartsInteractionItemIsDefined: import("reselect").
|
|
|
27
27
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
28
|
} & {
|
|
29
29
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
30
|
-
}, boolean, any[]>;
|
|
30
|
+
}, boolean, any[]>;
|
|
31
|
+
export declare const selectorChartsLastInteraction: 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("./useChartInteraction.types.js").UseChartInteractionState> & {
|
|
32
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
33
|
+
} & {
|
|
34
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
35
|
+
}, import("./useChartInteraction.types.js").InteractionUpdateSource | undefined, any[]>;
|
package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js
CHANGED
|
@@ -5,4 +5,5 @@ export const selectorChartsInteractionItem = createSelector([selectInteraction],
|
|
|
5
5
|
export const selectorChartsInteractionPointer = createSelector([selectInteraction], interaction => interaction?.pointer ?? null);
|
|
6
6
|
export const selectorChartsInteractionPointerX = createSelector([selectorChartsInteractionPointer], pointer => pointer && pointer.x);
|
|
7
7
|
export const selectorChartsInteractionPointerY = createSelector([selectorChartsInteractionPointer], pointer => pointer && pointer.y);
|
|
8
|
-
export const selectorChartsInteractionItemIsDefined = createSelector([selectorChartsInteractionItem], item => item !== null);
|
|
8
|
+
export const selectorChartsInteractionItemIsDefined = createSelector([selectorChartsInteractionItem], item => item !== null);
|
|
9
|
+
export const selectorChartsLastInteraction = createSelector([selectInteraction], interaction => interaction?.lastUpdate);
|
package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type Coordinate = {
|
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
};
|
|
7
|
+
export type InteractionUpdateSource = 'pointer' | 'keyboard';
|
|
7
8
|
export interface UseChartInteractionInstance {
|
|
8
9
|
/**
|
|
9
10
|
* Remove all interaction.
|
|
@@ -35,6 +36,11 @@ export interface UseChartInteractionState {
|
|
|
35
36
|
* The x/y SVG coordinate of the "main" pointer
|
|
36
37
|
*/
|
|
37
38
|
pointer: Coordinate | null;
|
|
39
|
+
/**
|
|
40
|
+
* The last interaction highlight update.
|
|
41
|
+
* Used to decide if highlight should be based on pointer position or keyboard navigation.
|
|
42
|
+
*/
|
|
43
|
+
lastUpdate: InteractionUpdateSource;
|
|
38
44
|
};
|
|
39
45
|
}
|
|
40
46
|
export type UseChartInteractionSignature = ChartPluginSignature<{
|