@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
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v8.
|
|
2
|
+
* @mui/x-charts v8.20.0
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -379,4 +379,16 @@ Object.keys(_ChartsBrushOverlay).forEach(function (key) {
|
|
|
379
379
|
return _ChartsBrushOverlay[key];
|
|
380
380
|
}
|
|
381
381
|
});
|
|
382
|
+
});
|
|
383
|
+
var _utils = require("./utils");
|
|
384
|
+
Object.keys(_utils).forEach(function (key) {
|
|
385
|
+
if (key === "default" || key === "__esModule") return;
|
|
386
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
387
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
388
|
+
Object.defineProperty(exports, key, {
|
|
389
|
+
enumerable: true,
|
|
390
|
+
get: function () {
|
|
391
|
+
return _utils[key];
|
|
392
|
+
}
|
|
393
|
+
});
|
|
382
394
|
});
|
package/internals/domUtils.js
CHANGED
|
@@ -96,11 +96,7 @@ const getStringSize = (text, style = {}) => {
|
|
|
96
96
|
});
|
|
97
97
|
measurementElem.textContent = str;
|
|
98
98
|
measurementSpanContainer.replaceChildren(measurementElem);
|
|
99
|
-
const
|
|
100
|
-
const result = {
|
|
101
|
-
width: rect.width,
|
|
102
|
-
height: rect.height
|
|
103
|
-
};
|
|
99
|
+
const result = measureSVGTextElement(measurementElem);
|
|
104
100
|
stringCache.set(cacheKey, result);
|
|
105
101
|
if (stringCache.size + 1 > MAX_CACHE_NUM) {
|
|
106
102
|
stringCache.clear();
|
|
@@ -145,21 +141,17 @@ function batchMeasureStrings(texts, style = {}) {
|
|
|
145
141
|
measurementContainer.style[camelCaseToDashCase(styleKey)] = convertPixelValue(styleKey, measurementSpanStyle[styleKey]);
|
|
146
142
|
return styleKey;
|
|
147
143
|
});
|
|
148
|
-
const
|
|
144
|
+
const measurementElements = [];
|
|
149
145
|
for (const string of textToMeasure) {
|
|
150
146
|
const measurementElem = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
151
147
|
measurementElem.textContent = `${string}`;
|
|
152
|
-
|
|
148
|
+
measurementElements.push(measurementElem);
|
|
153
149
|
}
|
|
154
|
-
measurementContainer.replaceChildren(...
|
|
150
|
+
measurementContainer.replaceChildren(...measurementElements);
|
|
155
151
|
for (let i = 0; i < textToMeasure.length; i += 1) {
|
|
156
152
|
const text = textToMeasure[i];
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
const result = {
|
|
160
|
-
width: rect.width,
|
|
161
|
-
height: rect.height
|
|
162
|
-
};
|
|
153
|
+
const measurementElem = measurementContainer.children[i];
|
|
154
|
+
const result = measureSVGTextElement(measurementElem);
|
|
163
155
|
const cacheKey = `${text}-${styleString}`;
|
|
164
156
|
stringCache.set(cacheKey, result);
|
|
165
157
|
sizeMap.set(text, result);
|
|
@@ -173,6 +165,30 @@ function batchMeasureStrings(texts, style = {}) {
|
|
|
173
165
|
}
|
|
174
166
|
return sizeMap;
|
|
175
167
|
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Measures an SVG text element using getBBox() with fallback to getBoundingClientRect()
|
|
171
|
+
* @param element SVG text element to measure
|
|
172
|
+
* @returns width and height of the text element
|
|
173
|
+
*/
|
|
174
|
+
function measureSVGTextElement(element) {
|
|
175
|
+
// getBBox() is more reliable across browsers for SVG elements
|
|
176
|
+
try {
|
|
177
|
+
const result = element.getBBox();
|
|
178
|
+
return {
|
|
179
|
+
width: result.width,
|
|
180
|
+
height: result.height
|
|
181
|
+
};
|
|
182
|
+
} catch {
|
|
183
|
+
// Fallback to getBoundingClientRect if getBBox fails
|
|
184
|
+
// This can happen in tests
|
|
185
|
+
const result = element.getBoundingClientRect();
|
|
186
|
+
return {
|
|
187
|
+
width: result.width,
|
|
188
|
+
height: result.height
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
176
192
|
let measurementContainer = null;
|
|
177
193
|
|
|
178
194
|
/**
|
package/internals/getScale.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { NumberValue } from '@mui/x-charts-vendor/d3-scale';
|
|
1
2
|
import { ContinuousScaleName, D3ContinuousScale } from "../models/axis.js";
|
|
2
|
-
export declare function getScale(scaleType: ContinuousScaleName, domain:
|
|
3
|
+
export declare function getScale<Domain extends NumberValue = any, Range = any>(scaleType: ContinuousScaleName, domain: Iterable<Domain>, range: readonly Range[]): D3ContinuousScale<Range, Range>;
|
package/internals/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { useBarPlotData } from "../BarChart/useBarPlotData.js";
|
|
|
15
15
|
export { useRadarChartProps } from "../RadarChart/useRadarChartProps.js";
|
|
16
16
|
export * from "../ChartContainer/useChartContainerProps.js";
|
|
17
17
|
export * from "../ChartDataProvider/useChartDataProviderProps.js";
|
|
18
|
-
export * from "./
|
|
18
|
+
export * from "./seriesSelectorOfType.js";
|
|
19
19
|
export * from "./plugins/corePlugins/useChartId/index.js";
|
|
20
20
|
export * from "./plugins/corePlugins/useChartSeries/index.js";
|
|
21
21
|
export * from "./plugins/corePlugins/useChartDimensions/index.js";
|
package/internals/index.js
CHANGED
|
@@ -182,15 +182,15 @@ Object.keys(_useChartDataProviderProps).forEach(function (key) {
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
|
-
var
|
|
186
|
-
Object.keys(
|
|
185
|
+
var _seriesSelectorOfType = require("./seriesSelectorOfType");
|
|
186
|
+
Object.keys(_seriesSelectorOfType).forEach(function (key) {
|
|
187
187
|
if (key === "default" || key === "__esModule") return;
|
|
188
188
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
189
|
-
if (key in exports && exports[key] ===
|
|
189
|
+
if (key in exports && exports[key] === _seriesSelectorOfType[key]) return;
|
|
190
190
|
Object.defineProperty(exports, key, {
|
|
191
191
|
enumerable: true,
|
|
192
192
|
get: function () {
|
|
193
|
-
return
|
|
193
|
+
return _seriesSelectorOfType[key];
|
|
194
194
|
}
|
|
195
195
|
});
|
|
196
196
|
});
|
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.selectorChartSkipAnimation = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _store = require("@mui/x-internals/store");
|
|
8
8
|
const selectorChartAnimationState = state => state.animation;
|
|
9
|
-
const selectorChartSkipAnimation = exports.selectorChartSkipAnimation = (0,
|
|
9
|
+
const selectorChartSkipAnimation = exports.selectorChartSkipAnimation = (0, _store.createSelector)(selectorChartAnimationState, state => state.skip || state.skipAnimationRequests > 0);
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.selectorChartSvgWidth = exports.selectorChartSvgHeight = exports.selectorChartPropsWidth = exports.selectorChartPropsHeight = exports.selectorChartMargin = exports.selectorChartDrawingArea = exports.selectorChartDimensionsState = void 0;
|
|
7
7
|
var _store = require("@mui/x-internals/store");
|
|
8
|
-
var _selectors = require("../../utils/selectors");
|
|
9
8
|
var _useChartAxisSize = require("../../featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors");
|
|
10
9
|
const selectorChartDimensionsState = state => state.dimensions;
|
|
11
10
|
exports.selectorChartDimensionsState = selectorChartDimensionsState;
|
|
@@ -34,7 +33,7 @@ const selectorChartDrawingArea = exports.selectorChartDrawingArea = (0, _store.c
|
|
|
34
33
|
bottom: marginBottom + axisSizeBottom
|
|
35
34
|
};
|
|
36
35
|
});
|
|
37
|
-
const selectorChartSvgWidth = exports.selectorChartSvgWidth = (0,
|
|
38
|
-
const selectorChartSvgHeight = exports.selectorChartSvgHeight = (0,
|
|
39
|
-
const selectorChartPropsWidth = exports.selectorChartPropsWidth = (0,
|
|
40
|
-
const selectorChartPropsHeight = exports.selectorChartPropsHeight = (0,
|
|
36
|
+
const selectorChartSvgWidth = exports.selectorChartSvgWidth = (0, _store.createSelector)(selectorChartDimensionsState, dimensionsState => dimensionsState.width);
|
|
37
|
+
const selectorChartSvgHeight = exports.selectorChartSvgHeight = (0, _store.createSelector)(selectorChartDimensionsState, dimensionsState => dimensionsState.height);
|
|
38
|
+
const selectorChartPropsWidth = exports.selectorChartPropsWidth = (0, _store.createSelector)(selectorChartDimensionsState, dimensionsState => dimensionsState.propsWidth);
|
|
39
|
+
const selectorChartPropsHeight = exports.selectorChartPropsHeight = (0, _store.createSelector)(selectorChartDimensionsState, dimensionsState => dimensionsState.propsHeight);
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.selectorPreferStrictDomainInLineCharts = exports.selectorChartExperimentalFeaturesState = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _store = require("@mui/x-internals/store");
|
|
8
8
|
const selectorChartExperimentalFeaturesState = state => state.experimentalFeatures;
|
|
9
9
|
exports.selectorChartExperimentalFeaturesState = selectorChartExperimentalFeaturesState;
|
|
10
|
-
const selectorPreferStrictDomainInLineCharts = exports.selectorPreferStrictDomainInLineCharts = (0,
|
|
10
|
+
const selectorPreferStrictDomainInLineCharts = exports.selectorPreferStrictDomainInLineCharts = (0, _store.createSelector)(selectorChartExperimentalFeaturesState, features => Boolean(features?.preferStrictDomainInLineCharts));
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.selectorChartId = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _store = require("@mui/x-internals/store");
|
|
8
8
|
const selectorChartIdState = state => state.id;
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -12,4 +12,4 @@ const selectorChartIdState = state => state.id;
|
|
|
12
12
|
* @param {ChartState<[UseChartIdSignature]>} state The state of the chart.
|
|
13
13
|
* @returns {string} The id attribute of the chart.
|
|
14
14
|
*/
|
|
15
|
-
const selectorChartId = exports.selectorChartId = (0,
|
|
15
|
+
const selectorChartId = exports.selectorChartId = (0, _store.createSelector)(selectorChartIdState, idState => idState.chartId);
|
package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js
CHANGED
|
@@ -50,6 +50,9 @@ const useChartInteractionListener = ({
|
|
|
50
50
|
name: 'zoomTurnWheel',
|
|
51
51
|
sensitivity: 0.01,
|
|
52
52
|
initialDelta: 1
|
|
53
|
+
}), new _core.TurnWheelGesture({
|
|
54
|
+
name: 'panTurnWheel',
|
|
55
|
+
sensitivity: 0.5
|
|
53
56
|
}), new _core.TapAndDragGesture({
|
|
54
57
|
name: 'zoomTapAndDrag',
|
|
55
58
|
dragThreshold: 10
|
|
@@ -69,7 +72,7 @@ const useChartInteractionListener = ({
|
|
|
69
72
|
if (!svg || !gestureManager) {
|
|
70
73
|
return undefined;
|
|
71
74
|
}
|
|
72
|
-
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag', 'zoomDoubleTapReset', 'brush'], svg);
|
|
75
|
+
gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'panTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag', 'zoomPressAndDrag', 'zoomDoubleTapReset', 'brush'], svg);
|
|
73
76
|
return () => {
|
|
74
77
|
// Cleanup gesture manager
|
|
75
78
|
gestureManager.unregisterAllGestures(svg);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type PressAndDragEvent, type PressAndDragGestureOptions, type TapAndDragEvent, type TapAndDragGestureOptions, type TapGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
|
|
2
2
|
import { ChartPluginSignature } from "../../models/index.js";
|
|
3
|
-
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd' | 'zoomDoubleTapReset' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd';
|
|
3
|
+
export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'zoomTurnWheel' | 'panTurnWheel' | 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd' | 'zoomPressAndDrag' | 'zoomPressAndDragStart' | 'zoomPressAndDragEnd' | 'move' | 'moveStart' | 'moveEnd' | 'tap' | 'quickPress' | 'quickPressEnd' | 'zoomDoubleTapReset' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd';
|
|
4
4
|
export type InteractionListenerResult = {
|
|
5
5
|
cleanup: () => void;
|
|
6
6
|
};
|
|
@@ -8,6 +8,7 @@ export type AddInteractionListener = {
|
|
|
8
8
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'brush' | 'brushStart' | 'brushCancel' | 'brushEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
9
9
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd', callback: (event: PinchEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
10
10
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTurnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
11
|
+
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'panTurnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
11
12
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'move' | 'moveStart' | 'moveEnd', callback: (event: MoveEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
12
13
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'tap' | 'zoomDoubleTapReset', callback: (event: TapEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
13
14
|
<CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'quickPress' | 'quickPressEnd', callback: (event: PressEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
|
|
@@ -18,6 +19,7 @@ export type UpdateZoomInteractionListeners = {
|
|
|
18
19
|
(interaction: 'zoomPan', options?: Omit<PanGestureOptions<'zoomPan'>, 'name'>): void;
|
|
19
20
|
(interaction: 'zoomPinch', options?: Omit<PinchGestureOptions<'zoomPinch'>, 'name'>): void;
|
|
20
21
|
(interaction: 'zoomTurnWheel', options?: Omit<TurnWheelGestureOptions<'zoomTurnWheel'>, 'name'>): void;
|
|
22
|
+
(interaction: 'panTurnWheel', options?: Omit<TurnWheelGestureOptions<'panTurnWheel'>, 'name'>): void;
|
|
21
23
|
(interaction: 'zoomTapAndDrag', options?: Omit<TapAndDragGestureOptions<'zoomTapAndDrag'>, 'name'>): void;
|
|
22
24
|
(interaction: 'zoomPressAndDrag', options?: Omit<PressAndDragGestureOptions<'zoomPressAndDrag'>, 'name'>): void;
|
|
23
25
|
(interaction: 'zoomDoubleTapReset', options?: Omit<TapGestureOptions<'zoomDoubleTapReset'>, 'name'>): void;
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { AllSeriesType } from "../../../../models/seriesType/index.js";
|
|
2
2
|
import { ChartSeriesType, DatasetType } from "../../../../models/seriesType/config.js";
|
|
3
3
|
import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { DefaultizedSeriesGroups, ProcessedSeries } from "./useChartSeries.types.js";
|
|
5
5
|
/**
|
|
6
|
-
* This
|
|
7
|
-
*
|
|
8
|
-
* It also add defaultized values such as the ids, colors
|
|
6
|
+
* This method groups series by type and adds defaultized values such as the ids and colors.
|
|
7
|
+
* It does NOT apply the series processors - that happens in a selector.
|
|
9
8
|
* @param series The array of series provided by the developer
|
|
10
9
|
* @param colors The color palette used to defaultize series colors
|
|
11
|
-
* @returns An object structuring all the series by type.
|
|
10
|
+
* @returns An object structuring all the series by type with default values.
|
|
12
11
|
*/
|
|
13
|
-
export declare const
|
|
12
|
+
export declare const defaultizeSeries: <TSeriesType extends ChartSeriesType>({
|
|
14
13
|
series,
|
|
15
14
|
colors,
|
|
16
|
-
seriesConfig
|
|
17
|
-
dataset
|
|
15
|
+
seriesConfig
|
|
18
16
|
}: {
|
|
19
17
|
series: Readonly<AllSeriesType<TSeriesType>[]>;
|
|
20
18
|
colors: readonly string[];
|
|
21
19
|
seriesConfig: ChartSeriesConfig<TSeriesType>;
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
}) => DefaultizedSeriesGroups<TSeriesType>;
|
|
21
|
+
/**
|
|
22
|
+
* Applies series processors to the defaultized series groups.
|
|
23
|
+
* This should be called in a selector to compute processed series on-demand.
|
|
24
|
+
* @param defaultizedSeries The defaultized series groups
|
|
25
|
+
* @param seriesConfig The series configuration
|
|
26
|
+
* @param dataset The optional dataset
|
|
27
|
+
* @returns Processed series with all transformations applied
|
|
28
|
+
*/
|
|
29
|
+
export declare const applySeriesProcessors: <TSeriesType extends ChartSeriesType>(defaultizedSeries: DefaultizedSeriesGroups<TSeriesType>, seriesConfig: ChartSeriesConfig<TSeriesType>, dataset?: Readonly<DatasetType>) => ProcessedSeries<TSeriesType>;
|
|
@@ -3,26 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.defaultizeSeries = exports.applySeriesProcessors = void 0;
|
|
7
7
|
/**
|
|
8
|
-
* This
|
|
9
|
-
*
|
|
10
|
-
* It also add defaultized values such as the ids, colors
|
|
8
|
+
* This method groups series by type and adds defaultized values such as the ids and colors.
|
|
9
|
+
* It does NOT apply the series processors - that happens in a selector.
|
|
11
10
|
* @param series The array of series provided by the developer
|
|
12
11
|
* @param colors The color palette used to defaultize series colors
|
|
13
|
-
* @returns An object structuring all the series by type.
|
|
12
|
+
* @returns An object structuring all the series by type with default values.
|
|
14
13
|
*/
|
|
15
|
-
const
|
|
14
|
+
const defaultizeSeries = ({
|
|
16
15
|
series,
|
|
17
16
|
colors,
|
|
18
|
-
seriesConfig
|
|
19
|
-
dataset
|
|
17
|
+
seriesConfig
|
|
20
18
|
}) => {
|
|
21
19
|
// Group series by type
|
|
22
20
|
const seriesGroups = {};
|
|
23
|
-
// Notice the line about uses `ChartSeriesType` instead of TSeriesType.
|
|
24
|
-
// That's probably because the series.type is not propagated from the generic but hardcoded in the config.
|
|
25
|
-
|
|
26
21
|
series.forEach((seriesData, seriesIndex) => {
|
|
27
22
|
const seriesWithDefaultValues = seriesConfig[seriesData.type].getSeriesWithDefaultValues(seriesData, seriesIndex, colors);
|
|
28
23
|
const id = seriesWithDefaultValues.id;
|
|
@@ -38,14 +33,28 @@ const preprocessSeries = ({
|
|
|
38
33
|
seriesGroups[seriesData.type].series[id] = seriesWithDefaultValues;
|
|
39
34
|
seriesGroups[seriesData.type].seriesOrder.push(id);
|
|
40
35
|
});
|
|
36
|
+
return seriesGroups;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Applies series processors to the defaultized series groups.
|
|
41
|
+
* This should be called in a selector to compute processed series on-demand.
|
|
42
|
+
* @param defaultizedSeries The defaultized series groups
|
|
43
|
+
* @param seriesConfig The series configuration
|
|
44
|
+
* @param dataset The optional dataset
|
|
45
|
+
* @returns Processed series with all transformations applied
|
|
46
|
+
*/
|
|
47
|
+
exports.defaultizeSeries = defaultizeSeries;
|
|
48
|
+
const applySeriesProcessors = (defaultizedSeries, seriesConfig, dataset) => {
|
|
41
49
|
const processedSeries = {};
|
|
50
|
+
|
|
42
51
|
// Apply formatter on a type group
|
|
43
52
|
Object.keys(seriesConfig).forEach(type => {
|
|
44
|
-
const group =
|
|
53
|
+
const group = defaultizedSeries[type];
|
|
45
54
|
if (group !== undefined) {
|
|
46
|
-
processedSeries[type] = seriesConfig[type]?.seriesProcessor?.(group, dataset) ??
|
|
55
|
+
processedSeries[type] = seriesConfig[type]?.seriesProcessor?.(group, dataset) ?? group;
|
|
47
56
|
}
|
|
48
57
|
});
|
|
49
58
|
return processedSeries;
|
|
50
59
|
};
|
|
51
|
-
exports.
|
|
60
|
+
exports.applySeriesProcessors = applySeriesProcessors;
|
|
@@ -32,11 +32,10 @@ const useChartSeries = ({
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
store.set('series', (0, _extends2.default)({}, store.state.series, {
|
|
35
|
-
|
|
35
|
+
defaultizedSeries: (0, _processSeries.defaultizeSeries)({
|
|
36
36
|
series,
|
|
37
37
|
colors: typeof colors === 'function' ? colors(theme) : colors,
|
|
38
|
-
seriesConfig
|
|
39
|
-
dataset
|
|
38
|
+
seriesConfig
|
|
40
39
|
}),
|
|
41
40
|
dataset
|
|
42
41
|
}));
|
|
@@ -67,11 +66,10 @@ useChartSeries.getInitialState = ({
|
|
|
67
66
|
return {
|
|
68
67
|
series: {
|
|
69
68
|
seriesConfig,
|
|
70
|
-
|
|
69
|
+
defaultizedSeries: (0, _processSeries.defaultizeSeries)({
|
|
71
70
|
series,
|
|
72
71
|
colors: typeof colors === 'function' ? colors(theme) : colors,
|
|
73
|
-
seriesConfig
|
|
74
|
-
dataset
|
|
72
|
+
seriesConfig
|
|
75
73
|
}),
|
|
76
74
|
dataset
|
|
77
75
|
}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { ChartRootSelector } from "../../utils/selectors.js";
|
|
2
2
|
import { UseChartSeriesSignature } from "./useChartSeries.types.js";
|
|
3
3
|
export declare const selectorChartSeriesState: ChartRootSelector<UseChartSeriesSignature>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const selectorChartDefaultizedSeries: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
5
5
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
6
|
-
}) => import("./useChartSeries.types.js").
|
|
6
|
+
}) => import("./useChartSeries.types.js").DefaultizedSeriesGroups<keyof import("../../../index.js").ChartsSeriesConfig>;
|
|
7
7
|
export declare const selectorChartSeriesConfig: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
8
8
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
9
9
|
}) => import("../../models/index.js").ChartSeriesConfig<keyof import("../../../index.js").ChartsSeriesConfig>;
|
|
10
10
|
/**
|
|
11
11
|
* Get the dataset from the series state.
|
|
12
|
-
* @param {ChartState<[UseChartSeriesSignature]>} state The state of the chart.
|
|
13
12
|
* @returns {DatasetType | undefined} The dataset.
|
|
14
13
|
*/
|
|
15
14
|
export declare const selectorChartDataset: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
16
15
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
17
|
-
}) => readonly import("../../../index.js").DatasetElementType<
|
|
16
|
+
}) => readonly import("../../../index.js").DatasetElementType<unknown>[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get the processed series after applying series processors.
|
|
19
|
+
* This selector computes the processed series on-demand from the defaultized series.
|
|
20
|
+
* @returns {ProcessedSeries} The processed series.
|
|
21
|
+
*/
|
|
22
|
+
export declare const selectorChartSeriesProcessed: (args_0: import("../useChartId/useChartId.types.js").UseChartIdState & import("../useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../useChartInteractionListener/index.js").UseChartInteractionListenerState & Partial<{}> & {
|
|
23
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
24
|
+
}) => import("./useChartSeries.types.js").ProcessedSeries<keyof import("../../../index.js").ChartsSeriesConfig>;
|
|
@@ -3,16 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectorChartSeriesState = exports.selectorChartSeriesProcessed = exports.selectorChartSeriesConfig = exports.selectorChartDataset = void 0;
|
|
7
|
-
var
|
|
6
|
+
exports.selectorChartSeriesState = exports.selectorChartSeriesProcessed = exports.selectorChartSeriesConfig = exports.selectorChartDefaultizedSeries = exports.selectorChartDataset = void 0;
|
|
7
|
+
var _store = require("@mui/x-internals/store");
|
|
8
|
+
var _processSeries = require("./processSeries");
|
|
8
9
|
const selectorChartSeriesState = state => state.series;
|
|
9
10
|
exports.selectorChartSeriesState = selectorChartSeriesState;
|
|
10
|
-
const
|
|
11
|
-
const selectorChartSeriesConfig = exports.selectorChartSeriesConfig = (0,
|
|
11
|
+
const selectorChartDefaultizedSeries = exports.selectorChartDefaultizedSeries = (0, _store.createSelector)(selectorChartSeriesState, seriesState => seriesState.defaultizedSeries);
|
|
12
|
+
const selectorChartSeriesConfig = exports.selectorChartSeriesConfig = (0, _store.createSelector)(selectorChartSeriesState, seriesState => seriesState.seriesConfig);
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Get the dataset from the series state.
|
|
15
|
-
* @param {ChartState<[UseChartSeriesSignature]>} state The state of the chart.
|
|
16
16
|
* @returns {DatasetType | undefined} The dataset.
|
|
17
17
|
*/
|
|
18
|
-
const selectorChartDataset = exports.selectorChartDataset = (0,
|
|
18
|
+
const selectorChartDataset = exports.selectorChartDataset = (0, _store.createSelector)(selectorChartSeriesState, seriesState => seriesState.dataset);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the processed series after applying series processors.
|
|
22
|
+
* This selector computes the processed series on-demand from the defaultized series.
|
|
23
|
+
* @returns {ProcessedSeries} The processed series.
|
|
24
|
+
*/
|
|
25
|
+
const selectorChartSeriesProcessed = exports.selectorChartSeriesProcessed = (0, _store.createSelectorMemoized)(selectorChartDefaultizedSeries, selectorChartSeriesConfig, selectorChartDataset, function selectorChartSeriesProcessed(defaultizedSeries, seriesConfig, dataset) {
|
|
26
|
+
return (0, _processSeries.applySeriesProcessors)(defaultizedSeries, seriesConfig, dataset);
|
|
27
|
+
});
|
|
@@ -2,7 +2,7 @@ import { AllSeriesType } from "../../../../models/seriesType/index.js";
|
|
|
2
2
|
import { ChartsColorPalette } from "../../../../colorPalettes/index.js";
|
|
3
3
|
import { ChartPluginSignature, ChartSeriesConfig } from "../../models/index.js";
|
|
4
4
|
import { ChartSeriesType, DatasetType } from "../../../../models/seriesType/config.js";
|
|
5
|
-
import { SeriesProcessorResult } from "../../models/seriesConfig/seriesProcessor.types.js";
|
|
5
|
+
import { SeriesProcessorParams, SeriesProcessorResult } from "../../models/seriesConfig/seriesProcessor.types.js";
|
|
6
6
|
export interface UseChartSeriesParameters<T extends ChartSeriesType = ChartSeriesType> {
|
|
7
7
|
/**
|
|
8
8
|
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
@@ -36,9 +36,10 @@ export type UseChartSeriesDefaultizedParameters<T extends ChartSeriesType = Char
|
|
|
36
36
|
theme: 'light' | 'dark';
|
|
37
37
|
};
|
|
38
38
|
export type ProcessedSeries<TSeriesTypes extends ChartSeriesType = ChartSeriesType> = { [type in TSeriesTypes]?: SeriesProcessorResult<type> };
|
|
39
|
+
export type DefaultizedSeriesGroups<TSeriesTypes extends ChartSeriesType = ChartSeriesType> = { [type in TSeriesTypes]?: SeriesProcessorParams<type> };
|
|
39
40
|
export interface UseChartSeriesState<T extends ChartSeriesType = ChartSeriesType> {
|
|
40
41
|
series: {
|
|
41
|
-
|
|
42
|
+
defaultizedSeries: DefaultizedSeriesGroups<T>;
|
|
42
43
|
seriesConfig: ChartSeriesConfig<T>;
|
|
43
44
|
dataset?: Readonly<DatasetType>;
|
|
44
45
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChartOptionalRootSelector } from "../../utils/selectors.js";
|
|
2
2
|
import type { UseChartBrushSignature } from "./useChartBrush.types.js";
|
|
3
3
|
export declare const selectorBrush: ChartOptionalRootSelector<UseChartBrushSignature>;
|
|
4
4
|
export declare const selectorBrushStart: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartBrush.types.js").UseChartBrushState> & {
|
|
@@ -4,18 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.selectorIsBrushSelectionActive = exports.selectorIsBrushEnabled = exports.selectorBrushState = exports.selectorBrushStartY = exports.selectorBrushStartX = exports.selectorBrushStart = exports.selectorBrushShouldPreventTooltip = exports.selectorBrushShouldPreventAxisHighlight = exports.selectorBrushCurrentY = exports.selectorBrushCurrentX = exports.selectorBrushCurrent = exports.selectorBrushConfigZoom = exports.selectorBrushConfigNoZoom = exports.selectorBrushConfig = exports.selectorBrush = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _store = require("@mui/x-internals/store");
|
|
8
8
|
var _useChartCartesianAxisRendering = require("../useChartCartesianAxis/useChartCartesianAxisRendering.selectors");
|
|
9
9
|
var _useChartSeries = require("../../corePlugins/useChartSeries");
|
|
10
10
|
const selectorBrush = state => state.brush;
|
|
11
11
|
exports.selectorBrush = selectorBrush;
|
|
12
|
-
const selectorBrushStart = exports.selectorBrushStart = (0,
|
|
13
|
-
const selectorBrushCurrent = exports.selectorBrushCurrent = (0,
|
|
14
|
-
const selectorBrushStartX = exports.selectorBrushStartX = (0,
|
|
15
|
-
const selectorBrushStartY = exports.selectorBrushStartY = (0,
|
|
16
|
-
const selectorBrushCurrentX = exports.selectorBrushCurrentX = (0,
|
|
17
|
-
const selectorBrushCurrentY = exports.selectorBrushCurrentY = (0,
|
|
18
|
-
const selectorBrushState = exports.selectorBrushState = (0,
|
|
12
|
+
const selectorBrushStart = exports.selectorBrushStart = (0, _store.createSelector)(selectorBrush, brush => brush?.start);
|
|
13
|
+
const selectorBrushCurrent = exports.selectorBrushCurrent = (0, _store.createSelector)(selectorBrush, brush => brush?.current);
|
|
14
|
+
const selectorBrushStartX = exports.selectorBrushStartX = (0, _store.createSelector)(selectorBrush, brush => brush?.start?.x ?? null);
|
|
15
|
+
const selectorBrushStartY = exports.selectorBrushStartY = (0, _store.createSelector)(selectorBrush, brush => brush?.start?.y ?? null);
|
|
16
|
+
const selectorBrushCurrentX = exports.selectorBrushCurrentX = (0, _store.createSelector)(selectorBrush, brush => brush?.current?.x ?? null);
|
|
17
|
+
const selectorBrushCurrentY = exports.selectorBrushCurrentY = (0, _store.createSelector)(selectorBrush, brush => brush?.current?.y ?? null);
|
|
18
|
+
const selectorBrushState = exports.selectorBrushState = (0, _store.createSelector)(selectorBrushStartX, selectorBrushStartY, selectorBrushCurrentX, selectorBrushCurrentY, (startX, startY, currentX, currentY) => {
|
|
19
19
|
if (startX === null || startY === null || currentX === null || currentY === null) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
@@ -30,7 +30,7 @@ const selectorBrushState = exports.selectorBrushState = (0, _selectors.createSel
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
|
-
const selectorBrushConfigNoZoom = exports.selectorBrushConfigNoZoom = (0,
|
|
33
|
+
const selectorBrushConfigNoZoom = exports.selectorBrushConfigNoZoom = (0, _store.createSelector)(_useChartSeries.selectorChartSeriesProcessed, series => {
|
|
34
34
|
let hasHorizontal = false;
|
|
35
35
|
let isBothDirections = false;
|
|
36
36
|
if (series) {
|
|
@@ -51,7 +51,7 @@ const selectorBrushConfigNoZoom = exports.selectorBrushConfigNoZoom = (0, _selec
|
|
|
51
51
|
}
|
|
52
52
|
return 'x';
|
|
53
53
|
});
|
|
54
|
-
const selectorBrushConfigZoom = exports.selectorBrushConfigZoom = (0,
|
|
54
|
+
const selectorBrushConfigZoom = exports.selectorBrushConfigZoom = (0, _store.createSelector)(_useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, function selectorBrushConfigZoom(optionsLookup) {
|
|
55
55
|
let hasX = false;
|
|
56
56
|
let hasY = false;
|
|
57
57
|
Object.values(optionsLookup).forEach(options => {
|
|
@@ -73,10 +73,10 @@ const selectorBrushConfigZoom = exports.selectorBrushConfigZoom = (0, _selectors
|
|
|
73
73
|
}
|
|
74
74
|
return null;
|
|
75
75
|
});
|
|
76
|
-
const selectorBrushConfig = exports.selectorBrushConfig = (0,
|
|
77
|
-
const selectorIsBrushEnabled = exports.selectorIsBrushEnabled = (0,
|
|
78
|
-
const selectorIsBrushSelectionActive = exports.selectorIsBrushSelectionActive = (0,
|
|
76
|
+
const selectorBrushConfig = exports.selectorBrushConfig = (0, _store.createSelector)(selectorBrushConfigNoZoom, selectorBrushConfigZoom, (configNoZoom, configZoom) => configZoom ?? configNoZoom);
|
|
77
|
+
const selectorIsBrushEnabled = exports.selectorIsBrushEnabled = (0, _store.createSelector)(selectorBrush, brush => brush?.enabled || brush?.isZoomBrushEnabled);
|
|
78
|
+
const selectorIsBrushSelectionActive = exports.selectorIsBrushSelectionActive = (0, _store.createSelector)(selectorIsBrushEnabled, selectorBrush, (isBrushEnabled, brush) => {
|
|
79
79
|
return isBrushEnabled && brush?.start !== null && brush?.current !== null;
|
|
80
80
|
});
|
|
81
|
-
const selectorBrushShouldPreventAxisHighlight = exports.selectorBrushShouldPreventAxisHighlight = (0,
|
|
82
|
-
const selectorBrushShouldPreventTooltip = exports.selectorBrushShouldPreventTooltip = (0,
|
|
81
|
+
const selectorBrushShouldPreventAxisHighlight = exports.selectorBrushShouldPreventAxisHighlight = (0, _store.createSelector)(selectorBrush, selectorIsBrushSelectionActive, (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventHighlight);
|
|
82
|
+
const selectorBrushShouldPreventTooltip = exports.selectorBrushShouldPreventTooltip = (0, _store.createSelector)(selectorBrush, selectorIsBrushSelectionActive, (brush, isBrushSelectionActive) => isBrushSelectionActive && brush?.preventTooltip);
|
package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slid
|
|
|
72
72
|
}
|
|
73
73
|
export interface UseChartCartesianAxisState {
|
|
74
74
|
/**
|
|
75
|
-
* @ignore - state populated by the
|
|
75
|
+
* @ignore - state populated by the useChartProZoom plugin
|
|
76
76
|
*/
|
|
77
77
|
zoom?: {
|
|
78
78
|
isInteracting: boolean;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.selectorChartPreviewYScales = exports.selectorChartPreviewXScales = exports.selectorChartPreviewComputedYAxis = exports.selectorChartPreviewComputedXAxis = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _store = require("@mui/x-internals/store");
|
|
8
8
|
var _useChartCartesianAxisLayout = require("./useChartCartesianAxisLayout.selectors");
|
|
9
9
|
var _useChartSeries = require("../../corePlugins/useChartSeries");
|
|
10
10
|
var _computeAxisValue = require("./computeAxisValue");
|
|
@@ -31,7 +31,7 @@ function createPreviewDrawingArea(axisDirection, mainChartDrawingArea) {
|
|
|
31
31
|
bottom: mainChartDrawingArea.height
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
const selectorChartPreviewXScales = exports.selectorChartPreviewXScales = (0,
|
|
34
|
+
const selectorChartPreviewXScales = exports.selectorChartPreviewXScales = (0, _store.createSelector)(_useChartCartesianAxisLayout.selectorChartRawXAxis, _useChartDimensions.selectorChartDrawingArea, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartCartesianAxisRendering.selectorChartNormalizedXScales, function selectorChartPreviewXScales(xAxes, chartDrawingArea, zoomOptions, normalizedXScales, axisId) {
|
|
35
35
|
const hasAxis = xAxes?.some(axis => axis.id === axisId);
|
|
36
36
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'x' : 'y', chartDrawingArea);
|
|
37
37
|
const options = zoomOptions[axisId];
|
|
@@ -46,7 +46,7 @@ const selectorChartPreviewXScales = exports.selectorChartPreviewXScales = (0, _s
|
|
|
46
46
|
});
|
|
47
47
|
return scales;
|
|
48
48
|
});
|
|
49
|
-
const selectorChartPreviewComputedXAxis = exports.selectorChartPreviewComputedXAxis = (0,
|
|
49
|
+
const selectorChartPreviewComputedXAxis = exports.selectorChartPreviewComputedXAxis = (0, _store.createSelector)(_useChartSeries.selectorChartSeriesProcessed, _useChartSeries.selectorChartSeriesConfig, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartDimensions.selectorChartDrawingArea, selectorChartPreviewXScales, _useChartCartesianAxisRendering.selectorChartXAxisWithDomains, (formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, {
|
|
50
50
|
axes,
|
|
51
51
|
domains
|
|
52
52
|
}, axisId) => {
|
|
@@ -75,7 +75,7 @@ const selectorChartPreviewComputedXAxis = exports.selectorChartPreviewComputedXA
|
|
|
75
75
|
}
|
|
76
76
|
return computedAxes.axis;
|
|
77
77
|
});
|
|
78
|
-
const selectorChartPreviewYScales = exports.selectorChartPreviewYScales = (0,
|
|
78
|
+
const selectorChartPreviewYScales = exports.selectorChartPreviewYScales = (0, _store.createSelector)(_useChartCartesianAxisLayout.selectorChartRawYAxis, _useChartDimensions.selectorChartDrawingArea, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartCartesianAxisRendering.selectorChartNormalizedYScales, function selectorChartPreviewYScales(yAxes, chartDrawingArea, zoomOptions, normalizedYScales, axisId) {
|
|
79
79
|
const hasAxis = yAxes?.some(axis => axis.id === axisId);
|
|
80
80
|
const drawingArea = createPreviewDrawingArea(hasAxis ? 'y' : 'x', chartDrawingArea);
|
|
81
81
|
const options = zoomOptions[axisId];
|
|
@@ -93,7 +93,7 @@ const selectorChartPreviewYScales = exports.selectorChartPreviewYScales = (0, _s
|
|
|
93
93
|
});
|
|
94
94
|
return scales;
|
|
95
95
|
});
|
|
96
|
-
const selectorChartPreviewComputedYAxis = exports.selectorChartPreviewComputedYAxis = (0,
|
|
96
|
+
const selectorChartPreviewComputedYAxis = exports.selectorChartPreviewComputedYAxis = (0, _store.createSelector)(_useChartSeries.selectorChartSeriesProcessed, _useChartSeries.selectorChartSeriesConfig, _useChartCartesianAxisRendering.selectorChartZoomOptionsLookup, _useChartDimensions.selectorChartDrawingArea, selectorChartPreviewYScales, _useChartCartesianAxisRendering.selectorChartYAxisWithDomains, (formattedSeries, seriesConfig, zoomOptions, chartDrawingArea, scales, {
|
|
97
97
|
axes,
|
|
98
98
|
domains
|
|
99
99
|
}, axisId) => {
|
|
@@ -4,6 +4,9 @@ import { AxisId, D3Scale } from "../../../../models/axis.js";
|
|
|
4
4
|
import { SeriesId } from "../../../../models/seriesType/common.js";
|
|
5
5
|
import { Flatbush } from "../../../Flatbush.js";
|
|
6
6
|
export declare const createZoomMap: (zoom: readonly ZoomData[]) => Map<AxisId, ZoomData>;
|
|
7
|
+
export declare const selectorChartHasZoom: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & {
|
|
8
|
+
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
9
|
+
}) => boolean;
|
|
7
10
|
/**
|
|
8
11
|
* Following selectors are not exported because they exist in the MIT chart only to ba able to reuse the Zoom state from the pro.
|
|
9
12
|
*/
|