@mui/x-charts 8.18.0 → 8.19.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/seriesConfig/bar/seriesProcessor.js +15 -9
- package/CHANGELOG.md +113 -0
- package/ChartsSurface/ChartsSurface.js +5 -2
- package/LineChart/seriesConfig/seriesProcessor.js +15 -10
- package/PieChart/PieArcPlot.js +5 -3
- package/esm/BarChart/seriesConfig/bar/seriesProcessor.js +15 -9
- package/esm/ChartsSurface/ChartsSurface.js +5 -2
- package/esm/LineChart/seriesConfig/seriesProcessor.js +15 -10
- package/esm/PieChart/PieArcPlot.js +5 -3
- package/esm/hooks/useBarSeries.js +3 -5
- package/esm/hooks/useLineSeries.js +3 -5
- package/esm/hooks/usePieSeries.js +3 -5
- package/esm/hooks/useRadarSeries.js +3 -5
- package/esm/hooks/useScatterSeries.js +3 -5
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/internals/domUtils.js +30 -14
- package/esm/internals/getScale.d.ts +2 -1
- package/esm/internals/index.d.ts +1 -1
- package/esm/internals/index.js +1 -1
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.js +2 -2
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +5 -6
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +2 -2
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +2 -2
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +4 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +3 -1
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +4 -4
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +15 -15
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +5 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +11 -11
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +5 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +7 -8
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +11 -12
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +8 -8
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +4 -4
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +11 -11
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +6 -6
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +7 -8
- package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.js +2 -2
- package/esm/internals/plugins/utils/selectors.d.ts +1 -14
- package/esm/internals/plugins/utils/selectors.js +1 -5
- package/esm/internals/seriesSelectorOfType.d.ts +20 -0
- package/esm/internals/seriesSelectorOfType.js +38 -0
- package/esm/models/seriesType/config.d.ts +2 -2
- package/esm/utils/index.d.ts +4 -0
- package/esm/utils/index.js +5 -0
- package/esm/utils/niceDomain.d.ts +20 -0
- package/esm/utils/niceDomain.js +24 -0
- package/hooks/useBarSeries.js +3 -6
- package/hooks/useLineSeries.js +3 -6
- package/hooks/usePieSeries.js +3 -6
- package/hooks/useRadarSeries.js +3 -6
- package/hooks/useScatterSeries.js +3 -6
- package/index.d.ts +2 -1
- package/index.js +13 -1
- package/internals/domUtils.js +30 -14
- package/internals/getScale.d.ts +2 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +4 -4
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.js +2 -2
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js +4 -5
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +2 -2
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.js +2 -2
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +4 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +3 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +4 -4
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +15 -15
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +5 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +11 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +4 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +6 -7
- package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +2 -2
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +2 -2
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -11
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +8 -8
- package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +4 -4
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +11 -11
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js +6 -6
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js +6 -7
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.js +2 -2
- package/internals/plugins/utils/selectors.d.ts +1 -14
- package/internals/plugins/utils/selectors.js +1 -8
- package/internals/seriesSelectorOfType.d.ts +20 -0
- package/internals/seriesSelectorOfType.js +46 -0
- package/models/seriesType/config.d.ts +2 -2
- package/package.json +4 -4
- package/utils/index.d.ts +4 -0
- package/utils/index.js +16 -0
- package/utils/niceDomain.d.ts +20 -0
- package/utils/niceDomain.js +29 -0
- package/esm/internals/createSeriesSelectorOfType.d.ts +0 -4
- package/esm/internals/createSeriesSelectorOfType.js +0 -45
- package/internals/createSeriesSelectorOfType.d.ts +0 -4
- package/internals/createSeriesSelectorOfType.js +0 -53
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
const selectorChartAnimationState = state => state.animation;
|
|
3
|
-
export const selectorChartSkipAnimation = createSelector(
|
|
3
|
+
export const selectorChartSkipAnimation = createSelector(selectorChartAnimationState, state => state.skip || state.skipAnimationRequests > 0);
|
package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { createSelectorMemoized } from '@mui/x-internals/store';
|
|
2
|
-
import { createSelector } from "../../utils/selectors.js";
|
|
1
|
+
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
3
2
|
import { selectorChartAxisSizes } from "../../featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js";
|
|
4
3
|
export const selectorChartDimensionsState = state => state.dimensions;
|
|
5
4
|
export const selectorChartMargin = state => state.dimensions.margin;
|
|
@@ -26,7 +25,7 @@ export const selectorChartDrawingArea = createSelectorMemoized(selectorChartDime
|
|
|
26
25
|
bottom: marginBottom + axisSizeBottom
|
|
27
26
|
};
|
|
28
27
|
});
|
|
29
|
-
export const selectorChartSvgWidth = createSelector(
|
|
30
|
-
export const selectorChartSvgHeight = createSelector(
|
|
31
|
-
export const selectorChartPropsWidth = createSelector(
|
|
32
|
-
export const selectorChartPropsHeight = createSelector(
|
|
28
|
+
export const selectorChartSvgWidth = createSelector(selectorChartDimensionsState, dimensionsState => dimensionsState.width);
|
|
29
|
+
export const selectorChartSvgHeight = createSelector(selectorChartDimensionsState, dimensionsState => dimensionsState.height);
|
|
30
|
+
export const selectorChartPropsWidth = createSelector(selectorChartDimensionsState, dimensionsState => dimensionsState.propsWidth);
|
|
31
|
+
export const selectorChartPropsHeight = createSelector(selectorChartDimensionsState, dimensionsState => dimensionsState.propsHeight);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
export const selectorChartExperimentalFeaturesState = state => state.experimentalFeatures;
|
|
3
|
-
export const selectorPreferStrictDomainInLineCharts = createSelector(
|
|
3
|
+
export const selectorPreferStrictDomainInLineCharts = createSelector(selectorChartExperimentalFeaturesState, features => Boolean(features?.preferStrictDomainInLineCharts));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
const selectorChartIdState = state => state.id;
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,4 +6,4 @@ const selectorChartIdState = state => state.id;
|
|
|
6
6
|
* @param {ChartState<[UseChartIdSignature]>} state The state of the chart.
|
|
7
7
|
* @returns {string} The id attribute of the chart.
|
|
8
8
|
*/
|
|
9
|
-
export const selectorChartId = createSelector(
|
|
9
|
+
export const selectorChartId = createSelector(selectorChartIdState, idState => idState.chartId);
|
package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js
CHANGED
|
@@ -44,6 +44,9 @@ export const useChartInteractionListener = ({
|
|
|
44
44
|
name: 'zoomTurnWheel',
|
|
45
45
|
sensitivity: 0.01,
|
|
46
46
|
initialDelta: 1
|
|
47
|
+
}), new TurnWheelGesture({
|
|
48
|
+
name: 'panTurnWheel',
|
|
49
|
+
sensitivity: 0.5
|
|
47
50
|
}), new TapAndDragGesture({
|
|
48
51
|
name: 'zoomTapAndDrag',
|
|
49
52
|
dragThreshold: 10
|
|
@@ -63,7 +66,7 @@ export const useChartInteractionListener = ({
|
|
|
63
66
|
if (!svg || !gestureManager) {
|
|
64
67
|
return undefined;
|
|
65
68
|
}
|
|
66
|
-
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag', 'zoomDoubleTapReset', 'brush'], svg);
|
|
69
|
+
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'panTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag', 'zoomDoubleTapReset', 'brush'], svg);
|
|
67
70
|
return () => {
|
|
68
71
|
// Cleanup gesture manager
|
|
69
72
|
gestureManager.unregisterAllGestures(svg);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type PressAndDragEvent, type PressAndDragGestureOptions, type TapAndDragEvent, type TapAndDragGestureOptions, type TapGestureOptions, 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' | 'zoomDoubleTapReset' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd';
|
|
3
|
+
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'panTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd' | 'zoomDoubleTapReset' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd';
|
|
4
4
|
export type InteractionListenerResult = {
|
|
5
5
|
cleanup: () => void;
|
|
6
6
|
};
|
|
@@ -8,6 +8,7 @@ export type AddInteractionListener = {
|
|
|
8
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
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'panTurnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
11
12
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'move' | 'moveStart' | 'moveEnd', callback: (event: MoveEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
12
13
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'tap' | 'zoomDoubleTapReset', callback: (event: TapEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
13
14
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'quickPress' | 'quickPressEnd', callback: (event: PressEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
@@ -18,6 +19,7 @@ export type UpdateZoomInteractionListeners = {
|
|
|
18
19
|
(interaction: 'zoomPan', options?: Omit<PanGestureOptions<'zoomPan'>, 'name'>): void;
|
|
19
20
|
(interaction: 'zoomPinch', options?: Omit<PinchGestureOptions<'zoomPinch'>, 'name'>): void;
|
|
20
21
|
(interaction: 'zoomTurnWheel', options?: Omit<TurnWheelGestureOptions<'zoomTurnWheel'>, 'name'>): void;
|
|
22
|
+
(interaction: 'panTurnWheel', options?: Omit<TurnWheelGestureOptions<'panTurnWheel'>, 'name'>): void;
|
|
21
23
|
(interaction: 'zoomTapAndDrag', options?: Omit<TapAndDragGestureOptions<'zoomTapAndDrag'>, 'name'>): void;
|
|
22
24
|
(interaction: 'zoomPressAndDrag', options?: Omit<PressAndDragGestureOptions<'zoomPressAndDrag'>, 'name'>): void;
|
|
23
25
|
(interaction: 'zoomDoubleTapReset', options?: Omit<TapGestureOptions<'zoomDoubleTapReset'>, 'name'>): void;
|
|
@@ -14,4 +14,4 @@ export declare const selectorChartSeriesConfig: (args_0: import("../useChartId/u
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const selectorChartDataset: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
16
16
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
17
|
-
}) => readonly import("../../../index.js").DatasetElementType<
|
|
17
|
+
}) => readonly import("../../../index.js").DatasetElementType<unknown>[] | undefined;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
export const selectorChartSeriesState = state => state.series;
|
|
3
|
-
export const selectorChartSeriesProcessed = createSelector(
|
|
4
|
-
export const selectorChartSeriesConfig = createSelector(
|
|
3
|
+
export const selectorChartSeriesProcessed = createSelector(selectorChartSeriesState, seriesState => seriesState.processedSeries);
|
|
4
|
+
export const selectorChartSeriesConfig = createSelector(selectorChartSeriesState, seriesState => seriesState.seriesConfig);
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Get the dataset from the series state.
|
|
8
8
|
* @param {ChartState<[UseChartSeriesSignature]>} state The state of the chart.
|
|
9
9
|
* @returns {DatasetType | undefined} The dataset.
|
|
10
10
|
*/
|
|
11
|
-
export const selectorChartDataset = createSelector(
|
|
11
|
+
export const selectorChartDataset = createSelector(selectorChartSeriesState, seriesState => seriesState.dataset);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChartOptionalRootSelector } from "../../utils/selectors.js";
|
|
2
2
|
import type { UseChartBrushSignature } from "./useChartBrush.types.js";
|
|
3
3
|
export declare const selectorBrush: ChartOptionalRootSelector<UseChartBrushSignature>;
|
|
4
4
|
export declare const selectorBrushStart: (args_0: 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> & {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
import { selectorChartZoomOptionsLookup } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
|
|
3
3
|
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
4
4
|
export const selectorBrush = state => state.brush;
|
|
5
|
-
export const selectorBrushStart = createSelector(
|
|
6
|
-
export const selectorBrushCurrent = createSelector(
|
|
7
|
-
export const selectorBrushStartX = createSelector(
|
|
8
|
-
export const selectorBrushStartY = createSelector(
|
|
9
|
-
export const selectorBrushCurrentX = createSelector(
|
|
10
|
-
export const selectorBrushCurrentY = createSelector(
|
|
11
|
-
export const selectorBrushState = createSelector(
|
|
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
12
|
if (startX === null || startY === null || currentX === null || currentY === null) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
@@ -23,7 +23,7 @@ export const selectorBrushState = createSelector([selectorBrushStartX, selectorB
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
});
|
|
26
|
-
export const selectorBrushConfigNoZoom = createSelector(
|
|
26
|
+
export const selectorBrushConfigNoZoom = createSelector(selectorChartSeriesProcessed, series => {
|
|
27
27
|
let hasHorizontal = false;
|
|
28
28
|
let isBothDirections = false;
|
|
29
29
|
if (series) {
|
|
@@ -44,7 +44,7 @@ export const selectorBrushConfigNoZoom = createSelector([selectorChartSeriesProc
|
|
|
44
44
|
}
|
|
45
45
|
return 'x';
|
|
46
46
|
});
|
|
47
|
-
export const selectorBrushConfigZoom = createSelector(
|
|
47
|
+
export const selectorBrushConfigZoom = createSelector(selectorChartZoomOptionsLookup, function selectorBrushConfigZoom(optionsLookup) {
|
|
48
48
|
let hasX = false;
|
|
49
49
|
let hasY = false;
|
|
50
50
|
Object.values(optionsLookup).forEach(options => {
|
|
@@ -66,10 +66,10 @@ export const selectorBrushConfigZoom = createSelector([selectorChartZoomOptionsL
|
|
|
66
66
|
}
|
|
67
67
|
return null;
|
|
68
68
|
});
|
|
69
|
-
export const selectorBrushConfig = createSelector(
|
|
70
|
-
export const selectorIsBrushEnabled = createSelector(
|
|
71
|
-
export const selectorIsBrushSelectionActive = createSelector(
|
|
69
|
+
export const selectorBrushConfig = createSelector(selectorBrushConfigNoZoom, selectorBrushConfigZoom, (configNoZoom, configZoom) => configZoom ?? configNoZoom);
|
|
70
|
+
export const selectorIsBrushEnabled = createSelector(selectorBrush, brush => brush?.enabled || brush?.isZoomBrushEnabled);
|
|
71
|
+
export const selectorIsBrushSelectionActive = createSelector(selectorIsBrushEnabled, selectorBrush, (isBrushEnabled, brush) => {
|
|
72
72
|
return isBrushEnabled && brush?.start !== null && brush?.current !== null;
|
|
73
73
|
});
|
|
74
|
-
export const selectorBrushShouldPreventAxisHighlight = createSelector(
|
|
75
|
-
export const selectorBrushShouldPreventTooltip = createSelector(
|
|
74
|
+
export const selectorBrushShouldPreventAxisHighlight = createSelector(selectorBrush, selectorIsBrushSelectionActive, (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventHighlight);
|
|
75
|
+
export const selectorBrushShouldPreventTooltip = createSelector(selectorBrush, selectorIsBrushSelectionActive, (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventTooltip);
|
package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slid
|
|
|
72
72
|
}
|
|
73
73
|
export interface UseChartCartesianAxisState {
|
|
74
74
|
/**
|
|
75
|
-
* @ignore - state populated by the
|
|
75
|
+
* @ignore - state populated by the useChartProZoom plugin
|
|
76
76
|
*/
|
|
77
77
|
zoom?: {
|
|
78
78
|
isInteracting: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
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";
|
|
@@ -25,7 +25,7 @@ function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
|
|
|
25
25
|
bottom: mainChartDrawingArea.height
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
export const selectorChartPreviewXScales = createSelector(
|
|
28
|
+
export const selectorChartPreviewXScales = createSelector(selectorChartRawXAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartNormalizedXScales, function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, normalizedXScales, axisId) {
|
|
29
29
|
const hasAxis = xAxes?.some(axis => axis.id === axisId);
|
|
30
30
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
|
|
31
31
|
const options = zoomOptions[axisId];
|
|
@@ -40,7 +40,7 @@ export const selectorChartPreviewXScales = createSelector([selectorChartRawXAxis
|
|
|
40
40
|
});
|
|
41
41
|
return scales;
|
|
42
42
|
});
|
|
43
|
-
export const selectorChartPreviewComputedXAxis = createSelector(
|
|
43
|
+
export const selectorChartPreviewComputedXAxis = createSelector(selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartDrawingArea, selectorChartPreviewXScales, selectorChartXAxisWithDomains, (formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, {
|
|
44
44
|
axes,
|
|
45
45
|
domains
|
|
46
46
|
}, axisId) => {
|
|
@@ -69,7 +69,7 @@ export const selectorChartPreviewComputedXAxis = createSelector([selectorChartSe
|
|
|
69
69
|
}
|
|
70
70
|
return computedAxes.axis;
|
|
71
71
|
});
|
|
72
|
-
export const selectorChartPreviewYScales = createSelector(
|
|
72
|
+
export const selectorChartPreviewYScales = createSelector(selectorChartRawYAxis, selectorChartDrawingArea, selectorChartZoomOptionsLookup, selectorChartNormalizedYScales, function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, normalizedYScales, axisId) {
|
|
73
73
|
const hasAxis = yAxes?.some(axis => axis.id === axisId);
|
|
74
74
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
|
|
75
75
|
const options = zoomOptions[axisId];
|
|
@@ -87,7 +87,7 @@ export const selectorChartPreviewYScales = createSelector([selectorChartRawYAxis
|
|
|
87
87
|
});
|
|
88
88
|
return scales;
|
|
89
89
|
});
|
|
90
|
-
export const selectorChartPreviewComputedYAxis = createSelector(
|
|
90
|
+
export const selectorChartPreviewComputedYAxis = createSelector(selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorChartZoomOptionsLookup, selectorChartDrawingArea, selectorChartPreviewYScales, selectorChartYAxisWithDomains, (formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, {
|
|
91
91
|
axes,
|
|
92
92
|
domains
|
|
93
93
|
}, axisId) => {
|
|
@@ -4,6 +4,9 @@ import { AxisId, D3Scale } from "../../../../models/axis.js";
|
|
|
4
4
|
import { SeriesId } from "../../../../models/seriesType/common.js";
|
|
5
5
|
import { Flatbush } from "../../../Flatbush.js";
|
|
6
6
|
export declare const createZoomMap: (zoom: readonly ZoomData[]) => Map<AxisId, ZoomData>;
|
|
7
|
+
export declare const selectorChartHasZoom: (args_0: 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> & {
|
|
8
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
9
|
+
}) => boolean;
|
|
7
10
|
/**
|
|
8
11
|
* Following selectors are not exported because they exist in the MIT chart only to ba able to reuse the Zoom state from the pro.
|
|
9
12
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { createSelectorMemoized } from '@mui/x-internals/store';
|
|
2
|
+
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
3
3
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/index.js";
|
|
4
4
|
import { selectorChartSeriesConfig, selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
5
|
-
import { createSelector } from "../../utils/selectors.js";
|
|
6
5
|
import { computeAxisValue } from "./computeAxisValue.js";
|
|
7
6
|
import { createContinuousScaleGetAxisFilter, createDiscreteScaleGetAxisFilter, createGetAxisFilters } from "./createAxisFilterMapper.js";
|
|
8
7
|
import { createZoomLookup } from "./createZoomLookup.js";
|
|
@@ -24,24 +23,25 @@ export const createZoomMap = zoom => {
|
|
|
24
23
|
return zoomItemMap;
|
|
25
24
|
};
|
|
26
25
|
const selectorChartZoomState = state => state.zoom;
|
|
26
|
+
export const selectorChartHasZoom = createSelector(selectorChartRawXAxis, selectorChartRawYAxis, (xAxes, yAxes) => xAxes?.some(axis => Boolean(axis.zoom)) || yAxes?.some(axis => Boolean(axis.zoom)) || false);
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Following selectors are not exported because they exist in the MIT chart only to ba able to reuse the Zoom state from the pro.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
export const selectorChartZoomIsInteracting = createSelector(
|
|
32
|
+
export const selectorChartZoomIsInteracting = createSelector(selectorChartZoomState, zoom => zoom?.isInteracting);
|
|
33
33
|
export const selectorChartZoomMap = createSelectorMemoized(selectorChartZoomState, function selectorChartZoomMap(zoom) {
|
|
34
34
|
return zoom?.zoomData && createZoomMap(zoom?.zoomData);
|
|
35
35
|
});
|
|
36
|
-
export const selectorChartAxisZoomData = createSelector(
|
|
36
|
+
export const selectorChartAxisZoomData = createSelector(selectorChartZoomMap, (zoomMap, axisId) => zoomMap?.get(axisId));
|
|
37
37
|
export const selectorChartZoomOptionsLookup = createSelectorMemoized(selectorChartRawXAxis, selectorChartRawYAxis, function selectorChartZoomOptionsLookup(xAxis, yAxis) {
|
|
38
38
|
return _extends({}, createZoomLookup('x')(xAxis), createZoomLookup('y')(yAxis));
|
|
39
39
|
});
|
|
40
|
-
export const selectorChartAxisZoomOptionsLookup = createSelector(
|
|
41
|
-
export const selectorDefaultXAxisTickNumber = createSelector(
|
|
40
|
+
export const selectorChartAxisZoomOptionsLookup = createSelector(selectorChartZoomOptionsLookup, (axisLookup, axisId) => axisLookup[axisId]);
|
|
41
|
+
export const selectorDefaultXAxisTickNumber = createSelector(selectorChartDrawingArea, function selectorDefaultXAxisTickNumber(drawingArea) {
|
|
42
42
|
return getDefaultTickNumber(drawingArea.width);
|
|
43
43
|
});
|
|
44
|
-
export const selectorDefaultYAxisTickNumber = createSelector(
|
|
44
|
+
export const selectorDefaultYAxisTickNumber = createSelector(selectorChartDrawingArea, function selectorDefaultYAxisTickNumber(drawingArea) {
|
|
45
45
|
return getDefaultTickNumber(drawingArea.height);
|
|
46
46
|
});
|
|
47
47
|
export const selectorChartXAxisWithDomains = createSelectorMemoized(selectorChartRawXAxis, selectorChartSeriesProcessed, selectorChartSeriesConfig, selectorPreferStrictDomainInLineCharts, selectorDefaultXAxisTickNumber, function selectorChartXAxisWithDomains(axes, formattedSeries, seriesConfig, preferStrictDomainInLineCharts, defaultTickNumber) {
|
|
@@ -255,16 +255,16 @@ export const selectorChartYAxis = createSelectorMemoized(selectorChartDrawingAre
|
|
|
255
255
|
domains
|
|
256
256
|
});
|
|
257
257
|
});
|
|
258
|
-
export const selectorChartAxis = createSelector(
|
|
259
|
-
export const selectorChartRawAxis = createSelector(
|
|
258
|
+
export const selectorChartAxis = createSelector(selectorChartXAxis, selectorChartYAxis, (xAxes, yAxes, axisId) => xAxes?.axis[axisId] ?? yAxes?.axis[axisId]);
|
|
259
|
+
export const selectorChartRawAxis = createSelector(selectorChartRawXAxis, selectorChartRawYAxis, (xAxes, yAxes, axisId) => {
|
|
260
260
|
const axis = xAxes?.find(a => a.id === axisId) ?? yAxes?.find(a => a.id === axisId) ?? null;
|
|
261
261
|
if (!axis) {
|
|
262
262
|
return undefined;
|
|
263
263
|
}
|
|
264
264
|
return axis;
|
|
265
265
|
});
|
|
266
|
-
export const selectorChartDefaultXAxisId = createSelector(
|
|
267
|
-
export const selectorChartDefaultYAxisId = createSelector(
|
|
266
|
+
export const selectorChartDefaultXAxisId = createSelector(selectorChartRawXAxis, xAxes => xAxes[0].id);
|
|
267
|
+
export const selectorChartDefaultYAxisId = createSelector(selectorChartRawYAxis, yAxes => yAxes[0].id);
|
|
268
268
|
const EMPTY_MAP = new Map();
|
|
269
269
|
export const selectorChartSeriesEmptyFlatbushMap = () => EMPTY_MAP;
|
|
270
270
|
export const selectorChartSeriesFlatbushMap = createSelectorMemoized(selectorChartSeriesProcessed, selectorChartNormalizedXScales, selectorChartNormalizedYScales, selectorChartDefaultXAxisId, selectorChartDefaultYAxisId, function selectChartSeriesFlatbushMap(allSeries, xAxesScaleMap, yAxesScaleMap, defaultXAxisId, defaultYAxisId) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { createSelectorMemoized } from '@mui/x-internals/store';
|
|
3
|
-
import { createSelector } from "../../utils/selectors.js";
|
|
2
|
+
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
4
3
|
import { selectorChartXAxis, selectorChartYAxis } from "./useChartCartesianAxisRendering.selectors.js";
|
|
5
4
|
import { selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue, selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue } from "./useChartCartesianInteraction.selectors.js";
|
|
6
5
|
import { selectorChartsKeyboardXAxisIndex, selectorChartsKeyboardYAxisIndex } from "../useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js";
|
|
@@ -59,8 +58,8 @@ const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, contro
|
|
|
59
58
|
}
|
|
60
59
|
return [];
|
|
61
60
|
};
|
|
62
|
-
export const selectorChartsHighlightXAxisValue = createSelector(
|
|
63
|
-
export const selectorChartsHighlightYAxisValue = createSelector(
|
|
61
|
+
export const selectorChartsHighlightXAxisValue = createSelector(selectorChartsInteractionXAxisIndex, selectorChartsInteractionXAxisValue, selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, selectorChartsKeyboardXAxisIndex, selectorChartsLastInteraction, selectorBrushShouldPreventAxisHighlight, selectAxisHighlightWithValue);
|
|
62
|
+
export const selectorChartsHighlightYAxisValue = createSelector(selectorChartsInteractionYAxisIndex, selectorChartsInteractionYAxisValue, selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, selectorChartsKeyboardYAxisIndex, selectorChartsLastInteraction, selectorBrushShouldPreventAxisHighlight, selectAxisHighlightWithValue);
|
|
64
63
|
|
|
65
64
|
/**
|
|
66
65
|
* Get the scale of the axis with highlight if controlled. The default axis otherwise.
|
|
@@ -75,5 +74,5 @@ const selectAxis = (axisItems, axis) => {
|
|
|
75
74
|
const filteredAxes = axisItems.map(item => axis.axis[item.axisId] ?? null).filter(item => item !== null);
|
|
76
75
|
return filteredAxes;
|
|
77
76
|
};
|
|
78
|
-
export const selectorChartsHighlightXAxis = createSelector(
|
|
79
|
-
export const selectorChartsHighlightYAxis = createSelector(
|
|
77
|
+
export const selectorChartsHighlightXAxis = createSelector(selectorChartControlledCartesianAxisHighlight, selectorChartXAxis, selectAxis);
|
|
78
|
+
export const selectorChartsHighlightYAxis = createSelector(selectorChartControlledCartesianAxisHighlight, selectorChartYAxis, selectAxis);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
2
|
-
import { createSelectorMemoizedWithOptions } from '@mui/x-internals/store';
|
|
3
|
-
import { createSelector } from "../../utils/selectors.js";
|
|
2
|
+
import { createSelector, createSelectorMemoizedWithOptions } from '@mui/x-internals/store';
|
|
4
3
|
import { selectorChartsInteractionPointerX, selectorChartsInteractionPointerY } from "../useChartInteraction/useChartInteraction.selectors.js";
|
|
5
4
|
import { getAxisIndex, getAxisValue } from "./getAxisValue.js";
|
|
6
5
|
import { selectorChartXAxis, selectorChartYAxis } from "./useChartCartesianAxisRendering.selectors.js";
|
|
@@ -19,9 +18,9 @@ export const selectChartsInteractionAxisIndex = (value, axes, id) => {
|
|
|
19
18
|
const index = indexGetter(value, axes, id);
|
|
20
19
|
return index === -1 ? null : index;
|
|
21
20
|
};
|
|
22
|
-
export const selectorChartsInteractionXAxisIndex = createSelector(
|
|
23
|
-
export const selectorChartsInteractionYAxisIndex = createSelector(
|
|
24
|
-
export const selectorChartAxisInteraction = createSelector(
|
|
21
|
+
export const selectorChartsInteractionXAxisIndex = createSelector(selectorChartsInteractionPointerX, selectorChartXAxis, selectChartsInteractionAxisIndex);
|
|
22
|
+
export const selectorChartsInteractionYAxisIndex = createSelector(selectorChartsInteractionPointerY, selectorChartYAxis, selectChartsInteractionAxisIndex);
|
|
23
|
+
export const selectorChartAxisInteraction = createSelector(selectorChartsInteractionPointerX, selectorChartsInteractionPointerY, selectorChartXAxis, selectorChartYAxis, (x, y, xAxis, yAxis) => [...(x === null ? [] : xAxis.axisIds.map(axisId => ({
|
|
25
24
|
axisId,
|
|
26
25
|
dataIndex: indexGetter(x, xAxis, axisId)
|
|
27
26
|
}))), ...(y === null ? [] : yAxis.axisIds.map(axisId => ({
|
|
@@ -39,13 +38,13 @@ function valueGetter(value, axes, indexes, ids = axes.axisIds[0]) {
|
|
|
39
38
|
return getAxisValue(axis.scale, axis.data, value, indexes[axisIndex]);
|
|
40
39
|
}) : getAxisValue(axes.axis[ids].scale, axes.axis[ids].data, value, indexes);
|
|
41
40
|
}
|
|
42
|
-
export const selectorChartsInteractionXAxisValue = createSelector(
|
|
41
|
+
export const selectorChartsInteractionXAxisValue = createSelector(selectorChartsInteractionPointerX, selectorChartXAxis, selectorChartsInteractionXAxisIndex, (x, xAxes, xIndex, id) => {
|
|
43
42
|
if (x === null || xAxes.axisIds.length === 0) {
|
|
44
43
|
return null;
|
|
45
44
|
}
|
|
46
45
|
return valueGetter(x, xAxes, xIndex, id);
|
|
47
46
|
});
|
|
48
|
-
export const selectorChartsInteractionYAxisValue = createSelector(
|
|
47
|
+
export const selectorChartsInteractionYAxisValue = createSelector(selectorChartsInteractionPointerY, selectorChartYAxis, selectorChartsInteractionYAxisIndex, (y, yAxes, yIndex, id) => {
|
|
49
48
|
if (y === null || yAxes.axisIds.length === 0) {
|
|
50
49
|
return null;
|
|
51
50
|
}
|
|
@@ -100,4 +99,4 @@ export const selectorChartsInteractionTooltipYAxes = createSelectorMemoizedWithO
|
|
|
100
99
|
/**
|
|
101
100
|
* Return `true` if the axis tooltip has something to display.
|
|
102
101
|
*/
|
|
103
|
-
export const selectorChartsInteractionAxisTooltip = createSelector(
|
|
102
|
+
export const selectorChartsInteractionAxisTooltip = createSelector(selectorChartsInteractionTooltipXAxes, selectorChartsInteractionTooltipYAxes, (xTooltip, yTooltip) => xTooltip.length > 0 || yTooltip.length > 0);
|
|
@@ -20,8 +20,8 @@ export function findClosestPoints(flatbush, drawingArea, seriesData, xScale, ySc
|
|
|
20
20
|
function sqDistFn(dx, dy) {
|
|
21
21
|
return fxSq * dx * dx + fySq * dy * dy;
|
|
22
22
|
}
|
|
23
|
-
const pointX = originalXScale(invertScale(xScale, svgPointX, dataIndex => seriesData[dataIndex]
|
|
24
|
-
const pointY = originalYScale(invertScale(yScale, svgPointY, dataIndex => seriesData[dataIndex]
|
|
23
|
+
const pointX = originalXScale(invertScale(xScale, svgPointX, dataIndex => seriesData[dataIndex]?.x));
|
|
24
|
+
const pointY = originalYScale(invertScale(yScale, svgPointY, dataIndex => seriesData[dataIndex]?.y));
|
|
25
25
|
return flatbush.neighbors(pointX, pointY, maxResults, maxRadius != null ? maxRadius * maxRadius : Infinity, excludeIfOutsideDrawingArea, sqDistFn);
|
|
26
26
|
}
|
|
27
27
|
function invertScale(scale, value, getDataPoint) {
|
package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
const selectVoronoi = state => state.voronoi;
|
|
3
|
-
export const selectorChartsIsVoronoiEnabled = createSelector(
|
|
3
|
+
export const selectorChartsIsVoronoiEnabled = createSelector(selectVoronoi, voronoi => voronoi?.isVoronoiEnabled);
|
package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { createSelectorMemoized } from '@mui/x-internals/store';
|
|
2
|
-
import { createSelector } from "../../utils/selectors.js";
|
|
1
|
+
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
3
2
|
import { createIsHighlighted } from "./createIsHighlighted.js";
|
|
4
3
|
import { createIsFaded } from "./createIsFaded.js";
|
|
5
4
|
import { getSeriesHighlightedItem, getSeriesUnfadedItem, isSeriesFaded, isSeriesHighlighted } from "./highlightStates.js";
|
|
6
5
|
import { selectorChartsKeyboardItem } from "../useChartKeyboardNavigation/index.js";
|
|
7
6
|
const selectHighlight = state => state.highlight;
|
|
8
7
|
const selectSeries = state => state.series;
|
|
9
|
-
export const selectorChartsHighlightScopePerSeriesId = createSelector(
|
|
8
|
+
export const selectorChartsHighlightScopePerSeriesId = createSelector(selectSeries, series => {
|
|
10
9
|
const map = new Map();
|
|
11
10
|
Object.keys(series.processedSeries).forEach(seriesType => {
|
|
12
11
|
const seriesData = series.processedSeries[seriesType];
|
|
@@ -20,7 +19,7 @@ export const selectorChartsHighlightScopePerSeriesId = createSelector([selectSer
|
|
|
20
19
|
export const selectorChartsHighlightedItem = createSelectorMemoized(selectHighlight, selectorChartsKeyboardItem, function selectorChartsHighlightedItem(highlight, keyboardItem) {
|
|
21
20
|
return highlight.lastUpdate === 'pointer' ? highlight.item : keyboardItem;
|
|
22
21
|
});
|
|
23
|
-
export const selectorChartsHighlightScope = createSelector(
|
|
22
|
+
export const selectorChartsHighlightScope = createSelector(selectorChartsHighlightScopePerSeriesId, selectorChartsHighlightedItem, function selectorChartsHighlightScope(seriesIdToHighlightScope, highlightedItem) {
|
|
24
23
|
if (!highlightedItem) {
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
@@ -30,15 +29,15 @@ export const selectorChartsHighlightScope = createSelector([selectorChartsHighli
|
|
|
30
29
|
}
|
|
31
30
|
return highlightScope;
|
|
32
31
|
});
|
|
33
|
-
export const selectorChartsIsHighlightedCallback = createSelector(
|
|
34
|
-
export const selectorChartsIsFadedCallback = createSelector(
|
|
35
|
-
export const selectorChartsIsHighlighted = createSelector(
|
|
32
|
+
export const selectorChartsIsHighlightedCallback = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, createIsHighlighted);
|
|
33
|
+
export const selectorChartsIsFadedCallback = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, createIsFaded);
|
|
34
|
+
export const selectorChartsIsHighlighted = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
|
|
36
35
|
return createIsHighlighted(highlightScope, highlightedItem)(item);
|
|
37
36
|
});
|
|
38
|
-
export const selectorChartIsSeriesHighlighted = createSelector(
|
|
39
|
-
export const selectorChartIsSeriesFaded = createSelector(
|
|
40
|
-
export const selectorChartSeriesUnfadedItem = createSelector(
|
|
41
|
-
export const selectorChartSeriesHighlightedItem = createSelector(
|
|
42
|
-
export const selectorChartsIsFaded = createSelector(
|
|
37
|
+
export const selectorChartIsSeriesHighlighted = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, isSeriesHighlighted);
|
|
38
|
+
export const selectorChartIsSeriesFaded = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, isSeriesFaded);
|
|
39
|
+
export const selectorChartSeriesUnfadedItem = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, getSeriesUnfadedItem);
|
|
40
|
+
export const selectorChartSeriesHighlightedItem = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, getSeriesHighlightedItem);
|
|
41
|
+
export const selectorChartsIsFaded = createSelector(selectorChartsHighlightScope, selectorChartsHighlightedItem, function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
|
|
43
42
|
return createIsFaded(highlightScope, highlightedItem)(item);
|
|
44
43
|
});
|
package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
const selectInteraction = state => state.interaction;
|
|
3
|
-
export const selectorChartsInteractionIsInitialized = createSelector(
|
|
4
|
-
export const selectorChartsInteractionItem = createSelector(
|
|
5
|
-
export const selectorChartsInteractionPointer = createSelector(
|
|
6
|
-
export const selectorChartsInteractionPointerX = createSelector(
|
|
7
|
-
export const selectorChartsInteractionPointerY = createSelector(
|
|
8
|
-
export const selectorChartsInteractionItemIsDefined = createSelector(
|
|
9
|
-
export const selectorChartsLastInteraction = createSelector(
|
|
3
|
+
export const selectorChartsInteractionIsInitialized = createSelector(selectInteraction, interaction => interaction !== undefined);
|
|
4
|
+
export const selectorChartsInteractionItem = createSelector(selectInteraction, interaction => interaction?.item ?? null);
|
|
5
|
+
export const selectorChartsInteractionPointer = createSelector(selectInteraction, interaction => interaction?.pointer ?? null);
|
|
6
|
+
export const selectorChartsInteractionPointerX = createSelector(selectorChartsInteractionPointer, pointer => pointer && pointer.x);
|
|
7
|
+
export const selectorChartsInteractionPointerY = createSelector(selectorChartsInteractionPointer, pointer => pointer && pointer.y);
|
|
8
|
+
export const selectorChartsInteractionItemIsDefined = createSelector(selectorChartsInteractionItem, item => item !== null);
|
|
9
|
+
export const selectorChartsLastInteraction = createSelector(selectInteraction, interaction => interaction?.lastUpdate);
|
package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
1
2
|
import { selectorChartSeriesConfig, selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
2
|
-
import { createSelector } from "../../utils/selectors.js";
|
|
3
3
|
import { selectorChartXAxis, selectorChartYAxis } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
|
|
4
4
|
import { selectorChartsKeyboardItem, selectorChartsKeyboardItemIsDefined } from "../useChartKeyboardNavigation/index.js";
|
|
5
5
|
import { selectorChartsInteractionItem, selectorChartsInteractionItemIsDefined, selectorChartsLastInteraction } from "./useChartInteraction.selectors.js";
|
|
6
6
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
|
|
7
7
|
import { isCartesianSeries } from "../../../isCartesian.js";
|
|
8
|
-
export const selectorChartsTooltipItem = createSelector(
|
|
9
|
-
export const selectorChartsTooltipItemIsDefined = createSelector(
|
|
10
|
-
export const selectorChartsTooltipItemPosition = createSelector(
|
|
8
|
+
export const selectorChartsTooltipItem = createSelector(selectorChartsLastInteraction, selectorChartsInteractionItem, selectorChartsKeyboardItem, (lastInteraction, interactionItem, keyboardItem) => lastInteraction === 'keyboard' ? keyboardItem : interactionItem ?? null);
|
|
9
|
+
export const selectorChartsTooltipItemIsDefined = createSelector(selectorChartsLastInteraction, selectorChartsInteractionItemIsDefined, selectorChartsKeyboardItemIsDefined, (lastInteraction, interactionItemIsDefined, keyboardItemIsDefined) => lastInteraction === 'keyboard' ? keyboardItemIsDefined : interactionItemIsDefined);
|
|
10
|
+
export const selectorChartsTooltipItemPosition = createSelector(selectorChartsTooltipItem, selectorChartDrawingArea, selectorChartSeriesConfig, selectorChartXAxis, selectorChartYAxis, selectorChartSeriesProcessed, (_, placement) => placement, function selectorChartsTooltipItemPosition(identifier, drawingArea, seriesConfig, {
|
|
11
11
|
axis: xAxis,
|
|
12
12
|
axisIds: xAxisIds
|
|
13
13
|
}, {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
3
3
|
import { selectorChartXAxis, selectorChartYAxis } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
|
|
4
4
|
const selectKeyboardNavigation = state => state.keyboardNavigation;
|
|
5
|
-
export const selectorChartsItemIsFocused = createSelector(
|
|
5
|
+
export const selectorChartsItemIsFocused = createSelector(selectKeyboardNavigation, (keyboardNavigationState, item) => {
|
|
6
6
|
return keyboardNavigationState?.item != null && keyboardNavigationState.item.type === item.seriesType && keyboardNavigationState.item.seriesId === item.seriesId && keyboardNavigationState.item.dataIndex === item.dataIndex;
|
|
7
7
|
});
|
|
8
|
-
export const selectorChartsHasFocusedItem = createSelector(
|
|
9
|
-
export const selectorChartsFocusedSeriesType = createSelector(
|
|
10
|
-
export const selectorChartsFocusedSeriesId = createSelector(
|
|
11
|
-
export const selectorChartsFocusedDataIndex = createSelector(
|
|
12
|
-
export const selectorChartsIsKeyboardNavigationEnabled = createSelector(
|
|
8
|
+
export const selectorChartsHasFocusedItem = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item != null);
|
|
9
|
+
export const selectorChartsFocusedSeriesType = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.type);
|
|
10
|
+
export const selectorChartsFocusedSeriesId = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
|
|
11
|
+
export const selectorChartsFocusedDataIndex = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
|
|
12
|
+
export const selectorChartsIsKeyboardNavigationEnabled = createSelector(selectKeyboardNavigation, keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Selectors to override highlight behavior.
|
|
@@ -32,9 +32,9 @@ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis,
|
|
|
32
32
|
dataIndex
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
export const selectorChartsKeyboardXAxisIndex = createSelector(
|
|
36
|
-
export const selectorChartsKeyboardYAxisIndex = createSelector(
|
|
37
|
-
export const selectorChartsKeyboardItem = createSelector(
|
|
35
|
+
export const selectorChartsKeyboardXAxisIndex = createSelector(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, selectorChartXAxis, selectorChartSeriesProcessed, createSelectAxisHighlight('x'));
|
|
36
|
+
export const selectorChartsKeyboardYAxisIndex = createSelector(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, selectorChartYAxis, selectorChartSeriesProcessed, createSelectAxisHighlight('y'));
|
|
37
|
+
export const selectorChartsKeyboardItem = createSelector(selectKeyboardNavigation, function selectorChartsKeyboardItem(keyboardState) {
|
|
38
38
|
if (keyboardState?.item == null) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
@@ -47,6 +47,6 @@ export const selectorChartsKeyboardItem = createSelector([selectKeyboardNavigati
|
|
|
47
47
|
}
|
|
48
48
|
return keyboardState.item;
|
|
49
49
|
});
|
|
50
|
-
export const selectorChartsKeyboardItemIsDefined = createSelector(
|
|
50
|
+
export const selectorChartsKeyboardItemIsDefined = createSelector(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, function selectorChartsKeyboardItemIsDefined(seriesType, seriesId, dataIndex) {
|
|
51
51
|
return seriesId !== undefined && dataIndex !== undefined;
|
|
52
52
|
});
|
package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
1
2
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/index.js";
|
|
2
3
|
import { selectorChartSeriesConfig, selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
3
|
-
import { createSelector } from "../../utils/selectors.js";
|
|
4
4
|
import { computeAxisValue } from "./computeAxisValue.js";
|
|
5
5
|
export const selectorChartPolarAxisState = state => state.polarAxis;
|
|
6
|
-
export const selectorChartRawRotationAxis = createSelector(
|
|
7
|
-
export const selectorChartRawRadiusAxis = createSelector(
|
|
6
|
+
export const selectorChartRawRotationAxis = createSelector(selectorChartPolarAxisState, axis => axis?.rotation);
|
|
7
|
+
export const selectorChartRawRadiusAxis = createSelector(selectorChartPolarAxisState, axis => axis?.radius);
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The only interesting selectors that merge axis data and zoom if provided.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export const selectorChartRotationAxis = createSelector(
|
|
13
|
+
export const selectorChartRotationAxis = createSelector(selectorChartRawRotationAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, (axis, drawingArea, formattedSeries, seriesConfig) => computeAxisValue({
|
|
14
14
|
drawingArea,
|
|
15
15
|
formattedSeries,
|
|
16
16
|
axis,
|
|
17
17
|
seriesConfig,
|
|
18
18
|
axisDirection: 'rotation'
|
|
19
19
|
}));
|
|
20
|
-
export const selectorChartRadiusAxis = createSelector(
|
|
20
|
+
export const selectorChartRadiusAxis = createSelector(selectorChartRawRadiusAxis, selectorChartDrawingArea, selectorChartSeriesProcessed, selectorChartSeriesConfig, (axis, drawingArea, formattedSeries, seriesConfig) => computeAxisValue({
|
|
21
21
|
drawingArea,
|
|
22
22
|
formattedSeries,
|
|
23
23
|
axis,
|
|
24
24
|
seriesConfig,
|
|
25
25
|
axisDirection: 'radius'
|
|
26
26
|
}));
|
|
27
|
-
export const selectorChartPolarCenter = createSelector(
|
|
27
|
+
export const selectorChartPolarCenter = createSelector(selectorChartDrawingArea, drawingArea => ({
|
|
28
28
|
cx: drawingArea.left + drawingArea.width / 2,
|
|
29
29
|
cy: drawingArea.top + drawingArea.height / 2
|
|
30
30
|
}));
|