@mui/x-charts-premium 9.7.0 → 9.8.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/BarChartPremium/webgl/BarWebGLProgram.d.mts +4 -5
- package/BarChartPremium/webgl/BarWebGLProgram.d.ts +4 -5
- package/BarChartPremium/webgl/BarWebGLProgram.js +24 -65
- package/BarChartPremium/webgl/BarWebGLProgram.mjs +24 -65
- package/BarChartPremium/webgl/shaders.d.mts +1 -1
- package/BarChartPremium/webgl/shaders.d.ts +1 -1
- package/BarChartPremium/webgl/shaders.js +2 -15
- package/BarChartPremium/webgl/shaders.mjs +3 -15
- package/CHANGELOG.md +130 -1
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.js +2 -2
- package/ChartsDataProviderPremium/ChartsDataProviderPremium.mjs +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.js +2 -2
- package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.mjs +2 -2
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.js +2 -2
- package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.mjs +2 -2
- package/HeatmapPremium/webgl/HeatmapWebGLProgram.js +12 -37
- package/HeatmapPremium/webgl/HeatmapWebGLProgram.mjs +12 -37
- package/HeatmapPremium/webgl/shaders.d.mts +3 -3
- package/HeatmapPremium/webgl/shaders.d.ts +3 -3
- package/HeatmapPremium/webgl/shaders.js +12 -15
- package/HeatmapPremium/webgl/shaders.mjs +13 -15
- package/HeatmapPremium/webgl/useHeatmapPlotData.js +3 -8
- package/HeatmapPremium/webgl/useHeatmapPlotData.mjs +3 -8
- package/Map/FocusedMapShape.js +5 -1
- package/Map/FocusedMapShape.mjs +5 -1
- package/Map/MapImagePlot.d.mts +39 -0
- package/Map/MapImagePlot.d.ts +39 -0
- package/Map/MapImagePlot.js +138 -0
- package/Map/MapImagePlot.mjs +132 -0
- package/Map/MapShape.d.mts +1 -1
- package/Map/MapShape.d.ts +1 -1
- package/Map/MapShape.js +6 -6
- package/Map/MapShape.mjs +6 -6
- package/Map/MapShapePlot.d.mts +8 -0
- package/Map/MapShapePlot.d.ts +8 -0
- package/Map/MapShapePlot.js +17 -5
- package/Map/MapShapePlot.mjs +17 -5
- package/Map/index.d.mts +1 -0
- package/Map/index.d.ts +1 -0
- package/Map/index.js +11 -0
- package/Map/index.mjs +1 -0
- package/Map/reprojectEquirectangularImage.d.mts +60 -0
- package/Map/reprojectEquirectangularImage.d.ts +60 -0
- package/Map/reprojectEquirectangularImage.js +116 -0
- package/Map/reprojectEquirectangularImage.mjs +110 -0
- package/Map/seriesConfig/descriptionGetter.js +5 -1
- package/Map/seriesConfig/descriptionGetter.mjs +5 -1
- package/Map/seriesConfig/getColor.js +18 -6
- package/Map/seriesConfig/getColor.mjs +18 -6
- package/Map/seriesConfig/highlight.d.mts +10 -0
- package/Map/seriesConfig/highlight.d.ts +10 -0
- package/Map/seriesConfig/highlight.js +52 -0
- package/Map/seriesConfig/highlight.mjs +45 -0
- package/Map/seriesConfig/identifierCleaner.d.mts +3 -0
- package/Map/seriesConfig/identifierCleaner.d.ts +3 -0
- package/Map/seriesConfig/identifierCleaner.js +14 -0
- package/Map/seriesConfig/identifierCleaner.mjs +8 -0
- package/Map/seriesConfig/identifierSerializer.d.mts +3 -0
- package/Map/seriesConfig/identifierSerializer.d.ts +3 -0
- package/Map/seriesConfig/identifierSerializer.js +12 -0
- package/Map/seriesConfig/identifierSerializer.mjs +6 -0
- package/Map/seriesConfig/index.js +8 -6
- package/Map/seriesConfig/index.mjs +7 -5
- package/Map/seriesConfig/keyboardFocusHandler.d.mts +0 -6
- package/Map/seriesConfig/keyboardFocusHandler.d.ts +0 -6
- package/Map/seriesConfig/keyboardFocusHandler.js +40 -7
- package/Map/seriesConfig/keyboardFocusHandler.mjs +41 -8
- package/Map/seriesConfig/seriesProcessor.js +11 -2
- package/Map/seriesConfig/seriesProcessor.mjs +11 -2
- package/Map/seriesConfig/tooltip.js +8 -4
- package/Map/seriesConfig/tooltip.mjs +8 -4
- package/Map/seriesConfig/tooltipPosition.d.mts +8 -3
- package/Map/seriesConfig/tooltipPosition.d.ts +8 -3
- package/Map/seriesConfig/tooltipPosition.js +21 -27
- package/Map/seriesConfig/tooltipPosition.mjs +22 -27
- package/ScatterChartPremium/webgl/ScatterWebGLProgram.d.mts +0 -2
- package/ScatterChartPremium/webgl/ScatterWebGLProgram.d.ts +0 -2
- package/ScatterChartPremium/webgl/ScatterWebGLProgram.js +23 -81
- package/ScatterChartPremium/webgl/ScatterWebGLProgram.mjs +23 -81
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/createGetVisibleCoordinate.d.mts +14 -0
- package/internals/createGetVisibleCoordinate.d.ts +14 -0
- package/internals/createGetVisibleCoordinate.js +66 -0
- package/internals/createGetVisibleCoordinate.mjs +60 -0
- package/models/seriesType/mapShape.d.mts +2 -1
- package/models/seriesType/mapShape.d.ts +2 -1
- package/package.json +5 -5
- package/utils/webgl/glsl.d.mts +15 -0
- package/utils/webgl/glsl.d.ts +15 -0
- package/utils/webgl/glsl.js +34 -0
- package/utils/webgl/glsl.mjs +28 -0
- package/utils/webgl/instancedAttribute.d.mts +28 -0
- package/utils/webgl/instancedAttribute.d.ts +28 -0
- package/utils/webgl/instancedAttribute.js +57 -0
- package/utils/webgl/instancedAttribute.mjs +50 -0
- package/utils/webgl/utils.d.mts +21 -2
- package/utils/webgl/utils.d.ts +21 -2
- package/utils/webgl/utils.js +44 -8
- package/utils/webgl/utils.mjs +41 -7
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createGetVisibleCoordinate } from "../internals/createGetVisibleCoordinate.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Warps an equirectangular raster so it matches an arbitrary d3-geo `projection`,
|
|
4
|
+
* returning the result as a PNG data URL (or `null` when it cannot be produced).
|
|
5
|
+
*
|
|
6
|
+
* ### Why inverse mapping
|
|
7
|
+
*
|
|
8
|
+
* Forward-projecting each *source* pixel to the screen leaves holes and overlaps,
|
|
9
|
+
* because the mapping is non-linear and area-distorting. Instead we walk every
|
|
10
|
+
* *destination* pixel and pull the color it should show from the source — inverse
|
|
11
|
+
* (destination-to-source) resampling, which fills the output exactly once.
|
|
12
|
+
*
|
|
13
|
+
* ### Algorithm
|
|
14
|
+
*
|
|
15
|
+
* For each destination pixel `(px, py)` of the drawing area:
|
|
16
|
+
*
|
|
17
|
+
* 1. Convert it to SVG coordinates `(left + px, top + py)` and resolve it to a
|
|
18
|
+
* `[lon, lat]` coordinate with {@link createVisibleCoordinate}, which returns
|
|
19
|
+
* `null` for pixels outside the visible map (post-clip and the spherical
|
|
20
|
+
* round-trip), leaving them transparent.
|
|
21
|
+
* 2. Discard coordinates outside `imageBounds` (no source data there).
|
|
22
|
+
* 3. Map `[lon, lat]` to a source pixel with nearest-neighbor sampling (the image
|
|
23
|
+
* being equirectangular, both axes are linear) and copy its RGBA.
|
|
24
|
+
*
|
|
25
|
+
* ### Failure modes
|
|
26
|
+
*
|
|
27
|
+
* Returns `null` when a 2D canvas context is unavailable, or when reading the
|
|
28
|
+
* source pixels throws because a cross-origin image without CORS headers has
|
|
29
|
+
* tainted the canvas.
|
|
30
|
+
*
|
|
31
|
+
* Complexity is `O(width × height)`; callers should treat it as a per-resize
|
|
32
|
+
* computation rather than a per-frame one.
|
|
33
|
+
*/
|
|
34
|
+
export function reprojectEquirectangularImage(params) {
|
|
35
|
+
const {
|
|
36
|
+
image,
|
|
37
|
+
projection,
|
|
38
|
+
area,
|
|
39
|
+
imageBounds
|
|
40
|
+
} = params;
|
|
41
|
+
if (typeof projection.invert !== 'function') {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const getVisibleCoordinate = createGetVisibleCoordinate(projection);
|
|
45
|
+
const {
|
|
46
|
+
left,
|
|
47
|
+
top
|
|
48
|
+
} = area;
|
|
49
|
+
const outWidth = Math.max(1, Math.round(area.width));
|
|
50
|
+
const outHeight = Math.max(1, Math.round(area.height));
|
|
51
|
+
const [[west, south], [east, north]] = imageBounds;
|
|
52
|
+
const source = document.createElement('canvas');
|
|
53
|
+
source.width = image.naturalWidth;
|
|
54
|
+
source.height = image.naturalHeight;
|
|
55
|
+
const sourceCtx = source.getContext('2d');
|
|
56
|
+
const output = document.createElement('canvas');
|
|
57
|
+
output.width = outWidth;
|
|
58
|
+
output.height = outHeight;
|
|
59
|
+
const outputCtx = output.getContext('2d');
|
|
60
|
+
if (!sourceCtx || !outputCtx) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
sourceCtx.drawImage(image, 0, 0);
|
|
64
|
+
let sourcePixels;
|
|
65
|
+
try {
|
|
66
|
+
sourcePixels = sourceCtx.getImageData(0, 0, source.width, source.height);
|
|
67
|
+
} catch {
|
|
68
|
+
// Cross-origin image without CORS taints the canvas: bail out.
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const sourceWidth = source.width;
|
|
72
|
+
const sourceHeight = source.height;
|
|
73
|
+
const target = outputCtx.createImageData(outWidth, outHeight);
|
|
74
|
+
|
|
75
|
+
// `west > east` means the source wraps across the antimeridian (e.g. 170°E..-170°E).
|
|
76
|
+
const lonWraps = east < west;
|
|
77
|
+
const lonSpan = lonWraps ? east - west + 360 : east - west;
|
|
78
|
+
for (let py = 0; py < outHeight; py += 1) {
|
|
79
|
+
for (let px = 0; px < outWidth; px += 1) {
|
|
80
|
+
// 1. Destination pixel -> geographic coordinate, or skip if not on the map.
|
|
81
|
+
const coordinates = getVisibleCoordinate([left + px, top + py]);
|
|
82
|
+
if (!coordinates) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const [lon, lat] = coordinates;
|
|
86
|
+
|
|
87
|
+
// 2. Outside the source image extent: nothing to sample.
|
|
88
|
+
const insideLon = lonWraps ? lon >= west || lon <= east : lon >= west && lon <= east;
|
|
89
|
+
if (!insideLon || lat < south || lat > north) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 3. Geographic coordinate -> source pixel (nearest neighbor). When the
|
|
94
|
+
// bounds wrap, longitudes past the antimeridian are offset by a full turn.
|
|
95
|
+
const lonOffset = lonWraps && lon <= east ? lon - west + 360 : lon - west;
|
|
96
|
+
let sx = Math.floor(lonOffset / lonSpan * sourceWidth);
|
|
97
|
+
let sy = Math.floor((north - lat) / (north - south) * sourceHeight);
|
|
98
|
+
sx = Math.min(Math.max(sx, 0), sourceWidth - 1);
|
|
99
|
+
sy = Math.min(Math.max(sy, 0), sourceHeight - 1);
|
|
100
|
+
const sourceIndex = (sy * sourceWidth + sx) * 4;
|
|
101
|
+
const targetIndex = (py * outWidth + px) * 4;
|
|
102
|
+
target.data[targetIndex] = sourcePixels.data[sourceIndex];
|
|
103
|
+
target.data[targetIndex + 1] = sourcePixels.data[sourceIndex + 1];
|
|
104
|
+
target.data[targetIndex + 2] = sourcePixels.data[sourceIndex + 2];
|
|
105
|
+
target.data[targetIndex + 3] = sourcePixels.data[sourceIndex + 3];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
outputCtx.putImageData(target, 0, 0);
|
|
109
|
+
return output.toDataURL();
|
|
110
|
+
}
|
|
@@ -9,7 +9,11 @@ const descriptionGetter = ({
|
|
|
9
9
|
identifier,
|
|
10
10
|
series
|
|
11
11
|
}) => {
|
|
12
|
-
const
|
|
12
|
+
const itemIndex = series.lookupByName.get(identifier.name);
|
|
13
|
+
if (itemIndex === undefined) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
const item = series.data[itemIndex];
|
|
13
17
|
if (!item) {
|
|
14
18
|
return '';
|
|
15
19
|
}
|
|
@@ -3,7 +3,11 @@ const descriptionGetter = ({
|
|
|
3
3
|
identifier,
|
|
4
4
|
series
|
|
5
5
|
}) => {
|
|
6
|
-
const
|
|
6
|
+
const itemIndex = series.lookupByName.get(identifier.name);
|
|
7
|
+
if (itemIndex === undefined) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
const item = series.data[itemIndex];
|
|
7
11
|
if (!item) {
|
|
8
12
|
return '';
|
|
9
13
|
}
|
|
@@ -7,11 +7,18 @@ exports.default = void 0;
|
|
|
7
7
|
const getColor = (series, _mainAxis, _secondaryAxis, zAxis) => {
|
|
8
8
|
const colorScale = zAxis?.colorScale;
|
|
9
9
|
if (colorScale) {
|
|
10
|
-
return
|
|
11
|
-
if (
|
|
10
|
+
return name => {
|
|
11
|
+
if (name == null) {
|
|
12
|
+
return series.color;
|
|
13
|
+
}
|
|
14
|
+
const itemIndex = series.lookupByName.get(name);
|
|
15
|
+
if (itemIndex === undefined) {
|
|
16
|
+
return series.color;
|
|
17
|
+
}
|
|
18
|
+
const item = series.data[itemIndex];
|
|
19
|
+
if (item === undefined) {
|
|
12
20
|
return series.color;
|
|
13
21
|
}
|
|
14
|
-
const item = series.data[dataIndex];
|
|
15
22
|
if (item.color !== undefined) {
|
|
16
23
|
return item.color;
|
|
17
24
|
}
|
|
@@ -20,11 +27,16 @@ const getColor = (series, _mainAxis, _secondaryAxis, zAxis) => {
|
|
|
20
27
|
return color;
|
|
21
28
|
};
|
|
22
29
|
}
|
|
23
|
-
return
|
|
24
|
-
if (
|
|
30
|
+
return name => {
|
|
31
|
+
if (name == null) {
|
|
32
|
+
return series.color;
|
|
33
|
+
}
|
|
34
|
+
const itemIndex = series.lookupByName.get(name);
|
|
35
|
+
if (itemIndex === undefined) {
|
|
25
36
|
return series.color;
|
|
26
37
|
}
|
|
27
|
-
|
|
38
|
+
const item = series.data[itemIndex];
|
|
39
|
+
return item?.color ?? series.color;
|
|
28
40
|
};
|
|
29
41
|
};
|
|
30
42
|
var _default = exports.default = getColor;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
const getColor = (series, _mainAxis, _secondaryAxis, zAxis) => {
|
|
2
2
|
const colorScale = zAxis?.colorScale;
|
|
3
3
|
if (colorScale) {
|
|
4
|
-
return
|
|
5
|
-
if (
|
|
4
|
+
return name => {
|
|
5
|
+
if (name == null) {
|
|
6
|
+
return series.color;
|
|
7
|
+
}
|
|
8
|
+
const itemIndex = series.lookupByName.get(name);
|
|
9
|
+
if (itemIndex === undefined) {
|
|
10
|
+
return series.color;
|
|
11
|
+
}
|
|
12
|
+
const item = series.data[itemIndex];
|
|
13
|
+
if (item === undefined) {
|
|
6
14
|
return series.color;
|
|
7
15
|
}
|
|
8
|
-
const item = series.data[dataIndex];
|
|
9
16
|
if (item.color !== undefined) {
|
|
10
17
|
return item.color;
|
|
11
18
|
}
|
|
@@ -14,11 +21,16 @@ const getColor = (series, _mainAxis, _secondaryAxis, zAxis) => {
|
|
|
14
21
|
return color;
|
|
15
22
|
};
|
|
16
23
|
}
|
|
17
|
-
return
|
|
18
|
-
if (
|
|
24
|
+
return name => {
|
|
25
|
+
if (name == null) {
|
|
26
|
+
return series.color;
|
|
27
|
+
}
|
|
28
|
+
const itemIndex = series.lookupByName.get(name);
|
|
29
|
+
if (itemIndex === undefined) {
|
|
19
30
|
return series.color;
|
|
20
31
|
}
|
|
21
|
-
|
|
32
|
+
const item = series.data[itemIndex];
|
|
33
|
+
return item?.color ?? series.color;
|
|
22
34
|
};
|
|
23
35
|
};
|
|
24
36
|
export default getColor;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HighlightScope } from '@mui/x-charts/context';
|
|
2
|
+
import type { HighlightItemIdentifier } from '@mui/x-charts/models';
|
|
3
|
+
/**
|
|
4
|
+
* The isHighlighted logic for main charts (those that are identified by an id and a name)
|
|
5
|
+
*/
|
|
6
|
+
export declare function createIsHighlighted(highlightScope: HighlightScope<'mapShape'> | null | undefined, highlightedItem: HighlightItemIdentifier<'mapShape'> | null): (item: HighlightItemIdentifier<"mapShape"> | null) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The isFade logic for main charts (those that are identified by an id and a name)
|
|
9
|
+
*/
|
|
10
|
+
export declare function createIsFaded(highlightScope: HighlightScope<'mapShape'> | null | undefined, highlightedItem: HighlightItemIdentifier<'mapShape'> | null): (item: HighlightItemIdentifier<"mapShape"> | null) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HighlightScope } from '@mui/x-charts/context';
|
|
2
|
+
import type { HighlightItemIdentifier } from '@mui/x-charts/models';
|
|
3
|
+
/**
|
|
4
|
+
* The isHighlighted logic for main charts (those that are identified by an id and a name)
|
|
5
|
+
*/
|
|
6
|
+
export declare function createIsHighlighted(highlightScope: HighlightScope<'mapShape'> | null | undefined, highlightedItem: HighlightItemIdentifier<'mapShape'> | null): (item: HighlightItemIdentifier<"mapShape"> | null) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The isFade logic for main charts (those that are identified by an id and a name)
|
|
9
|
+
*/
|
|
10
|
+
export declare function createIsFaded(highlightScope: HighlightScope<'mapShape'> | null | undefined, highlightedItem: HighlightItemIdentifier<'mapShape'> | null): (item: HighlightItemIdentifier<"mapShape"> | null) => boolean;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createIsFaded = createIsFaded;
|
|
7
|
+
exports.createIsHighlighted = createIsHighlighted;
|
|
8
|
+
function alwaysFalse() {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The isHighlighted logic for main charts (those that are identified by an id and a name)
|
|
14
|
+
*/
|
|
15
|
+
function createIsHighlighted(highlightScope, highlightedItem) {
|
|
16
|
+
if (!highlightScope || !highlightedItem) {
|
|
17
|
+
return alwaysFalse;
|
|
18
|
+
}
|
|
19
|
+
return function isHighlighted(item) {
|
|
20
|
+
if (!item) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (highlightScope.highlight === 'series') {
|
|
24
|
+
return item.seriesId === highlightedItem.seriesId;
|
|
25
|
+
}
|
|
26
|
+
if (highlightScope.highlight === 'item') {
|
|
27
|
+
return item.name === highlightedItem.name && item.seriesId === highlightedItem.seriesId;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The isFade logic for main charts (those that are identified by an id and a name)
|
|
35
|
+
*/
|
|
36
|
+
function createIsFaded(highlightScope, highlightedItem) {
|
|
37
|
+
if (!highlightScope || !highlightedItem) {
|
|
38
|
+
return alwaysFalse;
|
|
39
|
+
}
|
|
40
|
+
return function isFaded(item) {
|
|
41
|
+
if (!item) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
if (highlightScope.fade === 'series') {
|
|
45
|
+
return item.seriesId === highlightedItem.seriesId && item.name !== highlightedItem.name;
|
|
46
|
+
}
|
|
47
|
+
if (highlightScope.fade === 'global') {
|
|
48
|
+
return item.seriesId !== highlightedItem.seriesId || item.name !== highlightedItem.name;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function alwaysFalse() {
|
|
2
|
+
return false;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The isHighlighted logic for main charts (those that are identified by an id and a name)
|
|
7
|
+
*/
|
|
8
|
+
export function createIsHighlighted(highlightScope, highlightedItem) {
|
|
9
|
+
if (!highlightScope || !highlightedItem) {
|
|
10
|
+
return alwaysFalse;
|
|
11
|
+
}
|
|
12
|
+
return function isHighlighted(item) {
|
|
13
|
+
if (!item) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (highlightScope.highlight === 'series') {
|
|
17
|
+
return item.seriesId === highlightedItem.seriesId;
|
|
18
|
+
}
|
|
19
|
+
if (highlightScope.highlight === 'item') {
|
|
20
|
+
return item.name === highlightedItem.name && item.seriesId === highlightedItem.seriesId;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The isFade logic for main charts (those that are identified by an id and a name)
|
|
28
|
+
*/
|
|
29
|
+
export function createIsFaded(highlightScope, highlightedItem) {
|
|
30
|
+
if (!highlightScope || !highlightedItem) {
|
|
31
|
+
return alwaysFalse;
|
|
32
|
+
}
|
|
33
|
+
return function isFaded(item) {
|
|
34
|
+
if (!item) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (highlightScope.fade === 'series') {
|
|
38
|
+
return item.seriesId === highlightedItem.seriesId && item.name !== highlightedItem.name;
|
|
39
|
+
}
|
|
40
|
+
if (highlightScope.fade === 'global') {
|
|
41
|
+
return item.seriesId !== highlightedItem.seriesId || item.name !== highlightedItem.name;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const identifierCleaner = identifier => {
|
|
8
|
+
return {
|
|
9
|
+
type: identifier.type,
|
|
10
|
+
seriesId: identifier.seriesId,
|
|
11
|
+
name: identifier.name
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
var _default = exports.default = identifierCleaner;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _internals = require("@mui/x-charts/internals");
|
|
8
|
+
const identifierSerializer = identifier => {
|
|
9
|
+
const namePart = identifier.name == null ? '' : `(${identifier.name})`;
|
|
10
|
+
return `${(0, _internals.typeSerializer)(identifier.type)}${(0, _internals.seriesIdSerializer)(identifier.seriesId)}Name(${namePart})`;
|
|
11
|
+
};
|
|
12
|
+
var _default = exports.default = identifierSerializer;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { typeSerializer, seriesIdSerializer } from '@mui/x-charts/internals';
|
|
2
|
+
const identifierSerializer = identifier => {
|
|
3
|
+
const namePart = identifier.name == null ? '' : `(${identifier.name})`;
|
|
4
|
+
return `${typeSerializer(identifier.type)}${seriesIdSerializer(identifier.seriesId)}Name(${namePart})`;
|
|
5
|
+
};
|
|
6
|
+
export default identifierSerializer;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.mapShapeSeriesConfig = void 0;
|
|
8
|
-
var _internals = require("@mui/x-charts/internals");
|
|
9
8
|
var _seriesProcessor = _interopRequireDefault(require("./seriesProcessor"));
|
|
10
9
|
var _getColor = _interopRequireDefault(require("./getColor"));
|
|
11
10
|
var _legend = _interopRequireDefault(require("./legend"));
|
|
@@ -14,17 +13,20 @@ var _getSeriesWithDefaultValues = _interopRequireDefault(require("./getSeriesWit
|
|
|
14
13
|
var _descriptionGetter = _interopRequireDefault(require("./descriptionGetter"));
|
|
15
14
|
var _keyboardFocusHandler = _interopRequireDefault(require("./keyboardFocusHandler"));
|
|
16
15
|
var _tooltipPosition = _interopRequireDefault(require("./tooltipPosition"));
|
|
16
|
+
var _identifierSerializer = _interopRequireDefault(require("./identifierSerializer"));
|
|
17
|
+
var _identifierCleaner = _interopRequireDefault(require("./identifierCleaner"));
|
|
18
|
+
var _highlight = require("./highlight");
|
|
17
19
|
const mapShapeSeriesConfig = exports.mapShapeSeriesConfig = {
|
|
18
20
|
seriesProcessor: _seriesProcessor.default,
|
|
19
21
|
colorProcessor: _getColor.default,
|
|
20
22
|
legendGetter: _legend.default,
|
|
21
23
|
tooltipGetter: _tooltip.default,
|
|
22
|
-
|
|
24
|
+
selectorTooltipItemPosition: _tooltipPosition.default,
|
|
23
25
|
getSeriesWithDefaultValues: _getSeriesWithDefaultValues.default,
|
|
24
26
|
keyboardFocusHandler: _keyboardFocusHandler.default,
|
|
25
|
-
identifierSerializer:
|
|
26
|
-
identifierCleaner:
|
|
27
|
+
identifierSerializer: _identifierSerializer.default,
|
|
28
|
+
identifierCleaner: _identifierCleaner.default,
|
|
27
29
|
descriptionGetter: _descriptionGetter.default,
|
|
28
|
-
isHighlightedCreator:
|
|
29
|
-
isFadedCreator:
|
|
30
|
+
isHighlightedCreator: _highlight.createIsHighlighted,
|
|
31
|
+
isFadedCreator: _highlight.createIsFaded
|
|
30
32
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { identifierSerializerSeriesIdDataIndex, identifierCleanerSeriesIdDataIndex, createIsHighlighted, createIsFaded } from '@mui/x-charts/internals';
|
|
2
1
|
import seriesProcessor from "./seriesProcessor.mjs";
|
|
3
2
|
import getColor from "./getColor.mjs";
|
|
4
3
|
import legendGetter from "./legend.mjs";
|
|
@@ -6,17 +5,20 @@ import tooltipGetter from "./tooltip.mjs";
|
|
|
6
5
|
import getSeriesWithDefaultValues from "./getSeriesWithDefaultValues.mjs";
|
|
7
6
|
import descriptionGetter from "./descriptionGetter.mjs";
|
|
8
7
|
import keyboardFocusHandler from "./keyboardFocusHandler.mjs";
|
|
9
|
-
import
|
|
8
|
+
import selectorTooltipItemPosition from "./tooltipPosition.mjs";
|
|
9
|
+
import identifierSerializer from "./identifierSerializer.mjs";
|
|
10
|
+
import identifierCleaner from "./identifierCleaner.mjs";
|
|
11
|
+
import { createIsHighlighted, createIsFaded } from "./highlight.mjs";
|
|
10
12
|
export const mapShapeSeriesConfig = {
|
|
11
13
|
seriesProcessor,
|
|
12
14
|
colorProcessor: getColor,
|
|
13
15
|
legendGetter,
|
|
14
16
|
tooltipGetter,
|
|
15
|
-
|
|
17
|
+
selectorTooltipItemPosition,
|
|
16
18
|
getSeriesWithDefaultValues,
|
|
17
19
|
keyboardFocusHandler,
|
|
18
|
-
identifierSerializer
|
|
19
|
-
identifierCleaner
|
|
20
|
+
identifierSerializer,
|
|
21
|
+
identifierCleaner,
|
|
20
22
|
descriptionGetter,
|
|
21
23
|
isHighlightedCreator: createIsHighlighted,
|
|
22
24
|
isFadedCreator: createIsFaded
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import type { KeyboardFocusHandler } from '@mui/x-charts/internals';
|
|
2
|
-
/**
|
|
3
|
-
* Move the focus across the shapes of the map series.
|
|
4
|
-
*
|
|
5
|
-
* `ArrowRight`/`ArrowLeft` move to the next/previous shape of the focused series,
|
|
6
|
-
* while `ArrowUp`/`ArrowDown` move between series.
|
|
7
|
-
*/
|
|
8
2
|
declare const keyboardFocusHandler: KeyboardFocusHandler<'mapShape', 'mapShape'>;
|
|
9
3
|
export default keyboardFocusHandler;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
import type { KeyboardFocusHandler } from '@mui/x-charts/internals';
|
|
2
|
-
/**
|
|
3
|
-
* Move the focus across the shapes of the map series.
|
|
4
|
-
*
|
|
5
|
-
* `ArrowRight`/`ArrowLeft` move to the next/previous shape of the focused series,
|
|
6
|
-
* while `ArrowUp`/`ArrowDown` move between series.
|
|
7
|
-
*/
|
|
8
2
|
declare const keyboardFocusHandler: KeyboardFocusHandler<'mapShape', 'mapShape'>;
|
|
9
3
|
export default keyboardFocusHandler;
|
|
@@ -5,15 +5,48 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _internals = require("@mui/x-charts/internals");
|
|
8
|
+
/**
|
|
9
|
+
* Keyboard navigation for the map series.
|
|
10
|
+
*
|
|
11
|
+
* The `mapShape` identifier is keyed by the feature `name` (a string), but navigation itself
|
|
12
|
+
* is position-based, so the shared `createCommonKeyboardFocusHandler` does all the work
|
|
13
|
+
* (stepping, hidden-skipping, boundaries, moving between series). This handler only adapts the
|
|
14
|
+
* boundaries: it translates the focused `name` to a `dataIndex` on the way in (through the
|
|
15
|
+
* series `lookupByName` map), and the resulting `dataIndex` back to a `name` on the way out.
|
|
16
|
+
*
|
|
17
|
+
* `ArrowRight`/`ArrowLeft` step within the focused series, `ArrowUp`/`ArrowDown` move between series.
|
|
18
|
+
*/
|
|
19
|
+
|
|
8
20
|
const mapShapeSeriesTypes = new Set(['mapShape']);
|
|
9
21
|
const allowCycles = false;
|
|
10
22
|
const useCurrentSeriesMaxLength = true;
|
|
23
|
+
const commonFocusHandler = (0, _internals.createCommonKeyboardFocusHandler)(mapShapeSeriesTypes, allowCycles, useCurrentSeriesMaxLength);
|
|
24
|
+
const keyboardFocusHandler = event => {
|
|
25
|
+
const updateFocusedItem = commonFocusHandler(event);
|
|
26
|
+
if (!updateFocusedItem) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return (currentItem, state) => {
|
|
30
|
+
const mapSeries = (0, _internals.selectorChartSeriesProcessed)(state).mapShape;
|
|
11
31
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
32
|
+
// name -> dataIndex
|
|
33
|
+
const current = currentItem ? {
|
|
34
|
+
type: 'mapShape',
|
|
35
|
+
seriesId: currentItem.seriesId,
|
|
36
|
+
dataIndex: mapSeries?.series[currentItem.seriesId]?.lookupByName.get(currentItem.name) ?? -1
|
|
37
|
+
} : null;
|
|
38
|
+
const next = updateFocusedItem(current, state);
|
|
39
|
+
if (!next) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// dataIndex -> name
|
|
44
|
+
const name = mapSeries?.series[next.seriesId]?.data[next.dataIndex]?.name;
|
|
45
|
+
return name === undefined ? null : {
|
|
46
|
+
type: 'mapShape',
|
|
47
|
+
seriesId: next.seriesId,
|
|
48
|
+
name
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
19
52
|
var _default = exports.default = keyboardFocusHandler;
|
|
@@ -1,13 +1,46 @@
|
|
|
1
|
-
import { createCommonKeyboardFocusHandler } from '@mui/x-charts/internals';
|
|
1
|
+
import { createCommonKeyboardFocusHandler, selectorChartSeriesProcessed } from '@mui/x-charts/internals';
|
|
2
|
+
/**
|
|
3
|
+
* Keyboard navigation for the map series.
|
|
4
|
+
*
|
|
5
|
+
* The `mapShape` identifier is keyed by the feature `name` (a string), but navigation itself
|
|
6
|
+
* is position-based, so the shared `createCommonKeyboardFocusHandler` does all the work
|
|
7
|
+
* (stepping, hidden-skipping, boundaries, moving between series). This handler only adapts the
|
|
8
|
+
* boundaries: it translates the focused `name` to a `dataIndex` on the way in (through the
|
|
9
|
+
* series `lookupByName` map), and the resulting `dataIndex` back to a `name` on the way out.
|
|
10
|
+
*
|
|
11
|
+
* `ArrowRight`/`ArrowLeft` step within the focused series, `ArrowUp`/`ArrowDown` move between series.
|
|
12
|
+
*/
|
|
13
|
+
|
|
2
14
|
const mapShapeSeriesTypes = new Set(['mapShape']);
|
|
3
15
|
const allowCycles = false;
|
|
4
16
|
const useCurrentSeriesMaxLength = true;
|
|
17
|
+
const commonFocusHandler = createCommonKeyboardFocusHandler(mapShapeSeriesTypes, allowCycles, useCurrentSeriesMaxLength);
|
|
18
|
+
const keyboardFocusHandler = event => {
|
|
19
|
+
const updateFocusedItem = commonFocusHandler(event);
|
|
20
|
+
if (!updateFocusedItem) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return (currentItem, state) => {
|
|
24
|
+
const mapSeries = selectorChartSeriesProcessed(state).mapShape;
|
|
5
25
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
26
|
+
// name -> dataIndex
|
|
27
|
+
const current = currentItem ? {
|
|
28
|
+
type: 'mapShape',
|
|
29
|
+
seriesId: currentItem.seriesId,
|
|
30
|
+
dataIndex: mapSeries?.series[currentItem.seriesId]?.lookupByName.get(currentItem.name) ?? -1
|
|
31
|
+
} : null;
|
|
32
|
+
const next = updateFocusedItem(current, state);
|
|
33
|
+
if (!next) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// dataIndex -> name
|
|
38
|
+
const name = mapSeries?.series[next.seriesId]?.data[next.dataIndex]?.name;
|
|
39
|
+
return name === undefined ? null : {
|
|
40
|
+
type: 'mapShape',
|
|
41
|
+
seriesId: next.seriesId,
|
|
42
|
+
name
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
13
46
|
export default keyboardFocusHandler;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage"));
|
|
9
10
|
var _internals = require("@mui/x-charts/internals");
|
|
10
11
|
const defaultValueFormatter = v => v == null ? '' : String(v.value);
|
|
11
12
|
const seriesProcessor = ({
|
|
@@ -41,16 +42,24 @@ const seriesProcessor = ({
|
|
|
41
42
|
} else {
|
|
42
43
|
data = input.data ?? [];
|
|
43
44
|
}
|
|
45
|
+
const lookupByName = new Map();
|
|
46
|
+
data.forEach((item, index) => {
|
|
47
|
+
if (lookupByName.has(item.name)) {
|
|
48
|
+
throw new Error(process.env.NODE_ENV !== "production" ? `MUI X Charts: Series "${seriesId}" has a duplicated name "${item.name}".\n` + `Map shapes are identified by their name, so duplicates cannot be told apart for coloring, tooltips, and highlighting.\n` + `Ensure each data entry has a unique name.` : (0, _formatErrorMessage2.default)(294, seriesId, item.name));
|
|
49
|
+
}
|
|
50
|
+
lookupByName.set(item.name, index);
|
|
51
|
+
});
|
|
44
52
|
defaultizedSeries[seriesId] = (0, _extends2.default)({
|
|
45
53
|
labelMarkType: 'square'
|
|
46
54
|
}, input, {
|
|
47
|
-
data: data.map(
|
|
55
|
+
data: data.map(item => (0, _extends2.default)({}, item, {
|
|
48
56
|
hidden: !isItemVisible?.({
|
|
49
57
|
type: 'mapShape',
|
|
50
58
|
seriesId,
|
|
51
|
-
|
|
59
|
+
name: item.name
|
|
52
60
|
})
|
|
53
61
|
})),
|
|
62
|
+
lookupByName,
|
|
54
63
|
hidden: !isItemVisible?.({
|
|
55
64
|
type: 'mapShape',
|
|
56
65
|
seriesId
|