@wavemaker/react-native-echarts 1.0.0-dev.1 → 1.0.0-dev.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +360 -3
- package/area/area-chart.d.ts +1 -1
- package/area/area-chart.d.ts.map +1 -1
- package/area/area-chart.js +81 -50
- package/area/area-chart.props.d.ts +4 -0
- package/area/area-chart.props.d.ts.map +1 -1
- package/area/index.d.ts +1 -1
- package/area/index.d.ts.map +1 -1
- package/axis.d.ts +26 -0
- package/axis.d.ts.map +1 -1
- package/axis.js +35 -0
- package/bubble/bubble-chart.d.ts.map +1 -1
- package/bubble/bubble-chart.js +66 -35
- package/candlestick/candlestick-chart.d.ts.map +1 -1
- package/candlestick/candlestick-chart.js +37 -8
- package/cartesian/tooltip/axis-tooltip-presets.d.ts +5 -0
- package/cartesian/tooltip/axis-tooltip-presets.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip-presets.js +46 -0
- package/cartesian/tooltip/axis-tooltip.types.d.ts +38 -0
- package/cartesian/tooltip/axis-tooltip.types.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip.types.js +4 -0
- package/cartesian/tooltip/axis-tooltip.utils.d.ts +10 -0
- package/cartesian/tooltip/axis-tooltip.utils.d.ts.map +1 -0
- package/cartesian/tooltip/axis-tooltip.utils.js +121 -0
- package/cartesian/tooltip/default-axis-tooltip.d.ts +9 -0
- package/cartesian/tooltip/default-axis-tooltip.d.ts.map +1 -0
- package/cartesian/tooltip/default-axis-tooltip.js +53 -0
- package/cartesian/tooltip/index.d.ts +7 -0
- package/cartesian/tooltip/index.d.ts.map +1 -0
- package/cartesian/tooltip/index.js +4 -0
- package/cartesian/tooltip/use-axis-tooltip.d.ts +38 -0
- package/cartesian/tooltip/use-axis-tooltip.d.ts.map +1 -0
- package/cartesian/tooltip/use-axis-tooltip.js +54 -0
- package/column/column-chart.d.ts.map +1 -1
- package/column/column-chart.js +93 -33
- package/geo/geo-chart.d.ts.map +1 -1
- package/geo/geo-chart.js +56 -24
- package/geo/geo-chart.props.d.ts +11 -5
- package/geo/geo-chart.props.d.ts.map +1 -1
- package/geo/index.d.ts +1 -0
- package/geo/index.d.ts.map +1 -1
- package/geo/index.js +1 -0
- package/geo/tooltip/default-geo-tooltip.d.ts +6 -0
- package/geo/tooltip/default-geo-tooltip.d.ts.map +1 -0
- package/geo/tooltip/default-geo-tooltip.js +47 -0
- package/geo/tooltip/geo-item-tooltip-presets.d.ts +5 -0
- package/geo/tooltip/geo-item-tooltip-presets.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip-presets.js +35 -0
- package/geo/tooltip/geo-item-tooltip.types.d.ts +19 -0
- package/geo/tooltip/geo-item-tooltip.types.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip.types.js +3 -0
- package/geo/tooltip/geo-item-tooltip.utils.d.ts +14 -0
- package/geo/tooltip/geo-item-tooltip.utils.d.ts.map +1 -0
- package/geo/tooltip/geo-item-tooltip.utils.js +220 -0
- package/geo/tooltip/index.d.ts +7 -0
- package/geo/tooltip/index.d.ts.map +1 -0
- package/geo/tooltip/index.js +4 -0
- package/geo/tooltip/use-geo-item-tooltip.d.ts +26 -0
- package/geo/tooltip/use-geo-item-tooltip.d.ts.map +1 -0
- package/geo/tooltip/use-geo-item-tooltip.js +59 -0
- package/geo/us-chart.js +1 -1
- package/geo/us-states.json +54 -0
- package/geo/world.json +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -0
- package/legend/echarts-legend-layout.d.ts +20 -0
- package/legend/echarts-legend-layout.d.ts.map +1 -0
- package/legend/echarts-legend-layout.js +103 -0
- package/line/index.d.ts +1 -1
- package/line/index.d.ts.map +1 -1
- package/line/line-chart.d.ts +1 -1
- package/line/line-chart.d.ts.map +1 -1
- package/line/line-chart.props.d.ts +5 -0
- package/line/line-chart.props.d.ts.map +1 -1
- package/package.json +7 -4
- package/pie/index.d.ts +1 -0
- package/pie/index.d.ts.map +1 -1
- package/pie/index.js +1 -0
- package/pie/pie-chart.d.ts.map +1 -1
- package/pie/pie-chart.js +69 -45
- package/pie/pie-chart.props.d.ts +19 -8
- package/pie/pie-chart.props.d.ts.map +1 -1
- package/pie/tooltip/default-pie-tooltip.d.ts +5 -0
- package/pie/tooltip/default-pie-tooltip.d.ts.map +1 -0
- package/pie/tooltip/default-pie-tooltip.js +57 -0
- package/pie/tooltip/index.d.ts +7 -0
- package/pie/tooltip/index.d.ts.map +1 -0
- package/pie/tooltip/index.js +4 -0
- package/pie/tooltip/pie-item-tooltip-presets.d.ts +5 -0
- package/pie/tooltip/pie-item-tooltip-presets.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip-presets.js +39 -0
- package/pie/tooltip/pie-item-tooltip.types.d.ts +28 -0
- package/pie/tooltip/pie-item-tooltip.types.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip.types.js +3 -0
- package/pie/tooltip/pie-item-tooltip.utils.d.ts +9 -0
- package/pie/tooltip/pie-item-tooltip.utils.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip.utils.js +139 -0
- package/pie/tooltip/use-pie-item-tooltip.d.ts +24 -0
- package/pie/tooltip/use-pie-item-tooltip.d.ts.map +1 -0
- package/pie/tooltip/use-pie-item-tooltip.js +45 -0
- package/props/cartesian.d.ts +50 -13
- package/props/cartesian.d.ts.map +1 -1
- package/props/common.d.ts +2 -0
- package/props/common.d.ts.map +1 -1
- package/radar/index.d.ts +1 -0
- package/radar/index.d.ts.map +1 -1
- package/radar/index.js +1 -0
- package/radar/radar-chart.d.ts.map +1 -1
- package/radar/radar-chart.js +59 -12
- package/radar/radar-chart.props.d.ts +20 -2
- package/radar/radar-chart.props.d.ts.map +1 -1
- package/radar/tooltip/default-radar-tooltip.d.ts +6 -0
- package/radar/tooltip/default-radar-tooltip.d.ts.map +1 -0
- package/radar/tooltip/default-radar-tooltip.js +47 -0
- package/radar/tooltip/index.d.ts +7 -0
- package/radar/tooltip/index.d.ts.map +1 -0
- package/radar/tooltip/index.js +4 -0
- package/radar/tooltip/radar-item-tooltip-presets.d.ts +5 -0
- package/radar/tooltip/radar-item-tooltip-presets.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip-presets.js +50 -0
- package/radar/tooltip/radar-item-tooltip.types.d.ts +28 -0
- package/radar/tooltip/radar-item-tooltip.types.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip.types.js +3 -0
- package/radar/tooltip/radar-item-tooltip.utils.d.ts +9 -0
- package/radar/tooltip/radar-item-tooltip.utils.d.ts.map +1 -0
- package/radar/tooltip/radar-item-tooltip.utils.js +77 -0
- package/radar/tooltip/use-radar-item-tooltip.d.ts +22 -0
- package/radar/tooltip/use-radar-item-tooltip.d.ts.map +1 -0
- package/radar/tooltip/use-radar-item-tooltip.js +43 -0
- package/radial/index.d.ts +1 -0
- package/radial/index.d.ts.map +1 -1
- package/radial/index.js +1 -0
- package/radial/radial-chart.d.ts.map +1 -1
- package/radial/radial-chart.js +44 -16
- package/radial/radial-chart.props.d.ts +16 -3
- package/radial/radial-chart.props.d.ts.map +1 -1
- package/radial/tooltip/default-radial-tooltip.d.ts +6 -0
- package/radial/tooltip/default-radial-tooltip.d.ts.map +1 -0
- package/radial/tooltip/default-radial-tooltip.js +52 -0
- package/radial/tooltip/index.d.ts +7 -0
- package/radial/tooltip/index.d.ts.map +1 -0
- package/radial/tooltip/index.js +4 -0
- package/radial/tooltip/radial-item-tooltip-presets.d.ts +5 -0
- package/radial/tooltip/radial-item-tooltip-presets.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip-presets.js +43 -0
- package/radial/tooltip/radial-item-tooltip.types.d.ts +23 -0
- package/radial/tooltip/radial-item-tooltip.types.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip.types.js +3 -0
- package/radial/tooltip/radial-item-tooltip.utils.d.ts +9 -0
- package/radial/tooltip/radial-item-tooltip.utils.d.ts.map +1 -0
- package/radial/tooltip/radial-item-tooltip.utils.js +122 -0
- package/radial/tooltip/use-radial-item-tooltip.d.ts +22 -0
- package/radial/tooltip/use-radial-item-tooltip.d.ts.map +1 -0
- package/radial/tooltip/use-radial-item-tooltip.js +43 -0
- package/scatter/index.d.ts +1 -0
- package/scatter/index.d.ts.map +1 -1
- package/scatter/index.js +1 -0
- package/scatter/scatter-chart.d.ts.map +1 -1
- package/scatter/scatter-chart.js +64 -22
- package/scatter/scatter-chart.props.d.ts +7 -1
- package/scatter/scatter-chart.props.d.ts.map +1 -1
- package/scatter/tooltip/default-scatter-tooltip.d.ts +8 -0
- package/scatter/tooltip/default-scatter-tooltip.d.ts.map +1 -0
- package/scatter/tooltip/default-scatter-tooltip.js +57 -0
- package/scatter/tooltip/index.d.ts +7 -0
- package/scatter/tooltip/index.d.ts.map +1 -0
- package/scatter/tooltip/index.js +4 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.d.ts +5 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip-presets.js +49 -0
- package/scatter/tooltip/scatter-item-tooltip.types.d.ts +22 -0
- package/scatter/tooltip/scatter-item-tooltip.types.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip.types.js +3 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.d.ts +9 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.d.ts.map +1 -0
- package/scatter/tooltip/scatter-item-tooltip.utils.js +83 -0
- package/scatter/tooltip/use-scatter-item-tooltip.d.ts +25 -0
- package/scatter/tooltip/use-scatter-item-tooltip.d.ts.map +1 -0
- package/scatter/tooltip/use-scatter-item-tooltip.js +46 -0
- package/tooltip/chart-pointer-tooltip-overlay.d.ts +11 -0
- package/tooltip/chart-pointer-tooltip-overlay.d.ts.map +1 -0
- package/tooltip/chart-pointer-tooltip-overlay.js +88 -0
- package/tooltip/chart-tooltip-preset-shells.d.ts +66 -0
- package/tooltip/chart-tooltip-preset-shells.d.ts.map +1 -0
- package/tooltip/chart-tooltip-preset-shells.js +409 -0
- package/tooltip/index.d.ts +7 -0
- package/tooltip/index.d.ts.map +1 -0
- package/tooltip/index.js +1 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
function isCategoryAxisEntry(a) {
|
|
2
|
+
return String(a?.axisType ?? '').toLowerCase() === 'category';
|
|
3
|
+
}
|
|
4
|
+
function hasSeriesIndices(a) {
|
|
5
|
+
return Array.isArray(a?.seriesDataIndices) && a.seriesDataIndices.length > 0;
|
|
6
|
+
}
|
|
7
|
+
/** First numeric `dataIndex` carried on the axis tooltip batch (the authoritative index for that axis). */
|
|
8
|
+
function dataIndexFromSeriesDataIndices(indices) {
|
|
9
|
+
if (!Array.isArray(indices))
|
|
10
|
+
return undefined;
|
|
11
|
+
for (const item of indices) {
|
|
12
|
+
const d = item?.dataIndex;
|
|
13
|
+
if (typeof d === 'number' && !Number.isNaN(d))
|
|
14
|
+
return d;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
function seriesDataIndicesFromShowTipEvt(evt, categoryAxisIsY) {
|
|
19
|
+
const axes = evt?.dataByCoordSys?.[0]?.dataByAxis;
|
|
20
|
+
if (!Array.isArray(axes) || axes.length === 0)
|
|
21
|
+
return null;
|
|
22
|
+
const categoryAxes = axes.filter(isCategoryAxisEntry);
|
|
23
|
+
if (categoryAxes.length === 1) {
|
|
24
|
+
const axisEntry = categoryAxes[0];
|
|
25
|
+
return {
|
|
26
|
+
indices: Array.isArray(axisEntry.seriesDataIndices) ? axisEntry.seriesDataIndices : [],
|
|
27
|
+
axisEntry,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (categoryAxes.length > 1 && categoryAxisIsY != null) {
|
|
31
|
+
const dim = categoryAxisIsY ? 'y' : 'x';
|
|
32
|
+
const axisEntry = categoryAxes.find((a) => a?.axisDim === dim && hasSeriesIndices(a)) ??
|
|
33
|
+
categoryAxes.find((a) => a?.axisDim === dim) ??
|
|
34
|
+
categoryAxes[0];
|
|
35
|
+
return {
|
|
36
|
+
indices: Array.isArray(axisEntry.seriesDataIndices) ? axisEntry.seriesDataIndices : [],
|
|
37
|
+
axisEntry,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if (categoryAxisIsY === true) {
|
|
41
|
+
const yWith = axes.find((a) => a?.axisDim === 'y' && hasSeriesIndices(a));
|
|
42
|
+
if (yWith)
|
|
43
|
+
return { indices: yWith.seriesDataIndices, axisEntry: yWith };
|
|
44
|
+
const yAxis = axes.find((a) => a?.axisDim === 'y');
|
|
45
|
+
if (yAxis)
|
|
46
|
+
return { indices: Array.isArray(yAxis.seriesDataIndices) ? yAxis.seriesDataIndices : [], axisEntry: yAxis };
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (categoryAxisIsY === false) {
|
|
50
|
+
const xWith = axes.find((a) => a?.axisDim === 'x' && hasSeriesIndices(a));
|
|
51
|
+
if (xWith)
|
|
52
|
+
return { indices: xWith.seriesDataIndices, axisEntry: xWith };
|
|
53
|
+
const xAxis = axes.find((a) => a?.axisDim === 'x');
|
|
54
|
+
if (xAxis)
|
|
55
|
+
return { indices: Array.isArray(xAxis.seriesDataIndices) ? xAxis.seriesDataIndices : [], axisEntry: xAxis };
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const preferred = axes.find((a) => a?.axisDim === 'x' && hasSeriesIndices(a));
|
|
59
|
+
const fallback = axes.find((a) => hasSeriesIndices(a));
|
|
60
|
+
const axisEntry = preferred ?? fallback ?? axes[0];
|
|
61
|
+
const indices = axisEntry?.seriesDataIndices;
|
|
62
|
+
if (!Array.isArray(indices) || indices.length === 0)
|
|
63
|
+
return null;
|
|
64
|
+
return { indices, axisEntry };
|
|
65
|
+
}
|
|
66
|
+
/** Build axis tooltip params from an ECharts `showTip` dispatch payload. */
|
|
67
|
+
export function axisTooltipParamsFromShowTipEvent(evt, ctx, seriesTheme) {
|
|
68
|
+
const pointerX = evt?.x;
|
|
69
|
+
const pointerY = evt?.y;
|
|
70
|
+
if (typeof pointerX !== 'number' || typeof pointerY !== 'number')
|
|
71
|
+
return null;
|
|
72
|
+
if (Number.isNaN(pointerX) || Number.isNaN(pointerY))
|
|
73
|
+
return null;
|
|
74
|
+
const picked = seriesDataIndicesFromShowTipEvt(evt, ctx.categoryAxisIsY);
|
|
75
|
+
if (picked == null)
|
|
76
|
+
return null;
|
|
77
|
+
const { indices, axisEntry } = picked;
|
|
78
|
+
const dataIndexRaw = dataIndexFromSeriesDataIndices(indices) ??
|
|
79
|
+
(typeof axisEntry?.dataIndex === 'number' && !Number.isNaN(axisEntry.dataIndex)
|
|
80
|
+
? axisEntry.dataIndex
|
|
81
|
+
: undefined) ??
|
|
82
|
+
(typeof evt?.dataIndex === 'number' && !Number.isNaN(evt.dataIndex) ? evt.dataIndex : undefined) ??
|
|
83
|
+
0;
|
|
84
|
+
const { displaySeries: ds, categoryAxisData: cats } = ctx;
|
|
85
|
+
if (!ds?.length || dataIndexRaw < 0)
|
|
86
|
+
return null;
|
|
87
|
+
const indicesForSeries = Array.isArray(indices) && indices.length > 0
|
|
88
|
+
? indices
|
|
89
|
+
: ds.map((_, seriesIndex) => ({ seriesIndex, dataIndex: dataIndexRaw }));
|
|
90
|
+
const axisValue = cats[dataIndexRaw] ?? dataIndexRaw;
|
|
91
|
+
const themeLen = Math.max(seriesTheme.length, 1);
|
|
92
|
+
const series = indicesForSeries.map((item) => {
|
|
93
|
+
const seriesIndex = typeof item.seriesIndex === 'number' ? item.seriesIndex : 0;
|
|
94
|
+
const s = ds[seriesIndex];
|
|
95
|
+
const seriesName = s?.name != null && s.name !== '' ? String(s.name) : `Series ${seriesIndex + 1}`;
|
|
96
|
+
let value = 0;
|
|
97
|
+
const pt = s?.data?.[dataIndexRaw];
|
|
98
|
+
if (typeof pt === 'number')
|
|
99
|
+
value = pt;
|
|
100
|
+
else if (Array.isArray(pt) && pt.length >= 2)
|
|
101
|
+
value = Number(pt[1]);
|
|
102
|
+
const color = seriesTheme[seriesIndex % themeLen]?.color;
|
|
103
|
+
return {
|
|
104
|
+
seriesName,
|
|
105
|
+
value,
|
|
106
|
+
seriesIndex,
|
|
107
|
+
...(typeof color === 'string' ? { color } : {}),
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
axisValue,
|
|
112
|
+
dataIndex: dataIndexRaw,
|
|
113
|
+
series,
|
|
114
|
+
pointerX,
|
|
115
|
+
pointerY,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** Spread onto ECharts `tooltip` when using an RN overlay (`showTip` / `hideTip` still fire). */
|
|
119
|
+
export function axisTooltipShowContentFlag(useCustomTooltipOverlay) {
|
|
120
|
+
return { showContent: !useCustomTooltipOverlay };
|
|
121
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTheme } from '../../chart-theme.context';
|
|
3
|
+
import type { AxisTooltipParams } from './axis-tooltip.types';
|
|
4
|
+
/**
|
|
5
|
+
* Themed default axis tooltip as React Native (mirrors the former ECharts tooltip styling).
|
|
6
|
+
* Pass the result of this factory to {@link useAxisTooltip} when the consumer does not pass `renderTooltip`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createDefaultAxisTooltip(theme: Pick<ChartTheme, 'tooltip'>): (params: AxisTooltipParams) => React.ReactElement;
|
|
9
|
+
//# sourceMappingURL=default-axis-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-axis-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/cartesian/tooltip/default-axis-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GACjC,CAAC,MAAM,EAAE,iBAAiB,KAAK,KAAK,CAAC,YAAY,CA8BnD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* Themed default axis tooltip as React Native (mirrors the former ECharts tooltip styling).
|
|
5
|
+
* Pass the result of this factory to {@link useAxisTooltip} when the consumer does not pass `renderTooltip`.
|
|
6
|
+
*/
|
|
7
|
+
export function createDefaultAxisTooltip(theme) {
|
|
8
|
+
const t = theme.tooltip;
|
|
9
|
+
return function DefaultAxisTooltip(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
|
+
<Text style={[styles.axisTitle, { color: t.labelColor }]}>{String(params.axisValue)}</Text>
|
|
18
|
+
{params.series.map((item) => (<View key={item.seriesIndex} style={styles.row}>
|
|
19
|
+
{item.color != null && item.color !== '' ? (<View style={[styles.swatch, { backgroundColor: item.color }]}/>) : (<View style={styles.swatchPlaceholder}/>)}
|
|
20
|
+
<Text style={[styles.valueLine, { color: t.valueColor }]}>
|
|
21
|
+
<Text style={{ color: t.labelColor }}>{item.seriesName}: </Text>
|
|
22
|
+
{String(item.value)}
|
|
23
|
+
</Text>
|
|
24
|
+
</View>))}
|
|
25
|
+
</View>);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
axisTitle: {
|
|
30
|
+
fontWeight: '600',
|
|
31
|
+
marginBottom: 4,
|
|
32
|
+
},
|
|
33
|
+
row: {
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
marginTop: 2,
|
|
37
|
+
},
|
|
38
|
+
swatch: {
|
|
39
|
+
width: 8,
|
|
40
|
+
height: 8,
|
|
41
|
+
borderRadius: 4,
|
|
42
|
+
marginRight: 6,
|
|
43
|
+
},
|
|
44
|
+
swatchPlaceholder: {
|
|
45
|
+
width: 8,
|
|
46
|
+
height: 8,
|
|
47
|
+
marginRight: 6,
|
|
48
|
+
},
|
|
49
|
+
valueLine: {
|
|
50
|
+
fontSize: 12,
|
|
51
|
+
flex: 1,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createDefaultAxisTooltip } from './default-axis-tooltip';
|
|
2
|
+
export { createAxisTooltipPreset } from './axis-tooltip-presets';
|
|
3
|
+
export type { AxisTooltipContentParams, AxisTooltipContext, AxisTooltipParams, AxisTooltipSeriesItem, } from './axis-tooltip.types';
|
|
4
|
+
export { axisTooltipShowContentFlag, axisTooltipParamsFromShowTipEvent } from './axis-tooltip.utils';
|
|
5
|
+
export { AxisTooltipOverlay, useAxisTooltip } from './use-axis-tooltip';
|
|
6
|
+
export type { AxisTooltipOverlayProps, UseAxisTooltipOptions, UseAxisTooltipResult } from './use-axis-tooltip';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../components/chart/cartesian/tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,YAAY,EACV,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxE,YAAY,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createDefaultAxisTooltip } from './default-axis-tooltip';
|
|
2
|
+
export { createAxisTooltipPreset } from './axis-tooltip-presets';
|
|
3
|
+
export { axisTooltipShowContentFlag, axisTooltipParamsFromShowTipEvent } from './axis-tooltip.utils';
|
|
4
|
+
export { AxisTooltipOverlay, useAxisTooltip } from './use-axis-tooltip';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AxisTooltipContext, AxisTooltipParams } from './axis-tooltip.types';
|
|
3
|
+
export interface AxisTooltipOverlayProps {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
params: AxisTooltipParams | null;
|
|
7
|
+
children: (params: AxisTooltipParams) => React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/** Presentational overlay; use with your own state if you do not use the hook. */
|
|
10
|
+
export declare function AxisTooltipOverlay({ width, height, params, children }: AxisTooltipOverlayProps): React.JSX.Element | null;
|
|
11
|
+
export interface UseAxisTooltipOptions {
|
|
12
|
+
/**
|
|
13
|
+
* When true, registers `showTip` / `hideTip` listeners and drives the overlay.
|
|
14
|
+
* Typically matches whether the chart shows the RN tooltip overlay (see chart `tooltip` / `renderTooltip`).
|
|
15
|
+
*/
|
|
16
|
+
active: boolean;
|
|
17
|
+
/** Resolved renderer (include {@link createDefaultAxisTooltip} when the consumer does not pass one). */
|
|
18
|
+
renderTooltip: (params: AxisTooltipParams) => React.ReactNode;
|
|
19
|
+
contextRef: React.RefObject<AxisTooltipContext>;
|
|
20
|
+
themeSeriesRef: React.RefObject<Array<{
|
|
21
|
+
color: string;
|
|
22
|
+
}>>;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}
|
|
26
|
+
export interface UseAxisTooltipResult {
|
|
27
|
+
attachAxisTooltipListeners: (chart: {
|
|
28
|
+
on: (ev: string, fn: (...args: any[]) => void) => void;
|
|
29
|
+
off: (ev: string, fn: (...args: any[]) => void) => void;
|
|
30
|
+
}) => () => void;
|
|
31
|
+
renderAxisTooltipOverlay: () => React.ReactNode;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Axis tooltip as React Native UI: listens to ECharts `showTip` / `hideTip`, maps payload with
|
|
35
|
+
* {@link axisTooltipParamsFromShowTipEvent}, and positions an overlay near the pointer.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useAxisTooltip(options: UseAxisTooltipOptions): UseAxisTooltipResult;
|
|
38
|
+
//# sourceMappingURL=use-axis-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-axis-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/cartesian/tooltip/use-axis-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGlF,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACjC,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,KAAK,CAAC,SAAS,CAAC;CAC1D;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,uBAAuB,4BAY9F;AAED,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB,wGAAwG;IACxG,aAAa,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9D,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAChD,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,oBAAoB;IACnC,0BAA0B,EAAE,CAAC,KAAK,EAAE;QAClC,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,wBAAwB,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,oBAAoB,CA4CnF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { ChartPointerTooltipOverlay } from '../../tooltip/chart-pointer-tooltip-overlay';
|
|
3
|
+
import { axisTooltipParamsFromShowTipEvent } from './axis-tooltip.utils';
|
|
4
|
+
/** Presentational overlay; use with your own state if you do not use the hook. */
|
|
5
|
+
export function AxisTooltipOverlay({ width, height, params, children }) {
|
|
6
|
+
if (params == null)
|
|
7
|
+
return null;
|
|
8
|
+
return (<ChartPointerTooltipOverlay width={width} height={height} pointerX={params.pointerX} pointerY={params.pointerY}>
|
|
9
|
+
{children(params)}
|
|
10
|
+
</ChartPointerTooltipOverlay>);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Axis tooltip as React Native UI: listens to ECharts `showTip` / `hideTip`, maps payload with
|
|
14
|
+
* {@link axisTooltipParamsFromShowTipEvent}, and positions an overlay near the pointer.
|
|
15
|
+
*/
|
|
16
|
+
export function useAxisTooltip(options) {
|
|
17
|
+
const { active, renderTooltip, contextRef, themeSeriesRef, width, height } = options;
|
|
18
|
+
const [tooltipParams, setTooltipParams] = useState(null);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!active)
|
|
21
|
+
setTooltipParams(null);
|
|
22
|
+
}, [active]);
|
|
23
|
+
const attachAxisTooltipListeners = useCallback((chart) => {
|
|
24
|
+
if (!active)
|
|
25
|
+
return () => { };
|
|
26
|
+
const onShowTip = (evt) => {
|
|
27
|
+
const ctx = contextRef.current;
|
|
28
|
+
if (!ctx?.displaySeries?.length) {
|
|
29
|
+
setTooltipParams(null);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const params = axisTooltipParamsFromShowTipEvent(evt, ctx, themeSeriesRef.current ?? []);
|
|
33
|
+
setTooltipParams(params);
|
|
34
|
+
};
|
|
35
|
+
const onHideTip = () => setTooltipParams(null);
|
|
36
|
+
chart.on('showTip', onShowTip);
|
|
37
|
+
chart.on('hideTip', onHideTip);
|
|
38
|
+
return () => {
|
|
39
|
+
chart.off('showTip', onShowTip);
|
|
40
|
+
chart.off('hideTip', onHideTip);
|
|
41
|
+
};
|
|
42
|
+
}, [active, contextRef, themeSeriesRef]);
|
|
43
|
+
const renderAxisTooltipOverlay = useCallback(() => {
|
|
44
|
+
if (!active || tooltipParams == null)
|
|
45
|
+
return null;
|
|
46
|
+
return (<AxisTooltipOverlay width={width} height={height} params={tooltipParams}>
|
|
47
|
+
{renderTooltip}
|
|
48
|
+
</AxisTooltipOverlay>);
|
|
49
|
+
}, [active, renderTooltip, tooltipParams, width, height]);
|
|
50
|
+
return {
|
|
51
|
+
attachAxisTooltipListeners,
|
|
52
|
+
renderAxisTooltipOverlay,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/column/column-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"column-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/column/column-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAW1D,oCAAoC;AACpC,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAgpB7D,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
|
package/column/column-chart.js
CHANGED
|
@@ -5,7 +5,10 @@ import { BarChart as EChartsBarChart } from 'echarts/charts';
|
|
|
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 { createAxisTooltipPreset, useAxisTooltip } from '../cartesian/tooltip';
|
|
11
|
+
import { echartsLegendLayoutFragment, mergeCartesianGridForLegend, } from '../legend/echarts-legend-layout';
|
|
9
12
|
echarts.use([
|
|
10
13
|
TooltipComponent,
|
|
11
14
|
GridComponent,
|
|
@@ -13,12 +16,44 @@ echarts.use([
|
|
|
13
16
|
SkiaRenderer,
|
|
14
17
|
EChartsBarChart,
|
|
15
18
|
]);
|
|
16
|
-
|
|
19
|
+
/** Stable identity for default `cornerRadius` (inline `[4,4,0,0]` in params is a new array every render). */
|
|
20
|
+
const DEFAULT_COLUMN_CORNER_RADIUS = [4, 4, 0, 0];
|
|
21
|
+
function columnCornerRadiusDep(value) {
|
|
22
|
+
if (typeof value === 'number')
|
|
23
|
+
return value;
|
|
24
|
+
if (Array.isArray(value))
|
|
25
|
+
return value.join(',');
|
|
26
|
+
return '4,4,0,0';
|
|
27
|
+
}
|
|
28
|
+
const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, cornerRadius = DEFAULT_COLUMN_CORNER_RADIUS, horizontal = false, stack, stackNormalize = false, activeIndex, activeColor, barInsideLabelPosition = 'start', barInsideLabelFormatter, barOutsideLabelPosition = 'start', barOutsideLabelFormatter, itemStyle, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = true, legendPosition = 'bottom', showHighlighter = false, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
|
|
17
29
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
18
30
|
const chartRef = useRef(null);
|
|
19
31
|
const onSelectRef = useRef(onSelect);
|
|
20
32
|
onSelectRef.current = onSelect;
|
|
21
|
-
const selectContextRef = useRef({
|
|
33
|
+
const selectContextRef = useRef({
|
|
34
|
+
displaySeries: [],
|
|
35
|
+
categoryAxisData: [],
|
|
36
|
+
labelOverlayDuplicate: false,
|
|
37
|
+
categoryAxisIsY: false,
|
|
38
|
+
});
|
|
39
|
+
const themeSeriesRef = useRef(theme.series);
|
|
40
|
+
themeSeriesRef.current = theme.series;
|
|
41
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
42
|
+
const renderTooltipFn = useMemo(() => {
|
|
43
|
+
if (renderTooltip != null)
|
|
44
|
+
return renderTooltip;
|
|
45
|
+
if (tooltip === 'none')
|
|
46
|
+
return () => null;
|
|
47
|
+
return createAxisTooltipPreset(tooltip);
|
|
48
|
+
}, [renderTooltip, tooltip]);
|
|
49
|
+
const { attachAxisTooltipListeners, renderAxisTooltipOverlay } = useAxisTooltip({
|
|
50
|
+
active: tooltipOverlayActive,
|
|
51
|
+
renderTooltip: renderTooltipFn,
|
|
52
|
+
contextRef: selectContextRef,
|
|
53
|
+
themeSeriesRef,
|
|
54
|
+
width,
|
|
55
|
+
height,
|
|
56
|
+
});
|
|
22
57
|
const normalizedSeries = useMemo(() => {
|
|
23
58
|
let normalizedData = [];
|
|
24
59
|
if (!Array.isArray(data) || data.length === 0)
|
|
@@ -82,34 +117,31 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
82
117
|
};
|
|
83
118
|
});
|
|
84
119
|
}, [normalizedSeries, stackNormalize]);
|
|
120
|
+
const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
|
|
121
|
+
const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
|
|
85
122
|
const showLabelInside = barInsideLabelFormatter != null;
|
|
86
123
|
const showLabelOutside = barOutsideLabelFormatter != null;
|
|
87
124
|
const isSingleSeries = displaySeries.length === 1;
|
|
88
125
|
const labelOverlayDuplicate = showLabelInside && showLabelOutside && isSingleSeries;
|
|
89
|
-
|
|
90
|
-
const option = useMemo(() => {
|
|
126
|
+
const categoryAxisData = useMemo(() => {
|
|
91
127
|
const categories = (displaySeries[0]?.data ?? []).map((item) => String(item[0]));
|
|
92
128
|
const dataPoints = displaySeries.flatMap((s) => s.data.map((d) => d[1]));
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
color: 'rgba(0,0,0,0.08)',
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
}
|
|
108
|
-
: { trigger: 'axis' };
|
|
129
|
+
return categories.length > 0 ? categories : getAxis(dataPoints).map(String);
|
|
130
|
+
}, [displaySeries]);
|
|
131
|
+
selectContextRef.current = {
|
|
132
|
+
displaySeries,
|
|
133
|
+
categoryAxisData,
|
|
134
|
+
labelOverlayDuplicate,
|
|
135
|
+
categoryAxisIsY: horizontal,
|
|
136
|
+
};
|
|
137
|
+
const option = useMemo(() => {
|
|
138
|
+
const categories = (displaySeries[0]?.data ?? []).map((item) => String(item[0]));
|
|
139
|
+
const xAxisData = categoryAxisData;
|
|
109
140
|
const categoryAxisConfig = {
|
|
110
141
|
type: 'category',
|
|
111
142
|
data: xAxisData,
|
|
112
143
|
boundaryGap,
|
|
144
|
+
...(!horizontal ? (xAxisBounds ?? {}) : {}),
|
|
113
145
|
...((horizontal ? yAxisLabel : xAxisLabel) != null && (horizontal ? yAxisLabel : xAxisLabel) !== '' && {
|
|
114
146
|
name: horizontal ? yAxisLabel : xAxisLabel,
|
|
115
147
|
nameLocation: 'middle',
|
|
@@ -145,13 +177,15 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
145
177
|
},
|
|
146
178
|
},
|
|
147
179
|
};
|
|
180
|
+
const stackPct = stackNormalize && displaySeries.length > 1;
|
|
181
|
+
const valueAxisNumericExtras = stackPct
|
|
182
|
+
? { min: 0, max: 100 }
|
|
183
|
+
: horizontal
|
|
184
|
+
? { ...(valueAxisBounds ?? {}), ...(xAxisBounds ?? {}) }
|
|
185
|
+
: (valueAxisBounds ?? {});
|
|
148
186
|
const valueAxisConfig = {
|
|
149
187
|
type: 'value',
|
|
150
|
-
...
|
|
151
|
-
displaySeries.length > 1 && {
|
|
152
|
-
min: 0,
|
|
153
|
-
max: 100,
|
|
154
|
-
}),
|
|
188
|
+
...valueAxisNumericExtras,
|
|
155
189
|
...((horizontal ? xAxisLabel : yAxisLabel) != null && (horizontal ? xAxisLabel : yAxisLabel) !== '' && {
|
|
156
190
|
name: horizontal ? xAxisLabel : yAxisLabel,
|
|
157
191
|
nameLocation: 'middle',
|
|
@@ -197,6 +231,7 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
197
231
|
data: normalizedSeries
|
|
198
232
|
.filter((s) => 'name' in s && s.name)
|
|
199
233
|
.map((s) => s.name),
|
|
234
|
+
...echartsLegendLayoutFragment(legendPosition),
|
|
200
235
|
textStyle: {
|
|
201
236
|
color: theme.legend.textColor,
|
|
202
237
|
fontSize: theme.legend.fontSize,
|
|
@@ -368,22 +403,37 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
368
403
|
seriesConfig.push(labelOnlySeries);
|
|
369
404
|
}
|
|
370
405
|
const config = {
|
|
371
|
-
tooltip: tooltipConfig,
|
|
372
406
|
xAxis: xAxisConfig,
|
|
373
407
|
yAxis: yAxisConfig,
|
|
374
408
|
series: seriesConfig,
|
|
409
|
+
axisPointer: {
|
|
410
|
+
show: true,
|
|
411
|
+
type: 'line',
|
|
412
|
+
snap: true,
|
|
413
|
+
lineStyle: {
|
|
414
|
+
type: 'solid',
|
|
415
|
+
width: 1,
|
|
416
|
+
color: '#00000000',
|
|
417
|
+
show: false,
|
|
418
|
+
},
|
|
419
|
+
label: {
|
|
420
|
+
show: false,
|
|
421
|
+
},
|
|
422
|
+
},
|
|
375
423
|
};
|
|
376
424
|
if (legendConfig)
|
|
377
425
|
config.legend = legendConfig;
|
|
378
|
-
|
|
379
|
-
|
|
426
|
+
const mergedGrid = mergeCartesianGridForLegend(grid, legendPosition, showLegend, hasNamedSeries);
|
|
427
|
+
if (mergedGrid !== undefined && Object.keys(mergedGrid).length > 0) {
|
|
428
|
+
config.grid = mergedGrid;
|
|
429
|
+
}
|
|
380
430
|
return config;
|
|
381
431
|
}, [
|
|
382
432
|
theme,
|
|
383
433
|
normalizedSeries,
|
|
384
434
|
displaySeries,
|
|
385
435
|
boundaryGap,
|
|
386
|
-
cornerRadius,
|
|
436
|
+
columnCornerRadiusDep(cornerRadius),
|
|
387
437
|
horizontal,
|
|
388
438
|
stack,
|
|
389
439
|
stackNormalize,
|
|
@@ -402,20 +452,26 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
402
452
|
showYAxisSplitLines,
|
|
403
453
|
grid,
|
|
404
454
|
showLegend,
|
|
455
|
+
legendPosition,
|
|
405
456
|
hasNamedSeries,
|
|
406
457
|
showHighlighter,
|
|
458
|
+
tooltipOverlayActive,
|
|
407
459
|
xAxisTickLabelFormatter,
|
|
408
460
|
yAxisTickLabelFormatter,
|
|
409
|
-
xAxisTicks,
|
|
410
461
|
xAxisLabel,
|
|
411
462
|
yAxisLabel,
|
|
463
|
+
categoryAxisData,
|
|
464
|
+
valueAxisBounds,
|
|
465
|
+
xAxisBounds,
|
|
412
466
|
]);
|
|
413
467
|
useEffect(() => {
|
|
414
468
|
let chart;
|
|
469
|
+
let detachAxisTooltip = () => { };
|
|
415
470
|
if (chartRef.current) {
|
|
416
471
|
try {
|
|
417
472
|
chart = echarts.init(chartRef.current, 'light', { width, height });
|
|
418
473
|
chart.setOption(option);
|
|
474
|
+
detachAxisTooltip = attachAxisTooltipListeners(chart);
|
|
419
475
|
const handleSeriesClick = (params) => {
|
|
420
476
|
const cb = onSelectRef.current;
|
|
421
477
|
if (typeof cb !== 'function')
|
|
@@ -463,6 +519,7 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
463
519
|
}
|
|
464
520
|
}
|
|
465
521
|
return () => {
|
|
522
|
+
detachAxisTooltip();
|
|
466
523
|
if (chart) {
|
|
467
524
|
try {
|
|
468
525
|
chart.dispose();
|
|
@@ -472,8 +529,11 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
472
529
|
}
|
|
473
530
|
}
|
|
474
531
|
};
|
|
475
|
-
}, [option, width, height]);
|
|
476
|
-
return <
|
|
532
|
+
}, [option, width, height, attachAxisTooltipListeners]);
|
|
533
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
534
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
535
|
+
{renderAxisTooltipOverlay()}
|
|
536
|
+
</View>);
|
|
477
537
|
};
|
|
478
538
|
const ColumnChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
479
539
|
export const ColumnChart = Object.assign(ColumnChartComponent, {
|
package/geo/geo-chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geo-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/geo-chart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geo-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/geo-chart.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAoC,MAAM,mBAAmB,CAAC;AAOzF,OAAO,KAAgE,MAAM,OAAO,CAAC;AAGrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAErG,2GAA2G;AAC3G,eAAO,MAAM,iBAAiB,kCAAyC,CAAC;AA0PxE,eAAO,MAAM,QAAQ;;;;;;;CAEnB,CAAC"}
|