@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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
/** Themed default radial ring tooltip (React Native). */
|
|
4
|
+
export function createDefaultRadialTooltip(theme) {
|
|
5
|
+
const t = theme.tooltip;
|
|
6
|
+
return function DefaultRadialTooltip(params) {
|
|
7
|
+
const { ringLabel, value, color } = params;
|
|
8
|
+
const rest = Math.max(0, Math.min(100, 100 - value));
|
|
9
|
+
return (<View style={{
|
|
10
|
+
backgroundColor: t.backgroundColor,
|
|
11
|
+
borderColor: t.borderColor,
|
|
12
|
+
borderWidth: t.borderWidth,
|
|
13
|
+
borderRadius: t.borderRadius,
|
|
14
|
+
padding: t.padding,
|
|
15
|
+
}}>
|
|
16
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', marginBottom: 4 }}>
|
|
17
|
+
{color != null && color !== '' ? (<View style={[styles.swatch, { backgroundColor: color }]}/>) : (<View style={styles.swatchPlaceholder}/>)}
|
|
18
|
+
<Text style={[styles.title, { color: t.labelColor }]}>{ringLabel}</Text>
|
|
19
|
+
</View>
|
|
20
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
21
|
+
<Text style={{ color: t.labelColor }}>fill: </Text>
|
|
22
|
+
{value.toFixed(0)}%
|
|
23
|
+
</Text>
|
|
24
|
+
<Text style={[styles.line, { color: t.valueColor }]}>
|
|
25
|
+
<Text style={{ color: t.labelColor }}>remaining: </Text>
|
|
26
|
+
{rest.toFixed(0)}%
|
|
27
|
+
</Text>
|
|
28
|
+
</View>);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
title: {
|
|
33
|
+
fontWeight: '600',
|
|
34
|
+
fontSize: 13,
|
|
35
|
+
flex: 1,
|
|
36
|
+
},
|
|
37
|
+
line: {
|
|
38
|
+
fontSize: 12,
|
|
39
|
+
marginTop: 2,
|
|
40
|
+
},
|
|
41
|
+
swatch: {
|
|
42
|
+
width: 8,
|
|
43
|
+
height: 8,
|
|
44
|
+
borderRadius: 4,
|
|
45
|
+
marginRight: 6,
|
|
46
|
+
},
|
|
47
|
+
swatchPlaceholder: {
|
|
48
|
+
width: 8,
|
|
49
|
+
height: 8,
|
|
50
|
+
marginRight: 6,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createDefaultRadialTooltip } from './default-radial-tooltip';
|
|
2
|
+
export { createRadialTooltipPreset } from './radial-item-tooltip-presets';
|
|
3
|
+
export type { RadialItemTooltipContext, RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
4
|
+
export { radialItemParamsFromShowTip } from './radial-item-tooltip.utils';
|
|
5
|
+
export { useRadialItemTooltip } from './use-radial-item-tooltip';
|
|
6
|
+
export type { UseRadialItemTooltipOptions, UseRadialItemTooltipResult } from './use-radial-item-tooltip';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createDefaultRadialTooltip } from './default-radial-tooltip';
|
|
2
|
+
export { createRadialTooltipPreset } from './radial-item-tooltip-presets';
|
|
3
|
+
export { radialItemParamsFromShowTip } from './radial-item-tooltip.utils';
|
|
4
|
+
export { useRadialItemTooltip } from './use-radial-item-tooltip';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTooltipPreset } from '../../tooltip';
|
|
3
|
+
import type { RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
4
|
+
export declare function createRadialTooltipPreset(preset: ChartTooltipPreset): (params: RadialItemTooltipParams) => React.ReactElement;
|
|
5
|
+
//# sourceMappingURL=radial-item-tooltip-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial-item-tooltip-presets.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/radial-item-tooltip-presets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOxD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAiD3E,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,kBAAkB,GACzB,CAAC,MAAM,EAAE,uBAAuB,KAAK,KAAK,CAAC,YAAY,CAYzD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import { useChartTheme } from '../../chart-theme.context';
|
|
4
|
+
import { TooltipPresetCard, TooltipPresetCompact, TooltipPresetKpi, TooltipPresetStriped, } from '../../tooltip/chart-tooltip-preset-shells';
|
|
5
|
+
function radialCardFromParams(p) {
|
|
6
|
+
const { ringLabel, value, color } = p;
|
|
7
|
+
return (<TooltipPresetCard header={{ swatchColor: color, title: ringLabel, marginBottom: 6 }}>
|
|
8
|
+
<Text style={{ fontSize: 22, fontWeight: '800', color: '#0f172a' }}>{value.toFixed(0)}%</Text>
|
|
9
|
+
<Text style={{ fontSize: 12, color: '#64748b', marginTop: 4 }}>filled vs 100%</Text>
|
|
10
|
+
</TooltipPresetCard>);
|
|
11
|
+
}
|
|
12
|
+
function radialCompactFromParams(p) {
|
|
13
|
+
const { ringLabel, value } = p;
|
|
14
|
+
return <TooltipPresetCompact emphasis={ringLabel} detail={`${value.toFixed(0)}% fill`} wrap/>;
|
|
15
|
+
}
|
|
16
|
+
function RadialKpiPresetBody(p) {
|
|
17
|
+
const { theme } = useChartTheme();
|
|
18
|
+
const { ringLabel, value, color } = p;
|
|
19
|
+
return (<TooltipPresetKpi accentColor={color ?? '#3b82f6'} minWidth={140} overline={ringLabel} metric={<Text style={{ fontSize: 32, fontWeight: '800', color: theme.tooltip.valueColor, marginTop: 4 }}>
|
|
20
|
+
{value.toFixed(0)}%
|
|
21
|
+
</Text>} caption="of ring capacity"/>);
|
|
22
|
+
}
|
|
23
|
+
function radialStripedFromParams(p) {
|
|
24
|
+
const { ringLabel, value, color } = p;
|
|
25
|
+
const rest = Math.max(0, 100 - value);
|
|
26
|
+
return (<TooltipPresetStriped headerSwatch={{ color: color ?? '#64748b', title: ringLabel }} rows={[
|
|
27
|
+
{ key: 'filled', leftLabel: 'filled', right: `${value.toFixed(0)}%` },
|
|
28
|
+
{ key: 'remaining', leftLabel: 'remaining', right: `${rest.toFixed(0)}%` },
|
|
29
|
+
]}/>);
|
|
30
|
+
}
|
|
31
|
+
export function createRadialTooltipPreset(preset) {
|
|
32
|
+
switch (preset) {
|
|
33
|
+
case 'card':
|
|
34
|
+
return (p) => radialCardFromParams(p);
|
|
35
|
+
case 'compact':
|
|
36
|
+
return (p) => radialCompactFromParams(p);
|
|
37
|
+
case 'kpi':
|
|
38
|
+
return (p) => <RadialKpiPresetBody {...p}/>;
|
|
39
|
+
case 'striped':
|
|
40
|
+
return (p) => radialStripedFromParams(p);
|
|
41
|
+
}
|
|
42
|
+
throw new Error(`Unknown tooltip preset: ${String(preset)}`);
|
|
43
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Item tooltip for radial ring chart (multiple ECharts `pie` series; filled slice is `dataIndex` 0).
|
|
3
|
+
*/
|
|
4
|
+
export interface RadialItemTooltipParams {
|
|
5
|
+
pointerX: number;
|
|
6
|
+
pointerY: number;
|
|
7
|
+
/** Ring index (matches `data` array order). */
|
|
8
|
+
seriesIndex: number;
|
|
9
|
+
/** Always `0` for the filled segment (background track uses index 1 and has no tooltip). */
|
|
10
|
+
dataIndex: number;
|
|
11
|
+
/** Ring label from data, or a generated name. */
|
|
12
|
+
ringLabel: string;
|
|
13
|
+
/** Fill amount 0–100. */
|
|
14
|
+
value: number;
|
|
15
|
+
color?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface RadialItemTooltipContext {
|
|
18
|
+
normalizedSeries: Array<{
|
|
19
|
+
label?: string;
|
|
20
|
+
value: number;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=radial-item-tooltip.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial-item-tooltip.types.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/radial-item-tooltip.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,gBAAgB,EAAE,KAAK,CAAC;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RadialItemTooltipContext, RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
2
|
+
/**
|
|
3
|
+
* Build radial ring tooltip params from an ECharts `showTip` payload.
|
|
4
|
+
* Only the filled arc (`dataIndex` 0) is shown; the background track is ignored.
|
|
5
|
+
*/
|
|
6
|
+
export declare function radialItemParamsFromShowTip(chart: any, evt: any, ctx: RadialItemTooltipContext, themeSeries: Array<{
|
|
7
|
+
color: string;
|
|
8
|
+
}>): RadialItemTooltipParams | null;
|
|
9
|
+
//# sourceMappingURL=radial-item-tooltip.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radial-item-tooltip.utils.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/radial-item-tooltip.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AA+DrG;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,GAAG,EACV,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,wBAAwB,EAC7B,WAAW,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GACpC,uBAAuB,GAAG,IAAI,CAmDhC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
function resolveDataIndexInside(data, evt) {
|
|
2
|
+
if (typeof evt?.dataIndexInside === 'number' && !Number.isNaN(evt.dataIndexInside)) {
|
|
3
|
+
return evt.dataIndexInside;
|
|
4
|
+
}
|
|
5
|
+
if (typeof evt?.dataIndex === 'number' && !Number.isNaN(evt.dataIndex)) {
|
|
6
|
+
const mapped = typeof data?.indexOfRawIndex === 'function' ? data.indexOfRawIndex(evt.dataIndex) : evt.dataIndex;
|
|
7
|
+
if (typeof mapped === 'number' && !Number.isNaN(mapped))
|
|
8
|
+
return mapped;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
function pieSectorCenter(data, diInside) {
|
|
13
|
+
const layout = data.getItemLayout?.(diInside);
|
|
14
|
+
if (!layout || !Number.isFinite(layout.cx) || !Number.isFinite(layout.cy))
|
|
15
|
+
return null;
|
|
16
|
+
const cx = Number(layout.cx);
|
|
17
|
+
const cy = Number(layout.cy);
|
|
18
|
+
const r = Number(layout.r);
|
|
19
|
+
const r0 = Number(layout.r0 ?? 0);
|
|
20
|
+
const startAngle = Number(layout.startAngle);
|
|
21
|
+
const endAngle = Number(layout.endAngle);
|
|
22
|
+
if (!Number.isFinite(startAngle) || !Number.isFinite(endAngle))
|
|
23
|
+
return null;
|
|
24
|
+
const mid = (startAngle + endAngle) / 2;
|
|
25
|
+
const avgR = (r0 + r) / 2;
|
|
26
|
+
return {
|
|
27
|
+
x: cx + Math.cos(mid) * avgR,
|
|
28
|
+
y: cy + Math.sin(mid) * avgR,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function pointerFromEventOrSector(chart, evt, data) {
|
|
32
|
+
const ex = evt?.x;
|
|
33
|
+
const ey = evt?.y;
|
|
34
|
+
if (typeof ex === 'number' && typeof ey === 'number' && !Number.isNaN(ex) && !Number.isNaN(ey)) {
|
|
35
|
+
return { x: ex, y: ey };
|
|
36
|
+
}
|
|
37
|
+
return pieSectorCenter(data, 0);
|
|
38
|
+
}
|
|
39
|
+
function sliceValueAt(data, diInside) {
|
|
40
|
+
try {
|
|
41
|
+
const dim = typeof data.mapDimension === 'function' ? data.mapDimension('value') : null;
|
|
42
|
+
if (dim != null) {
|
|
43
|
+
const v = data.get(dim, diInside);
|
|
44
|
+
const n = Number(v);
|
|
45
|
+
if (Number.isFinite(n))
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
/* ignore */
|
|
51
|
+
}
|
|
52
|
+
const v0 = data.get?.(0, diInside);
|
|
53
|
+
const n0 = Number(v0);
|
|
54
|
+
if (Number.isFinite(n0))
|
|
55
|
+
return n0;
|
|
56
|
+
try {
|
|
57
|
+
const n1 = Number(data.get?.('value', diInside));
|
|
58
|
+
if (Number.isFinite(n1))
|
|
59
|
+
return n1;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
/* ignore */
|
|
63
|
+
}
|
|
64
|
+
return NaN;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Build radial ring tooltip params from an ECharts `showTip` payload.
|
|
68
|
+
* Only the filled arc (`dataIndex` 0) is shown; the background track is ignored.
|
|
69
|
+
*/
|
|
70
|
+
export function radialItemParamsFromShowTip(chart, evt, ctx, themeSeries) {
|
|
71
|
+
if (!chart || !evt)
|
|
72
|
+
return null;
|
|
73
|
+
if (Array.isArray(evt.dataByCoordSys) && evt.dataByCoordSys.length > 0)
|
|
74
|
+
return null;
|
|
75
|
+
const si = typeof evt.seriesIndex === 'number' ? evt.seriesIndex : 0;
|
|
76
|
+
if (si < 0 || si >= ctx.normalizedSeries.length)
|
|
77
|
+
return null;
|
|
78
|
+
const seriesModel = chart.getModel?.().getSeriesByIndex?.(si);
|
|
79
|
+
const seriesKind = seriesModel?.subType ?? seriesModel?.get?.('type');
|
|
80
|
+
if (!seriesModel || seriesKind !== 'pie')
|
|
81
|
+
return null;
|
|
82
|
+
const data = seriesModel.getData?.();
|
|
83
|
+
if (!data)
|
|
84
|
+
return null;
|
|
85
|
+
const diInside = resolveDataIndexInside(data, evt);
|
|
86
|
+
if (diInside == null || diInside !== 0)
|
|
87
|
+
return null;
|
|
88
|
+
const pixel = pointerFromEventOrSector(chart, evt, data);
|
|
89
|
+
if (!pixel)
|
|
90
|
+
return null;
|
|
91
|
+
const row = ctx.normalizedSeries[si];
|
|
92
|
+
if (!row)
|
|
93
|
+
return null;
|
|
94
|
+
const fromModel = sliceValueAt(data, 0);
|
|
95
|
+
const value = Number.isFinite(fromModel) ? fromModel : Number(row.value);
|
|
96
|
+
if (!Number.isFinite(value))
|
|
97
|
+
return null;
|
|
98
|
+
const ringLabel = row.label != null && row.label !== '' ? String(row.label) : `Ring ${si + 1}`;
|
|
99
|
+
let color;
|
|
100
|
+
try {
|
|
101
|
+
const style = data.getItemVisual?.(0, 'style');
|
|
102
|
+
const fill = style?.fill;
|
|
103
|
+
if (typeof fill === 'string' && fill !== '')
|
|
104
|
+
color = fill;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
/* ignore */
|
|
108
|
+
}
|
|
109
|
+
if (color == null) {
|
|
110
|
+
const themeLen = Math.max(themeSeries.length, 1);
|
|
111
|
+
color = themeSeries[si % themeLen]?.color;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
pointerX: pixel.x,
|
|
115
|
+
pointerY: pixel.y,
|
|
116
|
+
seriesIndex: si,
|
|
117
|
+
dataIndex: 0,
|
|
118
|
+
ringLabel,
|
|
119
|
+
value,
|
|
120
|
+
...(typeof color === 'string' ? { color } : {}),
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RadialItemTooltipContext, RadialItemTooltipParams } from './radial-item-tooltip.types';
|
|
3
|
+
export interface UseRadialItemTooltipOptions {
|
|
4
|
+
active: boolean;
|
|
5
|
+
renderTooltip: (params: RadialItemTooltipParams) => React.ReactNode;
|
|
6
|
+
contextRef: React.RefObject<RadialItemTooltipContext>;
|
|
7
|
+
themeSeriesRef: React.RefObject<Array<{
|
|
8
|
+
color: string;
|
|
9
|
+
}>>;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
13
|
+
export interface UseRadialItemTooltipResult {
|
|
14
|
+
attachRadialItemTooltipListeners: (chart: {
|
|
15
|
+
on: (ev: string, fn: (...args: any[]) => void) => void;
|
|
16
|
+
off: (ev: string, fn: (...args: any[]) => void) => void;
|
|
17
|
+
}) => () => void;
|
|
18
|
+
renderRadialTooltipOverlay: () => React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
/** Radial concentric ring tooltip as React Native UI (`trigger: 'item'`). */
|
|
21
|
+
export declare function useRadialItemTooltip(options: UseRadialItemTooltipOptions): UseRadialItemTooltipResult;
|
|
22
|
+
//# sourceMappingURL=use-radial-item-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-radial-item-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/radial/tooltip/use-radial-item-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGrG,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,KAAK,CAAC,SAAS,CAAC;IACpE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;IACtD,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,0BAA0B;IACzC,gCAAgC,EAAE,CAAC,KAAK,EAAE;QACxC,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC;QACvD,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAC;KACzD,KAAK,MAAM,IAAI,CAAC;IACjB,0BAA0B,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;CACnD;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,0BAA0B,CAiDrG"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { ChartPointerTooltipOverlay } from '../../tooltip/chart-pointer-tooltip-overlay';
|
|
3
|
+
import { radialItemParamsFromShowTip } from './radial-item-tooltip.utils';
|
|
4
|
+
/** Radial concentric ring tooltip as React Native UI (`trigger: 'item'`). */
|
|
5
|
+
export function useRadialItemTooltip(options) {
|
|
6
|
+
const { active, renderTooltip, contextRef, themeSeriesRef, width, height } = options;
|
|
7
|
+
const [params, setParams] = useState(null);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!active)
|
|
10
|
+
setParams(null);
|
|
11
|
+
}, [active]);
|
|
12
|
+
const attachRadialItemTooltipListeners = useCallback((chart) => {
|
|
13
|
+
if (!active)
|
|
14
|
+
return () => { };
|
|
15
|
+
const onShowTip = (evt) => {
|
|
16
|
+
const ctx = contextRef.current;
|
|
17
|
+
if (!ctx?.normalizedSeries?.length) {
|
|
18
|
+
setParams(null);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const next = radialItemParamsFromShowTip(chart, evt, ctx, themeSeriesRef.current ?? []);
|
|
22
|
+
setParams(next);
|
|
23
|
+
};
|
|
24
|
+
const onHideTip = () => setParams(null);
|
|
25
|
+
chart.on('showTip', onShowTip);
|
|
26
|
+
chart.on('hideTip', onHideTip);
|
|
27
|
+
return () => {
|
|
28
|
+
chart.off('showTip', onShowTip);
|
|
29
|
+
chart.off('hideTip', onHideTip);
|
|
30
|
+
};
|
|
31
|
+
}, [active, contextRef, themeSeriesRef]);
|
|
32
|
+
const renderRadialTooltipOverlay = useCallback(() => {
|
|
33
|
+
if (!active || params == null)
|
|
34
|
+
return null;
|
|
35
|
+
return (<ChartPointerTooltipOverlay width={width} height={height} pointerX={params.pointerX} pointerY={params.pointerY}>
|
|
36
|
+
{renderTooltip(params)}
|
|
37
|
+
</ChartPointerTooltipOverlay>);
|
|
38
|
+
}, [active, renderTooltip, params, width, height]);
|
|
39
|
+
return {
|
|
40
|
+
attachRadialItemTooltipListeners,
|
|
41
|
+
renderRadialTooltipOverlay,
|
|
42
|
+
};
|
|
43
|
+
}
|
package/scatter/index.d.ts
CHANGED
package/scatter/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,cAAc,WAAW,CAAC"}
|
package/scatter/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scatter-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAS/D,OAAO,KAAqC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"scatter-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAS/D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAY1D,qCAAqC;AACrC,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAsZlF,eAAO,MAAM,YAAY;;;;;;;CAEvB,CAAC"}
|
package/scatter/scatter-chart.js
CHANGED
|
@@ -5,7 +5,11 @@ import { LineChart as EChartsLineChart, ScatterChart as EChartsScatterChart } fr
|
|
|
5
5
|
import { GridComponent, LegendComponent, TooltipComponent, } from 'echarts/components';
|
|
6
6
|
import * as echarts from 'echarts/core';
|
|
7
7
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { View } from 'react-native';
|
|
9
|
+
import { getAxis, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
|
|
10
|
+
import { echartsLegendLayoutFragment, mergeCartesianGridForLegend, } from '../legend/echarts-legend-layout';
|
|
11
|
+
import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
|
|
12
|
+
import { createScatterTooltipPreset, useScatterItemTooltip } from './tooltip';
|
|
9
13
|
echarts.use([
|
|
10
14
|
TooltipComponent,
|
|
11
15
|
GridComponent,
|
|
@@ -31,12 +35,30 @@ function linearRegression(points) {
|
|
|
31
35
|
const intercept = (sumY - slope * sumX) / n;
|
|
32
36
|
return { slope, intercept };
|
|
33
37
|
}
|
|
34
|
-
const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', symbolSize = 8, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend =
|
|
38
|
+
const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', symbolSize = 8, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = true, legendPosition = 'bottom', showHighlighter = true, tooltip = 'card', showRegressionLine = false, xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
|
|
35
39
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
36
40
|
const chartRef = useRef(null);
|
|
37
41
|
const onSelectRef = useRef(onSelect);
|
|
38
42
|
onSelectRef.current = onSelect;
|
|
39
43
|
const selectContextRef = useRef({ normalizedSeries: [] });
|
|
44
|
+
const themeSeriesRef = useRef(theme.series);
|
|
45
|
+
themeSeriesRef.current = theme.series;
|
|
46
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
47
|
+
const renderTooltipFn = useMemo(() => {
|
|
48
|
+
if (renderTooltip != null)
|
|
49
|
+
return renderTooltip;
|
|
50
|
+
if (tooltip === 'none')
|
|
51
|
+
return () => null;
|
|
52
|
+
return createScatterTooltipPreset(tooltip);
|
|
53
|
+
}, [renderTooltip, tooltip]);
|
|
54
|
+
const { attachScatterItemTooltipListeners, renderScatterTooltipOverlay } = useScatterItemTooltip({
|
|
55
|
+
active: tooltipOverlayActive,
|
|
56
|
+
renderTooltip: renderTooltipFn,
|
|
57
|
+
contextRef: selectContextRef,
|
|
58
|
+
themeSeriesRef,
|
|
59
|
+
width,
|
|
60
|
+
height,
|
|
61
|
+
});
|
|
40
62
|
const normalizedSeries = useMemo(() => {
|
|
41
63
|
if (!Array.isArray(data) || data.length === 0)
|
|
42
64
|
return [];
|
|
@@ -51,29 +73,36 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
51
73
|
}, [data]);
|
|
52
74
|
const hasNamedSeries = useMemo(() => normalizedSeries.some((s) => 'name' in s && s.name), [normalizedSeries]);
|
|
53
75
|
selectContextRef.current = { normalizedSeries };
|
|
76
|
+
const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
|
|
77
|
+
const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
|
|
54
78
|
const option = useMemo(() => {
|
|
55
79
|
const dataPoints = normalizedSeries.map(s => s.data.map(item => item[0])).flat();
|
|
56
|
-
const xAxisData =
|
|
57
|
-
|
|
58
|
-
: getAxis(dataPoints).map(String);
|
|
59
|
-
const tooltipConfig = showHighlighter
|
|
80
|
+
const xAxisData = getAxis(dataPoints).map(String);
|
|
81
|
+
const tooltipConfig = tooltipOverlayActive
|
|
60
82
|
? {
|
|
61
83
|
trigger: 'item',
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
84
|
+
...axisTooltipShowContentFlag(true),
|
|
85
|
+
...(showHighlighter && {
|
|
86
|
+
axisPointer: {
|
|
65
87
|
type: 'line',
|
|
66
|
-
|
|
67
|
-
|
|
88
|
+
lineStyle: {
|
|
89
|
+
type: 'line',
|
|
90
|
+
width: 1,
|
|
91
|
+
color: '#00000000',
|
|
92
|
+
},
|
|
93
|
+
label: {
|
|
94
|
+
show: false,
|
|
95
|
+
},
|
|
68
96
|
},
|
|
69
|
-
},
|
|
97
|
+
}),
|
|
70
98
|
}
|
|
71
|
-
: {
|
|
72
|
-
//
|
|
99
|
+
: { show: false };
|
|
100
|
+
// X: category from binned coordinates; Y: value (data is [x, y] pairs)
|
|
73
101
|
const xAxisConfig = {
|
|
74
102
|
type: 'category',
|
|
75
103
|
boundaryGap,
|
|
76
104
|
data: xAxisData,
|
|
105
|
+
...(xAxisBounds ?? {}),
|
|
77
106
|
...(xAxisLabel != null && xAxisLabel !== '' && {
|
|
78
107
|
name: xAxisLabel,
|
|
79
108
|
nameLocation: 'middle',
|
|
@@ -95,7 +124,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
95
124
|
}
|
|
96
125
|
: { show: false },
|
|
97
126
|
axisTick: {
|
|
98
|
-
show: showXAxisTicks,
|
|
127
|
+
show: showXAxis && showXAxisTicks,
|
|
99
128
|
lineStyle: {
|
|
100
129
|
color: theme.axis.x.tickColor,
|
|
101
130
|
width: theme.axis.x.tickWidth,
|
|
@@ -111,6 +140,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
111
140
|
};
|
|
112
141
|
const yAxisConfig = {
|
|
113
142
|
type: 'value',
|
|
143
|
+
...(valueAxisBounds ?? {}),
|
|
114
144
|
...(yAxisLabel != null && yAxisLabel !== '' && {
|
|
115
145
|
name: yAxisLabel,
|
|
116
146
|
nameLocation: 'middle',
|
|
@@ -132,7 +162,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
132
162
|
}
|
|
133
163
|
: { show: false },
|
|
134
164
|
axisTick: {
|
|
135
|
-
show: showYAxisTicks,
|
|
165
|
+
show: showYAxis && showYAxisTicks,
|
|
136
166
|
lineStyle: {
|
|
137
167
|
color: theme.axis.y.tickColor,
|
|
138
168
|
width: theme.axis.y.tickWidth,
|
|
@@ -151,6 +181,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
151
181
|
data: normalizedSeries
|
|
152
182
|
.filter((s) => 'name' in s && s.name)
|
|
153
183
|
.map((s) => s.name),
|
|
184
|
+
...echartsLegendLayoutFragment(legendPosition),
|
|
154
185
|
textStyle: {
|
|
155
186
|
color: theme.legend.textColor,
|
|
156
187
|
fontSize: theme.legend.fontSize,
|
|
@@ -171,7 +202,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
171
202
|
itemStyle: { color: seriesColor },
|
|
172
203
|
emphasis: showHighlighter
|
|
173
204
|
? {
|
|
174
|
-
focus: '
|
|
205
|
+
focus: 'none',
|
|
175
206
|
scale: true,
|
|
176
207
|
symbol: 'circle',
|
|
177
208
|
symbolSize: 8,
|
|
@@ -219,8 +250,10 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
219
250
|
};
|
|
220
251
|
if (legendConfig)
|
|
221
252
|
config.legend = legendConfig;
|
|
222
|
-
|
|
223
|
-
|
|
253
|
+
const mergedGrid = mergeCartesianGridForLegend(grid, legendPosition, showLegend, hasNamedSeries);
|
|
254
|
+
if (mergedGrid !== undefined && Object.keys(mergedGrid).length > 0) {
|
|
255
|
+
config.grid = mergedGrid;
|
|
256
|
+
}
|
|
224
257
|
return config;
|
|
225
258
|
}, [
|
|
226
259
|
theme,
|
|
@@ -236,21 +269,26 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
236
269
|
boundaryGap,
|
|
237
270
|
grid,
|
|
238
271
|
showLegend,
|
|
272
|
+
legendPosition,
|
|
239
273
|
hasNamedSeries,
|
|
240
274
|
showHighlighter,
|
|
275
|
+
tooltipOverlayActive,
|
|
241
276
|
showRegressionLine,
|
|
242
277
|
xAxisTickLabelFormatter,
|
|
243
278
|
yAxisTickLabelFormatter,
|
|
244
|
-
xAxisTicks,
|
|
245
279
|
xAxisLabel,
|
|
246
280
|
yAxisLabel,
|
|
281
|
+
valueAxisBounds,
|
|
282
|
+
xAxisBounds,
|
|
247
283
|
]);
|
|
248
284
|
useEffect(() => {
|
|
249
285
|
let chart;
|
|
286
|
+
let detachScatterTooltip = () => { };
|
|
250
287
|
if (chartRef.current) {
|
|
251
288
|
try {
|
|
252
289
|
chart = echarts.init(chartRef.current, 'light', { width, height });
|
|
253
290
|
chart.setOption(option);
|
|
291
|
+
detachScatterTooltip = attachScatterItemTooltipListeners(chart);
|
|
254
292
|
const handleSeriesClick = (params) => {
|
|
255
293
|
const cb = onSelectRef.current;
|
|
256
294
|
if (typeof cb !== 'function')
|
|
@@ -292,6 +330,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
292
330
|
}
|
|
293
331
|
}
|
|
294
332
|
return () => {
|
|
333
|
+
detachScatterTooltip();
|
|
295
334
|
if (chart) {
|
|
296
335
|
try {
|
|
297
336
|
chart.dispose();
|
|
@@ -301,8 +340,11 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sy
|
|
|
301
340
|
}
|
|
302
341
|
}
|
|
303
342
|
};
|
|
304
|
-
}, [option, width, height]);
|
|
305
|
-
return <
|
|
343
|
+
}, [option, width, height, attachScatterItemTooltipListeners]);
|
|
344
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
345
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
346
|
+
{renderScatterTooltipOverlay()}
|
|
347
|
+
</View>);
|
|
306
348
|
};
|
|
307
349
|
const ScatterChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
308
350
|
export const ScatterChart = Object.assign(ScatterChartComponent, {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CartesianChartProps } from '../props/cartesian';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { ScatterItemTooltipParams } from './tooltip/scatter-item-tooltip.types';
|
|
2
4
|
/**
|
|
3
5
|
* Scatter data: array of [x, y] pairs per series.
|
|
4
6
|
* - Single series: number[][]
|
|
@@ -12,7 +14,7 @@ export type ScatterSeriesData = number[][] | Array<{
|
|
|
12
14
|
* Props for ScatterChart.
|
|
13
15
|
* common -> cartesian -> scatter
|
|
14
16
|
*/
|
|
15
|
-
export interface ScatterChartProps extends CartesianChartProps {
|
|
17
|
+
export interface ScatterChartProps extends Omit<CartesianChartProps, 'renderTooltip'> {
|
|
16
18
|
/**
|
|
17
19
|
* Scatter data: array of [x, y] pairs per series.
|
|
18
20
|
*/
|
|
@@ -32,5 +34,9 @@ export interface ScatterChartProps extends CartesianChartProps {
|
|
|
32
34
|
* @default false
|
|
33
35
|
*/
|
|
34
36
|
showRegressionLine?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Overrides the default React Native **item** tooltip body (scatter points; see {@link ScatterItemTooltipParams}).
|
|
39
|
+
*/
|
|
40
|
+
renderTooltip?: (params: ScatterItemTooltipParams) => ReactNode;
|
|
35
41
|
}
|
|
36
42
|
//# sourceMappingURL=scatter-chart.props.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scatter-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"scatter-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/scatter/scatter-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAErF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,EAAE,EAAE,GACV,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAAC,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC;IACnF;;OAEG;IACH,IAAI,EAAE,iBAAiB,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IACtG;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACzE;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,wBAAwB,KAAK,SAAS,CAAC;CACjE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartTheme } from '../../chart-theme.context';
|
|
3
|
+
import type { ScatterItemTooltipParams } from './scatter-item-tooltip.types';
|
|
4
|
+
/**
|
|
5
|
+
* Themed default scatter/bubble item tooltip (React Native).
|
|
6
|
+
*/
|
|
7
|
+
export declare function createDefaultScatterTooltip(theme: Pick<ChartTheme, 'tooltip'>): (params: ScatterItemTooltipParams) => React.ReactElement;
|
|
8
|
+
//# sourceMappingURL=default-scatter-tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-scatter-tooltip.d.ts","sourceRoot":"","sources":["../../../../../components/chart/scatter/tooltip/default-scatter-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAE7E;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GACjC,CAAC,MAAM,EAAE,wBAAwB,KAAK,KAAK,CAAC,YAAY,CAuC1D"}
|