@wavemaker/react-native-echarts 1.0.0-dev.5 → 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 +29 -3
- 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 +1 -1
- package/pie/index.d.ts +1 -0
- package/pie/index.d.ts.map +1 -1
- package/pie/index.js +1 -0
- package/pie/pie-chart.d.ts.map +1 -1
- package/pie/pie-chart.js +59 -36
- package/pie/pie-chart.props.d.ts +12 -6
- package/pie/pie-chart.props.d.ts.map +1 -1
- package/pie/tooltip/default-pie-tooltip.d.ts +5 -0
- package/pie/tooltip/default-pie-tooltip.d.ts.map +1 -0
- package/pie/tooltip/default-pie-tooltip.js +57 -0
- package/pie/tooltip/index.d.ts +7 -0
- package/pie/tooltip/index.d.ts.map +1 -0
- package/pie/tooltip/index.js +4 -0
- package/pie/tooltip/pie-item-tooltip-presets.d.ts +5 -0
- package/pie/tooltip/pie-item-tooltip-presets.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip-presets.js +39 -0
- package/pie/tooltip/pie-item-tooltip.types.d.ts +28 -0
- package/pie/tooltip/pie-item-tooltip.types.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip.types.js +3 -0
- package/pie/tooltip/pie-item-tooltip.utils.d.ts +9 -0
- package/pie/tooltip/pie-item-tooltip.utils.d.ts.map +1 -0
- package/pie/tooltip/pie-item-tooltip.utils.js +139 -0
- package/pie/tooltip/use-pie-item-tooltip.d.ts +24 -0
- package/pie/tooltip/use-pie-item-tooltip.d.ts.map +1 -0
- package/pie/tooltip/use-pie-item-tooltip.js +45 -0
- package/props/cartesian.d.ts +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,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;AAO1D,oCAAoC;AACpC,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAqnB7D,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
|
package/column/column-chart.js
CHANGED
|
@@ -5,7 +5,9 @@ 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 { View } from 'react-native';
|
|
8
9
|
import { getAxis } from '../axis';
|
|
10
|
+
import { createAxisTooltipPreset, useAxisTooltip } from '../cartesian/tooltip';
|
|
9
11
|
echarts.use([
|
|
10
12
|
TooltipComponent,
|
|
11
13
|
GridComponent,
|
|
@@ -13,12 +15,44 @@ echarts.use([
|
|
|
13
15
|
SkiaRenderer,
|
|
14
16
|
EChartsBarChart,
|
|
15
17
|
]);
|
|
16
|
-
|
|
18
|
+
/** Stable identity for default `cornerRadius` (inline `[4,4,0,0]` in params is a new array every render). */
|
|
19
|
+
const DEFAULT_COLUMN_CORNER_RADIUS = [4, 4, 0, 0];
|
|
20
|
+
function columnCornerRadiusDep(value) {
|
|
21
|
+
if (typeof value === 'number')
|
|
22
|
+
return value;
|
|
23
|
+
if (Array.isArray(value))
|
|
24
|
+
return value.join(',');
|
|
25
|
+
return '4,4,0,0';
|
|
26
|
+
}
|
|
27
|
+
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 = false, showHighlighter = false, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisTicks, xAxisLabel, yAxisLabel, onSelect, renderTooltip, ...props }) => {
|
|
17
28
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
18
29
|
const chartRef = useRef(null);
|
|
19
30
|
const onSelectRef = useRef(onSelect);
|
|
20
31
|
onSelectRef.current = onSelect;
|
|
21
|
-
const selectContextRef = useRef({
|
|
32
|
+
const selectContextRef = useRef({
|
|
33
|
+
displaySeries: [],
|
|
34
|
+
categoryAxisData: [],
|
|
35
|
+
labelOverlayDuplicate: false,
|
|
36
|
+
categoryAxisIsY: false,
|
|
37
|
+
});
|
|
38
|
+
const themeSeriesRef = useRef(theme.series);
|
|
39
|
+
themeSeriesRef.current = theme.series;
|
|
40
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
41
|
+
const renderTooltipFn = useMemo(() => {
|
|
42
|
+
if (renderTooltip != null)
|
|
43
|
+
return renderTooltip;
|
|
44
|
+
if (tooltip === 'none')
|
|
45
|
+
return () => null;
|
|
46
|
+
return createAxisTooltipPreset(tooltip);
|
|
47
|
+
}, [renderTooltip, tooltip]);
|
|
48
|
+
const { attachAxisTooltipListeners, renderAxisTooltipOverlay } = useAxisTooltip({
|
|
49
|
+
active: tooltipOverlayActive,
|
|
50
|
+
renderTooltip: renderTooltipFn,
|
|
51
|
+
contextRef: selectContextRef,
|
|
52
|
+
themeSeriesRef,
|
|
53
|
+
width,
|
|
54
|
+
height,
|
|
55
|
+
});
|
|
22
56
|
const normalizedSeries = useMemo(() => {
|
|
23
57
|
let normalizedData = [];
|
|
24
58
|
if (!Array.isArray(data) || data.length === 0)
|
|
@@ -86,26 +120,24 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
86
120
|
const showLabelOutside = barOutsideLabelFormatter != null;
|
|
87
121
|
const isSingleSeries = displaySeries.length === 1;
|
|
88
122
|
const labelOverlayDuplicate = showLabelInside && showLabelOutside && isSingleSeries;
|
|
89
|
-
|
|
90
|
-
const option = useMemo(() => {
|
|
123
|
+
const categoryAxisData = useMemo(() => {
|
|
91
124
|
const categories = (displaySeries[0]?.data ?? []).map((item) => String(item[0]));
|
|
92
125
|
const dataPoints = displaySeries.flatMap((s) => s.data.map((d) => d[1]));
|
|
93
|
-
|
|
126
|
+
return xAxisTicks != null && xAxisTicks.length > 0
|
|
94
127
|
? xAxisTicks
|
|
95
128
|
: categories.length > 0
|
|
96
129
|
? categories
|
|
97
130
|
: getAxis(dataPoints).map(String);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
: { trigger: 'axis' };
|
|
131
|
+
}, [displaySeries, xAxisTicks]);
|
|
132
|
+
selectContextRef.current = {
|
|
133
|
+
displaySeries,
|
|
134
|
+
categoryAxisData,
|
|
135
|
+
labelOverlayDuplicate,
|
|
136
|
+
categoryAxisIsY: horizontal,
|
|
137
|
+
};
|
|
138
|
+
const option = useMemo(() => {
|
|
139
|
+
const categories = (displaySeries[0]?.data ?? []).map((item) => String(item[0]));
|
|
140
|
+
const xAxisData = categoryAxisData;
|
|
109
141
|
const categoryAxisConfig = {
|
|
110
142
|
type: 'category',
|
|
111
143
|
data: xAxisData,
|
|
@@ -368,10 +400,23 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
368
400
|
seriesConfig.push(labelOnlySeries);
|
|
369
401
|
}
|
|
370
402
|
const config = {
|
|
371
|
-
tooltip: tooltipConfig,
|
|
372
403
|
xAxis: xAxisConfig,
|
|
373
404
|
yAxis: yAxisConfig,
|
|
374
405
|
series: seriesConfig,
|
|
406
|
+
axisPointer: {
|
|
407
|
+
show: true,
|
|
408
|
+
type: 'line',
|
|
409
|
+
snap: true,
|
|
410
|
+
lineStyle: {
|
|
411
|
+
type: 'solid',
|
|
412
|
+
width: 1,
|
|
413
|
+
color: '#00000000',
|
|
414
|
+
show: false,
|
|
415
|
+
},
|
|
416
|
+
label: {
|
|
417
|
+
show: false,
|
|
418
|
+
},
|
|
419
|
+
},
|
|
375
420
|
};
|
|
376
421
|
if (legendConfig)
|
|
377
422
|
config.legend = legendConfig;
|
|
@@ -383,7 +428,7 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
383
428
|
normalizedSeries,
|
|
384
429
|
displaySeries,
|
|
385
430
|
boundaryGap,
|
|
386
|
-
cornerRadius,
|
|
431
|
+
columnCornerRadiusDep(cornerRadius),
|
|
387
432
|
horizontal,
|
|
388
433
|
stack,
|
|
389
434
|
stackNormalize,
|
|
@@ -404,18 +449,22 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
404
449
|
showLegend,
|
|
405
450
|
hasNamedSeries,
|
|
406
451
|
showHighlighter,
|
|
452
|
+
tooltipOverlayActive,
|
|
407
453
|
xAxisTickLabelFormatter,
|
|
408
454
|
yAxisTickLabelFormatter,
|
|
409
455
|
xAxisTicks,
|
|
410
456
|
xAxisLabel,
|
|
411
457
|
yAxisLabel,
|
|
458
|
+
categoryAxisData,
|
|
412
459
|
]);
|
|
413
460
|
useEffect(() => {
|
|
414
461
|
let chart;
|
|
462
|
+
let detachAxisTooltip = () => { };
|
|
415
463
|
if (chartRef.current) {
|
|
416
464
|
try {
|
|
417
465
|
chart = echarts.init(chartRef.current, 'light', { width, height });
|
|
418
466
|
chart.setOption(option);
|
|
467
|
+
detachAxisTooltip = attachAxisTooltipListeners(chart);
|
|
419
468
|
const handleSeriesClick = (params) => {
|
|
420
469
|
const cb = onSelectRef.current;
|
|
421
470
|
if (typeof cb !== 'function')
|
|
@@ -463,6 +512,7 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
463
512
|
}
|
|
464
513
|
}
|
|
465
514
|
return () => {
|
|
515
|
+
detachAxisTooltip();
|
|
466
516
|
if (chart) {
|
|
467
517
|
try {
|
|
468
518
|
chart.dispose();
|
|
@@ -472,8 +522,11 @@ const ChartComponent = ({ data, width = 220, height = 350, boundaryGap = true, c
|
|
|
472
522
|
}
|
|
473
523
|
}
|
|
474
524
|
};
|
|
475
|
-
}, [option, width, height]);
|
|
476
|
-
return <
|
|
525
|
+
}, [option, width, height, attachAxisTooltipListeners]);
|
|
526
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
527
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
528
|
+
{renderAxisTooltipOverlay()}
|
|
529
|
+
</View>);
|
|
477
530
|
};
|
|
478
531
|
const ColumnChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
479
532
|
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"}
|
package/geo/geo-chart.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { withResponsiveContainer } from '../chart-container';
|
|
2
2
|
import { useChartTheme, withChartTheme } from '../chart-theme.context';
|
|
3
|
+
import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
|
|
4
|
+
import { createGeoTooltipPreset, useGeoItemTooltip } from './tooltip';
|
|
3
5
|
import { SkiaChart, SkiaRenderer } from '@wuba/react-native-echarts';
|
|
4
6
|
import { MapChart } from 'echarts/charts';
|
|
5
7
|
import { TooltipComponent, VisualMapComponent } from 'echarts/components';
|
|
6
8
|
import * as echarts from 'echarts/core';
|
|
7
9
|
import React, { createContext, useContext, useEffect, useMemo, useRef } from 'react';
|
|
8
|
-
import
|
|
10
|
+
import { View } from 'react-native';
|
|
11
|
+
import worldJson from './world.json';
|
|
9
12
|
/** Optional context to provide mapJson without passing as prop (avoids Storybook serialization issues). */
|
|
10
13
|
export const GeoMapJsonContext = createContext(null);
|
|
11
14
|
echarts.use([
|
|
@@ -15,13 +18,41 @@ echarts.use([
|
|
|
15
18
|
MapChart,
|
|
16
19
|
]);
|
|
17
20
|
const DEFAULT_MAP_NAME = 'world';
|
|
18
|
-
const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME, width = 400, height = 300, showLegend = true, showHighlighter = true,
|
|
21
|
+
const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME, width = 400, height = 300, showLegend = true, showHighlighter = true, tooltip = 'card', renderTooltip, visualMapMin, visualMapMax, visualMapMode = 'continuous', piecewisePieces, onSelect, ...props }) => {
|
|
19
22
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
20
23
|
const chartRef = useRef(null);
|
|
21
24
|
const onSelectRef = useRef(onSelect);
|
|
22
25
|
onSelectRef.current = onSelect;
|
|
26
|
+
const geoContextRef = useRef({ regions: [] });
|
|
27
|
+
const themeSeriesRef = useRef(theme.series);
|
|
28
|
+
themeSeriesRef.current = theme.series;
|
|
23
29
|
const contextMapJson = useContext(GeoMapJsonContext);
|
|
24
30
|
const mapJson = mapJsonProp ?? contextMapJson ?? worldJson;
|
|
31
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
32
|
+
const renderTooltipFn = useMemo(() => {
|
|
33
|
+
if (renderTooltip != null)
|
|
34
|
+
return renderTooltip;
|
|
35
|
+
if (tooltip === 'none')
|
|
36
|
+
return () => null;
|
|
37
|
+
return createGeoTooltipPreset(tooltip);
|
|
38
|
+
}, [renderTooltip, tooltip]);
|
|
39
|
+
const { attachGeoItemTooltipListeners, renderGeoTooltipOverlay } = useGeoItemTooltip({
|
|
40
|
+
active: tooltipOverlayActive,
|
|
41
|
+
renderTooltip: renderTooltipFn,
|
|
42
|
+
contextRef: geoContextRef,
|
|
43
|
+
themeSeriesRef,
|
|
44
|
+
width,
|
|
45
|
+
height,
|
|
46
|
+
});
|
|
47
|
+
const tooltipRegions = useMemo(() => {
|
|
48
|
+
if (!Array.isArray(data) || data.length === 0)
|
|
49
|
+
return [];
|
|
50
|
+
return data.map((d) => ({
|
|
51
|
+
name: String(d.name),
|
|
52
|
+
value: Number(d.value),
|
|
53
|
+
}));
|
|
54
|
+
}, [data]);
|
|
55
|
+
geoContextRef.current = { regions: tooltipRegions };
|
|
25
56
|
useEffect(() => {
|
|
26
57
|
if (mapJson?.type === 'FeatureCollection' && mapJson.features?.length) {
|
|
27
58
|
try {
|
|
@@ -47,20 +78,12 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
47
78
|
return { series: [{ type: 'map', map: mapName, data: [] }] };
|
|
48
79
|
}
|
|
49
80
|
const seriesColor = theme.series[0]?.color ?? '#3b82f6';
|
|
50
|
-
const tooltipConfig =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
: undefined,
|
|
58
|
-
backgroundColor: theme.tooltip.backgroundColor,
|
|
59
|
-
borderColor: theme.tooltip.borderColor,
|
|
60
|
-
borderWidth: theme.tooltip.borderWidth,
|
|
61
|
-
borderRadius: theme.tooltip.borderRadius,
|
|
62
|
-
padding: theme.tooltip.padding,
|
|
63
|
-
};
|
|
81
|
+
const tooltipConfig = tooltipOverlayActive
|
|
82
|
+
? {
|
|
83
|
+
trigger: 'item',
|
|
84
|
+
...axisTooltipShowContentFlag(true),
|
|
85
|
+
}
|
|
86
|
+
: { show: false };
|
|
64
87
|
const visualMapConfig = showLegend
|
|
65
88
|
? visualMapMode === 'piecewise' && piecewisePieces?.length
|
|
66
89
|
? {
|
|
@@ -112,15 +135,18 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
112
135
|
},
|
|
113
136
|
emphasis: showHighlighter
|
|
114
137
|
? {
|
|
138
|
+
focus: 'none',
|
|
115
139
|
itemStyle: {
|
|
116
|
-
areaColor: seriesColor,
|
|
117
140
|
borderColor: '#333',
|
|
118
141
|
borderWidth: 1,
|
|
119
142
|
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
143
|
+
// Avoid duplicating the region name when the RN tooltip is active.
|
|
144
|
+
label: tooltipOverlayActive
|
|
145
|
+
? { show: false }
|
|
146
|
+
: {
|
|
147
|
+
show: true,
|
|
148
|
+
color: theme.legend.textColor,
|
|
149
|
+
},
|
|
124
150
|
}
|
|
125
151
|
: { disabled: true },
|
|
126
152
|
};
|
|
@@ -138,12 +164,13 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
138
164
|
valueRange,
|
|
139
165
|
showLegend,
|
|
140
166
|
showHighlighter,
|
|
141
|
-
|
|
167
|
+
tooltipOverlayActive,
|
|
142
168
|
visualMapMode,
|
|
143
169
|
piecewisePieces,
|
|
144
170
|
]);
|
|
145
171
|
useEffect(() => {
|
|
146
172
|
let chart;
|
|
173
|
+
let detachGeoTooltip = () => { };
|
|
147
174
|
if (chartRef.current) {
|
|
148
175
|
try {
|
|
149
176
|
chart = echarts.init(chartRef.current, 'light', {
|
|
@@ -151,6 +178,7 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
151
178
|
height,
|
|
152
179
|
});
|
|
153
180
|
chart.setOption(option);
|
|
181
|
+
detachGeoTooltip = attachGeoItemTooltipListeners(chart);
|
|
154
182
|
const handleMapClick = (params) => {
|
|
155
183
|
const cb = onSelectRef.current;
|
|
156
184
|
if (typeof cb !== 'function')
|
|
@@ -182,6 +210,7 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
182
210
|
}
|
|
183
211
|
}
|
|
184
212
|
return () => {
|
|
213
|
+
detachGeoTooltip();
|
|
185
214
|
if (chart) {
|
|
186
215
|
try {
|
|
187
216
|
chart.dispose();
|
|
@@ -191,8 +220,11 @@ const ChartComponent = ({ data, mapJson: mapJsonProp, mapName = DEFAULT_MAP_NAME
|
|
|
191
220
|
}
|
|
192
221
|
}
|
|
193
222
|
};
|
|
194
|
-
}, [option, width, height]);
|
|
195
|
-
return <
|
|
223
|
+
}, [option, width, height, attachGeoItemTooltipListeners]);
|
|
224
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
225
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
226
|
+
{renderGeoTooltipOverlay()}
|
|
227
|
+
</View>);
|
|
196
228
|
};
|
|
197
229
|
const GeoChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
198
230
|
export const GeoChart = Object.assign(GeoChartComponent, {
|
package/geo/geo-chart.props.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { CommonChartProps } from '../props/common';
|
|
2
|
+
import type { ChartTooltipOption } from '../tooltip';
|
|
3
|
+
import type { GeoItemTooltipParams } from './tooltip/geo-item-tooltip.types';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
2
5
|
/** Emitted when the user taps/clicks a map region. */
|
|
3
6
|
export interface GeoChartSelectEvent {
|
|
4
7
|
name: string;
|
|
@@ -59,12 +62,15 @@ export interface GeoChartProps extends CommonChartProps {
|
|
|
59
62
|
*/
|
|
60
63
|
showHighlighter?: boolean;
|
|
61
64
|
/**
|
|
62
|
-
*
|
|
65
|
+
* Built-in region tooltip preset when `renderTooltip` is omitted. Use `none` to hide the overlay.
|
|
66
|
+
* @default 'card'
|
|
63
67
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
tooltip?: ChartTooltipOption;
|
|
69
|
+
/**
|
|
70
|
+
* Overrides the default React Native item tooltip body (see {@link GeoItemTooltipParams}).
|
|
71
|
+
* Takes precedence over {@link tooltip}.
|
|
72
|
+
*/
|
|
73
|
+
renderTooltip?: (params: GeoItemTooltipParams) => ReactNode;
|
|
68
74
|
/**
|
|
69
75
|
* Minimum value for the visual map scale. Auto-derived from data if not set.
|
|
70
76
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geo-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/geo-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"geo-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/geo-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,OAAO,CAAA;SAAE,CAAC;QACjD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACtC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD;;;OAGG;IACH,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,SAAS,CAAC;IAC5D;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;IAC3C;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpF;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACjD"}
|
package/geo/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { GeoChart, GeoMapJsonContext } from './geo-chart';
|
|
|
2
2
|
export { USChart } from './us-chart';
|
|
3
3
|
export { WorldChart } from './world-chart';
|
|
4
4
|
export type { GeoChartProps, GeoChartSelectEvent, GeoDataItem, GeoJSONMap, } from './geo-chart.props';
|
|
5
|
+
export * from './tooltip';
|
|
5
6
|
export type { USChartProps } from './us-chart';
|
|
6
7
|
export type { WorldChartProps } from './world-chart';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/geo/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
package/geo/index.js
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTheme } from '../../chart-theme.context';
|
|
3
|
+
import type { GeoItemTooltipParams } from './geo-item-tooltip.types';
|
|
4
|
+
/** Themed default geo / map item tooltip (React Native). */
|
|
5
|
+
export declare function createDefaultGeoTooltip(theme: Pick<ChartTheme, 'tooltip'>): (params: GeoItemTooltipParams) => React.ReactElement;
|
|
6
|
+
//# sourceMappingURL=default-geo-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-geo-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/geo/tooltip/default-geo-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,4DAA4D;AAC5D,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GACjC,CAAC,MAAM,EAAE,oBAAoB,KAAK,KAAK,CAAC,YAAY,CA6BtD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
/** Themed default geo / map item tooltip (React Native). */
|
|
4
|
+
export function createDefaultGeoTooltip(theme) {
|
|
5
|
+
const t = theme.tooltip;
|
|
6
|
+
return function DefaultGeoTooltip(params) {
|
|
7
|
+
const { name, value, color } = params;
|
|
8
|
+
return (<View style={{
|
|
9
|
+
backgroundColor: t.backgroundColor,
|
|
10
|
+
borderColor: t.borderColor,
|
|
11
|
+
borderWidth: t.borderWidth,
|
|
12
|
+
borderRadius: t.borderRadius,
|
|
13
|
+
padding: t.padding,
|
|
14
|
+
}}>
|
|
15
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 4 }}>
|
|
16
|
+
{color != null && color !== '' ? (<View style={[styles.swatch, { backgroundColor: color }]}/>) : (<View style={styles.swatchPlaceholder}/>)}
|
|
17
|
+
<Text style={[styles.title, { color: t.labelColor }]}>{name}</Text>
|
|
18
|
+
</View>
|
|
19
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
20
|
+
<Text style={{ color: t.labelColor }}>value: </Text>
|
|
21
|
+
{String(value)}
|
|
22
|
+
</Text>
|
|
23
|
+
</View>);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
title: {
|
|
28
|
+
fontWeight: '600',
|
|
29
|
+
fontSize: 13,
|
|
30
|
+
flex: 1,
|
|
31
|
+
},
|
|
32
|
+
line: {
|
|
33
|
+
fontSize: 12,
|
|
34
|
+
marginTop: 2,
|
|
35
|
+
},
|
|
36
|
+
swatch: {
|
|
37
|
+
width: 8,
|
|
38
|
+
height: 8,
|
|
39
|
+
borderRadius: 4,
|
|
40
|
+
marginRight: 6,
|
|
41
|
+
},
|
|
42
|
+
swatchPlaceholder: {
|
|
43
|
+
width: 8,
|
|
44
|
+
height: 8,
|
|
45
|
+
marginRight: 6,
|
|
46
|
+
},
|
|
47
|
+
});
|