@wavemaker/react-native-echarts 1.0.0-dev.4 → 1.0.0-dev.8
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 +211 -39
- package/area/area-chart.d.ts +1 -1
- package/area/area-chart.d.ts.map +1 -1
- package/area/area-chart.js +48 -23
- 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/bubble/bubble-chart.d.ts.map +1 -1
- package/bubble/bubble-chart.js +50 -31
- 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 +73 -20
- 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 +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 +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 +18 -2
- 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 +46 -12
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"radar-item-tooltip.utils.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radar/tooltip/radar-item-tooltip.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAwBlG;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,uBAAuB,EAC5B,WAAW,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GACpC,sBAAsB,GAAG,IAAI,CAoD/B"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 pointerFromEventOrCenter(chart, evt) {
|
|
13
|
+
const ex = evt?.x;
|
|
14
|
+
const ey = evt?.y;
|
|
15
|
+
if (typeof ex === 'number' && typeof ey === 'number' && !Number.isNaN(ex) && !Number.isNaN(ey)) {
|
|
16
|
+
return { x: ex, y: ey };
|
|
17
|
+
}
|
|
18
|
+
const w = typeof chart?.getWidth === 'function' ? chart.getWidth() : 0;
|
|
19
|
+
const h = typeof chart?.getHeight === 'function' ? chart.getHeight() : 0;
|
|
20
|
+
return { x: w > 0 ? w / 2 : 0, y: h > 0 ? h / 2 : 0 };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build radar item tooltip params from an ECharts `showTip` payload.
|
|
24
|
+
* Ignores axis-style payloads (`dataByCoordSys`).
|
|
25
|
+
*/
|
|
26
|
+
export function radarItemParamsFromShowTip(chart, evt, ctx, themeSeries) {
|
|
27
|
+
if (!chart || !evt)
|
|
28
|
+
return null;
|
|
29
|
+
if (Array.isArray(evt.dataByCoordSys) && evt.dataByCoordSys.length > 0)
|
|
30
|
+
return null;
|
|
31
|
+
const si = typeof evt.seriesIndex === 'number' ? evt.seriesIndex : 0;
|
|
32
|
+
const seriesModel = chart.getModel?.().getSeriesByIndex?.(si);
|
|
33
|
+
const seriesKind = seriesModel?.subType ?? seriesModel?.get?.('type');
|
|
34
|
+
if (!seriesModel || seriesKind !== 'radar')
|
|
35
|
+
return null;
|
|
36
|
+
const data = seriesModel.getData?.();
|
|
37
|
+
if (!data)
|
|
38
|
+
return null;
|
|
39
|
+
const diInside = resolveDataIndexInside(data, evt);
|
|
40
|
+
if (diInside == null || diInside < 0)
|
|
41
|
+
return null;
|
|
42
|
+
const row = ctx.normalizedSeries[diInside];
|
|
43
|
+
if (!row?.value?.length)
|
|
44
|
+
return null;
|
|
45
|
+
const pixel = pointerFromEventOrCenter(chart, evt);
|
|
46
|
+
const seriesName = String(data.getName?.(diInside) ?? row.name ?? '') || `Series ${diInside + 1}`;
|
|
47
|
+
const dimensionValues = ctx.indicators.map((ind, i) => ({
|
|
48
|
+
indicatorName: ind.name,
|
|
49
|
+
value: Number(row.value[i]),
|
|
50
|
+
}));
|
|
51
|
+
let color;
|
|
52
|
+
try {
|
|
53
|
+
const style = data.getItemVisual?.(diInside, 'style');
|
|
54
|
+
const stroke = style?.stroke;
|
|
55
|
+
const fill = style?.fill;
|
|
56
|
+
if (typeof stroke === 'string' && stroke !== '')
|
|
57
|
+
color = stroke;
|
|
58
|
+
else if (typeof fill === 'string' && fill !== '')
|
|
59
|
+
color = fill;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
/* ignore */
|
|
63
|
+
}
|
|
64
|
+
if (color == null) {
|
|
65
|
+
const themeLen = Math.max(themeSeries.length, 1);
|
|
66
|
+
color = themeSeries[diInside % themeLen]?.color;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
pointerX: pixel.x,
|
|
70
|
+
pointerY: pixel.y,
|
|
71
|
+
seriesIndex: si,
|
|
72
|
+
dataIndex: diInside,
|
|
73
|
+
seriesName,
|
|
74
|
+
dimensionValues,
|
|
75
|
+
...(typeof color === 'string' ? { color } : {}),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RadarItemTooltipContext, RadarItemTooltipParams } from './radar-item-tooltip.types';
|
|
3
|
+
export interface UseRadarItemTooltipOptions {
|
|
4
|
+
active: boolean;
|
|
5
|
+
renderTooltip: (params: RadarItemTooltipParams) => React.ReactNode;
|
|
6
|
+
contextRef: React.RefObject<RadarItemTooltipContext>;
|
|
7
|
+
themeSeriesRef: React.RefObject<Array<{
|
|
8
|
+
color: string;
|
|
9
|
+
}>>;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface UseRadarItemTooltipResult {
|
|
14
|
+
attachRadarItemTooltipListeners: (chart: {
|
|
15
|
+
on: (ev: string, fn: (...args: any[]) => void) => void;
|
|
16
|
+
off: (ev: string, fn: (...args: any[]) => void) => void;
|
|
17
|
+
}) => () => void;
|
|
18
|
+
renderRadarTooltipOverlay: () => React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/** Radar polygon item tooltip as React Native UI (`trigger: 'item'`). */
|
|
21
|
+
export declare function useRadarItemTooltip(options: UseRadarItemTooltipOptions): UseRadarItemTooltipResult;
|
|
22
|
+
//# sourceMappingURL=use-radar-item-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-radar-item-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radar/tooltip/use-radar-item-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGlG,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,KAAK,CAAC,SAAS,CAAC;IACnE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;IACrD,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,yBAAyB;IACxC,+BAA+B,EAAE,CAAC,KAAK,EAAE;QACvC,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,yBAAyB,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;CAClD;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,yBAAyB,CAiDlG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { ChartPointerTooltipOverlay } from '../../tooltip/chart-pointer-tooltip-overlay';
|
|
3
|
+
import { radarItemParamsFromShowTip } from './radar-item-tooltip.utils';
|
|
4
|
+
/** Radar polygon item tooltip as React Native UI (`trigger: 'item'`). */
|
|
5
|
+
export function useRadarItemTooltip(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 attachRadarItemTooltipListeners = useCallback((chart) => {
|
|
13
|
+
if (!active)
|
|
14
|
+
return () => { };
|
|
15
|
+
const onShowTip = (evt) => {
|
|
16
|
+
const ctx = contextRef.current;
|
|
17
|
+
if (!ctx?.normalizedSeries?.length || !ctx.indicators?.length) {
|
|
18
|
+
setParams(null);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const next = radarItemParamsFromShowTip(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 renderRadarTooltipOverlay = 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
|
+
attachRadarItemTooltipListeners,
|
|
41
|
+
renderRadarTooltipOverlay,
|
|
42
|
+
};
|
|
43
|
+
}
|
package/radial/index.d.ts
CHANGED
package/radial/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/radial/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,GACf,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/radial/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
package/radial/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radial-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/radial/radial-chart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"radial-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/radial/radial-chart.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAA0C,MAAM,sBAAsB,CAAC;AAOrG,OAAO,KAAqC,MAAM,OAAO,CAAC;AAI1D,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA+SrG,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
|
package/radial/radial-chart.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { withResponsiveContainer } from '../chart-container';
|
|
2
2
|
import { useChartTheme, withChartTheme } from '../chart-theme.context';
|
|
3
|
+
import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
|
|
4
|
+
import { createRadialTooltipPreset, useRadialItemTooltip } from './tooltip';
|
|
3
5
|
import { SkiaChart, SkiaRenderer } from '@wuba/react-native-echarts';
|
|
4
6
|
import { PieChart as EChartsPieChart } from 'echarts/charts';
|
|
5
7
|
import { LegendComponent, TitleComponent, TooltipComponent } from 'echarts/components';
|
|
6
8
|
import * as echarts from 'echarts/core';
|
|
7
9
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
10
|
+
import { View } from 'react-native';
|
|
8
11
|
echarts.use([TooltipComponent, TitleComponent, LegendComponent, SkiaRenderer, EChartsPieChart]);
|
|
9
12
|
/** Percent of height reserved for horizontal legend (top/bottom) to avoid overlap */
|
|
10
13
|
const LEGEND_RESERVE_PCT = 22;
|
|
@@ -20,12 +23,30 @@ const DEFAULT_RING_COLORS = [
|
|
|
20
23
|
'#93c5fd',
|
|
21
24
|
'#bfdbfe',
|
|
22
25
|
];
|
|
23
|
-
const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%', backgroundColor = '#e8e8e899', centerText, centerSubtext, showLegend = true, legendPosition = 'bottom', startAngle = 0, clockwise = false, ringGap = '4%', onSelect, ...props }) => {
|
|
26
|
+
const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%', backgroundColor = '#e8e8e899', centerText, centerSubtext, showLegend = true, legendPosition = 'bottom', startAngle = 0, clockwise = false, ringGap = '4%', tooltip = 'card', renderTooltip, onSelect, ...props }) => {
|
|
24
27
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
25
28
|
const chartRef = useRef(null);
|
|
26
29
|
const onSelectRef = useRef(onSelect);
|
|
27
30
|
onSelectRef.current = onSelect;
|
|
28
|
-
const
|
|
31
|
+
const radialContextRef = useRef({ normalizedSeries: [] });
|
|
32
|
+
const themeSeriesRef = useRef(theme.series);
|
|
33
|
+
themeSeriesRef.current = theme.series;
|
|
34
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
35
|
+
const renderTooltipFn = useMemo(() => {
|
|
36
|
+
if (renderTooltip != null)
|
|
37
|
+
return renderTooltip;
|
|
38
|
+
if (tooltip === 'none')
|
|
39
|
+
return () => null;
|
|
40
|
+
return createRadialTooltipPreset(tooltip);
|
|
41
|
+
}, [renderTooltip, tooltip]);
|
|
42
|
+
const { attachRadialItemTooltipListeners, renderRadialTooltipOverlay } = useRadialItemTooltip({
|
|
43
|
+
active: tooltipOverlayActive,
|
|
44
|
+
renderTooltip: renderTooltipFn,
|
|
45
|
+
contextRef: radialContextRef,
|
|
46
|
+
themeSeriesRef,
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
});
|
|
29
50
|
const normalizedData = useMemo(() => {
|
|
30
51
|
if (!Array.isArray(data) || data.length === 0)
|
|
31
52
|
return [];
|
|
@@ -34,7 +55,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
34
55
|
value: Math.min(100, Math.max(0, Number(d.value))),
|
|
35
56
|
}));
|
|
36
57
|
}, [data]);
|
|
37
|
-
|
|
58
|
+
radialContextRef.current = { normalizedSeries: normalizedData };
|
|
38
59
|
const option = useMemo(() => {
|
|
39
60
|
if (normalizedData.length === 0)
|
|
40
61
|
return { series: [] };
|
|
@@ -109,6 +130,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
109
130
|
label: { show: false },
|
|
110
131
|
labelLine: { show: false },
|
|
111
132
|
emphasis: {
|
|
133
|
+
focus: 'none',
|
|
112
134
|
scale: false,
|
|
113
135
|
itemStyle: {
|
|
114
136
|
shadowBlur: 8,
|
|
@@ -119,11 +141,14 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
119
141
|
};
|
|
120
142
|
});
|
|
121
143
|
const legendData = normalizedData.map((item, index) => `${item.label ?? `Ring ${index + 1}`} (${item.value}%)`);
|
|
122
|
-
const
|
|
123
|
-
|
|
144
|
+
const tooltipConfig = tooltipOverlayActive
|
|
145
|
+
? {
|
|
124
146
|
trigger: 'item',
|
|
125
|
-
|
|
126
|
-
}
|
|
147
|
+
...axisTooltipShowContentFlag(true),
|
|
148
|
+
}
|
|
149
|
+
: { show: false };
|
|
150
|
+
const config = {
|
|
151
|
+
tooltip: tooltipConfig,
|
|
127
152
|
series: seriesConfigs,
|
|
128
153
|
};
|
|
129
154
|
if (showLegend) {
|
|
@@ -176,9 +201,11 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
176
201
|
clockwise,
|
|
177
202
|
ringGap,
|
|
178
203
|
props.colors,
|
|
204
|
+
tooltipOverlayActive,
|
|
179
205
|
]);
|
|
180
206
|
useEffect(() => {
|
|
181
207
|
let chart;
|
|
208
|
+
let detachRadialTooltip = () => { };
|
|
182
209
|
if (chartRef.current) {
|
|
183
210
|
try {
|
|
184
211
|
chart = echarts.init(chartRef.current, 'light', {
|
|
@@ -186,6 +213,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
186
213
|
height,
|
|
187
214
|
});
|
|
188
215
|
chart.setOption(option);
|
|
216
|
+
detachRadialTooltip = attachRadialItemTooltipListeners(chart);
|
|
189
217
|
const handlePieClick = (params) => {
|
|
190
218
|
const cb = onSelectRef.current;
|
|
191
219
|
if (typeof cb !== 'function')
|
|
@@ -199,7 +227,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
199
227
|
const ringIndex = params.seriesIndex;
|
|
200
228
|
if (typeof ringIndex !== 'number' || ringIndex < 0)
|
|
201
229
|
return;
|
|
202
|
-
const row =
|
|
230
|
+
const row = radialContextRef.current.normalizedSeries[ringIndex];
|
|
203
231
|
if (!row)
|
|
204
232
|
return;
|
|
205
233
|
const event = {
|
|
@@ -217,6 +245,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
217
245
|
}
|
|
218
246
|
}
|
|
219
247
|
return () => {
|
|
248
|
+
detachRadialTooltip();
|
|
220
249
|
if (chart) {
|
|
221
250
|
try {
|
|
222
251
|
chart.dispose();
|
|
@@ -226,8 +255,11 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
226
255
|
}
|
|
227
256
|
}
|
|
228
257
|
};
|
|
229
|
-
}, [option, width, height]);
|
|
230
|
-
return <
|
|
258
|
+
}, [option, width, height, attachRadialItemTooltipListeners]);
|
|
259
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
260
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
261
|
+
{renderRadialTooltipOverlay()}
|
|
262
|
+
</View>);
|
|
231
263
|
};
|
|
232
264
|
const RadialChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
233
265
|
export const RadialChart = Object.assign(RadialChartComponent, {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { CommonChartProps } from '../props/common';
|
|
2
|
+
import type { ChartTooltipOption } from '../tooltip';
|
|
3
|
+
import type { RadialItemTooltipParams } from './tooltip/radial-item-tooltip.types';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
2
5
|
/** Emitted when the user taps/clicks a ring’s filled segment. */
|
|
3
6
|
export interface RadialChartSelectEvent {
|
|
4
7
|
seriesIndex: number;
|
|
@@ -8,7 +11,7 @@ export interface RadialChartSelectEvent {
|
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
13
|
* Single data item for radial chart: one concentric ring.
|
|
11
|
-
* value = fill percentage (0–100) for that ring; label optional (tooltip).
|
|
14
|
+
* value = fill percentage (0–100) for that ring; label optional (legend / tooltip).
|
|
12
15
|
*/
|
|
13
16
|
export interface RadialDataItem {
|
|
14
17
|
label?: string;
|
|
@@ -66,6 +69,16 @@ export interface RadialChartProps extends CommonChartProps {
|
|
|
66
69
|
* @default 'bottom'
|
|
67
70
|
*/
|
|
68
71
|
legendPosition?: 'left' | 'right' | 'top' | 'bottom';
|
|
72
|
+
/**
|
|
73
|
+
* Built-in item tooltip preset when `renderTooltip` is omitted. Use `none` to hide the overlay.
|
|
74
|
+
* @default 'card'
|
|
75
|
+
*/
|
|
76
|
+
tooltip?: ChartTooltipOption;
|
|
77
|
+
/**
|
|
78
|
+
* Overrides the default React Native item tooltip body (see {@link RadialItemTooltipParams}).
|
|
79
|
+
* Takes precedence over {@link tooltip}.
|
|
80
|
+
*/
|
|
81
|
+
renderTooltip?: (params: RadialItemTooltipParams) => ReactNode;
|
|
69
82
|
/**
|
|
70
83
|
* Called when the user selects (taps/clicks) a ring’s value segment.
|
|
71
84
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radial-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/radial/radial-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"radial-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/radial/radial-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,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,iEAAiE;AACjE,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD;;OAEG;IACH,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACrD;;;OAGG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,SAAS,CAAC;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACpD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTheme } from '../../chart-theme.context';
|
|
3
|
+
import type { RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
4
|
+
/** Themed default radial ring tooltip (React Native). */
|
|
5
|
+
export declare function createDefaultRadialTooltip(theme: Pick<ChartTheme, 'tooltip'>): (params: RadialItemTooltipParams) => React.ReactElement;
|
|
6
|
+
//# sourceMappingURL=default-radial-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-radial-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/default-radial-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,yDAAyD;AACzD,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GACjC,CAAC,MAAM,EAAE,uBAAuB,KAAK,KAAK,CAAC,YAAY,CAkCzD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
/** Themed default radial ring tooltip (React Native). */
|
|
4
|
+
export function createDefaultRadialTooltip(theme) {
|
|
5
|
+
const t = theme.tooltip;
|
|
6
|
+
return function DefaultRadialTooltip(params) {
|
|
7
|
+
const { ringLabel, value, color } = params;
|
|
8
|
+
const rest = Math.max(0, Math.min(100, 100 - value));
|
|
9
|
+
return (<View style={{
|
|
10
|
+
backgroundColor: t.backgroundColor,
|
|
11
|
+
borderColor: t.borderColor,
|
|
12
|
+
borderWidth: t.borderWidth,
|
|
13
|
+
borderRadius: t.borderRadius,
|
|
14
|
+
padding: t.padding,
|
|
15
|
+
}}>
|
|
16
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 4 }}>
|
|
17
|
+
{color != null && color !== '' ? (<View style={[styles.swatch, { backgroundColor: color }]}/>) : (<View style={styles.swatchPlaceholder}/>)}
|
|
18
|
+
<Text style={[styles.title, { color: t.labelColor }]}>{ringLabel}</Text>
|
|
19
|
+
</View>
|
|
20
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
21
|
+
<Text style={{ color: t.labelColor }}>fill: </Text>
|
|
22
|
+
{value.toFixed(0)}%
|
|
23
|
+
</Text>
|
|
24
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
25
|
+
<Text style={{ color: t.labelColor }}>remaining: </Text>
|
|
26
|
+
{rest.toFixed(0)}%
|
|
27
|
+
</Text>
|
|
28
|
+
</View>);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
title: {
|
|
33
|
+
fontWeight: '600',
|
|
34
|
+
fontSize: 13,
|
|
35
|
+
flex: 1,
|
|
36
|
+
},
|
|
37
|
+
line: {
|
|
38
|
+
fontSize: 12,
|
|
39
|
+
marginTop: 2,
|
|
40
|
+
},
|
|
41
|
+
swatch: {
|
|
42
|
+
width: 8,
|
|
43
|
+
height: 8,
|
|
44
|
+
borderRadius: 4,
|
|
45
|
+
marginRight: 6,
|
|
46
|
+
},
|
|
47
|
+
swatchPlaceholder: {
|
|
48
|
+
width: 8,
|
|
49
|
+
height: 8,
|
|
50
|
+
marginRight: 6,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createDefaultRadialTooltip } from './default-radial-tooltip';
|
|
2
|
+
export { createRadialTooltipPreset } from './radial-item-tooltip-presets';
|
|
3
|
+
export type { RadialItemTooltipContext, RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
4
|
+
export { radialItemParamsFromShowTip } from './radial-item-tooltip.utils';
|
|
5
|
+
export { useRadialItemTooltip } from './use-radial-item-tooltip';
|
|
6
|
+
export type { UseRadialItemTooltipOptions, UseRadialItemTooltipResult } from './use-radial-item-tooltip';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createDefaultRadialTooltip } from './default-radial-tooltip';
|
|
2
|
+
export { createRadialTooltipPreset } from './radial-item-tooltip-presets';
|
|
3
|
+
export { radialItemParamsFromShowTip } from './radial-item-tooltip.utils';
|
|
4
|
+
export { useRadialItemTooltip } from './use-radial-item-tooltip';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTooltipPreset } from '../../tooltip';
|
|
3
|
+
import type { RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
4
|
+
export declare function createRadialTooltipPreset(preset: ChartTooltipPreset): (params: RadialItemTooltipParams) => React.ReactElement;
|
|
5
|
+
//# sourceMappingURL=radial-item-tooltip-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial-item-tooltip-presets.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/radial-item-tooltip-presets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAiD3E,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,kBAAkB,GACzB,CAAC,MAAM,EAAE,uBAAuB,KAAK,KAAK,CAAC,YAAY,CAYzD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { useChartTheme } from '../../chart-theme.context';
|
|
4
|
+
import { TooltipPresetCard, TooltipPresetCompact, TooltipPresetKpi, TooltipPresetStriped, } from '../../tooltip/chart-tooltip-preset-shells';
|
|
5
|
+
function radialCardFromParams(p) {
|
|
6
|
+
const { ringLabel, value, color } = p;
|
|
7
|
+
return (<TooltipPresetCard header={{ swatchColor: color, title: ringLabel, marginBottom: 6 }}>
|
|
8
|
+
<Text style={{ fontSize: 22, fontWeight: '800', color: '#0f172a' }}>{value.toFixed(0)}%</Text>
|
|
9
|
+
<Text style={{ fontSize: 12, color: '#64748b', marginTop: 4 }}>filled vs 100%</Text>
|
|
10
|
+
</TooltipPresetCard>);
|
|
11
|
+
}
|
|
12
|
+
function radialCompactFromParams(p) {
|
|
13
|
+
const { ringLabel, value } = p;
|
|
14
|
+
return <TooltipPresetCompact emphasis={ringLabel} detail={`${value.toFixed(0)}% fill`} wrap/>;
|
|
15
|
+
}
|
|
16
|
+
function RadialKpiPresetBody(p) {
|
|
17
|
+
const { theme } = useChartTheme();
|
|
18
|
+
const { ringLabel, value, color } = p;
|
|
19
|
+
return (<TooltipPresetKpi accentColor={color ?? '#3b82f6'} minWidth={140} overline={ringLabel} metric={<Text style={{ fontSize: 32, fontWeight: '800', color: theme.tooltip.valueColor, marginTop: 4 }}>
|
|
20
|
+
{value.toFixed(0)}%
|
|
21
|
+
</Text>} caption="of ring capacity"/>);
|
|
22
|
+
}
|
|
23
|
+
function radialStripedFromParams(p) {
|
|
24
|
+
const { ringLabel, value, color } = p;
|
|
25
|
+
const rest = Math.max(0, 100 - value);
|
|
26
|
+
return (<TooltipPresetStriped headerSwatch={{ color: color ?? '#64748b', title: ringLabel }} rows={[
|
|
27
|
+
{ key: 'filled', leftLabel: 'filled', right: `${value.toFixed(0)}%` },
|
|
28
|
+
{ key: 'remaining', leftLabel: 'remaining', right: `${rest.toFixed(0)}%` },
|
|
29
|
+
]}/>);
|
|
30
|
+
}
|
|
31
|
+
export function createRadialTooltipPreset(preset) {
|
|
32
|
+
switch (preset) {
|
|
33
|
+
case 'card':
|
|
34
|
+
return (p) => radialCardFromParams(p);
|
|
35
|
+
case 'compact':
|
|
36
|
+
return (p) => radialCompactFromParams(p);
|
|
37
|
+
case 'kpi':
|
|
38
|
+
return (p) => <RadialKpiPresetBody {...p}/>;
|
|
39
|
+
case 'striped':
|
|
40
|
+
return (p) => radialStripedFromParams(p);
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`Unknown tooltip preset: ${String(preset)}`);
|
|
43
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item tooltip for radial ring chart (multiple ECharts `pie` series; filled slice is `dataIndex` 0).
|
|
3
|
+
*/
|
|
4
|
+
export interface RadialItemTooltipParams {
|
|
5
|
+
pointerX: number;
|
|
6
|
+
pointerY: number;
|
|
7
|
+
/** Ring index (matches `data` array order). */
|
|
8
|
+
seriesIndex: number;
|
|
9
|
+
/** Always `0` for the filled segment (background track uses index 1 and has no tooltip). */
|
|
10
|
+
dataIndex: number;
|
|
11
|
+
/** Ring label from data, or a generated name. */
|
|
12
|
+
ringLabel: string;
|
|
13
|
+
/** Fill amount 0–100. */
|
|
14
|
+
value: number;
|
|
15
|
+
color?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RadialItemTooltipContext {
|
|
18
|
+
normalizedSeries: Array<{
|
|
19
|
+
label?: string;
|
|
20
|
+
value: number;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=radial-item-tooltip.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial-item-tooltip.types.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/radial-item-tooltip.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,gBAAgB,EAAE,KAAK,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RadialItemTooltipContext, RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
2
|
+
/**
|
|
3
|
+
* Build radial ring tooltip params from an ECharts `showTip` payload.
|
|
4
|
+
* Only the filled arc (`dataIndex` 0) is shown; the background track is ignored.
|
|
5
|
+
*/
|
|
6
|
+
export declare function radialItemParamsFromShowTip(chart: any, evt: any, ctx: RadialItemTooltipContext, themeSeries: Array<{
|
|
7
|
+
color: string;
|
|
8
|
+
}>): RadialItemTooltipParams | null;
|
|
9
|
+
//# sourceMappingURL=radial-item-tooltip.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial-item-tooltip.utils.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/radial-item-tooltip.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AA+DrG;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,wBAAwB,EAC7B,WAAW,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GACpC,uBAAuB,GAAG,IAAI,CAmDhC"}
|