@mui/x-charts 8.14.0 → 8.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +8 -0
- package/BarChart/BarChart.plugins.d.ts +2 -1
- package/BarChart/BarChart.plugins.js +2 -1
- package/BarChart/useBarChartProps.js +4 -2
- package/BarChart/useBarPlotData.js +20 -33
- package/CHANGELOG.md +202 -0
- package/ChartContainer/ChartContainer.js +8 -0
- package/ChartContainer/useChartContainerProps.js +4 -2
- package/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +9 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
- package/ChartsBrushOverlay/ChartsBrushOverlay.js +102 -0
- package/ChartsBrushOverlay/index.d.ts +4 -0
- package/ChartsBrushOverlay/index.js +19 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.js +13 -8
- package/ChartsReferenceLine/ChartsYReferenceLine.js +13 -8
- package/ChartsReferenceLine/common.d.ts +3 -1
- package/ChartsReferenceLine/common.js +3 -1
- package/ChartsTooltip/ChartsTooltipContainer.js +20 -2
- package/ChartsXAxis/getVisibleLabels.js +45 -25
- package/Gauge/Gauge.js +2 -9
- package/Gauge/GaugeReferenceArc.d.ts +4 -1
- package/Gauge/GaugeReferenceArc.js +12 -3
- package/Gauge/GaugeValueArc.d.ts +4 -1
- package/Gauge/GaugeValueArc.js +16 -8
- package/Gauge/GaugeValueText.js +3 -1
- package/LineChart/LineChart.js +8 -0
- package/LineChart/LineChart.plugins.d.ts +2 -1
- package/LineChart/LineChart.plugins.js +2 -1
- package/LineChart/useLineChartProps.js +4 -2
- package/ScatterChart/ScatterChart.js +8 -0
- package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
- package/ScatterChart/ScatterChart.plugins.js +2 -1
- package/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
- package/ScatterChart/useScatterChartProps.js +5 -3
- package/SparkLineChart/SparkLineChart.js +8 -0
- package/esm/BarChart/BarChart.js +8 -0
- package/esm/BarChart/BarChart.plugins.d.ts +2 -1
- package/esm/BarChart/BarChart.plugins.js +2 -1
- package/esm/BarChart/useBarChartProps.js +4 -2
- package/esm/BarChart/useBarPlotData.js +20 -33
- package/esm/ChartContainer/ChartContainer.js +8 -0
- package/esm/ChartContainer/useChartContainerProps.js +4 -2
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +2 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +95 -0
- package/esm/ChartsBrushOverlay/index.d.ts +4 -0
- package/esm/ChartsBrushOverlay/index.js +2 -0
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +14 -9
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +14 -9
- package/esm/ChartsReferenceLine/common.d.ts +3 -1
- package/esm/ChartsReferenceLine/common.js +2 -0
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +20 -2
- package/esm/ChartsXAxis/getVisibleLabels.js +45 -25
- package/esm/Gauge/Gauge.js +2 -9
- package/esm/Gauge/GaugeReferenceArc.d.ts +4 -1
- package/esm/Gauge/GaugeReferenceArc.js +11 -2
- package/esm/Gauge/GaugeValueArc.d.ts +4 -1
- package/esm/Gauge/GaugeValueArc.js +16 -8
- package/esm/Gauge/GaugeValueText.js +3 -1
- package/esm/LineChart/LineChart.js +8 -0
- package/esm/LineChart/LineChart.plugins.d.ts +2 -1
- package/esm/LineChart/LineChart.plugins.js +2 -1
- package/esm/LineChart/useLineChartProps.js +4 -2
- package/esm/ScatterChart/ScatterChart.js +8 -0
- package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
- package/esm/ScatterChart/ScatterChart.plugins.js +2 -1
- package/esm/ScatterChart/seriesConfig/seriesProcessor.js +1 -1
- package/esm/ScatterChart/useScatterChartProps.js +5 -3
- package/esm/SparkLineChart/SparkLineChart.js +8 -0
- package/esm/hooks/index.d.ts +2 -1
- package/esm/hooks/index.js +2 -1
- package/esm/hooks/useBrush.d.ts +18 -0
- package/esm/hooks/useBrush.js +16 -0
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/internals/Flatbush.d.ts +63 -0
- package/esm/internals/Flatbush.js +468 -0
- package/esm/internals/domUtils.d.ts +9 -4
- package/esm/internals/domUtils.js +115 -52
- package/esm/internals/index.d.ts +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/internals/plugins/allPlugins.d.ts +4 -3
- package/esm/internals/plugins/allPlugins.js +2 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +16 -10
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/index.js +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +109 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +75 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +72 -0
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.js +1 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +19 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +41 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +33 -0
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +40 -81
- package/esm/internals/plugins/utils/selectors.d.ts +1 -1
- package/esm/locales/elGR.js +97 -99
- package/esm/models/seriesType/scatter.d.ts +2 -0
- package/esm/tests/constants.js +1 -0
- package/esm/themeAugmentation/components.d.ts +3 -0
- package/esm/themeAugmentation/overrides.d.ts +2 -0
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +12 -0
- package/hooks/useBrush.d.ts +18 -0
- package/hooks/useBrush.js +21 -0
- package/index.d.ts +2 -1
- package/index.js +13 -1
- package/internals/Flatbush.d.ts +63 -0
- package/internals/Flatbush.js +477 -0
- package/internals/domUtils.d.ts +9 -4
- package/internals/domUtils.js +119 -54
- package/internals/index.d.ts +1 -0
- package/internals/index.js +12 -0
- package/internals/plugins/allPlugins.d.ts +4 -3
- package/internals/plugins/allPlugins.js +2 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +16 -10
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartBrush/index.js +38 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +117 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +82 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +72 -0
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.js +5 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.d.ts +6 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js +3 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +19 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +43 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +4 -1
- package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.d.ts +5 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/findClosestPoints.js +39 -0
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +39 -80
- package/internals/plugins/utils/selectors.d.ts +1 -1
- package/locales/elGR.js +97 -99
- package/models/seriesType/scatter.d.ts +2 -0
- package/package.json +5 -4
- package/tests/constants.js +7 -0
- package/themeAugmentation/components.d.ts +3 -0
- package/themeAugmentation/overrides.d.ts +2 -0
|
@@ -1,60 +1,58 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
// DOM utils
|
|
2
|
+
// DOM utils adapted from
|
|
3
3
|
// https://github.com/recharts/recharts/blob/master/src/util/DOMUtils.ts
|
|
4
4
|
|
|
5
5
|
function isSsr() {
|
|
6
6
|
return typeof window === 'undefined';
|
|
7
7
|
}
|
|
8
8
|
const stringCache = new Map();
|
|
9
|
+
export function clearStringMeasurementCache() {
|
|
10
|
+
stringCache.clear();
|
|
11
|
+
}
|
|
9
12
|
const MAX_CACHE_NUM = 2000;
|
|
10
|
-
const
|
|
11
|
-
position: 'absolute',
|
|
12
|
-
top: '-20000px',
|
|
13
|
-
left: 0,
|
|
14
|
-
padding: 0,
|
|
15
|
-
margin: 0,
|
|
16
|
-
border: 'none',
|
|
17
|
-
whiteSpace: 'pre'
|
|
18
|
-
};
|
|
19
|
-
const STYLE_LIST = ['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom'];
|
|
20
|
-
export const MEASUREMENT_SPAN_ID = 'mui_measurement_span';
|
|
13
|
+
const PIXEL_STYLES = new Set(['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom']);
|
|
21
14
|
|
|
22
15
|
/**
|
|
23
|
-
*
|
|
16
|
+
* Convert number value to pixel value for certain CSS properties
|
|
24
17
|
* @param name CSS property name
|
|
25
18
|
* @param value
|
|
26
19
|
* @returns add 'px' for distance properties
|
|
27
20
|
*/
|
|
28
|
-
function
|
|
29
|
-
if (
|
|
21
|
+
function convertPixelValue(name, value) {
|
|
22
|
+
if (PIXEL_STYLES.has(name) && value === +value) {
|
|
30
23
|
return `${value}px`;
|
|
31
24
|
}
|
|
32
25
|
return value;
|
|
33
26
|
}
|
|
34
27
|
|
|
35
28
|
/**
|
|
36
|
-
*
|
|
29
|
+
* Converts camelcase to dash-case
|
|
37
30
|
* @param text camelcase css property
|
|
38
|
-
* @returns css property
|
|
39
31
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (entry === entry.toUpperCase()) {
|
|
44
|
-
return [...result, '-', entry.toLowerCase()];
|
|
45
|
-
}
|
|
46
|
-
return [...result, entry];
|
|
47
|
-
}, []);
|
|
48
|
-
return formatStrs.join('');
|
|
32
|
+
const AZ = /([A-Z])/g;
|
|
33
|
+
function camelCaseToDashCase(text) {
|
|
34
|
+
return String(text).replace(AZ, match => `-${match.toLowerCase()}`);
|
|
49
35
|
}
|
|
50
36
|
|
|
51
37
|
/**
|
|
52
|
-
*
|
|
38
|
+
* Converts a style object into a string to be used as a cache key
|
|
53
39
|
* @param style React style object
|
|
54
40
|
* @returns CSS styling string
|
|
55
41
|
*/
|
|
56
|
-
export
|
|
57
|
-
let
|
|
42
|
+
export function getStyleString(style) {
|
|
43
|
+
let result = '';
|
|
44
|
+
for (const key in style) {
|
|
45
|
+
if (Object.hasOwn(style, key)) {
|
|
46
|
+
const k = key;
|
|
47
|
+
const value = style[k];
|
|
48
|
+
if (value === undefined) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
result += `${camelCaseToDashCase(k)}:${convertPixelValue(k, value)};`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
58
56
|
|
|
59
57
|
/**
|
|
60
58
|
*
|
|
@@ -69,7 +67,7 @@ export const getStringSize = (text, style = {}) => {
|
|
|
69
67
|
height: 0
|
|
70
68
|
};
|
|
71
69
|
}
|
|
72
|
-
const str =
|
|
70
|
+
const str = String(text);
|
|
73
71
|
const styleString = getStyleString(style);
|
|
74
72
|
const cacheKey = `${str}-${styleString}`;
|
|
75
73
|
const size = stringCache.get(cacheKey);
|
|
@@ -77,22 +75,18 @@ export const getStringSize = (text, style = {}) => {
|
|
|
77
75
|
return size;
|
|
78
76
|
}
|
|
79
77
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
measurementSpan.setAttribute('id', MEASUREMENT_SPAN_ID);
|
|
84
|
-
measurementSpan.setAttribute('aria-hidden', 'true');
|
|
85
|
-
document.body.appendChild(measurementSpan);
|
|
86
|
-
}
|
|
78
|
+
const measurementSpanContainer = getMeasurementContainer();
|
|
79
|
+
const measurementElem = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
80
|
+
|
|
87
81
|
// Need to use CSS Object Model (CSSOM) to be able to comply with Content Security Policy (CSP)
|
|
88
82
|
// https://en.wikipedia.org/wiki/Content_Security_Policy
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
measurementSpan.style[camelToMiddleLine(styleKey)] = autoCompleteStyle(styleKey, measurementSpanStyle[styleKey]);
|
|
83
|
+
Object.keys(style).map(styleKey => {
|
|
84
|
+
measurementElem.style[camelCaseToDashCase(styleKey)] = convertPixelValue(styleKey, style[styleKey]);
|
|
92
85
|
return styleKey;
|
|
93
86
|
});
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
measurementElem.textContent = str;
|
|
88
|
+
measurementSpanContainer.replaceChildren(measurementElem);
|
|
89
|
+
const rect = measurementElem.getBoundingClientRect();
|
|
96
90
|
const result = {
|
|
97
91
|
width: rect.width,
|
|
98
92
|
height: rect.height
|
|
@@ -103,15 +97,7 @@ export const getStringSize = (text, style = {}) => {
|
|
|
103
97
|
}
|
|
104
98
|
if (process.env.NODE_ENV === 'test') {
|
|
105
99
|
// In test environment, we clean the measurement span immediately
|
|
106
|
-
|
|
107
|
-
} else {
|
|
108
|
-
if (domCleanTimeout) {
|
|
109
|
-
clearTimeout(domCleanTimeout);
|
|
110
|
-
}
|
|
111
|
-
domCleanTimeout = setTimeout(() => {
|
|
112
|
-
// Limit node cleaning to once per render cycle
|
|
113
|
-
measurementSpan.textContent = '';
|
|
114
|
-
}, 0);
|
|
100
|
+
measurementSpanContainer.replaceChildren();
|
|
115
101
|
}
|
|
116
102
|
return result;
|
|
117
103
|
} catch {
|
|
@@ -120,4 +106,81 @@ export const getStringSize = (text, style = {}) => {
|
|
|
120
106
|
height: 0
|
|
121
107
|
};
|
|
122
108
|
}
|
|
123
|
-
};
|
|
109
|
+
};
|
|
110
|
+
export function batchMeasureStrings(texts, style = {}) {
|
|
111
|
+
if (isSsr()) {
|
|
112
|
+
return new Map(Array.from(texts).map(text => [text, {
|
|
113
|
+
width: 0,
|
|
114
|
+
height: 0
|
|
115
|
+
}]));
|
|
116
|
+
}
|
|
117
|
+
const sizeMap = new Map();
|
|
118
|
+
const textToMeasure = [];
|
|
119
|
+
const styleString = getStyleString(style);
|
|
120
|
+
for (const text of texts) {
|
|
121
|
+
const cacheKey = `${text}-${styleString}`;
|
|
122
|
+
const size = stringCache.get(cacheKey);
|
|
123
|
+
if (size) {
|
|
124
|
+
sizeMap.set(text, size);
|
|
125
|
+
} else {
|
|
126
|
+
textToMeasure.push(text);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const measurementContainer = getMeasurementContainer();
|
|
130
|
+
// Need to use CSS Object Model (CSSOM) to be able to comply with Content Security Policy (CSP)
|
|
131
|
+
// https://en.wikipedia.org/wiki/Content_Security_Policy
|
|
132
|
+
const measurementSpanStyle = _extends({}, style);
|
|
133
|
+
Object.keys(measurementSpanStyle).map(styleKey => {
|
|
134
|
+
measurementContainer.style[camelCaseToDashCase(styleKey)] = convertPixelValue(styleKey, measurementSpanStyle[styleKey]);
|
|
135
|
+
return styleKey;
|
|
136
|
+
});
|
|
137
|
+
const measurementElems = [];
|
|
138
|
+
for (const string of textToMeasure) {
|
|
139
|
+
const measurementElem = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
140
|
+
measurementElem.textContent = `${string}`;
|
|
141
|
+
measurementElems.push(measurementElem);
|
|
142
|
+
}
|
|
143
|
+
measurementContainer.replaceChildren(...measurementElems);
|
|
144
|
+
for (let i = 0; i < textToMeasure.length; i += 1) {
|
|
145
|
+
const text = textToMeasure[i];
|
|
146
|
+
const measurementSpan = measurementContainer.children[i];
|
|
147
|
+
const rect = measurementSpan.getBoundingClientRect();
|
|
148
|
+
const result = {
|
|
149
|
+
width: rect.width,
|
|
150
|
+
height: rect.height
|
|
151
|
+
};
|
|
152
|
+
const cacheKey = `${text}-${styleString}`;
|
|
153
|
+
stringCache.set(cacheKey, result);
|
|
154
|
+
sizeMap.set(text, result);
|
|
155
|
+
}
|
|
156
|
+
if (stringCache.size + 1 > MAX_CACHE_NUM) {
|
|
157
|
+
stringCache.clear();
|
|
158
|
+
}
|
|
159
|
+
if (process.env.NODE_ENV === 'test') {
|
|
160
|
+
// In test environment, we clean the measurement span immediately
|
|
161
|
+
measurementContainer.replaceChildren();
|
|
162
|
+
}
|
|
163
|
+
return sizeMap;
|
|
164
|
+
}
|
|
165
|
+
let measurementContainer = null;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Get (or create) a hidden span element to measure text size.
|
|
169
|
+
*/
|
|
170
|
+
function getMeasurementContainer() {
|
|
171
|
+
if (measurementContainer === null) {
|
|
172
|
+
measurementContainer = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
173
|
+
measurementContainer.setAttribute('aria-hidden', 'true');
|
|
174
|
+
measurementContainer.style.position = 'absolute';
|
|
175
|
+
measurementContainer.style.top = '-20000px';
|
|
176
|
+
measurementContainer.style.left = '0';
|
|
177
|
+
measurementContainer.style.padding = '0';
|
|
178
|
+
measurementContainer.style.margin = '0';
|
|
179
|
+
measurementContainer.style.border = 'none';
|
|
180
|
+
measurementContainer.style.pointerEvents = 'none';
|
|
181
|
+
measurementContainer.style.visibility = 'hidden';
|
|
182
|
+
measurementContainer.style.contain = 'strict';
|
|
183
|
+
document.body.appendChild(measurementContainer);
|
|
184
|
+
}
|
|
185
|
+
return measurementContainer;
|
|
186
|
+
}
|
package/esm/internals/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
|
27
27
|
export * from "./plugins/featurePlugins/useChartHighlight/index.js";
|
|
28
28
|
export * from "./plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
29
29
|
export * from "./plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
30
|
+
export * from "./plugins/featurePlugins/useChartBrush/index.js";
|
|
30
31
|
export * from "./plugins/utils/selectors.js";
|
|
31
32
|
export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
|
|
32
33
|
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
package/esm/internals/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./plugins/featurePlugins/useChartInteraction/index.js";
|
|
|
32
32
|
export * from "./plugins/featurePlugins/useChartHighlight/index.js";
|
|
33
33
|
export * from "./plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
34
34
|
export * from "./plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
35
|
+
export * from "./plugins/featurePlugins/useChartBrush/index.js";
|
|
35
36
|
export * from "./plugins/utils/selectors.js";
|
|
36
37
|
export { getAxisTriggerTooltip as getCartesianAxisTriggerTooltip } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisTriggerTooltip.js";
|
|
37
38
|
export { getAxisIndex as getCartesianAxisIndex } from "./plugins/featurePlugins/useChartCartesianAxis/getAxisValue.js";
|
|
@@ -6,6 +6,7 @@ import { UseChartKeyboardNavigationSignature } from "./featurePlugins/useChartKe
|
|
|
6
6
|
import { UseChartPolarAxisSignature } from "./featurePlugins/useChartPolarAxis/index.js";
|
|
7
7
|
import { UseChartClosestPointSignature } from "./featurePlugins/useChartClosestPoint/index.js";
|
|
8
8
|
import { UseChartZAxisSignature } from "./featurePlugins/useChartZAxis/index.js";
|
|
9
|
-
|
|
10
|
-
export type
|
|
11
|
-
export
|
|
9
|
+
import { UseChartBrushSignature } from "./featurePlugins/useChartBrush/index.js";
|
|
10
|
+
export type AllPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<TSeries>, UseChartPolarAxisSignature, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
11
|
+
export type DefaultPluginSignatures<TSeries extends ChartSeriesType = ChartSeriesType> = [UseChartZAxisSignature, UseChartBrushSignature, UseChartCartesianAxisSignature<TSeries>, UseChartInteractionSignature, UseChartHighlightSignature, UseChartClosestPointSignature, UseChartKeyboardNavigationSignature];
|
|
12
|
+
export declare const DEFAULT_PLUGINS: readonly [import("./models/index.js").ChartPlugin<UseChartZAxisSignature>, import("./models/index.js").ChartPlugin<UseChartBrushSignature>, import("./models/index.js").ChartPlugin<UseChartCartesianAxisSignature<any>>, import("./models/index.js").ChartPlugin<UseChartInteractionSignature>, import("./models/index.js").ChartPlugin<UseChartHighlightSignature>, import("./models/index.js").ChartPlugin<UseChartClosestPointSignature>, import("./models/index.js").ChartPlugin<UseChartKeyboardNavigationSignature>];
|
|
@@ -6,4 +6,5 @@ import { useChartInteraction } from "./featurePlugins/useChartInteraction/index.
|
|
|
6
6
|
import { useChartKeyboardNavigation } from "./featurePlugins/useChartKeyboardNavigation/index.js";
|
|
7
7
|
import { useChartClosestPoint } from "./featurePlugins/useChartClosestPoint/index.js";
|
|
8
8
|
import { useChartZAxis } from "./featurePlugins/useChartZAxis/index.js";
|
|
9
|
-
|
|
9
|
+
import { useChartBrush } from "./featurePlugins/useChartBrush/index.js";
|
|
10
|
+
export const DEFAULT_PLUGINS = [useChartZAxis, useChartBrush, useChartCartesianAxis, useChartInteraction, useChartHighlight, useChartClosestPoint, useChartKeyboardNavigation];
|
package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js
CHANGED
|
@@ -18,14 +18,26 @@ export const useChartInteractionListener = ({
|
|
|
18
18
|
name: 'pan',
|
|
19
19
|
threshold: 0,
|
|
20
20
|
maxPointers: 1
|
|
21
|
+
}), new MoveGesture({
|
|
22
|
+
name: 'move',
|
|
23
|
+
preventIf: ['pan', 'zoomPinch', 'zoomPan']
|
|
24
|
+
}), new TapGesture({
|
|
25
|
+
name: 'tap',
|
|
26
|
+
preventIf: ['pan', 'zoomPinch', 'zoomPan']
|
|
27
|
+
}), new PressGesture({
|
|
28
|
+
name: 'quickPress',
|
|
29
|
+
duration: 50
|
|
21
30
|
}), new PanGesture({
|
|
31
|
+
name: 'brush',
|
|
32
|
+
threshold: 0,
|
|
33
|
+
maxPointers: 1
|
|
34
|
+
}),
|
|
35
|
+
// Zoom gestures
|
|
36
|
+
new PanGesture({
|
|
22
37
|
name: 'zoomPan',
|
|
23
38
|
threshold: 0,
|
|
24
39
|
maxPointers: 1,
|
|
25
40
|
preventIf: ['zoomTapAndDrag', 'zoomPressAndDrag']
|
|
26
|
-
}), new MoveGesture({
|
|
27
|
-
name: 'move',
|
|
28
|
-
preventIf: ['pan', 'zoomPinch', 'zoomPan'] // Prevent move gesture when pan is active
|
|
29
41
|
}), new PinchGesture({
|
|
30
42
|
name: 'zoomPinch',
|
|
31
43
|
threshold: 5,
|
|
@@ -34,12 +46,6 @@ export const useChartInteractionListener = ({
|
|
|
34
46
|
name: 'zoomTurnWheel',
|
|
35
47
|
sensitivity: 0.01,
|
|
36
48
|
initialDelta: 1
|
|
37
|
-
}), new TapGesture({
|
|
38
|
-
name: 'tap',
|
|
39
|
-
preventIf: ['pan', 'zoomPan', 'zoomPinch']
|
|
40
|
-
}), new PressGesture({
|
|
41
|
-
name: 'quickPress',
|
|
42
|
-
duration: 50
|
|
43
49
|
}), new TapAndDragGesture({
|
|
44
50
|
name: 'zoomTapAndDrag',
|
|
45
51
|
dragThreshold: 10
|
|
@@ -56,7 +62,7 @@ export const useChartInteractionListener = ({
|
|
|
56
62
|
if (!svg || !gestureManager) {
|
|
57
63
|
return undefined;
|
|
58
64
|
}
|
|
59
|
-
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag'], svg);
|
|
65
|
+
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag', 'brush'], svg);
|
|
60
66
|
return () => {
|
|
61
67
|
// Cleanup gesture manager
|
|
62
68
|
gestureManager.unregisterAllGestures(svg);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type PressAndDragEvent, type PressAndDragGestureOptions, type TapAndDragEvent, type TapAndDragGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
|
|
2
2
|
import { ChartPluginSignature } from "../../models/index.js";
|
|
3
|
-
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd';
|
|
3
|
+
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd';
|
|
4
4
|
export type InteractionListenerResult = {
|
|
5
5
|
cleanup: () => void;
|
|
6
6
|
};
|
|
7
7
|
export type AddInteractionListener = {
|
|
8
|
-
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
8
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
9
9
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd', callback: (event: PinchEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
10
10
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTurnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
11
11
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'move' | 'moveStart' | 'moveEnd', callback: (event: MoveEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import useEventCallback from '@mui/utils/useEventCallback';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
|
+
import { getSVGPoint } from "../../../getSVGPoint.js";
|
|
8
|
+
export const useChartBrush = ({
|
|
9
|
+
store,
|
|
10
|
+
svgRef,
|
|
11
|
+
instance,
|
|
12
|
+
params
|
|
13
|
+
}) => {
|
|
14
|
+
useEnhancedEffect(() => {
|
|
15
|
+
store.update(prev => {
|
|
16
|
+
return _extends({}, prev, {
|
|
17
|
+
brush: _extends({}, prev.brush, {
|
|
18
|
+
enabled: params.brushConfig.enabled,
|
|
19
|
+
preventTooltip: params.brushConfig.preventTooltip,
|
|
20
|
+
preventHighlight: params.brushConfig.preventHighlight
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}, [store, params.brushConfig.enabled, params.brushConfig.preventTooltip, params.brushConfig.preventHighlight]);
|
|
25
|
+
const setBrushCoordinates = useEventCallback(function setBrushCoordinates(point) {
|
|
26
|
+
store.update(prev => {
|
|
27
|
+
return _extends({}, prev, {
|
|
28
|
+
brush: _extends({}, prev.brush, {
|
|
29
|
+
start: prev.brush.start ?? point,
|
|
30
|
+
current: point
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
const clearBrush = useEventCallback(function clearBrush() {
|
|
36
|
+
store.update(prev => {
|
|
37
|
+
return _extends({}, prev, {
|
|
38
|
+
brush: _extends({}, prev.brush, {
|
|
39
|
+
start: null,
|
|
40
|
+
current: null
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
const element = svgRef.current;
|
|
47
|
+
if (element === null || !store.getSnapshot().brush.enabled) {
|
|
48
|
+
return () => {};
|
|
49
|
+
}
|
|
50
|
+
const handleBrushStart = event => {
|
|
51
|
+
if (event.detail.target?.closest('[data-charts-zoom-slider]')) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const point = getSVGPoint(element, {
|
|
55
|
+
clientX: event.detail.initialCentroid.x,
|
|
56
|
+
clientY: event.detail.initialCentroid.y
|
|
57
|
+
});
|
|
58
|
+
setBrushCoordinates(point);
|
|
59
|
+
};
|
|
60
|
+
const handleBrush = event => {
|
|
61
|
+
const currentPoint = getSVGPoint(element, {
|
|
62
|
+
clientX: event.detail.centroid.x,
|
|
63
|
+
clientY: event.detail.centroid.y
|
|
64
|
+
});
|
|
65
|
+
setBrushCoordinates(currentPoint);
|
|
66
|
+
};
|
|
67
|
+
const brushStartHandler = instance.addInteractionListener('brushStart', handleBrushStart);
|
|
68
|
+
const brushHandler = instance.addInteractionListener('brush', handleBrush);
|
|
69
|
+
const brushCancelHandler = instance.addInteractionListener('brushCancel', clearBrush);
|
|
70
|
+
const brushEndHandler = instance.addInteractionListener('brushEnd', clearBrush);
|
|
71
|
+
return () => {
|
|
72
|
+
brushStartHandler.cleanup();
|
|
73
|
+
brushHandler.cleanup();
|
|
74
|
+
brushEndHandler.cleanup();
|
|
75
|
+
brushCancelHandler.cleanup();
|
|
76
|
+
};
|
|
77
|
+
}, [svgRef, instance, store, clearBrush, setBrushCoordinates]);
|
|
78
|
+
return {
|
|
79
|
+
instance: {
|
|
80
|
+
setBrushCoordinates,
|
|
81
|
+
clearBrush
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
useChartBrush.params = {
|
|
86
|
+
brushConfig: true
|
|
87
|
+
};
|
|
88
|
+
useChartBrush.getDefaultizedParams = ({
|
|
89
|
+
params
|
|
90
|
+
}) => {
|
|
91
|
+
return _extends({}, params, {
|
|
92
|
+
brushConfig: {
|
|
93
|
+
enabled: params?.brushConfig?.enabled ?? false,
|
|
94
|
+
preventTooltip: params?.brushConfig?.preventTooltip ?? true,
|
|
95
|
+
preventHighlight: params?.brushConfig?.preventHighlight ?? true
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
useChartBrush.getInitialState = params => {
|
|
100
|
+
return {
|
|
101
|
+
brush: {
|
|
102
|
+
enabled: params.brushConfig.enabled,
|
|
103
|
+
preventTooltip: params.brushConfig.preventTooltip,
|
|
104
|
+
preventHighlight: params.brushConfig.preventHighlight,
|
|
105
|
+
start: null,
|
|
106
|
+
current: null
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type ChartOptionalRootSelector } from "../../utils/selectors.js";
|
|
2
|
+
import type { UseChartBrushSignature } from "./useChartBrush.types.js";
|
|
3
|
+
export declare const selectorBrush: ChartOptionalRootSelector<UseChartBrushSignature>;
|
|
4
|
+
export declare const selectorBrushStart: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
5
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
6
|
+
} & {
|
|
7
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
8
|
+
}, import("./useChartBrush.types.js").Point | null | undefined, any[]>;
|
|
9
|
+
export declare const selectorBrushCurrent: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
10
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
11
|
+
} & {
|
|
12
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
13
|
+
}, import("./useChartBrush.types.js").Point | null | undefined, any[]>;
|
|
14
|
+
export declare const selectorBrushStartX: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
15
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
16
|
+
} & {
|
|
17
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
18
|
+
}, number | null, any[]>;
|
|
19
|
+
export declare const selectorBrushStartY: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
20
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
21
|
+
} & {
|
|
22
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
23
|
+
}, number | null, any[]>;
|
|
24
|
+
export declare const selectorBrushCurrentX: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
25
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
26
|
+
} & {
|
|
27
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
28
|
+
}, number | null, any[]>;
|
|
29
|
+
export declare const selectorBrushCurrentY: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
30
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
31
|
+
} & {
|
|
32
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
33
|
+
}, number | null, any[]>;
|
|
34
|
+
export declare const selectorBrushState: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
35
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
36
|
+
} & {
|
|
37
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
38
|
+
}, {
|
|
39
|
+
start: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
current: {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
};
|
|
47
|
+
} | null, any[]>;
|
|
48
|
+
export declare const selectorBrushConfigNoZoom: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
49
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
50
|
+
} & {
|
|
51
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
52
|
+
}, "x" | "y" | "xy", any[]>;
|
|
53
|
+
export declare const selectorBrushConfigZoom: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("../useChartCartesianAxis/index.js").UseChartCartesianAxisState> & {
|
|
54
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
55
|
+
} & {
|
|
56
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
57
|
+
}, "x" | "y" | "xy" | null, []>;
|
|
58
|
+
export declare const selectorBrushConfig: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
59
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
60
|
+
} & {
|
|
61
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
62
|
+
} & Partial<import("../useChartCartesianAxis/index.js").UseChartCartesianAxisState>, "x" | "y" | "xy", any[]>;
|
|
63
|
+
export declare const selectorIsBrushEnabled: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
64
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
65
|
+
} & {
|
|
66
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
67
|
+
}, boolean | undefined, any[]>;
|
|
68
|
+
export declare const selectorIsBrushSelectionActive: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
69
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
70
|
+
} & {
|
|
71
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
72
|
+
}, boolean | undefined, any[]>;
|
|
73
|
+
export declare const selectorBrushShouldPreventAxisHighlight: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
74
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
75
|
+
} & {
|
|
76
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
77
|
+
}, boolean | undefined, any[]>;
|
|
78
|
+
export declare const selectorBrushShouldPreventTooltip: import("reselect").Selector<import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
79
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
80
|
+
} & {
|
|
81
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
82
|
+
}, boolean | undefined, any[]>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createSelector } from "../../utils/selectors.js";
|
|
2
|
+
import { selectorChartZoomOptionsLookup } from "../useChartCartesianAxis/index.js";
|
|
3
|
+
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
export const selectorBrush = state => state.brush;
|
|
5
|
+
export const selectorBrushStart = createSelector([selectorBrush], brush => brush?.start);
|
|
6
|
+
export const selectorBrushCurrent = createSelector([selectorBrush], brush => brush?.current);
|
|
7
|
+
export const selectorBrushStartX = createSelector([selectorBrush], brush => brush?.start?.x ?? null);
|
|
8
|
+
export const selectorBrushStartY = createSelector([selectorBrush], brush => brush?.start?.y ?? null);
|
|
9
|
+
export const selectorBrushCurrentX = createSelector([selectorBrush], brush => brush?.current?.x ?? null);
|
|
10
|
+
export const selectorBrushCurrentY = createSelector([selectorBrush], brush => brush?.current?.y ?? null);
|
|
11
|
+
export const selectorBrushState = createSelector([selectorBrushStartX, selectorBrushStartY, selectorBrushCurrentX, selectorBrushCurrentY], (startX, startY, currentX, currentY) => {
|
|
12
|
+
if (startX === null || startY === null || currentX === null || currentY === null) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
start: {
|
|
17
|
+
x: startX,
|
|
18
|
+
y: startY
|
|
19
|
+
},
|
|
20
|
+
current: {
|
|
21
|
+
x: currentX,
|
|
22
|
+
y: currentY
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
export const selectorBrushConfigNoZoom = createSelector([selectorChartSeriesProcessed], series => {
|
|
27
|
+
let hasHorizontal = false;
|
|
28
|
+
let isBothDirections = false;
|
|
29
|
+
if (series) {
|
|
30
|
+
Object.entries(series).forEach(([seriesType, seriesData]) => {
|
|
31
|
+
if (Object.values(seriesData.series).some(s => s.layout === 'horizontal')) {
|
|
32
|
+
hasHorizontal = true;
|
|
33
|
+
}
|
|
34
|
+
if (seriesType === 'scatter' && seriesData.seriesOrder.length > 0) {
|
|
35
|
+
isBothDirections = true;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (isBothDirections) {
|
|
40
|
+
return 'xy';
|
|
41
|
+
}
|
|
42
|
+
if (hasHorizontal) {
|
|
43
|
+
return 'y';
|
|
44
|
+
}
|
|
45
|
+
return 'x';
|
|
46
|
+
});
|
|
47
|
+
export const selectorBrushConfigZoom = createSelector([selectorChartZoomOptionsLookup], optionsLookup => {
|
|
48
|
+
let hasX = false;
|
|
49
|
+
let hasY = false;
|
|
50
|
+
Object.values(optionsLookup).forEach(options => {
|
|
51
|
+
if (options.axisDirection === 'y') {
|
|
52
|
+
hasY = true;
|
|
53
|
+
}
|
|
54
|
+
if (options.axisDirection === 'x') {
|
|
55
|
+
hasX = true;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
if (hasX && hasY) {
|
|
59
|
+
return 'xy';
|
|
60
|
+
}
|
|
61
|
+
if (hasY) {
|
|
62
|
+
return 'y';
|
|
63
|
+
}
|
|
64
|
+
if (hasX) {
|
|
65
|
+
return 'x';
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
});
|
|
69
|
+
export const selectorBrushConfig = createSelector([selectorBrushConfigNoZoom, selectorBrushConfigZoom], (configNoZoom, configZoom) => configZoom ?? configNoZoom);
|
|
70
|
+
export const selectorIsBrushEnabled = createSelector([selectorBrush], brush => brush?.enabled);
|
|
71
|
+
export const selectorIsBrushSelectionActive = createSelector([selectorBrush], brush => {
|
|
72
|
+
return brush?.enabled && brush?.start !== null && brush?.current !== null;
|
|
73
|
+
});
|
|
74
|
+
export const selectorBrushShouldPreventAxisHighlight = createSelector([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventHighlight);
|
|
75
|
+
export const selectorBrushShouldPreventTooltip = createSelector([selectorBrush, selectorIsBrushSelectionActive], (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventTooltip);
|