@wavemaker/react-native-echarts 1.0.0-dev.1 → 1.0.0-dev.11
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/README.md +360 -3
- package/area/area-chart.d.ts +1 -1
- package/area/area-chart.d.ts.map +1 -1
- package/area/area-chart.js +81 -50
- package/area/area-chart.props.d.ts +4 -0
- package/area/area-chart.props.d.ts.map +1 -1
- package/area/index.d.ts +1 -1
- package/area/index.d.ts.map +1 -1
- package/axis.d.ts +26 -0
- package/axis.d.ts.map +1 -1
- package/axis.js +35 -0
- package/bubble/bubble-chart.d.ts.map +1 -1
- package/bubble/bubble-chart.js +66 -35
- package/candlestick/candlestick-chart.d.ts.map +1 -1
- package/candlestick/candlestick-chart.js +37 -8
- package/cartesian/tooltip/axis-tooltip-presets.d.ts +5 -0
- package/cartesian/tooltip/axis-tooltip-presets.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip-presets.js +46 -0
- package/cartesian/tooltip/axis-tooltip.types.d.ts +38 -0
- package/cartesian/tooltip/axis-tooltip.types.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip.types.js +4 -0
- package/cartesian/tooltip/axis-tooltip.utils.d.ts +10 -0
- package/cartesian/tooltip/axis-tooltip.utils.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip.utils.js +121 -0
- package/cartesian/tooltip/default-axis-tooltip.d.ts +9 -0
- package/cartesian/tooltip/default-axis-tooltip.d.ts.map +1 -0
- package/cartesian/tooltip/default-axis-tooltip.js +53 -0
- package/cartesian/tooltip/index.d.ts +7 -0
- package/cartesian/tooltip/index.d.ts.map +1 -0
- package/cartesian/tooltip/index.js +4 -0
- package/cartesian/tooltip/use-axis-tooltip.d.ts +38 -0
- package/cartesian/tooltip/use-axis-tooltip.d.ts.map +1 -0
- package/cartesian/tooltip/use-axis-tooltip.js +54 -0
- package/column/column-chart.d.ts.map +1 -1
- package/column/column-chart.js +93 -33
- package/geo/geo-chart.d.ts.map +1 -1
- package/geo/geo-chart.js +56 -24
- package/geo/geo-chart.props.d.ts +11 -5
- package/geo/geo-chart.props.d.ts.map +1 -1
- package/geo/index.d.ts +1 -0
- package/geo/index.d.ts.map +1 -1
- package/geo/index.js +1 -0
- package/geo/tooltip/default-geo-tooltip.d.ts +6 -0
- package/geo/tooltip/default-geo-tooltip.d.ts.map +1 -0
- package/geo/tooltip/default-geo-tooltip.js +47 -0
- package/geo/tooltip/geo-item-tooltip-presets.d.ts +5 -0
- package/geo/tooltip/geo-item-tooltip-presets.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip-presets.js +35 -0
- package/geo/tooltip/geo-item-tooltip.types.d.ts +19 -0
- package/geo/tooltip/geo-item-tooltip.types.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip.types.js +3 -0
- package/geo/tooltip/geo-item-tooltip.utils.d.ts +14 -0
- package/geo/tooltip/geo-item-tooltip.utils.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip.utils.js +220 -0
- package/geo/tooltip/index.d.ts +7 -0
- package/geo/tooltip/index.d.ts.map +1 -0
- package/geo/tooltip/index.js +4 -0
- package/geo/tooltip/use-geo-item-tooltip.d.ts +26 -0
- package/geo/tooltip/use-geo-item-tooltip.d.ts.map +1 -0
- package/geo/tooltip/use-geo-item-tooltip.js +59 -0
- package/geo/us-chart.js +1 -1
- package/geo/us-states.json +54 -0
- package/geo/world.json +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -0
- package/legend/echarts-legend-layout.d.ts +20 -0
- package/legend/echarts-legend-layout.d.ts.map +1 -0
- package/legend/echarts-legend-layout.js +103 -0
- package/line/index.d.ts +1 -1
- package/line/index.d.ts.map +1 -1
- package/line/line-chart.d.ts +1 -1
- package/line/line-chart.d.ts.map +1 -1
- package/line/line-chart.props.d.ts +5 -0
- package/line/line-chart.props.d.ts.map +1 -1
- package/package.json +7 -4
- package/pie/index.d.ts +1 -0
- package/pie/index.d.ts.map +1 -1
- package/pie/index.js +1 -0
- package/pie/pie-chart.d.ts.map +1 -1
- package/pie/pie-chart.js +69 -45
- package/pie/pie-chart.props.d.ts +19 -8
- package/pie/pie-chart.props.d.ts.map +1 -1
- package/pie/tooltip/default-pie-tooltip.d.ts +5 -0
- package/pie/tooltip/default-pie-tooltip.d.ts.map +1 -0
- package/pie/tooltip/default-pie-tooltip.js +57 -0
- package/pie/tooltip/index.d.ts +7 -0
- package/pie/tooltip/index.d.ts.map +1 -0
- package/pie/tooltip/index.js +4 -0
- package/pie/tooltip/pie-item-tooltip-presets.d.ts +5 -0
- package/pie/tooltip/pie-item-tooltip-presets.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip-presets.js +39 -0
- package/pie/tooltip/pie-item-tooltip.types.d.ts +28 -0
- package/pie/tooltip/pie-item-tooltip.types.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip.types.js +3 -0
- package/pie/tooltip/pie-item-tooltip.utils.d.ts +9 -0
- package/pie/tooltip/pie-item-tooltip.utils.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip.utils.js +139 -0
- package/pie/tooltip/use-pie-item-tooltip.d.ts +24 -0
- package/pie/tooltip/use-pie-item-tooltip.d.ts.map +1 -0
- package/pie/tooltip/use-pie-item-tooltip.js +45 -0
- package/props/cartesian.d.ts +50 -13
- package/props/cartesian.d.ts.map +1 -1
- package/props/common.d.ts +2 -0
- package/props/common.d.ts.map +1 -1
- package/radar/index.d.ts +1 -0
- package/radar/index.d.ts.map +1 -1
- package/radar/index.js +1 -0
- package/radar/radar-chart.d.ts.map +1 -1
- package/radar/radar-chart.js +59 -12
- package/radar/radar-chart.props.d.ts +20 -2
- package/radar/radar-chart.props.d.ts.map +1 -1
- package/radar/tooltip/default-radar-tooltip.d.ts +6 -0
- package/radar/tooltip/default-radar-tooltip.d.ts.map +1 -0
- package/radar/tooltip/default-radar-tooltip.js +47 -0
- package/radar/tooltip/index.d.ts +7 -0
- package/radar/tooltip/index.d.ts.map +1 -0
- package/radar/tooltip/index.js +4 -0
- package/radar/tooltip/radar-item-tooltip-presets.d.ts +5 -0
- package/radar/tooltip/radar-item-tooltip-presets.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip-presets.js +50 -0
- package/radar/tooltip/radar-item-tooltip.types.d.ts +28 -0
- package/radar/tooltip/radar-item-tooltip.types.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip.types.js +3 -0
- package/radar/tooltip/radar-item-tooltip.utils.d.ts +9 -0
- package/radar/tooltip/radar-item-tooltip.utils.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip.utils.js +77 -0
- package/radar/tooltip/use-radar-item-tooltip.d.ts +22 -0
- package/radar/tooltip/use-radar-item-tooltip.d.ts.map +1 -0
- package/radar/tooltip/use-radar-item-tooltip.js +43 -0
- package/radial/index.d.ts +1 -0
- package/radial/index.d.ts.map +1 -1
- package/radial/index.js +1 -0
- package/radial/radial-chart.d.ts.map +1 -1
- package/radial/radial-chart.js +44 -16
- package/radial/radial-chart.props.d.ts +16 -3
- package/radial/radial-chart.props.d.ts.map +1 -1
- package/radial/tooltip/default-radial-tooltip.d.ts +6 -0
- package/radial/tooltip/default-radial-tooltip.d.ts.map +1 -0
- package/radial/tooltip/default-radial-tooltip.js +52 -0
- package/radial/tooltip/index.d.ts +7 -0
- package/radial/tooltip/index.d.ts.map +1 -0
- package/radial/tooltip/index.js +4 -0
- package/radial/tooltip/radial-item-tooltip-presets.d.ts +5 -0
- package/radial/tooltip/radial-item-tooltip-presets.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip-presets.js +43 -0
- package/radial/tooltip/radial-item-tooltip.types.d.ts +23 -0
- package/radial/tooltip/radial-item-tooltip.types.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip.types.js +3 -0
- package/radial/tooltip/radial-item-tooltip.utils.d.ts +9 -0
- package/radial/tooltip/radial-item-tooltip.utils.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip.utils.js +122 -0
- package/radial/tooltip/use-radial-item-tooltip.d.ts +22 -0
- package/radial/tooltip/use-radial-item-tooltip.d.ts.map +1 -0
- package/radial/tooltip/use-radial-item-tooltip.js +43 -0
- package/scatter/index.d.ts +1 -0
- package/scatter/index.d.ts.map +1 -1
- package/scatter/index.js +1 -0
- package/scatter/scatter-chart.d.ts.map +1 -1
- package/scatter/scatter-chart.js +64 -22
- package/scatter/scatter-chart.props.d.ts +7 -1
- package/scatter/scatter-chart.props.d.ts.map +1 -1
- package/scatter/tooltip/default-scatter-tooltip.d.ts +8 -0
- package/scatter/tooltip/default-scatter-tooltip.d.ts.map +1 -0
- package/scatter/tooltip/default-scatter-tooltip.js +57 -0
- package/scatter/tooltip/index.d.ts +7 -0
- package/scatter/tooltip/index.d.ts.map +1 -0
- package/scatter/tooltip/index.js +4 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.d.ts +5 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.js +49 -0
- package/scatter/tooltip/scatter-item-tooltip.types.d.ts +22 -0
- package/scatter/tooltip/scatter-item-tooltip.types.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip.types.js +3 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.d.ts +9 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.js +83 -0
- package/scatter/tooltip/use-scatter-item-tooltip.d.ts +25 -0
- package/scatter/tooltip/use-scatter-item-tooltip.d.ts.map +1 -0
- package/scatter/tooltip/use-scatter-item-tooltip.js +46 -0
- package/tooltip/chart-pointer-tooltip-overlay.d.ts +11 -0
- package/tooltip/chart-pointer-tooltip-overlay.d.ts.map +1 -0
- package/tooltip/chart-pointer-tooltip-overlay.js +88 -0
- package/tooltip/chart-tooltip-preset-shells.d.ts +66 -0
- package/tooltip/chart-tooltip-preset-shells.d.ts.map +1 -0
- package/tooltip/chart-tooltip-preset-shells.js +409 -0
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.d.ts.map +1 -0
- package/tooltip/index.js +1 -0
package/geo/geo-chart.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { withResponsiveContainer } from '../chart-container';
|
|
2
2
|
import { useChartTheme, withChartTheme } from '../chart-theme.context';
|
|
3
|
+
import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
|
|
4
|
+
import { createGeoTooltipPreset, useGeoItemTooltip } from './tooltip';
|
|
3
5
|
import { SkiaChart, SkiaRenderer } from '@wuba/react-native-echarts';
|
|
4
6
|
import { MapChart } from 'echarts/charts';
|
|
5
7
|
import { TooltipComponent, VisualMapComponent } from 'echarts/components';
|
|
6
8
|
import * as echarts from 'echarts/core';
|
|
7
9
|
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
|
8
|
-
import
|
|
10
|
+
import { View } from 'react-native';
|
|
11
|
+
import worldJson from './world.json';
|
|
9
12
|
/** Optional context to provide mapJson without passing as prop (avoids Storybook serialization issues). */
|
|
10
13
|
export const GeoMapJsonContext = createContext(null);
|
|
11
14
|
echarts.use([
|
|
@@ -15,13 +18,41 @@ echarts.use([
|
|
|
15
18
|
MapChart,
|
|
16
19
|
]);
|
|
17
20
|
const DEFAULT_MAP_NAME = 'world';
|
|
18
|
-
const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME, width = 400, height = 300, showLegend = true, showHighlighter = true,
|
|
21
|
+
const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME, width = 400, height = 300, showLegend = true, showHighlighter = true, tooltip = 'card', renderTooltip, visualMapMin, visualMapMax, visualMapMode = 'continuous', piecewisePieces, onSelect, ...props }) => {
|
|
19
22
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
20
23
|
const chartRef = useRef(null);
|
|
21
24
|
const onSelectRef = useRef(onSelect);
|
|
22
25
|
onSelectRef.current = onSelect;
|
|
26
|
+
const geoContextRef = useRef({ regions: [] });
|
|
27
|
+
const themeSeriesRef = useRef(theme.series);
|
|
28
|
+
themeSeriesRef.current = theme.series;
|
|
23
29
|
const contextMapJson = useContext(GeoMapJsonContext);
|
|
24
30
|
const mapJson = mapJsonProp ?? contextMapJson ?? worldJson;
|
|
31
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
32
|
+
const renderTooltipFn = useMemo(() => {
|
|
33
|
+
if (renderTooltip != null)
|
|
34
|
+
return renderTooltip;
|
|
35
|
+
if (tooltip === 'none')
|
|
36
|
+
return () => null;
|
|
37
|
+
return createGeoTooltipPreset(tooltip);
|
|
38
|
+
}, [renderTooltip, tooltip]);
|
|
39
|
+
const { attachGeoItemTooltipListeners, renderGeoTooltipOverlay } = useGeoItemTooltip({
|
|
40
|
+
active: tooltipOverlayActive,
|
|
41
|
+
renderTooltip: renderTooltipFn,
|
|
42
|
+
contextRef: geoContextRef,
|
|
43
|
+
themeSeriesRef,
|
|
44
|
+
width,
|
|
45
|
+
height,
|
|
46
|
+
});
|
|
47
|
+
const tooltipRegions = useMemo(() => {
|
|
48
|
+
if (!Array.isArray(data) || data.length === 0)
|
|
49
|
+
return [];
|
|
50
|
+
return data.map((d) => ({
|
|
51
|
+
name: String(d.name),
|
|
52
|
+
value: Number(d.value),
|
|
53
|
+
}));
|
|
54
|
+
}, [data]);
|
|
55
|
+
geoContextRef.current = { regions: tooltipRegions };
|
|
25
56
|
useEffect(() => {
|
|
26
57
|
if (mapJson?.type === 'FeatureCollection' && mapJson.features?.length) {
|
|
27
58
|
try {
|
|
@@ -47,20 +78,12 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
47
78
|
return { series: [{ type: 'map', map: mapName, data: [] }] };
|
|
48
79
|
}
|
|
49
80
|
const seriesColor = theme.series[0]?.color ?? '#3b82f6';
|
|
50
|
-
const tooltipConfig =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
: undefined,
|
|
58
|
-
backgroundColor: theme.tooltip.backgroundColor,
|
|
59
|
-
borderColor: theme.tooltip.borderColor,
|
|
60
|
-
borderWidth: theme.tooltip.borderWidth,
|
|
61
|
-
borderRadius: theme.tooltip.borderRadius,
|
|
62
|
-
padding: theme.tooltip.padding,
|
|
63
|
-
};
|
|
81
|
+
const tooltipConfig = tooltipOverlayActive
|
|
82
|
+
? {
|
|
83
|
+
trigger: 'item',
|
|
84
|
+
...axisTooltipShowContentFlag(true),
|
|
85
|
+
}
|
|
86
|
+
: { show: false };
|
|
64
87
|
const visualMapConfig = showLegend
|
|
65
88
|
? visualMapMode === 'piecewise' && piecewisePieces?.length
|
|
66
89
|
? {
|
|
@@ -112,15 +135,18 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
112
135
|
},
|
|
113
136
|
emphasis: showHighlighter
|
|
114
137
|
? {
|
|
138
|
+
focus: 'none',
|
|
115
139
|
itemStyle: {
|
|
116
|
-
areaColor: seriesColor,
|
|
117
140
|
borderColor: '#333',
|
|
118
141
|
borderWidth: 1,
|
|
119
142
|
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
143
|
+
// Avoid duplicating the region name when the RN tooltip is active.
|
|
144
|
+
label: tooltipOverlayActive
|
|
145
|
+
? { show: false }
|
|
146
|
+
: {
|
|
147
|
+
show: true,
|
|
148
|
+
color: theme.legend.textColor,
|
|
149
|
+
},
|
|
124
150
|
}
|
|
125
151
|
: { disabled: true },
|
|
126
152
|
};
|
|
@@ -138,12 +164,13 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
138
164
|
valueRange,
|
|
139
165
|
showLegend,
|
|
140
166
|
showHighlighter,
|
|
141
|
-
|
|
167
|
+
tooltipOverlayActive,
|
|
142
168
|
visualMapMode,
|
|
143
169
|
piecewisePieces,
|
|
144
170
|
]);
|
|
145
171
|
useEffect(() => {
|
|
146
172
|
let chart;
|
|
173
|
+
let detachGeoTooltip = () => { };
|
|
147
174
|
if (chartRef.current) {
|
|
148
175
|
try {
|
|
149
176
|
chart = echarts.init(chartRef.current, 'light', {
|
|
@@ -151,6 +178,7 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
151
178
|
height,
|
|
152
179
|
});
|
|
153
180
|
chart.setOption(option);
|
|
181
|
+
detachGeoTooltip = attachGeoItemTooltipListeners(chart);
|
|
154
182
|
const handleMapClick = (params) => {
|
|
155
183
|
const cb = onSelectRef.current;
|
|
156
184
|
if (typeof cb !== 'function')
|
|
@@ -182,6 +210,7 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
182
210
|
}
|
|
183
211
|
}
|
|
184
212
|
return () => {
|
|
213
|
+
detachGeoTooltip();
|
|
185
214
|
if (chart) {
|
|
186
215
|
try {
|
|
187
216
|
chart.dispose();
|
|
@@ -191,8 +220,11 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
191
220
|
}
|
|
192
221
|
}
|
|
193
222
|
};
|
|
194
|
-
}, [option, width, height]);
|
|
195
|
-
return <
|
|
223
|
+
}, [option, width, height, attachGeoItemTooltipListeners]);
|
|
224
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
225
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
226
|
+
{renderGeoTooltipOverlay()}
|
|
227
|
+
</View>);
|
|
196
228
|
};
|
|
197
229
|
const GeoChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
198
230
|
export const GeoChart = Object.assign(GeoChartComponent, {
|
package/geo/geo-chart.props.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { CommonChartProps } from '../props/common';
|
|
2
|
+
import type { ChartTooltipOption } from '../tooltip';
|
|
3
|
+
import type { GeoItemTooltipParams } from './tooltip/geo-item-tooltip.types';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
2
5
|
/** Emitted when the user taps/clicks a map region. */
|
|
3
6
|
export interface GeoChartSelectEvent {
|
|
4
7
|
name: string;
|
|
@@ -59,12 +62,15 @@ export interface GeoChartProps extends CommonChartProps {
|
|
|
59
62
|
*/
|
|
60
63
|
showHighlighter?: boolean;
|
|
61
64
|
/**
|
|
62
|
-
*
|
|
65
|
+
* Built-in region tooltip preset when `renderTooltip` is omitted. Use `none` to hide the overlay.
|
|
66
|
+
* @default 'card'
|
|
63
67
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
tooltip?: ChartTooltipOption;
|
|
69
|
+
/**
|
|
70
|
+
* Overrides the default React Native item tooltip body (see {@link GeoItemTooltipParams}).
|
|
71
|
+
* Takes precedence over {@link tooltip}.
|
|
72
|
+
*/
|
|
73
|
+
renderTooltip?: (params: GeoItemTooltipParams) => ReactNode;
|
|
68
74
|
/**
|
|
69
75
|
* Minimum value for the visual map scale. Auto-derived from data if not set.
|
|
70
76
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geo-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/geo-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"geo-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/geo-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,OAAO,CAAA;SAAE,CAAC;QACjD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACtC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD;;;OAGG;IACH,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,SAAS,CAAC;IAC5D;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;IAC3C;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpF;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACjD"}
|
package/geo/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { GeoChart, GeoMapJsonContext } from './geo-chart';
|
|
|
2
2
|
export { USChart } from './us-chart';
|
|
3
3
|
export { WorldChart } from './world-chart';
|
|
4
4
|
export type { GeoChartProps, GeoChartSelectEvent, GeoDataItem, GeoJSONMap, } from './geo-chart.props';
|
|
5
|
+
export * from './tooltip';
|
|
5
6
|
export type { USChartProps } from './us-chart';
|
|
6
7
|
export type { WorldChartProps } from './world-chart';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/geo/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
package/geo/index.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTheme } from '../../chart-theme.context';
|
|
3
|
+
import type { GeoItemTooltipParams } from './geo-item-tooltip.types';
|
|
4
|
+
/** Themed default geo / map item tooltip (React Native). */
|
|
5
|
+
export declare function createDefaultGeoTooltip(theme: Pick<ChartTheme, 'tooltip'>): (params: GeoItemTooltipParams) => React.ReactElement;
|
|
6
|
+
//# sourceMappingURL=default-geo-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-geo-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/geo/tooltip/default-geo-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,4DAA4D;AAC5D,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GACjC,CAAC,MAAM,EAAE,oBAAoB,KAAK,KAAK,CAAC,YAAY,CA6BtD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
/** Themed default geo / map item tooltip (React Native). */
|
|
4
|
+
export function createDefaultGeoTooltip(theme) {
|
|
5
|
+
const t = theme.tooltip;
|
|
6
|
+
return function DefaultGeoTooltip(params) {
|
|
7
|
+
const { name, value, color } = params;
|
|
8
|
+
return (<View style={{
|
|
9
|
+
backgroundColor: t.backgroundColor,
|
|
10
|
+
borderColor: t.borderColor,
|
|
11
|
+
borderWidth: t.borderWidth,
|
|
12
|
+
borderRadius: t.borderRadius,
|
|
13
|
+
padding: t.padding,
|
|
14
|
+
}}>
|
|
15
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 4 }}>
|
|
16
|
+
{color != null && color !== '' ? (<View style={[styles.swatch, { backgroundColor: color }]}/>) : (<View style={styles.swatchPlaceholder}/>)}
|
|
17
|
+
<Text style={[styles.title, { color: t.labelColor }]}>{name}</Text>
|
|
18
|
+
</View>
|
|
19
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
20
|
+
<Text style={{ color: t.labelColor }}>value: </Text>
|
|
21
|
+
{String(value)}
|
|
22
|
+
</Text>
|
|
23
|
+
</View>);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
title: {
|
|
28
|
+
fontWeight: '600',
|
|
29
|
+
fontSize: 13,
|
|
30
|
+
flex: 1,
|
|
31
|
+
},
|
|
32
|
+
line: {
|
|
33
|
+
fontSize: 12,
|
|
34
|
+
marginTop: 2,
|
|
35
|
+
},
|
|
36
|
+
swatch: {
|
|
37
|
+
width: 8,
|
|
38
|
+
height: 8,
|
|
39
|
+
borderRadius: 4,
|
|
40
|
+
marginRight: 6,
|
|
41
|
+
},
|
|
42
|
+
swatchPlaceholder: {
|
|
43
|
+
width: 8,
|
|
44
|
+
height: 8,
|
|
45
|
+
marginRight: 6,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTooltipPreset } from '../../tooltip';
|
|
3
|
+
import type { GeoItemTooltipParams } from './geo-item-tooltip.types';
|
|
4
|
+
export declare function createGeoTooltipPreset(preset: ChartTooltipPreset): (params: GeoItemTooltipParams) => React.ReactElement;
|
|
5
|
+
//# sourceMappingURL=geo-item-tooltip-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo-item-tooltip-presets.d.ts","sourceRoot":"","sources":["../../../../../components/chart/geo/tooltip/geo-item-tooltip-presets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA2CrE,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,kBAAkB,GACzB,CAAC,MAAM,EAAE,oBAAoB,KAAK,KAAK,CAAC,YAAY,CAYtD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { TooltipPresetCard, TooltipPresetCompact, TooltipPresetKpi, TooltipPresetStriped, } from '../../tooltip/chart-tooltip-preset-shells';
|
|
4
|
+
function geoCardFromParams(p) {
|
|
5
|
+
const { name, value, color } = p;
|
|
6
|
+
return (<TooltipPresetCard minWidth={140} header={{ swatchColor: color, title: name, titleVariant: 'emphasis', marginBottom: 6 }}>
|
|
7
|
+
<Text style={{ fontSize: 20, fontWeight: '800', color: '#0f172a' }}>{String(value)}</Text>
|
|
8
|
+
<Text style={{ fontSize: 11, color: '#64748b', marginTop: 4 }}>Value</Text>
|
|
9
|
+
</TooltipPresetCard>);
|
|
10
|
+
}
|
|
11
|
+
function geoCompactFromParams(p) {
|
|
12
|
+
const { name, value } = p;
|
|
13
|
+
return <TooltipPresetCompact emphasis={name} detail={String(value)} wrap={false}/>;
|
|
14
|
+
}
|
|
15
|
+
function geoKpiFromParams(p) {
|
|
16
|
+
const { name, value, color } = p;
|
|
17
|
+
return (<TooltipPresetKpi accentColor={color ?? '#3b82f6'} minWidth={140} overline={name} metric={String(value)} caption="Region value"/>);
|
|
18
|
+
}
|
|
19
|
+
function geoStripedFromParams(p) {
|
|
20
|
+
const { name, value, color } = p;
|
|
21
|
+
return (<TooltipPresetStriped headerSwatch={{ color: color ?? '#64748b', title: name }} rows={[{ key: 'value', leftLabel: 'value', right: String(value) }]}/>);
|
|
22
|
+
}
|
|
23
|
+
export function createGeoTooltipPreset(preset) {
|
|
24
|
+
switch (preset) {
|
|
25
|
+
case 'card':
|
|
26
|
+
return (p) => geoCardFromParams(p);
|
|
27
|
+
case 'compact':
|
|
28
|
+
return (p) => geoCompactFromParams(p);
|
|
29
|
+
case 'kpi':
|
|
30
|
+
return (p) => geoKpiFromParams(p);
|
|
31
|
+
case 'striped':
|
|
32
|
+
return (p) => geoStripedFromParams(p);
|
|
33
|
+
}
|
|
34
|
+
throw new Error(`Unknown tooltip preset: ${String(preset)}`);
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item tooltip for map / geo (`trigger: 'item'`, `series.type` === `map`).
|
|
3
|
+
*/
|
|
4
|
+
export interface GeoItemTooltipParams {
|
|
5
|
+
pointerX: number;
|
|
6
|
+
pointerY: number;
|
|
7
|
+
/** Region name (matches map feature / data `name`). */
|
|
8
|
+
name: string;
|
|
9
|
+
value: number;
|
|
10
|
+
color?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface GeoItemTooltipContext {
|
|
13
|
+
/** Normalized `{ name, value }` rows from chart `data` (for lookup when the event omits value). */
|
|
14
|
+
regions: Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
value: number;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=geo-item-tooltip.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo-item-tooltip.types.d.ts","sourceRoot":"","sources":["../../../../../components/chart/geo/tooltip/geo-item-tooltip.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,mGAAmG;IACnG,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACjD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GeoItemTooltipContext, GeoItemTooltipParams } from './geo-item-tooltip.types';
|
|
2
|
+
/**
|
|
3
|
+
* Build geo map item tooltip params from an ECharts `showTip` payload.
|
|
4
|
+
* Ignores axis-style payloads (`dataByCoordSys`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function geoItemParamsFromShowTip(chart: any, evt: any, ctx: GeoItemTooltipContext, themeSeries: Array<{
|
|
7
|
+
color: string;
|
|
8
|
+
}>,
|
|
9
|
+
/** Prefer over region centroid: matches the pointer that drove hover / emphasis. */
|
|
10
|
+
lastZrPointer?: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
} | null): GeoItemTooltipParams | null;
|
|
14
|
+
//# sourceMappingURL=geo-item-tooltip.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo-item-tooltip.utils.d.ts","sourceRoot":"","sources":["../../../../../components/chart/geo/tooltip/geo-item-tooltip.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0I5F;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,qBAAqB,EAC1B,WAAW,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACrC,oFAAoF;AACpF,aAAa,CAAC,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAC9C,oBAAoB,GAAG,IAAI,CAqE7B"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
function resolveDataIndexInside(data, evt) {
|
|
2
|
+
if (typeof evt?.dataIndexInside === 'number' && !Number.isNaN(evt.dataIndexInside)) {
|
|
3
|
+
return evt.dataIndexInside;
|
|
4
|
+
}
|
|
5
|
+
if (typeof evt?.dataIndex === 'number' && !Number.isNaN(evt.dataIndex)) {
|
|
6
|
+
const mapped = typeof data?.indexOfRawIndex === 'function' ? data.indexOfRawIndex(evt.dataIndex) : evt.dataIndex;
|
|
7
|
+
if (typeof mapped === 'number' && !Number.isNaN(mapped))
|
|
8
|
+
return mapped;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
/** Resolve region row index in series data when `showTip` only carries `name`. */
|
|
13
|
+
function resolveRegionDataIndex(data, name, diInside) {
|
|
14
|
+
if (diInside != null && diInside >= 0)
|
|
15
|
+
return diInside;
|
|
16
|
+
if (!data || name === '')
|
|
17
|
+
return null;
|
|
18
|
+
try {
|
|
19
|
+
if (typeof data.indexOfName === 'function') {
|
|
20
|
+
const i = data.indexOfName(name);
|
|
21
|
+
if (typeof i === 'number' && i >= 0)
|
|
22
|
+
return i;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
/* ignore */
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const n = typeof data.count === 'function' ? data.count() : 0;
|
|
30
|
+
for (let i = 0; i < n; i++) {
|
|
31
|
+
if (String(data.getName?.(i) ?? '') === name)
|
|
32
|
+
return i;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
/* ignore */
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Pointer from `showTip` / zrender when present (map dispatch often omits `x`/`y`).
|
|
42
|
+
*/
|
|
43
|
+
function pointerFromEvent(evt) {
|
|
44
|
+
const pairs = [
|
|
45
|
+
[evt?.x, evt?.y],
|
|
46
|
+
[evt?.offsetX, evt?.offsetY],
|
|
47
|
+
[evt?.event?.offsetX, evt?.event?.offsetY],
|
|
48
|
+
[evt?.event?.zrX, evt?.event?.zrY],
|
|
49
|
+
];
|
|
50
|
+
for (const [x, y] of pairs) {
|
|
51
|
+
if (typeof x === 'number' && typeof y === 'number' && !Number.isNaN(x) && !Number.isNaN(y)) {
|
|
52
|
+
return { x, y };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/** Last zrender pointer (chart pixel space); `showTip` for `trigger: 'item'` map often omits x/y. */
|
|
58
|
+
function pointerFromZrLast(last) {
|
|
59
|
+
if (last == null)
|
|
60
|
+
return null;
|
|
61
|
+
const { x, y } = last;
|
|
62
|
+
if (typeof x === 'number' && typeof y === 'number' && !Number.isNaN(x) && !Number.isNaN(y)) {
|
|
63
|
+
return { x, y };
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/** Match ECharts `findPointFromSeries`: series tooltip position or region graphic centroid. */
|
|
68
|
+
function pointerFromMapRegion(chart, seriesIndex, dataIndexInside) {
|
|
69
|
+
try {
|
|
70
|
+
const seriesModel = chart.getModel?.().getSeriesByIndex?.(seriesIndex);
|
|
71
|
+
if (!seriesModel)
|
|
72
|
+
return null;
|
|
73
|
+
const data = seriesModel.getData?.();
|
|
74
|
+
if (!data)
|
|
75
|
+
return null;
|
|
76
|
+
if (typeof seriesModel.getTooltipPosition === 'function') {
|
|
77
|
+
const pt = seriesModel.getTooltipPosition(dataIndexInside);
|
|
78
|
+
if (Array.isArray(pt) && pt.length >= 2 && Number.isFinite(pt[0]) && Number.isFinite(pt[1])) {
|
|
79
|
+
return { x: pt[0], y: pt[1] };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const el = data.getItemGraphicEl?.(dataIndexInside);
|
|
83
|
+
if (el && typeof el.getBoundingRect === 'function') {
|
|
84
|
+
const rect = el.getBoundingRect().clone();
|
|
85
|
+
const transform = el.transform;
|
|
86
|
+
if (rect && typeof rect.applyTransform === 'function' && transform != null) {
|
|
87
|
+
rect.applyTransform(transform);
|
|
88
|
+
}
|
|
89
|
+
const cx = rect.x + rect.width / 2;
|
|
90
|
+
const cy = rect.y + rect.height / 2;
|
|
91
|
+
if (Number.isFinite(cx) && Number.isFinite(cy)) {
|
|
92
|
+
return { x: cx, y: cy };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
/* ignore */
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function pointerFromConvertToPixel(chart, seriesIndex, name) {
|
|
102
|
+
try {
|
|
103
|
+
if (typeof chart.convertToPixel !== 'function')
|
|
104
|
+
return null;
|
|
105
|
+
const pt = chart.convertToPixel({ seriesIndex }, name);
|
|
106
|
+
if (Array.isArray(pt) && pt.length >= 2 && Number.isFinite(pt[0]) && Number.isFinite(pt[1])) {
|
|
107
|
+
return { x: pt[0], y: pt[1] };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
/* ignore */
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
function pointerFromEventOrCenter(chart, evt) {
|
|
116
|
+
const w = typeof chart?.getWidth === 'function' ? chart.getWidth() : 0;
|
|
117
|
+
const h = typeof chart?.getHeight === 'function' ? chart.getHeight() : 0;
|
|
118
|
+
return { x: w > 0 ? w / 2 : 0, y: h > 0 ? h / 2 : 0 };
|
|
119
|
+
}
|
|
120
|
+
function sliceValueAt(data, diInside) {
|
|
121
|
+
try {
|
|
122
|
+
const dim = typeof data.mapDimension === 'function' ? data.mapDimension('value') : null;
|
|
123
|
+
if (dim != null) {
|
|
124
|
+
const v = data.get(dim, diInside);
|
|
125
|
+
const n = Number(v);
|
|
126
|
+
if (Number.isFinite(n))
|
|
127
|
+
return n;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
/* ignore */
|
|
132
|
+
}
|
|
133
|
+
const v0 = data.get?.(0, diInside);
|
|
134
|
+
const n0 = Number(v0);
|
|
135
|
+
if (Number.isFinite(n0))
|
|
136
|
+
return n0;
|
|
137
|
+
try {
|
|
138
|
+
const n1 = Number(data.get?.('value', diInside));
|
|
139
|
+
if (Number.isFinite(n1))
|
|
140
|
+
return n1;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
/* ignore */
|
|
144
|
+
}
|
|
145
|
+
return NaN;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Build geo map item tooltip params from an ECharts `showTip` payload.
|
|
149
|
+
* Ignores axis-style payloads (`dataByCoordSys`).
|
|
150
|
+
*/
|
|
151
|
+
export function geoItemParamsFromShowTip(chart, evt, ctx, themeSeries,
|
|
152
|
+
/** Prefer over region centroid: matches the pointer that drove hover / emphasis. */
|
|
153
|
+
lastZrPointer) {
|
|
154
|
+
if (!chart || !evt)
|
|
155
|
+
return null;
|
|
156
|
+
if (Array.isArray(evt.dataByCoordSys) && evt.dataByCoordSys.length > 0)
|
|
157
|
+
return null;
|
|
158
|
+
const si = typeof evt.seriesIndex === 'number' ? evt.seriesIndex : 0;
|
|
159
|
+
const seriesModel = chart.getModel?.().getSeriesByIndex?.(si);
|
|
160
|
+
const seriesKind = seriesModel?.subType ?? seriesModel?.get?.('type');
|
|
161
|
+
if (!seriesModel || seriesKind !== 'map')
|
|
162
|
+
return null;
|
|
163
|
+
const data = seriesModel.getData?.();
|
|
164
|
+
if (!data)
|
|
165
|
+
return null;
|
|
166
|
+
const diInside = resolveDataIndexInside(data, evt);
|
|
167
|
+
let name = typeof evt.name === 'string' && evt.name.trim() !== ''
|
|
168
|
+
? evt.name.trim()
|
|
169
|
+
: '';
|
|
170
|
+
if (name === '' && diInside != null && typeof data.getName === 'function') {
|
|
171
|
+
name = String(data.getName(diInside) ?? '').trim();
|
|
172
|
+
}
|
|
173
|
+
if (name === '')
|
|
174
|
+
return null;
|
|
175
|
+
const regionDi = resolveRegionDataIndex(data, name, diInside);
|
|
176
|
+
const row = ctx.regions.find((r) => r.name === name);
|
|
177
|
+
let value = row != null ? Number(row.value) : NaN;
|
|
178
|
+
if (!Number.isFinite(value)) {
|
|
179
|
+
const fromEvt = typeof evt.value === 'number'
|
|
180
|
+
? evt.value
|
|
181
|
+
: typeof evt.data?.value === 'number'
|
|
182
|
+
? evt.data.value
|
|
183
|
+
: NaN;
|
|
184
|
+
value =
|
|
185
|
+
Number.isFinite(fromEvt) ? fromEvt : regionDi != null && regionDi >= 0 ? sliceValueAt(data, regionDi) : NaN;
|
|
186
|
+
}
|
|
187
|
+
if (!Number.isFinite(value))
|
|
188
|
+
value = 0;
|
|
189
|
+
const pixel = pointerFromZrLast(lastZrPointer) ??
|
|
190
|
+
pointerFromEvent(evt) ??
|
|
191
|
+
(regionDi != null && regionDi >= 0 ? pointerFromMapRegion(chart, si, regionDi) : null) ??
|
|
192
|
+
(regionDi != null && regionDi >= 0 ? pointerFromConvertToPixel(chart, si, name) : null) ??
|
|
193
|
+
pointerFromEventOrCenter(chart, evt);
|
|
194
|
+
let color;
|
|
195
|
+
if (regionDi != null && regionDi >= 0) {
|
|
196
|
+
try {
|
|
197
|
+
const style = data.getItemVisual?.(regionDi, 'style');
|
|
198
|
+
const area = style?.areaColor;
|
|
199
|
+
const fill = style?.fill;
|
|
200
|
+
if (typeof area === 'string' && area !== '')
|
|
201
|
+
color = area;
|
|
202
|
+
else if (typeof fill === 'string' && fill !== '')
|
|
203
|
+
color = fill;
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
/* ignore */
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (color == null) {
|
|
210
|
+
const themeLen = Math.max(themeSeries.length, 1);
|
|
211
|
+
color = themeSeries[0 % themeLen]?.color;
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
pointerX: pixel.x,
|
|
215
|
+
pointerY: pixel.y,
|
|
216
|
+
name,
|
|
217
|
+
value,
|
|
218
|
+
...(typeof color === 'string' ? { color } : {}),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createDefaultGeoTooltip } from './default-geo-tooltip';
|
|
2
|
+
export { createGeoTooltipPreset } from './geo-item-tooltip-presets';
|
|
3
|
+
export type { GeoItemTooltipContext, GeoItemTooltipParams } from './geo-item-tooltip.types';
|
|
4
|
+
export { geoItemParamsFromShowTip } from './geo-item-tooltip.utils';
|
|
5
|
+
export { useGeoItemTooltip } from './use-geo-item-tooltip';
|
|
6
|
+
export type { UseGeoItemTooltipOptions, UseGeoItemTooltipResult } from './use-geo-item-tooltip';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../components/chart/geo/tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { GeoItemTooltipContext, GeoItemTooltipParams } from './geo-item-tooltip.types';
|
|
3
|
+
export interface UseGeoItemTooltipOptions {
|
|
4
|
+
active: boolean;
|
|
5
|
+
renderTooltip: (params: GeoItemTooltipParams) => React.ReactNode;
|
|
6
|
+
contextRef: React.RefObject<GeoItemTooltipContext>;
|
|
7
|
+
themeSeriesRef: React.RefObject<Array<{
|
|
8
|
+
color: string;
|
|
9
|
+
}>>;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface UseGeoItemTooltipResult {
|
|
14
|
+
attachGeoItemTooltipListeners: (chart: {
|
|
15
|
+
on: (ev: string, fn: (...args: any[]) => void) => void;
|
|
16
|
+
off: (ev: string, fn: (...args: any[]) => void) => void;
|
|
17
|
+
getZr?: () => {
|
|
18
|
+
on: (ev: string, fn: (...args: any[]) => void) => void;
|
|
19
|
+
off: (ev: string, fn: (...args: any[]) => void) => void;
|
|
20
|
+
};
|
|
21
|
+
}) => () => void;
|
|
22
|
+
renderGeoTooltipOverlay: () => React.ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/** Geo / map region tooltip as React Native UI (`trigger: 'item'`). */
|
|
25
|
+
export declare function useGeoItemTooltip(options: UseGeoItemTooltipOptions): UseGeoItemTooltipResult;
|
|
26
|
+
//# sourceMappingURL=use-geo-item-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-geo-item-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/geo/tooltip/use-geo-item-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAG5F,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,KAAK,CAAC,SAAS,CAAC;IACjE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;IACnD,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,6BAA6B,EAAE,CAAC,KAAK,EAAE;QACrC,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC;QACvD,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC;QACxD,KAAK,CAAC,EAAE,MAAM;YAAE,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC;YAAC,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAA;SAAE,CAAC;KACnI,KAAK,MAAM,IAAI,CAAC;IACjB,uBAAuB,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;CAChD;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,uBAAuB,CAqE5F"}
|