@wavemaker/react-native-echarts 1.0.0-dev.1 → 1.0.0-dev.10
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
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type { CommonChartProps } from '../props/common';
|
|
1
|
+
import type { CommonChartProps, LegendPosition } from '../props/common';
|
|
2
|
+
import type { ChartTooltipOption } from '../tooltip';
|
|
3
|
+
import type { RadarItemTooltipParams } from './tooltip/radar-item-tooltip.types';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
2
5
|
/** Emitted when the user taps/clicks a radar series (polygon). */
|
|
3
6
|
export interface RadarChartSelectEvent {
|
|
4
7
|
seriesIndex: number;
|
|
@@ -49,9 +52,14 @@ export interface RadarChartProps extends CommonChartProps {
|
|
|
49
52
|
symbolSize?: number | number[] | ((value: unknown) => number | number[]);
|
|
50
53
|
/**
|
|
51
54
|
* Whether to display a legend for named series.
|
|
52
|
-
* @default
|
|
55
|
+
* @default true
|
|
53
56
|
*/
|
|
54
57
|
showLegend?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Legend position. Top and bottom use a horizontal legend that wraps; left and right use a vertical legend.
|
|
60
|
+
* @default 'bottom'
|
|
61
|
+
*/
|
|
62
|
+
legendPosition?: LegendPosition;
|
|
55
63
|
/**
|
|
56
64
|
* Whether to show emphasis (highlight) when interacting with the chart.
|
|
57
65
|
* @default true
|
|
@@ -72,6 +80,16 @@ export interface RadarChartProps extends CommonChartProps {
|
|
|
72
80
|
* @default true
|
|
73
81
|
*/
|
|
74
82
|
showAxisLine?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Built-in item tooltip preset when `renderTooltip` is omitted. Use `none` to hide the overlay.
|
|
85
|
+
* @default 'card'
|
|
86
|
+
*/
|
|
87
|
+
tooltip?: ChartTooltipOption;
|
|
88
|
+
/**
|
|
89
|
+
* Overrides the default React Native item tooltip body (see {@link RadarItemTooltipParams}).
|
|
90
|
+
* Takes precedence over {@link tooltip}.
|
|
91
|
+
*/
|
|
92
|
+
renderTooltip?: (params: RadarItemTooltipParams) => ReactNode;
|
|
75
93
|
/**
|
|
76
94
|
* Called when the user selects (taps/clicks) a radar series polygon.
|
|
77
95
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radar-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/radar/radar-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"radar-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/radar/radar-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,kEAAkE;AAClE,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,EAAE,GACR,KAAK,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD;;;OAGG;IACH,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B;;OAEG;IACH,IAAI,EAAE,eAAe,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IACtG;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACzE;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,SAAS,CAAC;IAC9D;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACnD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTheme } from '../../chart-theme.context';
|
|
3
|
+
import type { RadarItemTooltipParams } from './radar-item-tooltip.types';
|
|
4
|
+
/** Themed default radar item tooltip (React Native). */
|
|
5
|
+
export declare function createDefaultRadarTooltip(theme: Pick<ChartTheme, 'tooltip'>): (params: RadarItemTooltipParams) => React.ReactElement;
|
|
6
|
+
//# sourceMappingURL=default-radar-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-radar-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radar/tooltip/default-radar-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEzE,wDAAwD;AACxD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GACjC,CAAC,MAAM,EAAE,sBAAsB,KAAK,KAAK,CAAC,YAAY,CA+BxD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
/** Themed default radar item tooltip (React Native). */
|
|
4
|
+
export function createDefaultRadarTooltip(theme) {
|
|
5
|
+
const t = theme.tooltip;
|
|
6
|
+
return function DefaultRadarTooltip(params) {
|
|
7
|
+
const { seriesName, dimensionValues, 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: 6 }}>
|
|
16
|
+
{color != null && color !== '' ? (<View style={[styles.swatch, { backgroundColor: color }]}/>) : (<View style={styles.swatchPlaceholder}/>)}
|
|
17
|
+
<Text style={[styles.title, { color: t.labelColor }]}>{seriesName}</Text>
|
|
18
|
+
</View>
|
|
19
|
+
{dimensionValues.map((d) => (<Text key={d.indicatorName} style={[styles.line, { color: t.valueColor }]}>
|
|
20
|
+
<Text style={{ color: t.labelColor }}>{d.indicatorName}: </Text>
|
|
21
|
+
{Number.isFinite(d.value) ? String(d.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,7 @@
|
|
|
1
|
+
export { createDefaultRadarTooltip } from './default-radar-tooltip';
|
|
2
|
+
export { createRadarTooltipPreset } from './radar-item-tooltip-presets';
|
|
3
|
+
export type { RadarItemTooltipContext, RadarItemTooltipDimension, RadarItemTooltipParams, } from './radar-item-tooltip.types';
|
|
4
|
+
export { radarItemParamsFromShowTip } from './radar-item-tooltip.utils';
|
|
5
|
+
export { useRadarItemTooltip } from './use-radar-item-tooltip';
|
|
6
|
+
export type { UseRadarItemTooltipOptions, UseRadarItemTooltipResult } from './use-radar-item-tooltip';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radar/tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,YAAY,EACV,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,YAAY,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createDefaultRadarTooltip } from './default-radar-tooltip';
|
|
2
|
+
export { createRadarTooltipPreset } from './radar-item-tooltip-presets';
|
|
3
|
+
export { radarItemParamsFromShowTip } from './radar-item-tooltip.utils';
|
|
4
|
+
export { useRadarItemTooltip } from './use-radar-item-tooltip';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTooltipPreset } from '../../tooltip';
|
|
3
|
+
import type { RadarItemTooltipParams } from './radar-item-tooltip.types';
|
|
4
|
+
export declare function createRadarTooltipPreset(preset: ChartTooltipPreset): (params: RadarItemTooltipParams) => React.ReactElement;
|
|
5
|
+
//# sourceMappingURL=radar-item-tooltip-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radar-item-tooltip-presets.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radar/tooltip/radar-item-tooltip-presets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAqEzE,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,kBAAkB,GACzB,CAAC,MAAM,EAAE,sBAAsB,KAAK,KAAK,CAAC,YAAY,CAYxD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TooltipPresetCard, TooltipPresetCompact, TooltipPresetKpi, TooltipPresetStriped, } from '../../tooltip/chart-tooltip-preset-shells';
|
|
3
|
+
function radarCardFromParams(p) {
|
|
4
|
+
const { seriesName, dimensionValues, color } = p;
|
|
5
|
+
return (<TooltipPresetCard header={{ swatchColor: color, title: seriesName }} keyValueRows={dimensionValues.map((d) => ({
|
|
6
|
+
key: d.indicatorName,
|
|
7
|
+
left: d.indicatorName,
|
|
8
|
+
right: String(d.value),
|
|
9
|
+
}))}/>);
|
|
10
|
+
}
|
|
11
|
+
function radarCompactFromParams(p) {
|
|
12
|
+
const { seriesName, dimensionValues } = p;
|
|
13
|
+
const avg = dimensionValues.length > 0
|
|
14
|
+
? dimensionValues.reduce((s, d) => s + (Number.isFinite(d.value) ? d.value : 0), 0) / dimensionValues.length
|
|
15
|
+
: 0;
|
|
16
|
+
return (<TooltipPresetCompact emphasis={seriesName} detail={`avg ${avg.toFixed(1)} · ${dimensionValues.length} axes`} wrap/>);
|
|
17
|
+
}
|
|
18
|
+
function radarKpiFromParams(p) {
|
|
19
|
+
const { seriesName, dimensionValues, color } = p;
|
|
20
|
+
const primary = dimensionValues[0];
|
|
21
|
+
const rest = dimensionValues.slice(1);
|
|
22
|
+
return (<TooltipPresetKpi accentColor={color ?? '#3b82f6'} minWidth={160} overline={seriesName} metric={primary != null ? String(primary.value) : ''} caption={primary?.indicatorName} footerRows={rest.length > 0
|
|
23
|
+
? rest.map((d) => ({
|
|
24
|
+
key: d.indicatorName,
|
|
25
|
+
left: d.indicatorName,
|
|
26
|
+
right: String(d.value),
|
|
27
|
+
}))
|
|
28
|
+
: undefined}/>);
|
|
29
|
+
}
|
|
30
|
+
function radarStripedFromParams(p) {
|
|
31
|
+
const { seriesName, dimensionValues, color } = p;
|
|
32
|
+
return (<TooltipPresetStriped headerSwatch={{ color: color ?? '#64748b', title: seriesName }} rows={dimensionValues.map((d) => ({
|
|
33
|
+
key: d.indicatorName,
|
|
34
|
+
leftLabel: d.indicatorName,
|
|
35
|
+
right: String(d.value),
|
|
36
|
+
}))}/>);
|
|
37
|
+
}
|
|
38
|
+
export function createRadarTooltipPreset(preset) {
|
|
39
|
+
switch (preset) {
|
|
40
|
+
case 'card':
|
|
41
|
+
return (p) => radarCardFromParams(p);
|
|
42
|
+
case 'compact':
|
|
43
|
+
return (p) => radarCompactFromParams(p);
|
|
44
|
+
case 'kpi':
|
|
45
|
+
return (p) => radarKpiFromParams(p);
|
|
46
|
+
case 'striped':
|
|
47
|
+
return (p) => radarStripedFromParams(p);
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Unknown tooltip preset: ${String(preset)}`);
|
|
50
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item tooltip for radar (`trigger: 'item'`, one ECharts radar series with multiple polygons).
|
|
3
|
+
*/
|
|
4
|
+
export interface RadarItemTooltipDimension {
|
|
5
|
+
indicatorName: string;
|
|
6
|
+
value: number;
|
|
7
|
+
}
|
|
8
|
+
export interface RadarItemTooltipParams {
|
|
9
|
+
pointerX: number;
|
|
10
|
+
pointerY: number;
|
|
11
|
+
/** ECharts series index (typically `0` for a single radar series). */
|
|
12
|
+
seriesIndex: number;
|
|
13
|
+
/** Index of the hovered polygon / named series row. */
|
|
14
|
+
dataIndex: number;
|
|
15
|
+
seriesName: string;
|
|
16
|
+
dimensionValues: RadarItemTooltipDimension[];
|
|
17
|
+
color?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface RadarItemTooltipContext {
|
|
20
|
+
indicators: Array<{
|
|
21
|
+
name: string;
|
|
22
|
+
}>;
|
|
23
|
+
normalizedSeries: Array<{
|
|
24
|
+
name: string;
|
|
25
|
+
value: number[];
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=radar-item-tooltip.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radar-item-tooltip.types.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radar/tooltip/radar-item-tooltip.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,yBAAyB,EAAE,CAAC;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpC,gBAAgB,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;CAC5D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RadarItemTooltipContext, RadarItemTooltipParams } from './radar-item-tooltip.types';
|
|
2
|
+
/**
|
|
3
|
+
* Build radar item tooltip params from an ECharts `showTip` payload.
|
|
4
|
+
* Ignores axis-style payloads (`dataByCoordSys`).
|
|
5
|
+
*/
|
|
6
|
+
export declare function radarItemParamsFromShowTip(chart: any, evt: any, ctx: RadarItemTooltipContext, themeSeries: Array<{
|
|
7
|
+
color: string;
|
|
8
|
+
}>): RadarItemTooltipParams | null;
|
|
9
|
+
//# sourceMappingURL=radar-item-tooltip.utils.d.ts.map
|
|
@@ -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;AAQrG,OAAO,KAAqC,MAAM,OAAO,CAAC;AAI1D,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA0SrG,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
|
package/radial/radial-chart.js
CHANGED
|
@@ -1,10 +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 { echartsLegendLayoutFragment } from '../legend/echarts-legend-layout';
|
|
5
|
+
import { createRadialTooltipPreset, useRadialItemTooltip } from './tooltip';
|
|
3
6
|
import { SkiaChart, SkiaRenderer } from '@wuba/react-native-echarts';
|
|
4
7
|
import { PieChart as EChartsPieChart } from 'echarts/charts';
|
|
5
8
|
import { LegendComponent, TitleComponent, TooltipComponent } from 'echarts/components';
|
|
6
9
|
import * as echarts from 'echarts/core';
|
|
7
10
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
11
|
+
import { View } from 'react-native';
|
|
8
12
|
echarts.use([TooltipComponent, TitleComponent, LegendComponent, SkiaRenderer, EChartsPieChart]);
|
|
9
13
|
/** Percent of height reserved for horizontal legend (top/bottom) to avoid overlap */
|
|
10
14
|
const LEGEND_RESERVE_PCT = 22;
|
|
@@ -20,12 +24,30 @@ const DEFAULT_RING_COLORS = [
|
|
|
20
24
|
'#93c5fd',
|
|
21
25
|
'#bfdbfe',
|
|
22
26
|
];
|
|
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 }) => {
|
|
27
|
+
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
28
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
25
29
|
const chartRef = useRef(null);
|
|
26
30
|
const onSelectRef = useRef(onSelect);
|
|
27
31
|
onSelectRef.current = onSelect;
|
|
28
|
-
const
|
|
32
|
+
const radialContextRef = useRef({ normalizedSeries: [] });
|
|
33
|
+
const themeSeriesRef = useRef(theme.series);
|
|
34
|
+
themeSeriesRef.current = theme.series;
|
|
35
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
36
|
+
const renderTooltipFn = useMemo(() => {
|
|
37
|
+
if (renderTooltip != null)
|
|
38
|
+
return renderTooltip;
|
|
39
|
+
if (tooltip === 'none')
|
|
40
|
+
return () => null;
|
|
41
|
+
return createRadialTooltipPreset(tooltip);
|
|
42
|
+
}, [renderTooltip, tooltip]);
|
|
43
|
+
const { attachRadialItemTooltipListeners, renderRadialTooltipOverlay } = useRadialItemTooltip({
|
|
44
|
+
active: tooltipOverlayActive,
|
|
45
|
+
renderTooltip: renderTooltipFn,
|
|
46
|
+
contextRef: radialContextRef,
|
|
47
|
+
themeSeriesRef,
|
|
48
|
+
width,
|
|
49
|
+
height,
|
|
50
|
+
});
|
|
29
51
|
const normalizedData = useMemo(() => {
|
|
30
52
|
if (!Array.isArray(data) || data.length === 0)
|
|
31
53
|
return [];
|
|
@@ -34,7 +56,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
34
56
|
value: Math.min(100, Math.max(0, Number(d.value))),
|
|
35
57
|
}));
|
|
36
58
|
}, [data]);
|
|
37
|
-
|
|
59
|
+
radialContextRef.current = { normalizedSeries: normalizedData };
|
|
38
60
|
const option = useMemo(() => {
|
|
39
61
|
if (normalizedData.length === 0)
|
|
40
62
|
return { series: [] };
|
|
@@ -109,6 +131,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
109
131
|
label: { show: false },
|
|
110
132
|
labelLine: { show: false },
|
|
111
133
|
emphasis: {
|
|
134
|
+
focus: 'none',
|
|
112
135
|
scale: false,
|
|
113
136
|
itemStyle: {
|
|
114
137
|
shadowBlur: 8,
|
|
@@ -119,23 +142,21 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
119
142
|
};
|
|
120
143
|
});
|
|
121
144
|
const legendData = normalizedData.map((item, index) => `${item.label ?? `Ring ${index + 1}`} (${item.value}%)`);
|
|
122
|
-
const
|
|
123
|
-
|
|
145
|
+
const tooltipConfig = tooltipOverlayActive
|
|
146
|
+
? {
|
|
124
147
|
trigger: 'item',
|
|
125
|
-
|
|
126
|
-
}
|
|
148
|
+
...axisTooltipShowContentFlag(true),
|
|
149
|
+
}
|
|
150
|
+
: { show: false };
|
|
151
|
+
const config = {
|
|
152
|
+
tooltip: tooltipConfig,
|
|
127
153
|
series: seriesConfigs,
|
|
128
154
|
};
|
|
129
155
|
if (showLegend) {
|
|
130
|
-
const isVertical = legendPosition === 'left' || legendPosition === 'right';
|
|
131
156
|
config.legend = {
|
|
132
157
|
show: true,
|
|
133
158
|
data: legendData,
|
|
134
|
-
|
|
135
|
-
...(legendPosition === 'top' && { top: 8 }),
|
|
136
|
-
...(legendPosition === 'bottom' && { bottom: 8 }),
|
|
137
|
-
...(legendPosition === 'left' && { left: 8 }),
|
|
138
|
-
...(legendPosition === 'right' && { right: 8 }),
|
|
159
|
+
...echartsLegendLayoutFragment(legendPosition),
|
|
139
160
|
textStyle: {
|
|
140
161
|
color: theme.legend?.textColor ?? '#333333',
|
|
141
162
|
fontSize: theme.legend?.fontSize ?? 11,
|
|
@@ -176,9 +197,11 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
176
197
|
clockwise,
|
|
177
198
|
ringGap,
|
|
178
199
|
props.colors,
|
|
200
|
+
tooltipOverlayActive,
|
|
179
201
|
]);
|
|
180
202
|
useEffect(() => {
|
|
181
203
|
let chart;
|
|
204
|
+
let detachRadialTooltip = () => { };
|
|
182
205
|
if (chartRef.current) {
|
|
183
206
|
try {
|
|
184
207
|
chart = echarts.init(chartRef.current, 'light', {
|
|
@@ -186,6 +209,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
186
209
|
height,
|
|
187
210
|
});
|
|
188
211
|
chart.setOption(option);
|
|
212
|
+
detachRadialTooltip = attachRadialItemTooltipListeners(chart);
|
|
189
213
|
const handlePieClick = (params) => {
|
|
190
214
|
const cb = onSelectRef.current;
|
|
191
215
|
if (typeof cb !== 'function')
|
|
@@ -199,7 +223,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
199
223
|
const ringIndex = params.seriesIndex;
|
|
200
224
|
if (typeof ringIndex !== 'number' || ringIndex < 0)
|
|
201
225
|
return;
|
|
202
|
-
const row =
|
|
226
|
+
const row = radialContextRef.current.normalizedSeries[ringIndex];
|
|
203
227
|
if (!row)
|
|
204
228
|
return;
|
|
205
229
|
const event = {
|
|
@@ -217,6 +241,7 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
217
241
|
}
|
|
218
242
|
}
|
|
219
243
|
return () => {
|
|
244
|
+
detachRadialTooltip();
|
|
220
245
|
if (chart) {
|
|
221
246
|
try {
|
|
222
247
|
chart.dispose();
|
|
@@ -226,8 +251,11 @@ const ChartComponent = ({ data, width = 220, height = 350, innerRadius = '20%',
|
|
|
226
251
|
}
|
|
227
252
|
}
|
|
228
253
|
};
|
|
229
|
-
}, [option, width, height]);
|
|
230
|
-
return <
|
|
254
|
+
}, [option, width, height, attachRadialItemTooltipListeners]);
|
|
255
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
256
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
257
|
+
{renderRadialTooltipOverlay()}
|
|
258
|
+
</View>);
|
|
231
259
|
};
|
|
232
260
|
const RadialChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
233
261
|
export const RadialChart = Object.assign(RadialChartComponent, {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type { CommonChartProps } from '../props/common';
|
|
1
|
+
import type { CommonChartProps, LegendPosition } 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;
|
|
@@ -65,7 +68,17 @@ export interface RadialChartProps extends CommonChartProps {
|
|
|
65
68
|
* Position of the legend.
|
|
66
69
|
* @default 'bottom'
|
|
67
70
|
*/
|
|
68
|
-
legendPosition?:
|
|
71
|
+
legendPosition?: LegendPosition;
|
|
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,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACxE,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,cAAc,CAAC;IAChC;;;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"}
|