@mui/x-charts 8.14.1 → 8.15.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.js +8 -0
- package/BarChart/BarChart.plugins.d.ts +2 -1
- package/BarChart/BarChart.plugins.js +2 -1
- package/BarChart/useBarChartProps.js +4 -2
- package/CHANGELOG.md +107 -0
- package/ChartContainer/ChartContainer.js +8 -0
- package/ChartContainer/useChartContainerProps.js +4 -2
- package/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +9 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.js +102 -0
- package/ChartsBrushOverlay/index.d.ts +4 -0
- package/ChartsBrushOverlay/index.js +19 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.js +13 -8
- package/ChartsReferenceLine/ChartsYReferenceLine.js +13 -8
- package/ChartsReferenceLine/common.d.ts +3 -1
- package/ChartsReferenceLine/common.js +3 -1
- package/ChartsTooltip/ChartsTooltipContainer.js +20 -2
- package/ChartsXAxis/getVisibleLabels.js +45 -25
- package/LineChart/LineChart.js +8 -0
- package/LineChart/LineChart.plugins.d.ts +2 -1
- package/LineChart/LineChart.plugins.js +2 -1
- package/LineChart/useLineChartProps.js +4 -2
- package/ScatterChart/ScatterChart.js +8 -0
- package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
- package/ScatterChart/ScatterChart.plugins.js +2 -1
- package/ScatterChart/useScatterChartProps.js +5 -3
- package/SparkLineChart/SparkLineChart.js +8 -0
- package/esm/BarChart/BarChart.js +8 -0
- package/esm/BarChart/BarChart.plugins.d.ts +2 -1
- package/esm/BarChart/BarChart.plugins.js +2 -1
- package/esm/BarChart/useBarChartProps.js +4 -2
- package/esm/ChartContainer/ChartContainer.js +8 -0
- package/esm/ChartContainer/useChartContainerProps.js +4 -2
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +2 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +95 -0
- package/esm/ChartsBrushOverlay/index.d.ts +4 -0
- package/esm/ChartsBrushOverlay/index.js +2 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +14 -9
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +14 -9
- package/esm/ChartsReferenceLine/common.d.ts +3 -1
- package/esm/ChartsReferenceLine/common.js +2 -0
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +20 -2
- package/esm/ChartsXAxis/getVisibleLabels.js +45 -25
- package/esm/LineChart/LineChart.js +8 -0
- package/esm/LineChart/LineChart.plugins.d.ts +2 -1
- package/esm/LineChart/LineChart.plugins.js +2 -1
- package/esm/LineChart/useLineChartProps.js +4 -2
- package/esm/ScatterChart/ScatterChart.js +8 -0
- package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
- package/esm/ScatterChart/ScatterChart.plugins.js +2 -1
- package/esm/ScatterChart/useScatterChartProps.js +5 -3
- package/esm/SparkLineChart/SparkLineChart.js +8 -0
- package/esm/hooks/index.d.ts +2 -1
- package/esm/hooks/index.js +2 -1
- package/esm/hooks/useBrush.d.ts +18 -0
- package/esm/hooks/useBrush.js +16 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/internals/domUtils.d.ts +9 -4
- package/esm/internals/domUtils.js +115 -52
- package/esm/internals/index.d.ts +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/internals/plugins/allPlugins.d.ts +4 -3
- package/esm/internals/plugins/allPlugins.js +2 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +16 -10
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/index.js +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +109 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +75 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +72 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
- package/esm/internals/plugins/utils/selectors.d.ts +1 -1
- package/esm/locales/elGR.js +97 -99
- package/esm/tests/constants.js +1 -0
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +12 -0
- package/hooks/useBrush.d.ts +18 -0
- package/hooks/useBrush.js +21 -0
- package/index.d.ts +2 -1
- package/index.js +13 -1
- package/internals/domUtils.d.ts +9 -4
- package/internals/domUtils.js +119 -54
- package/internals/index.d.ts +1 -0
- package/internals/index.js +12 -0
- package/internals/plugins/allPlugins.d.ts +4 -3
- package/internals/plugins/allPlugins.js +2 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +16 -10
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartBrush/index.js +38 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +117 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +82 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +72 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.js +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
- package/internals/plugins/utils/selectors.d.ts +1 -1
- package/locales/elGR.js +97 -99
- package/package.json +3 -3
- package/tests/constants.js +7 -0
- package/esm/internals/Flatbush.bench.js +0 -42
- package/internals/Flatbush.bench.d.ts +0 -1
- package/internals/Flatbush.bench.js +0 -44
- /package/esm/internals/{Flatbush.bench.d.ts → plugins/featurePlugins/useChartBrush/useChartBrush.types.js} +0 -0
package/esm/internals/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
|
27
27
|
export * from "./plugins/featurePlugins/useChartHighlight/index.js";
|
|
28
28
|
export * from "./plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
29
29
|
export * from "./plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
30
|
+
export * from "./plugins/featurePlugins/useChartBrush/index.js";
|
|
30
31
|
export * from "./plugins/utils/selectors.js";
|
|
31
32
|
export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
|
|
32
33
|
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
|
32
32
|
export * from "./plugins/featurePlugins/useChartHighlight/index.js";
|
|
33
33
|
export * from "./plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
34
34
|
export * from "./plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
35
|
+
export * from "./plugins/featurePlugins/useChartBrush/index.js";
|
|
35
36
|
export * from "./plugins/utils/selectors.js";
|
|
36
37
|
export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
|
|
37
38
|
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
|
@@ -6,6 +6,7 @@ import { UseChartKeyboardNavigationSignature } from "./featurePlugins/useChartKe
|
|
|
6
6
|
import { UseChartPolarAxisSignature } from "./featurePlugins/useChartPolarAxis/index.js";
|
|
7
7
|
import { UseChartClosestPointSignature } from "./featurePlugins/useChartClosestPoint/index.js";
|
|
8
8
|
import { UseChartZAxisSignature } from "./featurePlugins/useChartZAxis/index.js";
|
|
9
|
-
|
|
10
|
-
export type
|
|
11
|
-
export
|
|
9
|
+
import { UseChartBrushSignature } from "./featurePlugins/useChartBrush/index.js";
|
|
10
|
+
export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
11
|
+
export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
12
|
+
export declare const DEFAULT_PLUGINS: readonly [import("./models/index.js").ChartPlugin<UseChartZAxisSignature>, import("./models/index.js").ChartPlugin<UseChartBrushSignature>, import("./models/index.js").ChartPlugin<UseChartCartesianAxisSignature<any>>, import("./models/index.js").ChartPlugin<UseChartInteractionSignature>, import("./models/index.js").ChartPlugin<UseChartHighlightSignature>, import("./models/index.js").ChartPlugin<UseChartClosestPointSignature>, import("./models/index.js").ChartPlugin<UseChartKeyboardNavigationSignature>];
|
|
@@ -6,4 +6,5 @@ import { useChartInteraction } from "./featurePlugins/useChartInteraction/index.
|
|
|
6
6
|
import { useChartKeyboardNavigation } from "./featurePlugins/useChartKeyboardNavigation/index.js";
|
|
7
7
|
import { useChartClosestPoint } from "./featurePlugins/useChartClosestPoint/index.js";
|
|
8
8
|
import { useChartZAxis } from "./featurePlugins/useChartZAxis/index.js";
|
|
9
|
-
|
|
9
|
+
import { useChartBrush } from "./featurePlugins/useChartBrush/index.js";
|
|
10
|
+
export const DEFAULT_PLUGINS = [useChartZAxis, useChartBrush, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartClosestPoint, useChartKeyboardNavigation];
|
package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js
CHANGED
|
@@ -18,14 +18,26 @@ export const useChartInteractionListener = ({
|
|
|
18
18
|
name: 'pan',
|
|
19
19
|
threshold: 0,
|
|
20
20
|
maxPointers: 1
|
|
21
|
+
}), new MoveGesture({
|
|
22
|
+
name: 'move',
|
|
23
|
+
preventIf: ['pan', 'zoomPinch', 'zoomPan']
|
|
24
|
+
}), new TapGesture({
|
|
25
|
+
name: 'tap',
|
|
26
|
+
preventIf: ['pan', 'zoomPinch', 'zoomPan']
|
|
27
|
+
}), new PressGesture({
|
|
28
|
+
name: 'quickPress',
|
|
29
|
+
duration: 50
|
|
21
30
|
}), new PanGesture({
|
|
31
|
+
name: 'brush',
|
|
32
|
+
threshold: 0,
|
|
33
|
+
maxPointers: 1
|
|
34
|
+
}),
|
|
35
|
+
// Zoom gestures
|
|
36
|
+
new PanGesture({
|
|
22
37
|
name: 'zoomPan',
|
|
23
38
|
threshold: 0,
|
|
24
39
|
maxPointers: 1,
|
|
25
40
|
preventIf: ['zoomTapAndDrag', 'zoomPressAndDrag']
|
|
26
|
-
}), new MoveGesture({
|
|
27
|
-
name: 'move',
|
|
28
|
-
preventIf: ['pan', 'zoomPinch', 'zoomPan'] // Prevent move gesture when pan is active
|
|
29
41
|
}), new PinchGesture({
|
|
30
42
|
name: 'zoomPinch',
|
|
31
43
|
threshold: 5,
|
|
@@ -34,12 +46,6 @@ export const useChartInteractionListener = ({
|
|
|
34
46
|
name: 'zoomTurnWheel',
|
|
35
47
|
sensitivity: 0.01,
|
|
36
48
|
initialDelta: 1
|
|
37
|
-
}), new TapGesture({
|
|
38
|
-
name: 'tap',
|
|
39
|
-
preventIf: ['pan', 'zoomPan', 'zoomPinch']
|
|
40
|
-
}), new PressGesture({
|
|
41
|
-
name: 'quickPress',
|
|
42
|
-
duration: 50
|
|
43
49
|
}), new TapAndDragGesture({
|
|
44
50
|
name: 'zoomTapAndDrag',
|
|
45
51
|
dragThreshold: 10
|
|
@@ -56,7 +62,7 @@ export const useChartInteractionListener = ({
|
|
|
56
62
|
if (!svg || !gestureManager) {
|
|
57
63
|
return undefined;
|
|
58
64
|
}
|
|
59
|
-
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag'], svg);
|
|
65
|
+
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag', 'brush'], svg);
|
|
60
66
|
return () => {
|
|
61
67
|
// Cleanup gesture manager
|
|
62
68
|
gestureManager.unregisterAllGestures(svg);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type PressAndDragEvent, type PressAndDragGestureOptions, 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' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd';
|
|
3
|
+
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd';
|
|
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' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
8
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
9
9
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd', callback: (event: PinchEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
10
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;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
|
+
import { getSVGPoint } from "../../../getSVGPoint.js";
|
|
8
|
+
export const useChartBrush = ({
|
|
9
|
+
store,
|
|
10
|
+
svgRef,
|
|
11
|
+
instance,
|
|
12
|
+
params
|
|
13
|
+
}) => {
|
|
14
|
+
useEnhancedEffect(() => {
|
|
15
|
+
store.update(prev => {
|
|
16
|
+
return _extends({}, prev, {
|
|
17
|
+
brush: _extends({}, prev.brush, {
|
|
18
|
+
enabled: params.brushConfig.enabled,
|
|
19
|
+
preventTooltip: params.brushConfig.preventTooltip,
|
|
20
|
+
preventHighlight: params.brushConfig.preventHighlight
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}, [store, params.brushConfig.enabled, params.brushConfig.preventTooltip, params.brushConfig.preventHighlight]);
|
|
25
|
+
const setBrushCoordinates = useEventCallback(function setBrushCoordinates(point) {
|
|
26
|
+
store.update(prev => {
|
|
27
|
+
return _extends({}, prev, {
|
|
28
|
+
brush: _extends({}, prev.brush, {
|
|
29
|
+
start: prev.brush.start ?? point,
|
|
30
|
+
current: point
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
const clearBrush = useEventCallback(function clearBrush() {
|
|
36
|
+
store.update(prev => {
|
|
37
|
+
return _extends({}, prev, {
|
|
38
|
+
brush: _extends({}, prev.brush, {
|
|
39
|
+
start: null,
|
|
40
|
+
current: null
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
const element = svgRef.current;
|
|
47
|
+
if (element === null || !store.getSnapshot().brush.enabled) {
|
|
48
|
+
return () => {};
|
|
49
|
+
}
|
|
50
|
+
const handleBrushStart = event => {
|
|
51
|
+
if (event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const point = getSVGPoint(element, {
|
|
55
|
+
clientX: event.detail.initialCentroid.x,
|
|
56
|
+
clientY: event.detail.initialCentroid.y
|
|
57
|
+
});
|
|
58
|
+
setBrushCoordinates(point);
|
|
59
|
+
};
|
|
60
|
+
const handleBrush = event => {
|
|
61
|
+
const currentPoint = getSVGPoint(element, {
|
|
62
|
+
clientX: event.detail.centroid.x,
|
|
63
|
+
clientY: event.detail.centroid.y
|
|
64
|
+
});
|
|
65
|
+
setBrushCoordinates(currentPoint);
|
|
66
|
+
};
|
|
67
|
+
const brushStartHandler = instance.addInteractionListener('brushStart', handleBrushStart);
|
|
68
|
+
const brushHandler = instance.addInteractionListener('brush', handleBrush);
|
|
69
|
+
const brushCancelHandler = instance.addInteractionListener('brushCancel', clearBrush);
|
|
70
|
+
const brushEndHandler = instance.addInteractionListener('brushEnd', clearBrush);
|
|
71
|
+
return () => {
|
|
72
|
+
brushStartHandler.cleanup();
|
|
73
|
+
brushHandler.cleanup();
|
|
74
|
+
brushEndHandler.cleanup();
|
|
75
|
+
brushCancelHandler.cleanup();
|
|
76
|
+
};
|
|
77
|
+
}, [svgRef, instance, store, clearBrush, setBrushCoordinates]);
|
|
78
|
+
return {
|
|
79
|
+
instance: {
|
|
80
|
+
setBrushCoordinates,
|
|
81
|
+
clearBrush
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
useChartBrush.params = {
|
|
86
|
+
brushConfig: true
|
|
87
|
+
};
|
|
88
|
+
useChartBrush.getDefaultizedParams = ({
|
|
89
|
+
params
|
|
90
|
+
}) => {
|
|
91
|
+
return _extends({}, params, {
|
|
92
|
+
brushConfig: {
|
|
93
|
+
enabled: params?.brushConfig?.enabled ?? false,
|
|
94
|
+
preventTooltip: params?.brushConfig?.preventTooltip ?? true,
|
|
95
|
+
preventHighlight: params?.brushConfig?.preventHighlight ?? true
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
useChartBrush.getInitialState = params => {
|
|
100
|
+
return {
|
|
101
|
+
brush: {
|
|
102
|
+
enabled: params.brushConfig.enabled,
|
|
103
|
+
preventTooltip: params.brushConfig.preventTooltip,
|
|
104
|
+
preventHighlight: params.brushConfig.preventHighlight,
|
|
105
|
+
start: null,
|
|
106
|
+
current: null
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ChartOptionalRootSelector } from "../../utils/selectors.js";
|
|
2
|
+
import type { UseChartBrushSignature } from "./useChartBrush.types.js";
|
|
3
|
+
export declare const selectorBrush: ChartOptionalRootSelector<UseChartBrushSignature>;
|
|
4
|
+
export declare const selectorBrushStart: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
5
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
6
|
+
} & {
|
|
7
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
8
|
+
}, import("./useChartBrush.types.js").Point | null | undefined, any[]>;
|
|
9
|
+
export declare const selectorBrushCurrent: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
10
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
11
|
+
} & {
|
|
12
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
13
|
+
}, import("./useChartBrush.types.js").Point | null | undefined, any[]>;
|
|
14
|
+
export declare const selectorBrushStartX: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
15
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
16
|
+
} & {
|
|
17
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
18
|
+
}, number | null, any[]>;
|
|
19
|
+
export declare const selectorBrushStartY: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
20
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
21
|
+
} & {
|
|
22
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
23
|
+
}, number | null, any[]>;
|
|
24
|
+
export declare const selectorBrushCurrentX: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
25
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
26
|
+
} & {
|
|
27
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
|
+
}, number | null, any[]>;
|
|
29
|
+
export declare const selectorBrushCurrentY: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
30
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
31
|
+
} & {
|
|
32
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
33
|
+
}, number | null, any[]>;
|
|
34
|
+
export declare const selectorBrushState: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
35
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
36
|
+
} & {
|
|
37
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
38
|
+
}, {
|
|
39
|
+
start: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
current: {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
};
|
|
47
|
+
} | null, any[]>;
|
|
48
|
+
export declare const selectorBrushConfigNoZoom: 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<{}> & {
|
|
49
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
50
|
+
} & {
|
|
51
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
52
|
+
}, "x" | "y" | "xy", any[]>;
|
|
53
|
+
export declare const selectorBrushConfigZoom: 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/index.js").UseChartCartesianAxisState> & {
|
|
54
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
55
|
+
} & {
|
|
56
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
57
|
+
}, "x" | "y" | "xy" | null, []>;
|
|
58
|
+
export declare const selectorBrushConfig: 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<{}> & {
|
|
59
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
60
|
+
} & {
|
|
61
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
62
|
+
} & Partial<import("../useChartCartesianAxis/index.js").UseChartCartesianAxisState>, "x" | "y" | "xy", any[]>;
|
|
63
|
+
export declare const selectorIsBrushEnabled: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
64
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
65
|
+
} & {
|
|
66
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
67
|
+
}, boolean | undefined, any[]>;
|
|
68
|
+
export declare const selectorIsBrushSelectionActive: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
69
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
70
|
+
} & {
|
|
71
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
72
|
+
}, boolean | undefined, any[]>;
|
|
73
|
+
export declare const selectorBrushShouldPreventAxisHighlight: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
74
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
75
|
+
} & {
|
|
76
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
77
|
+
}, boolean | undefined, any[]>;
|
|
78
|
+
export declare const selectorBrushShouldPreventTooltip: 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("./useChartBrush.types.js").UseChartBrushState> & {
|
|
79
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
80
|
+
} & {
|
|
81
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
82
|
+
}, boolean | undefined, any[]>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createSelector } from "../../utils/selectors.js";
|
|
2
|
+
import { selectorChartZoomOptionsLookup } from "../useChartCartesianAxis/index.js";
|
|
3
|
+
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
export const selectorBrush = state => state.brush;
|
|
5
|
+
export const selectorBrushStart = createSelector([selectorBrush], brush => brush?.start);
|
|
6
|
+
export const selectorBrushCurrent = createSelector([selectorBrush], brush => brush?.current);
|
|
7
|
+
export const selectorBrushStartX = createSelector([selectorBrush], brush => brush?.start?.x ?? null);
|
|
8
|
+
export const selectorBrushStartY = createSelector([selectorBrush], brush => brush?.start?.y ?? null);
|
|
9
|
+
export const selectorBrushCurrentX = createSelector([selectorBrush], brush => brush?.current?.x ?? null);
|
|
10
|
+
export const selectorBrushCurrentY = createSelector([selectorBrush], brush => brush?.current?.y ?? null);
|
|
11
|
+
export const selectorBrushState = createSelector([selectorBrushStartX, selectorBrushStartY, selectorBrushCurrentX, selectorBrushCurrentY], (startX, startY, currentX, currentY) => {
|
|
12
|
+
if (startX === null || startY === null || currentX === null || currentY === null) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
start: {
|
|
17
|
+
x: startX,
|
|
18
|
+
y: startY
|
|
19
|
+
},
|
|
20
|
+
current: {
|
|
21
|
+
x: currentX,
|
|
22
|
+
y: currentY
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
export const selectorBrushConfigNoZoom = createSelector([selectorChartSeriesProcessed], series => {
|
|
27
|
+
let hasHorizontal = false;
|
|
28
|
+
let isBothDirections = false;
|
|
29
|
+
if (series) {
|
|
30
|
+
Object.entries(series).forEach(([seriesType, seriesData]) => {
|
|
31
|
+
if (Object.values(seriesData.series).some(s => s.layout === 'horizontal')) {
|
|
32
|
+
hasHorizontal = true;
|
|
33
|
+
}
|
|
34
|
+
if (seriesType === 'scatter' && seriesData.seriesOrder.length > 0) {
|
|
35
|
+
isBothDirections = true;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (isBothDirections) {
|
|
40
|
+
return 'xy';
|
|
41
|
+
}
|
|
42
|
+
if (hasHorizontal) {
|
|
43
|
+
return 'y';
|
|
44
|
+
}
|
|
45
|
+
return 'x';
|
|
46
|
+
});
|
|
47
|
+
export const selectorBrushConfigZoom = createSelector([selectorChartZoomOptionsLookup], optionsLookup => {
|
|
48
|
+
let hasX = false;
|
|
49
|
+
let hasY = false;
|
|
50
|
+
Object.values(optionsLookup).forEach(options => {
|
|
51
|
+
if (options.axisDirection === 'y') {
|
|
52
|
+
hasY = true;
|
|
53
|
+
}
|
|
54
|
+
if (options.axisDirection === 'x') {
|
|
55
|
+
hasX = true;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (hasX && hasY) {
|
|
59
|
+
return 'xy';
|
|
60
|
+
}
|
|
61
|
+
if (hasY) {
|
|
62
|
+
return 'y';
|
|
63
|
+
}
|
|
64
|
+
if (hasX) {
|
|
65
|
+
return 'x';
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
});
|
|
69
|
+
export const selectorBrushConfig = createSelector([selectorBrushConfigNoZoom, selectorBrushConfigZoom], (configNoZoom, configZoom) => configZoom ?? configNoZoom);
|
|
70
|
+
export const selectorIsBrushEnabled = createSelector([selectorBrush], brush => brush?.enabled);
|
|
71
|
+
export const selectorIsBrushSelectionActive = createSelector([selectorBrush], brush => {
|
|
72
|
+
return brush?.enabled && brush?.start !== null && brush?.current !== null;
|
|
73
|
+
});
|
|
74
|
+
export const selectorBrushShouldPreventAxisHighlight = createSelector([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventHighlight);
|
|
75
|
+
export const selectorBrushShouldPreventTooltip = createSelector([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventTooltip);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ChartPluginSignature } from "../../models/index.js";
|
|
2
|
+
export type Point = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
};
|
|
6
|
+
export interface UseChartBrushState {
|
|
7
|
+
brush: {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the brush interaction is enabled.
|
|
10
|
+
*/
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether to prevent tooltip from showing during brush interaction.
|
|
14
|
+
*/
|
|
15
|
+
preventTooltip: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to prevent highlighting during brush interaction.
|
|
18
|
+
*/
|
|
19
|
+
preventHighlight: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The starting coordinate of the brush interaction.
|
|
22
|
+
*/
|
|
23
|
+
start: Point | null;
|
|
24
|
+
/**
|
|
25
|
+
* The current coordinate of the brush interaction.
|
|
26
|
+
*/
|
|
27
|
+
current: Point | null;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface UseChartBrushInstance {
|
|
31
|
+
/**
|
|
32
|
+
* Set the brush coordinates.
|
|
33
|
+
* @param {Point | null} point The point coordinate, if start value is null, it will set both start and current to this value.
|
|
34
|
+
*/
|
|
35
|
+
setBrushCoordinates: (point: Point | null) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Clear the brush coordinates.
|
|
38
|
+
*/
|
|
39
|
+
clearBrush: () => void;
|
|
40
|
+
}
|
|
41
|
+
export interface BrushConfig {
|
|
42
|
+
/**
|
|
43
|
+
* Whether the brush interaction is enabled.
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to prevent tooltip from showing during brush interaction.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
preventTooltip?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to prevent highlighting during brush interaction.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
preventHighlight?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface UseChartBrushParameters {
|
|
59
|
+
/**
|
|
60
|
+
* Configuration for the brush interaction.
|
|
61
|
+
*/
|
|
62
|
+
brushConfig?: BrushConfig;
|
|
63
|
+
}
|
|
64
|
+
export type UseChartBrushDefaultizedParameters = {
|
|
65
|
+
brushConfig: Required<BrushConfig>;
|
|
66
|
+
};
|
|
67
|
+
export type UseChartBrushSignature = ChartPluginSignature<{
|
|
68
|
+
params: UseChartBrushParameters;
|
|
69
|
+
defaultizedParams: UseChartBrushDefaultizedParameters;
|
|
70
|
+
state: UseChartBrushState;
|
|
71
|
+
instance: UseChartBrushInstance;
|
|
72
|
+
}>;
|
|
@@ -3,9 +3,10 @@ export const createZoomLookup = axisDirection => (axes = []) => axes.reduce((acc
|
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
const {
|
|
5
5
|
zoom,
|
|
6
|
-
id: axisId
|
|
6
|
+
id: axisId,
|
|
7
|
+
reverse
|
|
7
8
|
} = v;
|
|
8
|
-
const defaultizedZoom = defaultizeZoom(zoom, axisId, axisDirection);
|
|
9
|
+
const defaultizedZoom = defaultizeZoom(zoom, axisId, axisDirection, reverse);
|
|
9
10
|
if (defaultizedZoom) {
|
|
10
11
|
acc[axisId] = defaultizedZoom;
|
|
11
12
|
}
|
|
@@ -25,7 +25,7 @@ export function defaultizeXAxis(inAxes, dataset) {
|
|
|
25
25
|
id,
|
|
26
26
|
position,
|
|
27
27
|
height: axisConfig.height ?? defaultHeight,
|
|
28
|
-
zoom: defaultizeZoom(axisConfig.zoom, id, 'x')
|
|
28
|
+
zoom: defaultizeZoom(axisConfig.zoom, id, 'x', axisConfig.reverse)
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
// Increment the offset for the next axis
|
|
@@ -75,7 +75,7 @@ export function defaultizeYAxis(inAxes, dataset) {
|
|
|
75
75
|
id,
|
|
76
76
|
position,
|
|
77
77
|
width: axisConfig.width ?? defaultWidth,
|
|
78
|
-
zoom: defaultizeZoom(axisConfig.zoom, id, 'y')
|
|
78
|
+
zoom: defaultizeZoom(axisConfig.zoom, id, 'y', axisConfig.reverse)
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
// Increment the offset for the next axis
|
|
@@ -9,6 +9,7 @@ export declare const defaultZoomOptions: {
|
|
|
9
9
|
maxSpan: number;
|
|
10
10
|
panning: true;
|
|
11
11
|
filterMode: "keep";
|
|
12
|
+
reverse: false;
|
|
12
13
|
slider: {
|
|
13
14
|
enabled: false;
|
|
14
15
|
preview: false;
|
|
@@ -16,4 +17,4 @@ export declare const defaultZoomOptions: {
|
|
|
16
17
|
showTooltip: import("./zoom.types.js").ZoomSliderShowTooltip;
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
|
-
export declare const defaultizeZoom: (zoom: boolean | ZoomOptions | undefined, axisId: AxisId, axisDirection: "x" | "y") => DefaultizedZoomOptions | undefined;
|
|
20
|
+
export declare const defaultizeZoom: (zoom: boolean | ZoomOptions | undefined, axisId: AxisId, axisDirection: "x" | "y", reverse?: boolean) => DefaultizedZoomOptions | undefined;
|
|
@@ -8,6 +8,7 @@ export const defaultZoomOptions = {
|
|
|
8
8
|
maxSpan: 100,
|
|
9
9
|
panning: true,
|
|
10
10
|
filterMode: 'keep',
|
|
11
|
+
reverse: false,
|
|
11
12
|
slider: {
|
|
12
13
|
enabled: false,
|
|
13
14
|
preview: false,
|
|
@@ -15,7 +16,7 @@ export const defaultZoomOptions = {
|
|
|
15
16
|
showTooltip: DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP
|
|
16
17
|
}
|
|
17
18
|
};
|
|
18
|
-
export const defaultizeZoom = (zoom, axisId, axisDirection) => {
|
|
19
|
+
export const defaultizeZoom = (zoom, axisId, axisDirection, reverse) => {
|
|
19
20
|
if (!zoom) {
|
|
20
21
|
return undefined;
|
|
21
22
|
}
|
|
@@ -23,12 +24,16 @@ export const defaultizeZoom = (zoom, axisId, axisDirection) => {
|
|
|
23
24
|
return _extends({
|
|
24
25
|
axisId,
|
|
25
26
|
axisDirection
|
|
26
|
-
}, defaultZoomOptions
|
|
27
|
+
}, defaultZoomOptions, {
|
|
28
|
+
reverse: reverse ?? false
|
|
29
|
+
});
|
|
27
30
|
}
|
|
28
31
|
return _extends({
|
|
29
32
|
axisId,
|
|
30
33
|
axisDirection
|
|
31
|
-
}, defaultZoomOptions,
|
|
34
|
+
}, defaultZoomOptions, {
|
|
35
|
+
reverse: reverse ?? false
|
|
36
|
+
}, zoom, {
|
|
32
37
|
slider: _extends({}, defaultZoomOptions.slider, {
|
|
33
38
|
size: zoom.slider?.preview ?? defaultZoomOptions.slider.preview ? DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE : DEFAULT_ZOOM_SLIDER_SIZE
|
|
34
39
|
}, zoom.slider)
|
package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { UseChartSeriesSignature } from "../../corePlugins/useChartSeries/i
|
|
|
5
5
|
import type { ZoomData, ZoomOptions, ZoomSliderShowTooltip } from "./zoom.types.js";
|
|
6
6
|
import type { UseChartInteractionSignature } from "../useChartInteraction/index.js";
|
|
7
7
|
import type { ChartsAxisProps } from "../../../../ChartsAxis/index.js";
|
|
8
|
+
import type { UseChartBrushSignature } from "../useChartBrush/index.js";
|
|
8
9
|
/**
|
|
9
10
|
* The axes' configuration after computing.
|
|
10
11
|
* An axis in this state already contains a scale function and all the necessary properties to be rendered.
|
|
@@ -67,6 +68,7 @@ export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slid
|
|
|
67
68
|
axisId: AxisId;
|
|
68
69
|
axisDirection: 'x' | 'y';
|
|
69
70
|
slider: DefaultedZoomSliderOptions;
|
|
71
|
+
reverse: boolean;
|
|
70
72
|
}
|
|
71
73
|
export interface UseChartCartesianAxisState {
|
|
72
74
|
/**
|
|
@@ -94,5 +96,5 @@ export type UseChartCartesianAxisSignature<SeriesType extends ChartSeriesType =
|
|
|
94
96
|
defaultizedParams: UseChartCartesianAxisDefaultizedParameters;
|
|
95
97
|
state: UseChartCartesianAxisState;
|
|
96
98
|
dependencies: [UseChartSeriesSignature<SeriesType>];
|
|
97
|
-
optionalDependencies: [UseChartInteractionSignature];
|
|
99
|
+
optionalDependencies: [UseChartInteractionSignature, UseChartBrushSignature];
|
|
98
100
|
}>;
|
|
@@ -3,17 +3,17 @@ export declare const selectorChartsHighlightXAxisIndex: import("reselect").Selec
|
|
|
3
3
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
4
4
|
} & {
|
|
5
5
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
6
|
-
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
|
|
6
|
+
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
|
|
7
7
|
export declare const selectorChartsHighlightYAxisIndex: 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/useChartInteraction.types.js").UseChartInteractionState> & {
|
|
8
8
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
9
9
|
} & {
|
|
10
10
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
11
|
-
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
|
|
11
|
+
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
|
|
12
12
|
export declare const selectorChartsHighlightXAxisValue: 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/useChartInteraction.types.js").UseChartInteractionState> & {
|
|
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<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, {
|
|
16
|
+
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, {
|
|
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<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, {
|
|
29
|
+
} & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, {
|
|
30
30
|
value: any;
|
|
31
31
|
axisId: import("../../../index.js").AxisId;
|
|
32
32
|
dataIndex: number;
|