@mui/x-charts 8.18.0 → 8.20.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 +175 -0
- package/ChartsGrid/ChartsHorizontalGrid.js +5 -1
- package/ChartsGrid/ChartsVerticalGrid.js +5 -1
- package/ChartsSurface/ChartsSurface.js +5 -2
- package/ChartsTooltip/ChartsTooltipContainer.js +1 -1
- package/LineChart/seriesConfig/seriesProcessor.js +15 -10
- package/PieChart/PieArcPlot.js +5 -3
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +2 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +2 -2
- package/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.d.ts +7 -0
- package/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.js +26 -0
- package/esm/BarChart/seriesConfig/bar/seriesProcessor.js +15 -9
- package/esm/ChartsGrid/ChartsHorizontalGrid.js +5 -1
- package/esm/ChartsGrid/ChartsVerticalGrid.js +5 -1
- package/esm/ChartsSurface/ChartsSurface.js +5 -2
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +1 -1
- package/esm/LineChart/seriesConfig/seriesProcessor.js +15 -10
- package/esm/PieChart/PieArcPlot.js +5 -3
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +1 -1
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +1 -1
- package/esm/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.d.ts +7 -0
- package/esm/RadarChart/RadarSeriesPlot/useInteractionAllItemProps.js +18 -0
- package/esm/hooks/useBarSeries.js +3 -5
- package/esm/hooks/useInteractionItemProps.d.ts +0 -5
- package/esm/hooks/useInteractionItemProps.js +0 -11
- 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/hooks/useTicks.js +12 -3
- 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/processSeries.d.ts +16 -10
- package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.js +20 -12
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +5 -7
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +11 -4
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +14 -5
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +3 -2
- 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.js +16 -12
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +15 -16
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +4 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +8 -8
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +4 -4
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +15 -10
- 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/useInteractionItemProps.d.ts +0 -5
- package/hooks/useInteractionItemProps.js +1 -13
- 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/hooks/useTicks.js +12 -3
- 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/processSeries.d.ts +16 -10
- package/internals/plugins/corePlugins/useChartSeries/processSeries.js +23 -14
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +4 -6
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +11 -4
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js +15 -6
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +3 -2
- 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.js +16 -12
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +14 -15
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.types.d.ts +4 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +8 -8
- package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +4 -4
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +15 -10
- 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
|
@@ -5,22 +5,24 @@ import * as React from 'react';
|
|
|
5
5
|
import useEventCallback from '@mui/utils/useEventCallback';
|
|
6
6
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
7
|
import { getNextSeriesWithData, getPreviousSeriesWithData, seriesHasData } from "./useChartKeyboardNavigation.helpers.js";
|
|
8
|
+
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
8
9
|
function getNextIndexFocusedItem(state) {
|
|
10
|
+
const processedSeries = selectorChartSeriesProcessed(state);
|
|
9
11
|
let {
|
|
10
12
|
type,
|
|
11
13
|
seriesId
|
|
12
14
|
} = state.keyboardNavigation.item ?? {};
|
|
13
15
|
if (type === undefined ||
|
|
14
16
|
// @ts-ignore sankey is not in MIT version
|
|
15
|
-
type === 'sankey' || seriesId === undefined || !seriesHasData(
|
|
16
|
-
const nextSeries = getNextSeriesWithData(
|
|
17
|
+
type === 'sankey' || seriesId === undefined || !seriesHasData(processedSeries, type, seriesId)) {
|
|
18
|
+
const nextSeries = getNextSeriesWithData(processedSeries, type, seriesId);
|
|
17
19
|
if (nextSeries === null) {
|
|
18
20
|
return null;
|
|
19
21
|
}
|
|
20
22
|
type = nextSeries.type;
|
|
21
23
|
seriesId = nextSeries.seriesId;
|
|
22
24
|
}
|
|
23
|
-
const dataLength =
|
|
25
|
+
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
24
26
|
return {
|
|
25
27
|
type,
|
|
26
28
|
seriesId,
|
|
@@ -28,21 +30,22 @@ function getNextIndexFocusedItem(state) {
|
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
function getPreviousIndexFocusedItem(state) {
|
|
33
|
+
const processedSeries = selectorChartSeriesProcessed(state);
|
|
31
34
|
let {
|
|
32
35
|
type,
|
|
33
36
|
seriesId
|
|
34
37
|
} = state.keyboardNavigation.item ?? {};
|
|
35
38
|
if (type === undefined ||
|
|
36
39
|
// @ts-ignore sankey is not in MIT version
|
|
37
|
-
type === 'sankey' || seriesId === undefined || !seriesHasData(
|
|
38
|
-
const previousSeries = getPreviousSeriesWithData(
|
|
40
|
+
type === 'sankey' || seriesId === undefined || !seriesHasData(processedSeries, type, seriesId)) {
|
|
41
|
+
const previousSeries = getPreviousSeriesWithData(processedSeries, type, seriesId);
|
|
39
42
|
if (previousSeries === null) {
|
|
40
43
|
return null;
|
|
41
44
|
}
|
|
42
45
|
type = previousSeries.type;
|
|
43
46
|
seriesId = previousSeries.seriesId;
|
|
44
47
|
}
|
|
45
|
-
const dataLength =
|
|
48
|
+
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
46
49
|
return {
|
|
47
50
|
type,
|
|
48
51
|
seriesId,
|
|
@@ -50,17 +53,18 @@ function getPreviousIndexFocusedItem(state) {
|
|
|
50
53
|
};
|
|
51
54
|
}
|
|
52
55
|
function getNextSeriesFocusedItem(state) {
|
|
56
|
+
const processedSeries = selectorChartSeriesProcessed(state);
|
|
53
57
|
let {
|
|
54
58
|
type,
|
|
55
59
|
seriesId
|
|
56
60
|
} = state.keyboardNavigation.item ?? {};
|
|
57
|
-
const nextSeries = getNextSeriesWithData(
|
|
61
|
+
const nextSeries = getNextSeriesWithData(processedSeries, type, seriesId);
|
|
58
62
|
if (nextSeries === null) {
|
|
59
63
|
return null; // No series to move the focus to.
|
|
60
64
|
}
|
|
61
65
|
type = nextSeries.type;
|
|
62
66
|
seriesId = nextSeries.seriesId;
|
|
63
|
-
const dataLength =
|
|
67
|
+
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
64
68
|
return {
|
|
65
69
|
type,
|
|
66
70
|
seriesId,
|
|
@@ -68,17 +72,18 @@ function getNextSeriesFocusedItem(state) {
|
|
|
68
72
|
};
|
|
69
73
|
}
|
|
70
74
|
function getPreviousSeriesFocusedItem(state) {
|
|
75
|
+
const processedSeries = selectorChartSeriesProcessed(state);
|
|
71
76
|
let {
|
|
72
77
|
type,
|
|
73
78
|
seriesId
|
|
74
79
|
} = state.keyboardNavigation.item ?? {};
|
|
75
|
-
const previousSeries = getPreviousSeriesWithData(
|
|
80
|
+
const previousSeries = getPreviousSeriesWithData(processedSeries, type, seriesId);
|
|
76
81
|
if (previousSeries === null) {
|
|
77
82
|
return null; // No series to move the focus to.
|
|
78
83
|
}
|
|
79
84
|
type = previousSeries.type;
|
|
80
85
|
seriesId = previousSeries.seriesId;
|
|
81
|
-
const dataLength =
|
|
86
|
+
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
82
87
|
return {
|
|
83
88
|
type,
|
|
84
89
|
seriesId,
|
|
@@ -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
|
}));
|
package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.js
CHANGED
|
@@ -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 { generateSvg2rotation } from "./coordinateTransformation.js";
|
|
6
5
|
import { getAxisIndex } from "./getAxisIndex.js";
|
|
@@ -19,15 +18,15 @@ function indexGetter(value, axes, ids) {
|
|
|
19
18
|
/**
|
|
20
19
|
* Helper to get the rotation associated to the interaction coordinate.
|
|
21
20
|
*/
|
|
22
|
-
const selectorChartsInteractionRotationAngle = createSelector(
|
|
21
|
+
const selectorChartsInteractionRotationAngle = createSelector(selectorChartsInteractionPointerX, selectorChartsInteractionPointerY, selectorChartPolarCenter, (x, y, center) => {
|
|
23
22
|
if (x === null || y === null) {
|
|
24
23
|
return null;
|
|
25
24
|
}
|
|
26
25
|
return generateSvg2rotation(center)(x, y);
|
|
27
26
|
});
|
|
28
|
-
export const selectorChartsInteractionRotationAxisIndex = createSelector(
|
|
29
|
-
export const selectorChartsInteractionRotationAxisIndexes = createSelector(
|
|
30
|
-
export const selectorChartsInteractionRotationAxisValue = createSelector(
|
|
27
|
+
export const selectorChartsInteractionRotationAxisIndex = createSelector(selectorChartsInteractionRotationAngle, selectorChartRotationAxis, optionalGetAxisId, (rotation, rotationAxis, id = rotationAxis.axisIds[0]) => rotation === null ? null : indexGetter(rotation, rotationAxis, id));
|
|
28
|
+
export const selectorChartsInteractionRotationAxisIndexes = createSelector(selectorChartsInteractionRotationAngle, selectorChartRotationAxis, optionalGetAxisIds, (rotation, rotationAxis, ids = rotationAxis.axisIds) => rotation === null ? null : indexGetter(rotation, rotationAxis, ids));
|
|
29
|
+
export const selectorChartsInteractionRotationAxisValue = createSelector(selectorChartRotationAxis, selectorChartsInteractionRotationAxisIndex, optionalGetAxisId, (rotationAxis, rotationIndex, id = rotationAxis.axisIds[0]) => {
|
|
31
30
|
if (rotationIndex === null || rotationIndex === -1 || rotationAxis.axisIds.length === 0) {
|
|
32
31
|
return null;
|
|
33
32
|
}
|
|
@@ -37,7 +36,7 @@ export const selectorChartsInteractionRotationAxisValue = createSelector([select
|
|
|
37
36
|
}
|
|
38
37
|
return data[rotationIndex];
|
|
39
38
|
});
|
|
40
|
-
export const selectorChartsInteractionRotationAxisValues = createSelector(
|
|
39
|
+
export const selectorChartsInteractionRotationAxisValues = createSelector(selectorChartRotationAxis, selectorChartsInteractionRotationAxisIndexes, optionalGetAxisIds, (rotationAxis, rotationIndexes, ids = rotationAxis.axisIds) => {
|
|
41
40
|
if (rotationIndexes === null) {
|
|
42
41
|
return null;
|
|
43
42
|
}
|
|
@@ -84,4 +83,4 @@ export const selectorChartsInteractionTooltipRadiusAxes = () => {
|
|
|
84
83
|
/**
|
|
85
84
|
* Return `true` if the axis tooltip has something to display.
|
|
86
85
|
*/
|
|
87
|
-
export const selectorChartsInteractionPolarAxisTooltip = createSelector(
|
|
86
|
+
export const selectorChartsInteractionPolarAxisTooltip = createSelector(selectorChartsInteractionTooltipRotationAxes, rotationTooltip => rotationTooltip.length > 0);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createSelector } from
|
|
1
|
+
import { createSelector } from '@mui/x-internals/store';
|
|
2
2
|
const selectRootState = state => state;
|
|
3
|
-
export const selectorChartZAxis = createSelector(
|
|
3
|
+
export const selectorChartZAxis = createSelector(selectRootState, state => state.zAxis);
|
|
@@ -2,17 +2,4 @@ import type { Selector } from 'reselect';
|
|
|
2
2
|
import { ChartAnyPluginSignature } from "../models/plugin.js";
|
|
3
3
|
import { ChartState } from "../models/chart.js";
|
|
4
4
|
export type ChartRootSelector<TSignature extends ChartAnyPluginSignature, T extends keyof TSignature['state'] = keyof TSignature['state']> = Selector<ChartState<[TSignature]>, TSignature['state'][T]>;
|
|
5
|
-
export type ChartOptionalRootSelector<TSignature extends ChartAnyPluginSignature> = Selector<ChartState<[], [TSignature]>, TSignature['state'][keyof TSignature['state']] | undefined>;
|
|
6
|
-
type StateFromSelectorList<Selectors extends readonly any[]> = Selectors extends [f: infer F, ...other: infer R] ? StateFromSelector<F> extends StateFromSelectorList<R> ? StateFromSelector<F> : StateFromSelectorList<R> : {};
|
|
7
|
-
type StateFromSelector<T> = T extends ((first: infer F, ...args: any[]) => any) ? F : never;
|
|
8
|
-
type Fn = (...args: any[]) => any;
|
|
9
|
-
type ReturnTypes<FunctionsArray extends readonly Fn[]> = { [Index in keyof FunctionsArray]: FunctionsArray[Index] extends FunctionsArray[number] ? ReturnType<FunctionsArray[Index]> : never };
|
|
10
|
-
type MergeParams<STypes extends readonly unknown[], CTypes extends readonly unknown[]> = STypes['length'] extends 0 ? CTypes : MergeParams<DropFirst<STypes>, DropFirst<CTypes>>;
|
|
11
|
-
type DropFirst<T> = T extends [any, ...infer Xs] ? Xs : [];
|
|
12
|
-
type SelectorArgs<Args extends any[], Selectors extends ReadonlyArray<Selector<any>>, Combiner extends (...args: readonly [...ReturnTypes<Selectors>, ...Args]) => any> = Selectors['length'] extends 0 ? MergeParams<ReturnTypes<Selectors>, Parameters<Combiner>> : [StateFromSelectorList<Selectors>, ...MergeParams<ReturnTypes<Selectors>, Parameters<Combiner>>];
|
|
13
|
-
type ChartSelector<Args extends any[], Selectors extends ReadonlyArray<Selector<any>>, Combiner extends (...args: readonly [...ReturnTypes<Selectors>, ...Args]) => any> = (...args: SelectorArgs<Args, Selectors, Combiner>) => ReturnType<Combiner>;
|
|
14
|
-
/**
|
|
15
|
-
* Method wrapping reselect's createChartSelector to provide caching for chart instances.
|
|
16
|
-
*/
|
|
17
|
-
export declare const createSelector: <const Args extends any[], const Selectors extends ReadonlyArray<Selector<any>>, const Combiner extends (...args: readonly [...ReturnTypes<Selectors>, ...Args]) => any>(inputSelectors: [...Selectors], combiner: Combiner) => ChartSelector<Args, Selectors, Combiner>;
|
|
18
|
-
export {};
|
|
5
|
+
export type ChartOptionalRootSelector<TSignature extends ChartAnyPluginSignature> = Selector<ChartState<[], [TSignature]>, TSignature['state'][keyof TSignature['state']] | undefined>;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Method wrapping reselect's createChartSelector to provide caching for chart instances.
|
|
4
|
-
*/
|
|
5
|
-
export const createSelector = (inputSelectors, combiner) => internalCreateSelector(...inputSelectors, combiner);
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChartSeriesDefaultized, ChartsSeriesConfig } from "../models/seriesType/config.js";
|
|
2
|
+
import { SeriesId } from "../models/seriesType/common.js";
|
|
3
|
+
import type { ProcessedSeries } from "./plugins/corePlugins/useChartSeries/index.js";
|
|
4
|
+
export declare const selectorAllSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
5
|
+
cacheKey: import("./index.js").ChartStateCacheKey;
|
|
6
|
+
}, seriesType: keyof ChartsSeriesConfig) => import("./index.js").SeriesProcessorResult<"line"> | import("./index.js").SeriesProcessorResult<"bar"> | {
|
|
7
|
+
series: Record<SeriesId, import("../index.js").DefaultizedScatterSeriesType>;
|
|
8
|
+
seriesOrder: SeriesId[];
|
|
9
|
+
} | {
|
|
10
|
+
series: Record<SeriesId, import("../index.js").DefaultizedPieSeriesType>;
|
|
11
|
+
seriesOrder: SeriesId[];
|
|
12
|
+
} | {
|
|
13
|
+
series: Record<SeriesId, import("../index.js").DefaultizedRadarSeriesType>;
|
|
14
|
+
seriesOrder: SeriesId[];
|
|
15
|
+
} | undefined;
|
|
16
|
+
export declare const selectorSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
17
|
+
cacheKey: import("./index.js").ChartStateCacheKey;
|
|
18
|
+
}, seriesType: keyof ChartsSeriesConfig, ids?: SeriesId | SeriesId[] | undefined) => import("../index.js").DefaultizedRadarSeriesType | import("../index.js").DefaultizedLineSeriesType | import("../index.js").DefaultizedBarSeriesType | import("../index.js").DefaultizedScatterSeriesType | import("../index.js").DefaultizedPieSeriesType | (import("../index.js").DefaultizedRadarSeriesType | import("../index.js").DefaultizedLineSeriesType | import("../index.js").DefaultizedBarSeriesType | import("../index.js").DefaultizedScatterSeriesType | import("../index.js").DefaultizedPieSeriesType | undefined)[] | undefined;
|
|
19
|
+
export declare const useAllSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T) => ProcessedSeries[T];
|
|
20
|
+
export declare const useSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T, seriesId?: SeriesId | SeriesId[]) => ChartSeriesDefaultized<T> | ChartSeriesDefaultized<T>[] | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { warnOnce } from '@mui/x-internals/warning';
|
|
2
|
+
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
3
|
+
import { selectorChartSeriesProcessed } from "./plugins/corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
4
|
+
import { useStore } from "./store/useStore.js";
|
|
5
|
+
import { useSelector } from "./store/useSelector.js";
|
|
6
|
+
export const selectorAllSeriesOfType = createSelector(selectorChartSeriesProcessed, (processedSeries, seriesType) => processedSeries[seriesType]);
|
|
7
|
+
export const selectorSeriesOfType = createSelectorMemoized(selectorChartSeriesProcessed, (processedSeries, seriesType, ids) => {
|
|
8
|
+
if (!ids || Array.isArray(ids) && ids.length === 0) {
|
|
9
|
+
return processedSeries[seriesType]?.seriesOrder?.map(seriesId => processedSeries[seriesType]?.series[seriesId]) ?? [];
|
|
10
|
+
}
|
|
11
|
+
if (!Array.isArray(ids)) {
|
|
12
|
+
return processedSeries[seriesType]?.series?.[ids];
|
|
13
|
+
}
|
|
14
|
+
const result = [];
|
|
15
|
+
const failedIds = [];
|
|
16
|
+
for (const id of ids) {
|
|
17
|
+
const series = processedSeries[seriesType]?.series?.[id];
|
|
18
|
+
if (series) {
|
|
19
|
+
result.push(series);
|
|
20
|
+
} else {
|
|
21
|
+
failedIds.push(id);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (process.env.NODE_ENV !== 'production' && failedIds.length > 0) {
|
|
25
|
+
const formattedIds = failedIds.map(v => JSON.stringify(v)).join(', ');
|
|
26
|
+
const fnName = `use${seriesType.charAt(0).toUpperCase()}${seriesType.slice(1)}Series`;
|
|
27
|
+
warnOnce([`MUI X Charts: The following ids provided to "${fnName}" could not be found: ${formattedIds}.`, `Make sure that they exist and their series are using the "${seriesType}" series type.`]);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
});
|
|
31
|
+
export const useAllSeriesOfType = seriesType => {
|
|
32
|
+
const store = useStore();
|
|
33
|
+
return useSelector(store, selectorAllSeriesOfType, seriesType);
|
|
34
|
+
};
|
|
35
|
+
export const useSeriesOfType = (seriesType, seriesId) => {
|
|
36
|
+
const store = useStore();
|
|
37
|
+
return useSelector(store, selectorSeriesOfType, seriesType, seriesId);
|
|
38
|
+
};
|
|
@@ -83,6 +83,6 @@ export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConf
|
|
|
83
83
|
export type ChartItemIdentifier<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
|
|
84
84
|
export type ChartItemIdentifierWithData<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifierWithData'];
|
|
85
85
|
export type DatasetElementType<T> = {
|
|
86
|
-
[key: string]:
|
|
86
|
+
[key: string]: T;
|
|
87
87
|
};
|
|
88
|
-
export type DatasetType<T =
|
|
88
|
+
export type DatasetType<T = unknown> = DatasetElementType<T>[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
|
2
|
+
import { ContinuousScaleName } from "../models/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns a nice domain for the given scale type and domain.
|
|
5
|
+
* Does not modify the original domain.
|
|
6
|
+
*
|
|
7
|
+
* Providing a count improves the nice domain calculation by trying to align tick values to round
|
|
8
|
+
* numbers or dates.
|
|
9
|
+
*
|
|
10
|
+
* For example, if you have a domain of [29, 72] and there are 5 ticks, the nice domain will be
|
|
11
|
+
* [20, 80] so that the ticks can be at [20, 35, 50, 65, 80].
|
|
12
|
+
* However, if there are 11 ticks, the nice domain will be [25, 75] so that the ticks can be at
|
|
13
|
+
* [25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75].
|
|
14
|
+
*
|
|
15
|
+
* @param scaleType The type of the scale (e.g., 'linear', 'log', 'time', etc.).
|
|
16
|
+
* @param domain The domain to be made nicer.
|
|
17
|
+
* @param count An optional number of ticks to improve the nice domain calculation. Defaults to 5.
|
|
18
|
+
*/
|
|
19
|
+
export declare function niceDomain<Domain extends NumberValue>(scaleType: Exclude<ContinuousScaleName, 'time' | 'utc'>, domain: Iterable<Domain>, count?: number): Domain[];
|
|
20
|
+
export declare function niceDomain<Domain extends NumberValue>(scaleType: 'time' | 'utc', domain: Iterable<Domain>, count?: number): Date[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getScale } from "../internals/getScale.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a nice domain for the given scale type and domain.
|
|
5
|
+
* Does not modify the original domain.
|
|
6
|
+
*
|
|
7
|
+
* Providing a count improves the nice domain calculation by trying to align tick values to round
|
|
8
|
+
* numbers or dates.
|
|
9
|
+
*
|
|
10
|
+
* For example, if you have a domain of [29, 72] and there are 5 ticks, the nice domain will be
|
|
11
|
+
* [20, 80] so that the ticks can be at [20, 35, 50, 65, 80].
|
|
12
|
+
* However, if there are 11 ticks, the nice domain will be [25, 75] so that the ticks can be at
|
|
13
|
+
* [25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75].
|
|
14
|
+
*
|
|
15
|
+
* @param scaleType The type of the scale (e.g., 'linear', 'log', 'time', etc.).
|
|
16
|
+
* @param domain The domain to be made nicer.
|
|
17
|
+
* @param count An optional number of ticks to improve the nice domain calculation. Defaults to 5.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export function niceDomain(scaleType, domain, count = 5) {
|
|
21
|
+
const scale = getScale(scaleType, domain, [0, 1]);
|
|
22
|
+
scale.nice(count);
|
|
23
|
+
return scale.domain();
|
|
24
|
+
}
|
package/hooks/useBarSeries.js
CHANGED
|
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useBarSeries = useBarSeries;
|
|
8
8
|
exports.useBarSeriesContext = useBarSeriesContext;
|
|
9
|
-
var
|
|
10
|
-
const useSelectorSeries = (0, _createSeriesSelectorOfType.createSeriesSelectorsOfType)('bar');
|
|
11
|
-
const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeriesSelectorOfType)('bar');
|
|
12
|
-
|
|
9
|
+
var _seriesSelectorOfType = require("../internals/seriesSelectorOfType");
|
|
13
10
|
/**
|
|
14
11
|
* Get access to the internal state of bar series.
|
|
15
12
|
*
|
|
@@ -33,7 +30,7 @@ const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeries
|
|
|
33
30
|
*/
|
|
34
31
|
|
|
35
32
|
function useBarSeries(seriesIds) {
|
|
36
|
-
return
|
|
33
|
+
return (0, _seriesSelectorOfType.useSeriesOfType)('bar', seriesIds);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
/**
|
|
@@ -45,5 +42,5 @@ function useBarSeries(seriesIds) {
|
|
|
45
42
|
* @returns the bar series
|
|
46
43
|
*/
|
|
47
44
|
function useBarSeriesContext() {
|
|
48
|
-
return
|
|
45
|
+
return (0, _seriesSelectorOfType.useAllSeriesOfType)('bar');
|
|
49
46
|
}
|
|
@@ -9,11 +9,6 @@ export declare const useInteractionItemProps: (data: SeriesItemIdentifierWithDat
|
|
|
9
9
|
onPointerLeave?: () => void;
|
|
10
10
|
onPointerDown?: (event: React.PointerEvent) => void;
|
|
11
11
|
};
|
|
12
|
-
export declare const useInteractionAllItemProps: (data: SeriesItemIdentifierWithData[], skip?: boolean) => {
|
|
13
|
-
onPointerEnter?: () => void;
|
|
14
|
-
onPointerLeave?: () => void;
|
|
15
|
-
onPointerDown?: (event: React.PointerEvent) => void;
|
|
16
|
-
}[];
|
|
17
12
|
export declare function getInteractionItemProps(instance: ChartInstance<[UseChartInteractionSignature, UseChartHighlightSignature]>, item: ChartItemIdentifierWithData<ChartSeriesType>): {
|
|
18
13
|
onPointerEnter?: () => void;
|
|
19
14
|
onPointerLeave?: () => void;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
9
|
exports.getInteractionItemProps = getInteractionItemProps;
|
|
10
|
-
exports.useInteractionItemProps =
|
|
10
|
+
exports.useInteractionItemProps = void 0;
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
13
|
var _ChartProvider = require("../context/ChartProvider");
|
|
@@ -48,18 +48,6 @@ const useInteractionItemProps = (data, skip) => {
|
|
|
48
48
|
}, [skip, onPointerEnter, onPointerLeave]);
|
|
49
49
|
};
|
|
50
50
|
exports.useInteractionItemProps = useInteractionItemProps;
|
|
51
|
-
const useInteractionAllItemProps = (data, skip) => {
|
|
52
|
-
const {
|
|
53
|
-
instance
|
|
54
|
-
} = (0, _ChartProvider.useChartContext)();
|
|
55
|
-
const results = React.useMemo(() => {
|
|
56
|
-
return data.map(item => {
|
|
57
|
-
return skip ? {} : getInteractionItemProps(instance, item);
|
|
58
|
-
});
|
|
59
|
-
}, [data, instance, skip]);
|
|
60
|
-
return results;
|
|
61
|
-
};
|
|
62
|
-
exports.useInteractionAllItemProps = useInteractionAllItemProps;
|
|
63
51
|
function getInteractionItemProps(instance, item) {
|
|
64
52
|
function onPointerEnter() {
|
|
65
53
|
if (!item) {
|
package/hooks/useLineSeries.js
CHANGED
|
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useLineSeries = useLineSeries;
|
|
8
8
|
exports.useLineSeriesContext = useLineSeriesContext;
|
|
9
|
-
var
|
|
10
|
-
const useSelectorSeries = (0, _createSeriesSelectorOfType.createSeriesSelectorsOfType)('line');
|
|
11
|
-
const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeriesSelectorOfType)('line');
|
|
12
|
-
|
|
9
|
+
var _seriesSelectorOfType = require("../internals/seriesSelectorOfType");
|
|
13
10
|
/**
|
|
14
11
|
* Get access to the internal state of line series.
|
|
15
12
|
*
|
|
@@ -33,7 +30,7 @@ const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeries
|
|
|
33
30
|
*/
|
|
34
31
|
|
|
35
32
|
function useLineSeries(seriesIds) {
|
|
36
|
-
return
|
|
33
|
+
return (0, _seriesSelectorOfType.useSeriesOfType)('line', seriesIds);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
/**
|
|
@@ -45,5 +42,5 @@ function useLineSeries(seriesIds) {
|
|
|
45
42
|
* @returns the line series
|
|
46
43
|
*/
|
|
47
44
|
function useLineSeriesContext() {
|
|
48
|
-
return
|
|
45
|
+
return (0, _seriesSelectorOfType.useAllSeriesOfType)('line');
|
|
49
46
|
}
|
package/hooks/usePieSeries.js
CHANGED
|
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.usePieSeries = usePieSeries;
|
|
8
8
|
exports.usePieSeriesContext = usePieSeriesContext;
|
|
9
|
-
var
|
|
10
|
-
const useSelectorSeries = (0, _createSeriesSelectorOfType.createSeriesSelectorsOfType)('pie');
|
|
11
|
-
const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeriesSelectorOfType)('pie');
|
|
12
|
-
|
|
9
|
+
var _seriesSelectorOfType = require("../internals/seriesSelectorOfType");
|
|
13
10
|
/**
|
|
14
11
|
* Get access to the internal state of pie series.
|
|
15
12
|
*
|
|
@@ -33,7 +30,7 @@ const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeries
|
|
|
33
30
|
*/
|
|
34
31
|
|
|
35
32
|
function usePieSeries(seriesIds) {
|
|
36
|
-
return
|
|
33
|
+
return (0, _seriesSelectorOfType.useSeriesOfType)('pie', seriesIds);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
/**
|
|
@@ -44,5 +41,5 @@ function usePieSeries(seriesIds) {
|
|
|
44
41
|
* @returns the pie series
|
|
45
42
|
*/
|
|
46
43
|
function usePieSeriesContext() {
|
|
47
|
-
return
|
|
44
|
+
return (0, _seriesSelectorOfType.useAllSeriesOfType)('pie');
|
|
48
45
|
}
|
package/hooks/useRadarSeries.js
CHANGED
|
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useRadarSeries = useRadarSeries;
|
|
8
8
|
exports.useRadarSeriesContext = useRadarSeriesContext;
|
|
9
|
-
var
|
|
10
|
-
const useSelectorSeries = (0, _createSeriesSelectorOfType.createSeriesSelectorsOfType)('radar');
|
|
11
|
-
const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeriesSelectorOfType)('radar');
|
|
12
|
-
|
|
9
|
+
var _seriesSelectorOfType = require("../internals/seriesSelectorOfType");
|
|
13
10
|
/**
|
|
14
11
|
* Get access to the internal state of radar series.
|
|
15
12
|
*
|
|
@@ -33,7 +30,7 @@ const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeries
|
|
|
33
30
|
*/
|
|
34
31
|
|
|
35
32
|
function useRadarSeries(seriesIds) {
|
|
36
|
-
return
|
|
33
|
+
return (0, _seriesSelectorOfType.useSeriesOfType)('radar', seriesIds);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
/**
|
|
@@ -44,5 +41,5 @@ function useRadarSeries(seriesIds) {
|
|
|
44
41
|
* @returns the radar series
|
|
45
42
|
*/
|
|
46
43
|
function useRadarSeriesContext() {
|
|
47
|
-
return
|
|
44
|
+
return (0, _seriesSelectorOfType.useAllSeriesOfType)('radar');
|
|
48
45
|
}
|
|
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useScatterSeries = useScatterSeries;
|
|
8
8
|
exports.useScatterSeriesContext = useScatterSeriesContext;
|
|
9
|
-
var
|
|
10
|
-
const useSelectorSeries = (0, _createSeriesSelectorOfType.createSeriesSelectorsOfType)('scatter');
|
|
11
|
-
const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeriesSelectorOfType)('scatter');
|
|
12
|
-
|
|
9
|
+
var _seriesSelectorOfType = require("../internals/seriesSelectorOfType");
|
|
13
10
|
/**
|
|
14
11
|
* Get access to the internal state of scatter series.
|
|
15
12
|
*
|
|
@@ -33,7 +30,7 @@ const useSelectorSeriesContext = (0, _createSeriesSelectorOfType.createAllSeries
|
|
|
33
30
|
*/
|
|
34
31
|
|
|
35
32
|
function useScatterSeries(seriesIds) {
|
|
36
|
-
return
|
|
33
|
+
return (0, _seriesSelectorOfType.useSeriesOfType)('scatter', seriesIds);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
/**
|
|
@@ -44,5 +41,5 @@ function useScatterSeries(seriesIds) {
|
|
|
44
41
|
* @returns the scatter series
|
|
45
42
|
*/
|
|
46
43
|
function useScatterSeriesContext() {
|
|
47
|
-
return
|
|
44
|
+
return (0, _seriesSelectorOfType.useAllSeriesOfType)('scatter');
|
|
48
45
|
}
|
package/hooks/useTicks.js
CHANGED
|
@@ -17,6 +17,9 @@ const offsetRatio = {
|
|
|
17
17
|
end: 1,
|
|
18
18
|
middle: 0.5
|
|
19
19
|
};
|
|
20
|
+
function getTickPosition(scale, value, placement) {
|
|
21
|
+
return scale(value) - (scale.step() - scale.bandwidth()) / 2 + offsetRatio[placement] * scale.step();
|
|
22
|
+
}
|
|
20
23
|
function getTicks(options) {
|
|
21
24
|
const {
|
|
22
25
|
scale,
|
|
@@ -35,7 +38,13 @@ function getTicks(options) {
|
|
|
35
38
|
if (scale.bandwidth() > 0) {
|
|
36
39
|
// scale type = 'band'
|
|
37
40
|
const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
|
|
38
|
-
|
|
41
|
+
const isReversed = scale.range()[0] > scale.range()[1];
|
|
42
|
+
// Indexes are inclusive regarding the entire band.
|
|
43
|
+
const startIndex = filteredDomain.findIndex(value => {
|
|
44
|
+
return isInside(getTickPosition(scale, value, isReversed ? 'start' : 'end'));
|
|
45
|
+
});
|
|
46
|
+
const endIndex = filteredDomain.findLastIndex(value => isInside(getTickPosition(scale, value, isReversed ? 'end' : 'start')));
|
|
47
|
+
return [...filteredDomain.slice(startIndex, endIndex + 1).map(value => {
|
|
39
48
|
const defaultTickLabel = `${value}`;
|
|
40
49
|
return {
|
|
41
50
|
value,
|
|
@@ -45,10 +54,10 @@ function getTicks(options) {
|
|
|
45
54
|
tickNumber,
|
|
46
55
|
defaultTickLabel
|
|
47
56
|
}) ?? defaultTickLabel,
|
|
48
|
-
offset:
|
|
57
|
+
offset: getTickPosition(scale, value, tickPlacement),
|
|
49
58
|
labelOffset: tickLabelPlacement === 'tick' ? 0 : scale.step() * (offsetRatio[tickLabelPlacement] - offsetRatio[tickPlacement])
|
|
50
59
|
};
|
|
51
|
-
}), ...(tickPlacement === 'extremities' ? [{
|
|
60
|
+
}), ...(tickPlacement === 'extremities' && endIndex === domain.length - 1 && isInside(scale.range()[1]) ? [{
|
|
52
61
|
formattedValue: undefined,
|
|
53
62
|
offset: scale.range()[1],
|
|
54
63
|
labelOffset: 0
|
package/index.d.ts
CHANGED
|
@@ -29,4 +29,5 @@ export type { ChartContainerProps } from "./ChartContainer/index.js";
|
|
|
29
29
|
export * from "./ChartDataProvider/index.js";
|
|
30
30
|
export * from "./Toolbar/index.js";
|
|
31
31
|
export * from "./ChartsWrapper/index.js";
|
|
32
|
-
export * from "./ChartsBrushOverlay/index.js";
|
|
32
|
+
export * from "./ChartsBrushOverlay/index.js";
|
|
33
|
+
export * from "./utils/index.js";
|