@wavemaker/react-native-echarts 1.0.0-dev.5 → 1.0.0-dev.9
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 +29 -3
- package/area/area-chart.d.ts +1 -1
- package/area/area-chart.d.ts.map +1 -1
- package/area/area-chart.js +63 -37
- 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 +59 -33
- package/candlestick/candlestick-chart.d.ts.map +1 -1
- package/candlestick/candlestick-chart.js +15 -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 +86 -31
- 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/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 +1 -1
- 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 +59 -36
- package/pie/pie-chart.props.d.ts +12 -6
- 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 +43 -11
- package/props/cartesian.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 +52 -10
- package/radar/radar-chart.props.d.ts +13 -0
- 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 +42 -10
- package/radial/radial-chart.props.d.ts +14 -1
- 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 +57 -20
- 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
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
function pieSectorCenter(data, diInside) {
|
|
13
|
+
const layout = data.getItemLayout?.(diInside);
|
|
14
|
+
if (!layout || !Number.isFinite(layout.cx) || !Number.isFinite(layout.cy))
|
|
15
|
+
return null;
|
|
16
|
+
const cx = Number(layout.cx);
|
|
17
|
+
const cy = Number(layout.cy);
|
|
18
|
+
const r = Number(layout.r);
|
|
19
|
+
const r0 = Number(layout.r0 ?? 0);
|
|
20
|
+
const startAngle = Number(layout.startAngle);
|
|
21
|
+
const endAngle = Number(layout.endAngle);
|
|
22
|
+
if (!Number.isFinite(startAngle) || !Number.isFinite(endAngle))
|
|
23
|
+
return null;
|
|
24
|
+
const mid = (startAngle + endAngle) / 2;
|
|
25
|
+
const avgR = (r0 + r) / 2;
|
|
26
|
+
return {
|
|
27
|
+
x: cx + Math.cos(mid) * avgR,
|
|
28
|
+
y: cy + Math.sin(mid) * avgR,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function pointerFromEventOrSector(chart, evt, data) {
|
|
32
|
+
const ex = evt?.x;
|
|
33
|
+
const ey = evt?.y;
|
|
34
|
+
if (typeof ex === 'number' && typeof ey === 'number' && !Number.isNaN(ex) && !Number.isNaN(ey)) {
|
|
35
|
+
return { x: ex, y: ey };
|
|
36
|
+
}
|
|
37
|
+
return pieSectorCenter(data, 0);
|
|
38
|
+
}
|
|
39
|
+
function sliceValueAt(data, diInside) {
|
|
40
|
+
try {
|
|
41
|
+
const dim = typeof data.mapDimension === 'function' ? data.mapDimension('value') : null;
|
|
42
|
+
if (dim != null) {
|
|
43
|
+
const v = data.get(dim, diInside);
|
|
44
|
+
const n = Number(v);
|
|
45
|
+
if (Number.isFinite(n))
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
/* ignore */
|
|
51
|
+
}
|
|
52
|
+
const v0 = data.get?.(0, diInside);
|
|
53
|
+
const n0 = Number(v0);
|
|
54
|
+
if (Number.isFinite(n0))
|
|
55
|
+
return n0;
|
|
56
|
+
try {
|
|
57
|
+
const n1 = Number(data.get?.('value', diInside));
|
|
58
|
+
if (Number.isFinite(n1))
|
|
59
|
+
return n1;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
/* ignore */
|
|
63
|
+
}
|
|
64
|
+
return NaN;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Build radial ring tooltip params from an ECharts `showTip` payload.
|
|
68
|
+
* Only the filled arc (`dataIndex` 0) is shown; the background track is ignored.
|
|
69
|
+
*/
|
|
70
|
+
export function radialItemParamsFromShowTip(chart, evt, ctx, themeSeries) {
|
|
71
|
+
if (!chart || !evt)
|
|
72
|
+
return null;
|
|
73
|
+
if (Array.isArray(evt.dataByCoordSys) && evt.dataByCoordSys.length > 0)
|
|
74
|
+
return null;
|
|
75
|
+
const si = typeof evt.seriesIndex === 'number' ? evt.seriesIndex : 0;
|
|
76
|
+
if (si < 0 || si >= ctx.normalizedSeries.length)
|
|
77
|
+
return null;
|
|
78
|
+
const seriesModel = chart.getModel?.().getSeriesByIndex?.(si);
|
|
79
|
+
const seriesKind = seriesModel?.subType ?? seriesModel?.get?.('type');
|
|
80
|
+
if (!seriesModel || seriesKind !== 'pie')
|
|
81
|
+
return null;
|
|
82
|
+
const data = seriesModel.getData?.();
|
|
83
|
+
if (!data)
|
|
84
|
+
return null;
|
|
85
|
+
const diInside = resolveDataIndexInside(data, evt);
|
|
86
|
+
if (diInside == null || diInside !== 0)
|
|
87
|
+
return null;
|
|
88
|
+
const pixel = pointerFromEventOrSector(chart, evt, data);
|
|
89
|
+
if (!pixel)
|
|
90
|
+
return null;
|
|
91
|
+
const row = ctx.normalizedSeries[si];
|
|
92
|
+
if (!row)
|
|
93
|
+
return null;
|
|
94
|
+
const fromModel = sliceValueAt(data, 0);
|
|
95
|
+
const value = Number.isFinite(fromModel) ? fromModel : Number(row.value);
|
|
96
|
+
if (!Number.isFinite(value))
|
|
97
|
+
return null;
|
|
98
|
+
const ringLabel = row.label != null && row.label !== '' ? String(row.label) : `Ring ${si + 1}`;
|
|
99
|
+
let color;
|
|
100
|
+
try {
|
|
101
|
+
const style = data.getItemVisual?.(0, 'style');
|
|
102
|
+
const fill = style?.fill;
|
|
103
|
+
if (typeof fill === 'string' && fill !== '')
|
|
104
|
+
color = fill;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
/* ignore */
|
|
108
|
+
}
|
|
109
|
+
if (color == null) {
|
|
110
|
+
const themeLen = Math.max(themeSeries.length, 1);
|
|
111
|
+
color = themeSeries[si % themeLen]?.color;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
pointerX: pixel.x,
|
|
115
|
+
pointerY: pixel.y,
|
|
116
|
+
seriesIndex: si,
|
|
117
|
+
dataIndex: 0,
|
|
118
|
+
ringLabel,
|
|
119
|
+
value,
|
|
120
|
+
...(typeof color === 'string' ? { color } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RadialItemTooltipContext, RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
3
|
+
export interface UseRadialItemTooltipOptions {
|
|
4
|
+
active: boolean;
|
|
5
|
+
renderTooltip: (params: RadialItemTooltipParams) => React.ReactNode;
|
|
6
|
+
contextRef: React.RefObject<RadialItemTooltipContext>;
|
|
7
|
+
themeSeriesRef: React.RefObject<Array<{
|
|
8
|
+
color: string;
|
|
9
|
+
}>>;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface UseRadialItemTooltipResult {
|
|
14
|
+
attachRadialItemTooltipListeners: (chart: {
|
|
15
|
+
on: (ev: string, fn: (...args: any[]) => void) => void;
|
|
16
|
+
off: (ev: string, fn: (...args: any[]) => void) => void;
|
|
17
|
+
}) => () => void;
|
|
18
|
+
renderRadialTooltipOverlay: () => React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/** Radial concentric ring tooltip as React Native UI (`trigger: 'item'`). */
|
|
21
|
+
export declare function useRadialItemTooltip(options: UseRadialItemTooltipOptions): UseRadialItemTooltipResult;
|
|
22
|
+
//# sourceMappingURL=use-radial-item-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-radial-item-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/use-radial-item-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGrG,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,KAAK,CAAC,SAAS,CAAC;IACpE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;IACtD,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,0BAA0B;IACzC,gCAAgC,EAAE,CAAC,KAAK,EAAE;QACxC,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;KACzD,KAAK,MAAM,IAAI,CAAC;IACjB,0BAA0B,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;CACnD;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,0BAA0B,CAiDrG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { ChartPointerTooltipOverlay } from '../../tooltip/chart-pointer-tooltip-overlay';
|
|
3
|
+
import { radialItemParamsFromShowTip } from './radial-item-tooltip.utils';
|
|
4
|
+
/** Radial concentric ring tooltip as React Native UI (`trigger: 'item'`). */
|
|
5
|
+
export function useRadialItemTooltip(options) {
|
|
6
|
+
const { active, renderTooltip, contextRef, themeSeriesRef, width, height } = options;
|
|
7
|
+
const [params, setParams] = useState(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!active)
|
|
10
|
+
setParams(null);
|
|
11
|
+
}, [active]);
|
|
12
|
+
const attachRadialItemTooltipListeners = useCallback((chart) => {
|
|
13
|
+
if (!active)
|
|
14
|
+
return () => { };
|
|
15
|
+
const onShowTip = (evt) => {
|
|
16
|
+
const ctx = contextRef.current;
|
|
17
|
+
if (!ctx?.normalizedSeries?.length) {
|
|
18
|
+
setParams(null);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const next = radialItemParamsFromShowTip(chart, evt, ctx, themeSeriesRef.current ?? []);
|
|
22
|
+
setParams(next);
|
|
23
|
+
};
|
|
24
|
+
const onHideTip = () => setParams(null);
|
|
25
|
+
chart.on('showTip', onShowTip);
|
|
26
|
+
chart.on('hideTip', onHideTip);
|
|
27
|
+
return () => {
|
|
28
|
+
chart.off('showTip', onShowTip);
|
|
29
|
+
chart.off('hideTip', onHideTip);
|
|
30
|
+
};
|
|
31
|
+
}, [active, contextRef, themeSeriesRef]);
|
|
32
|
+
const renderRadialTooltipOverlay = useCallback(() => {
|
|
33
|
+
if (!active || params == null)
|
|
34
|
+
return null;
|
|
35
|
+
return (<ChartPointerTooltipOverlay width={width} height={height} pointerX={params.pointerX} pointerY={params.pointerY}>
|
|
36
|
+
{renderTooltip(params)}
|
|
37
|
+
</ChartPointerTooltipOverlay>);
|
|
38
|
+
}, [active, renderTooltip, params, width, height]);
|
|
39
|
+
return {
|
|
40
|
+
attachRadialItemTooltipListeners,
|
|
41
|
+
renderRadialTooltipOverlay,
|
|
42
|
+
};
|
|
43
|
+
}
|
package/scatter/index.d.ts
CHANGED
package/scatter/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,cAAc,WAAW,CAAC"}
|
package/scatter/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scatter-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAS/D,OAAO,KAAqC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"scatter-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAS/D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAQ1D,qCAAqC;AACrC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AA2YlF,eAAO,MAAM,YAAY;;;;;;;CAEvB,CAAC"}
|
package/scatter/scatter-chart.js
CHANGED
|
@@ -5,7 +5,10 @@ import { LineChart as EChartsLineChart, ScatterChart as EChartsScatterChart } fr
|
|
|
5
5
|
import { GridComponent, LegendComponent, TooltipComponent, } from 'echarts/components';
|
|
6
6
|
import * as echarts from 'echarts/core';
|
|
7
7
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { View } from 'react-native';
|
|
9
|
+
import { getAxis, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
|
|
10
|
+
import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
|
|
11
|
+
import { createScatterTooltipPreset, useScatterItemTooltip } from './tooltip';
|
|
9
12
|
echarts.use([
|
|
10
13
|
TooltipComponent,
|
|
11
14
|
GridComponent,
|
|
@@ -31,12 +34,30 @@ function linearRegression(points) {
|
|
|
31
34
|
const intercept = (sumY - slope * sumX) / n;
|
|
32
35
|
return { slope, intercept };
|
|
33
36
|
}
|
|
34
|
-
const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', symbolSize = 8, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = false, showHighlighter = true, showRegressionLine = false, xAxisTickLabelFormatter, yAxisTickLabelFormatter,
|
|
37
|
+
const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', symbolSize = 8, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = false, showHighlighter = true, tooltip = 'card', showRegressionLine = false, xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
|
|
35
38
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
36
39
|
const chartRef = useRef(null);
|
|
37
40
|
const onSelectRef = useRef(onSelect);
|
|
38
41
|
onSelectRef.current = onSelect;
|
|
39
42
|
const selectContextRef = useRef({ normalizedSeries: [] });
|
|
43
|
+
const themeSeriesRef = useRef(theme.series);
|
|
44
|
+
themeSeriesRef.current = theme.series;
|
|
45
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
46
|
+
const renderTooltipFn = useMemo(() => {
|
|
47
|
+
if (renderTooltip != null)
|
|
48
|
+
return renderTooltip;
|
|
49
|
+
if (tooltip === 'none')
|
|
50
|
+
return () => null;
|
|
51
|
+
return createScatterTooltipPreset(tooltip);
|
|
52
|
+
}, [renderTooltip, tooltip]);
|
|
53
|
+
const { attachScatterItemTooltipListeners, renderScatterTooltipOverlay } = useScatterItemTooltip({
|
|
54
|
+
active: tooltipOverlayActive,
|
|
55
|
+
renderTooltip: renderTooltipFn,
|
|
56
|
+
contextRef: selectContextRef,
|
|
57
|
+
themeSeriesRef,
|
|
58
|
+
width,
|
|
59
|
+
height,
|
|
60
|
+
});
|
|
40
61
|
const normalizedSeries = useMemo(() => {
|
|
41
62
|
if (!Array.isArray(data) || data.length === 0)
|
|
42
63
|
return [];
|
|
@@ -51,29 +72,36 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
51
72
|
}, [data]);
|
|
52
73
|
const hasNamedSeries = useMemo(() => normalizedSeries.some((s) => 'name' in s && s.name), [normalizedSeries]);
|
|
53
74
|
selectContextRef.current = { normalizedSeries };
|
|
75
|
+
const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
|
|
76
|
+
const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
|
|
54
77
|
const option = useMemo(() => {
|
|
55
78
|
const dataPoints = normalizedSeries.map(s => s.data.map(item => item[0])).flat();
|
|
56
|
-
const xAxisData =
|
|
57
|
-
|
|
58
|
-
: getAxis(dataPoints).map(String);
|
|
59
|
-
const tooltipConfig = showHighlighter
|
|
79
|
+
const xAxisData = getAxis(dataPoints).map(String);
|
|
80
|
+
const tooltipConfig = tooltipOverlayActive
|
|
60
81
|
? {
|
|
61
82
|
trigger: 'item',
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
83
|
+
...axisTooltipShowContentFlag(true),
|
|
84
|
+
...(showHighlighter && {
|
|
85
|
+
axisPointer: {
|
|
65
86
|
type: 'line',
|
|
66
|
-
|
|
67
|
-
|
|
87
|
+
lineStyle: {
|
|
88
|
+
type: 'line',
|
|
89
|
+
width: 1,
|
|
90
|
+
color: '#00000000',
|
|
91
|
+
},
|
|
92
|
+
label: {
|
|
93
|
+
show: false,
|
|
94
|
+
},
|
|
68
95
|
},
|
|
69
|
-
},
|
|
96
|
+
}),
|
|
70
97
|
}
|
|
71
|
-
: {
|
|
72
|
-
//
|
|
98
|
+
: { show: false };
|
|
99
|
+
// X: category from binned coordinates; Y: value (data is [x, y] pairs)
|
|
73
100
|
const xAxisConfig = {
|
|
74
101
|
type: 'category',
|
|
75
102
|
boundaryGap,
|
|
76
103
|
data: xAxisData,
|
|
104
|
+
...(xAxisBounds ?? {}),
|
|
77
105
|
...(xAxisLabel != null && xAxisLabel !== '' && {
|
|
78
106
|
name: xAxisLabel,
|
|
79
107
|
nameLocation: 'middle',
|
|
@@ -95,7 +123,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
95
123
|
}
|
|
96
124
|
: { show: false },
|
|
97
125
|
axisTick: {
|
|
98
|
-
show: showXAxisTicks,
|
|
126
|
+
show: showXAxis && showXAxisTicks,
|
|
99
127
|
lineStyle: {
|
|
100
128
|
color: theme.axis.x.tickColor,
|
|
101
129
|
width: theme.axis.x.tickWidth,
|
|
@@ -111,6 +139,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
111
139
|
};
|
|
112
140
|
const yAxisConfig = {
|
|
113
141
|
type: 'value',
|
|
142
|
+
...(valueAxisBounds ?? {}),
|
|
114
143
|
...(yAxisLabel != null && yAxisLabel !== '' && {
|
|
115
144
|
name: yAxisLabel,
|
|
116
145
|
nameLocation: 'middle',
|
|
@@ -132,7 +161,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
132
161
|
}
|
|
133
162
|
: { show: false },
|
|
134
163
|
axisTick: {
|
|
135
|
-
show: showYAxisTicks,
|
|
164
|
+
show: showYAxis && showYAxisTicks,
|
|
136
165
|
lineStyle: {
|
|
137
166
|
color: theme.axis.y.tickColor,
|
|
138
167
|
width: theme.axis.y.tickWidth,
|
|
@@ -171,7 +200,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
171
200
|
itemStyle: { color: seriesColor },
|
|
172
201
|
emphasis: showHighlighter
|
|
173
202
|
? {
|
|
174
|
-
focus: '
|
|
203
|
+
focus: 'none',
|
|
175
204
|
scale: true,
|
|
176
205
|
symbol: 'circle',
|
|
177
206
|
symbolSize: 8,
|
|
@@ -238,19 +267,23 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
238
267
|
showLegend,
|
|
239
268
|
hasNamedSeries,
|
|
240
269
|
showHighlighter,
|
|
270
|
+
tooltipOverlayActive,
|
|
241
271
|
showRegressionLine,
|
|
242
272
|
xAxisTickLabelFormatter,
|
|
243
273
|
yAxisTickLabelFormatter,
|
|
244
|
-
xAxisTicks,
|
|
245
274
|
xAxisLabel,
|
|
246
275
|
yAxisLabel,
|
|
276
|
+
valueAxisBounds,
|
|
277
|
+
xAxisBounds,
|
|
247
278
|
]);
|
|
248
279
|
useEffect(() => {
|
|
249
280
|
let chart;
|
|
281
|
+
let detachScatterTooltip = () => { };
|
|
250
282
|
if (chartRef.current) {
|
|
251
283
|
try {
|
|
252
284
|
chart = echarts.init(chartRef.current, 'light', { width, height });
|
|
253
285
|
chart.setOption(option);
|
|
286
|
+
detachScatterTooltip = attachScatterItemTooltipListeners(chart);
|
|
254
287
|
const handleSeriesClick = (params) => {
|
|
255
288
|
const cb = onSelectRef.current;
|
|
256
289
|
if (typeof cb !== 'function')
|
|
@@ -292,6 +325,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
292
325
|
}
|
|
293
326
|
}
|
|
294
327
|
return () => {
|
|
328
|
+
detachScatterTooltip();
|
|
295
329
|
if (chart) {
|
|
296
330
|
try {
|
|
297
331
|
chart.dispose();
|
|
@@ -301,8 +335,11 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
301
335
|
}
|
|
302
336
|
}
|
|
303
337
|
};
|
|
304
|
-
}, [option, width, height]);
|
|
305
|
-
return <
|
|
338
|
+
}, [option, width, height, attachScatterItemTooltipListeners]);
|
|
339
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
340
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
341
|
+
{renderScatterTooltipOverlay()}
|
|
342
|
+
</View>);
|
|
306
343
|
};
|
|
307
344
|
const ScatterChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
308
345
|
export const ScatterChart = Object.assign(ScatterChartComponent, {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CartesianChartProps } from '../props/cartesian';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { ScatterItemTooltipParams } from './tooltip/scatter-item-tooltip.types';
|
|
2
4
|
/**
|
|
3
5
|
* Scatter data: array of [x, y] pairs per series.
|
|
4
6
|
* - Single series: number[][]
|
|
@@ -12,7 +14,7 @@ export type ScatterSeriesData = number[][] | Array<{
|
|
|
12
14
|
* Props for ScatterChart.
|
|
13
15
|
* common -> cartesian -> scatter
|
|
14
16
|
*/
|
|
15
|
-
export interface ScatterChartProps extends CartesianChartProps {
|
|
17
|
+
export interface ScatterChartProps extends Omit<CartesianChartProps, 'renderTooltip'> {
|
|
16
18
|
/**
|
|
17
19
|
* Scatter data: array of [x, y] pairs per series.
|
|
18
20
|
*/
|
|
@@ -32,5 +34,9 @@ export interface ScatterChartProps extends CartesianChartProps {
|
|
|
32
34
|
* @default false
|
|
33
35
|
*/
|
|
34
36
|
showRegressionLine?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Overrides the default React Native **item** tooltip body (scatter points; see {@link ScatterItemTooltipParams}).
|
|
39
|
+
*/
|
|
40
|
+
renderTooltip?: (params: ScatterItemTooltipParams) => ReactNode;
|
|
35
41
|
}
|
|
36
42
|
//# sourceMappingURL=scatter-chart.props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scatter-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"scatter-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAErF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,EAAE,EAAE,GACV,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAAC,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC;IACnF;;OAEG;IACH,IAAI,EAAE,iBAAiB,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IACtG;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACzE;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,SAAS,CAAC;CACjE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTheme } from '../../chart-theme.context';
|
|
3
|
+
import type { ScatterItemTooltipParams } from './scatter-item-tooltip.types';
|
|
4
|
+
/**
|
|
5
|
+
* Themed default scatter/bubble item tooltip (React Native).
|
|
6
|
+
*/
|
|
7
|
+
export declare function createDefaultScatterTooltip(theme: Pick<ChartTheme, 'tooltip'>): (params: ScatterItemTooltipParams) => React.ReactElement;
|
|
8
|
+
//# sourceMappingURL=default-scatter-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-scatter-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/scatter/tooltip/default-scatter-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAE7E;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GACjC,CAAC,MAAM,EAAE,wBAAwB,KAAK,KAAK,CAAC,YAAY,CAuC1D"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* Themed default scatter/bubble item tooltip (React Native).
|
|
5
|
+
*/
|
|
6
|
+
export function createDefaultScatterTooltip(theme) {
|
|
7
|
+
const t = theme.tooltip;
|
|
8
|
+
return function DefaultScatterTooltip(params) {
|
|
9
|
+
const { seriesName, x, y, z, color } = params;
|
|
10
|
+
return (<View style={{
|
|
11
|
+
backgroundColor: t.backgroundColor,
|
|
12
|
+
borderColor: t.borderColor,
|
|
13
|
+
borderWidth: t.borderWidth,
|
|
14
|
+
borderRadius: t.borderRadius,
|
|
15
|
+
padding: t.padding,
|
|
16
|
+
}}>
|
|
17
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 4 }}>
|
|
18
|
+
{color != null && color !== '' ? (<View style={[styles.swatch, { backgroundColor: color }]}/>) : (<View style={styles.swatchPlaceholder}/>)}
|
|
19
|
+
<Text style={[styles.title, { color: t.labelColor }]}>{seriesName}</Text>
|
|
20
|
+
</View>
|
|
21
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
22
|
+
<Text style={{ color: t.labelColor }}>x: </Text>
|
|
23
|
+
{String(x)}
|
|
24
|
+
</Text>
|
|
25
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
26
|
+
<Text style={{ color: t.labelColor }}>y: </Text>
|
|
27
|
+
{String(y)}
|
|
28
|
+
</Text>
|
|
29
|
+
{z != null && Number.isFinite(z) ? (<Text style={[styles.line, { color: t.valueColor }]}>
|
|
30
|
+
<Text style={{ color: t.labelColor }}>size: </Text>
|
|
31
|
+
{String(z)}
|
|
32
|
+
</Text>) : null}
|
|
33
|
+
</View>);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const styles = StyleSheet.create({
|
|
37
|
+
title: {
|
|
38
|
+
fontWeight: '600',
|
|
39
|
+
fontSize: 13,
|
|
40
|
+
flex: 1,
|
|
41
|
+
},
|
|
42
|
+
line: {
|
|
43
|
+
fontSize: 12,
|
|
44
|
+
marginTop: 2,
|
|
45
|
+
},
|
|
46
|
+
swatch: {
|
|
47
|
+
width: 8,
|
|
48
|
+
height: 8,
|
|
49
|
+
borderRadius: 4,
|
|
50
|
+
marginRight: 6,
|
|
51
|
+
},
|
|
52
|
+
swatchPlaceholder: {
|
|
53
|
+
width: 8,
|
|
54
|
+
height: 8,
|
|
55
|
+
marginRight: 6,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createDefaultScatterTooltip } from './default-scatter-tooltip';
|
|
2
|
+
export { createScatterTooltipPreset } from './scatter-item-tooltip-presets';
|
|
3
|
+
export type { ScatterItemTooltipContext, ScatterItemTooltipParams } from './scatter-item-tooltip.types';
|
|
4
|
+
export { scatterItemParamsFromShowTip } from './scatter-item-tooltip.utils';
|
|
5
|
+
export { useScatterItemTooltip } from './use-scatter-item-tooltip';
|
|
6
|
+
export type { UseScatterItemTooltipOptions, UseScatterItemTooltipResult } from './use-scatter-item-tooltip';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../components/chart/scatter/tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,YAAY,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxG,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createDefaultScatterTooltip } from './default-scatter-tooltip';
|
|
2
|
+
export { createScatterTooltipPreset } from './scatter-item-tooltip-presets';
|
|
3
|
+
export { scatterItemParamsFromShowTip } from './scatter-item-tooltip.utils';
|
|
4
|
+
export { useScatterItemTooltip } from './use-scatter-item-tooltip';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTooltipPreset } from '../../tooltip';
|
|
3
|
+
import type { ScatterItemTooltipParams } from './scatter-item-tooltip.types';
|
|
4
|
+
export declare function createScatterTooltipPreset(preset: ChartTooltipPreset): (params: ScatterItemTooltipParams) => React.ReactElement;
|
|
5
|
+
//# sourceMappingURL=scatter-item-tooltip-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scatter-item-tooltip-presets.d.ts","sourceRoot":"","sources":["../../../../../components/chart/scatter/tooltip/scatter-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,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AA8D7E,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,kBAAkB,GACzB,CAAC,MAAM,EAAE,wBAAwB,KAAK,KAAK,CAAC,YAAY,CAY1D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 scatterCardFromParams(p) {
|
|
5
|
+
const { seriesName, x, y, z, color } = p;
|
|
6
|
+
return (<TooltipPresetCard header={{ swatchColor: color, title: seriesName }}>
|
|
7
|
+
<Text style={{ fontSize: 14, fontWeight: '700', color: '#0f172a' }}>
|
|
8
|
+
({String(x)}, {String(y)})
|
|
9
|
+
</Text>
|
|
10
|
+
{z != null && Number.isFinite(z) ? (<Text style={{ fontSize: 12, color: '#64748b', marginTop: 4 }}>size: {String(z)}</Text>) : null}
|
|
11
|
+
</TooltipPresetCard>);
|
|
12
|
+
}
|
|
13
|
+
function scatterCompactFromParams(p) {
|
|
14
|
+
const { seriesName, x, y, z } = p;
|
|
15
|
+
const zPart = z != null && Number.isFinite(z) ? ` · ${String(z)}` : '';
|
|
16
|
+
return (<TooltipPresetCompact emphasis={seriesName} detail={`(${String(x)}, ${String(y)}${zPart})`} wrap/>);
|
|
17
|
+
}
|
|
18
|
+
function scatterKpiFromParams(p) {
|
|
19
|
+
const { seriesName, x, y, z, color } = p;
|
|
20
|
+
return (<TooltipPresetKpi accentColor={color ?? '#3b82f6'} minWidth={140} overline={seriesName} metric={String(y)} caption={`y at x = ${String(x)}${z != null && Number.isFinite(z) ? ` · size ${String(z)}` : ''}`}/>);
|
|
21
|
+
}
|
|
22
|
+
function scatterStripedFromParams(p) {
|
|
23
|
+
const { seriesName, x, y, z, color } = p;
|
|
24
|
+
const rows = [
|
|
25
|
+
{ key: 'x', leftLabel: 'x', right: String(x) },
|
|
26
|
+
{ key: 'y', leftLabel: 'y', right: String(y) },
|
|
27
|
+
...(z != null && Number.isFinite(z)
|
|
28
|
+
? [{ key: 'size', leftLabel: 'size', right: String(z) }]
|
|
29
|
+
: []),
|
|
30
|
+
];
|
|
31
|
+
return (<TooltipPresetStriped headerSwatch={{ color: color ?? '#64748b', title: seriesName }} rows={rows.map((row) => ({
|
|
32
|
+
key: row.key,
|
|
33
|
+
leftLabel: row.leftLabel,
|
|
34
|
+
right: row.right,
|
|
35
|
+
}))}/>);
|
|
36
|
+
}
|
|
37
|
+
export function createScatterTooltipPreset(preset) {
|
|
38
|
+
switch (preset) {
|
|
39
|
+
case 'card':
|
|
40
|
+
return (p) => scatterCardFromParams(p);
|
|
41
|
+
case 'compact':
|
|
42
|
+
return (p) => scatterCompactFromParams(p);
|
|
43
|
+
case 'kpi':
|
|
44
|
+
return (p) => scatterKpiFromParams(p);
|
|
45
|
+
case 'striped':
|
|
46
|
+
return (p) => scatterStripedFromParams(p);
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Unknown tooltip preset: ${String(preset)}`);
|
|
49
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item tooltip payload for scatter / bubble (ECharts `trigger: 'item'`, `showTip` without `dataByCoordSys`).
|
|
3
|
+
*/
|
|
4
|
+
export interface ScatterItemTooltipParams {
|
|
5
|
+
pointerX: number;
|
|
6
|
+
pointerY: number;
|
|
7
|
+
seriesIndex: number;
|
|
8
|
+
dataIndex: number;
|
|
9
|
+
seriesName: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
/** Third dimension (bubble size) when present. */
|
|
13
|
+
z?: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ScatterItemTooltipContext {
|
|
17
|
+
normalizedSeries: Array<{
|
|
18
|
+
name?: string;
|
|
19
|
+
data: number[][];
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=scatter-item-tooltip.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scatter-item-tooltip.types.d.ts","sourceRoot":"","sources":["../../../../../components/chart/scatter/tooltip/scatter-item-tooltip.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,kDAAkD;IAClD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;KAAE,CAAC,CAAC;CAC9D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ScatterItemTooltipContext, ScatterItemTooltipParams } from './scatter-item-tooltip.types';
|
|
2
|
+
/**
|
|
3
|
+
* Build scatter/bubble tooltip params from an ECharts `showTip` action and chart instance.
|
|
4
|
+
* Ignores axis-style payloads (`dataByCoordSys`). Skips non-scatter series (e.g. regression line).
|
|
5
|
+
*/
|
|
6
|
+
export declare function scatterItemParamsFromShowTip(chart: any, evt: any, ctx: ScatterItemTooltipContext, themeSeries: Array<{
|
|
7
|
+
color: string;
|
|
8
|
+
}>): ScatterItemTooltipParams | null;
|
|
9
|
+
//# sourceMappingURL=scatter-item-tooltip.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scatter-item-tooltip.utils.d.ts","sourceRoot":"","sources":["../../../../../components/chart/scatter/tooltip/scatter-item-tooltip.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAoCxG;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,yBAAyB,EAC9B,WAAW,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GACpC,wBAAwB,GAAG,IAAI,CA6CjC"}
|