@wavemaker/react-native-echarts 1.0.0-dev.5 → 1.0.0-dev.9
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 +63 -37
- 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 +59 -33
- package/candlestick/candlestick-chart.d.ts.map +1 -1
- package/candlestick/candlestick-chart.js +15 -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 +86 -31
- 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 +43 -11
- 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 +57 -20
- 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
package/README.md
CHANGED
|
@@ -25,6 +25,13 @@ npm install @shopify/react-native-skia @wuba/react-native-echarts echarts zrende
|
|
|
25
25
|
|
|
26
26
|
`react` and `react-native` are also peers; they should already be present in your app.
|
|
27
27
|
|
|
28
|
+
**Note**:
|
|
29
|
+
There is an issue with echarts library. Due to which compilation fails with an error. Here is the link to the issue.
|
|
30
|
+
https://github.com/apache/echarts/pull/20485
|
|
31
|
+
|
|
32
|
+
Till the issue is fixed, follow the workaround mentioned in the below link.
|
|
33
|
+
https://github.com/wuba/react-native-echarts/issues/239#issuecomment-2899678660
|
|
34
|
+
|
|
28
35
|
## Chart gallery
|
|
29
36
|
|
|
30
37
|
Preview thumbnails for the chart examples in `assets/images/charts`. Each image uses the same width and height (200×200) so the layout stays even; `object-fit: contain` keeps aspect ratios readable.
|
|
@@ -335,14 +342,33 @@ cd dist/npm-packages/charts && npm publish
|
|
|
335
342
|
|
|
336
343
|
## Development
|
|
337
344
|
|
|
338
|
-
|
|
345
|
+
Work from the **repository root** (the directory that contains `package.json`, `components/`, and `stories/`).
|
|
346
|
+
|
|
347
|
+
### Browser (Storybook)
|
|
348
|
+
|
|
349
|
+
Storybook runs the chart stories in the browser with Vite. After install, it serves at **http://localhost:6006**.
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
npm install
|
|
353
|
+
npm run storybook
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Mobile (Expo sample app)
|
|
357
|
+
|
|
358
|
+
The **`expo-app/`** project is a small Expo Router app that consumes the library via **[yalc](https://github.com/wclr/yalc)**. Install **`yalc` globally** first so those commands are on your `PATH`.
|
|
339
359
|
|
|
340
360
|
```bash
|
|
361
|
+
npm install -g yalc
|
|
362
|
+
cd /path/to/repo # repository root directory
|
|
363
|
+
npm install
|
|
364
|
+
npm run generate:package
|
|
365
|
+
cd expo-app
|
|
341
366
|
npm install
|
|
342
|
-
npx expo start
|
|
343
|
-
npm run storybook # to checout the component stories
|
|
367
|
+
npx expo start
|
|
344
368
|
```
|
|
345
369
|
|
|
370
|
+
Whenever you change library source under `components/` or related entry points, run **`npm run generate:package`** again from the repo root so the yalc-linked package is rebuilt and republished. When changes are not reflecting in the app even after reload, use **`npx expo start -c`**.
|
|
371
|
+
|
|
346
372
|
---
|
|
347
373
|
|
|
348
374
|
## Maintainers
|
package/area/area-chart.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AreaChartProps } from './area-chart.props';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export type { AreaChartProps, AreaChartSelectEvent, SeriesData, } from './area-chart.props';
|
|
3
|
+
export type { AreaChartProps, AreaChartSelectEvent, AreaChartAxisTooltipParams, AreaChartTooltipSeriesItem, SeriesData, } from './area-chart.props';
|
|
4
4
|
export declare const AreaChart: ((props: AreaChartProps & {
|
|
5
5
|
theme?: Partial<import("..").ChartTheme>;
|
|
6
6
|
} & {
|
package/area/area-chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"area-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/area/area-chart.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"area-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/area/area-chart.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAWzD,OAAO,KAAqC,MAAM,OAAO,CAAC;AAK1D,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,UAAU,GACX,MAAM,oBAAoB,CAAC;AA4e5B,eAAO,MAAM,SAAS;;;;;;;CAEpB,CAAC"}
|
package/area/area-chart.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { withResponsiveContainer } from '../chart-container';
|
|
2
2
|
import { useChartTheme, withChartTheme } from '../chart-theme.context';
|
|
3
|
+
import { createAxisTooltipPreset, useAxisTooltip } from '../cartesian/tooltip';
|
|
3
4
|
import { SkiaChart, SkiaRenderer } from '@wuba/react-native-echarts';
|
|
4
5
|
import { LineChart } from 'echarts/charts';
|
|
5
6
|
import { GridComponent, LegendComponent, TooltipComponent } from 'echarts/components';
|
|
6
7
|
import * as echarts from 'echarts/core';
|
|
7
8
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
8
|
-
import {
|
|
9
|
+
import { View } from 'react-native';
|
|
10
|
+
import { getAxis, valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
|
|
9
11
|
// Register necessary components for this chart
|
|
10
12
|
echarts.use([
|
|
11
13
|
TooltipComponent,
|
|
@@ -14,14 +16,32 @@ echarts.use([
|
|
|
14
16
|
SkiaRenderer,
|
|
15
17
|
LineChart,
|
|
16
18
|
]);
|
|
17
|
-
const ChartComponent = ({ data, width = 220, height = 350, type = 'default', step, boundaryGap = false, stack, stackNormalize = false, symbol, symbolSize, areaOpacity = 0.6, areaFill = 'gradient', showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = false, showHighlighter = true, xAxisTickLabelFormatter, yAxisTickLabelFormatter,
|
|
19
|
+
const ChartComponent = ({ data, width = 220, height = 350, type = 'default', step, boundaryGap = false, stack, stackNormalize = false, symbol, symbolSize, areaOpacity = 0.6, areaFill = 'gradient', showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, grid, showLegend = false, showHighlighter = true, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
|
|
18
20
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
19
21
|
const chartRef = useRef(null);
|
|
20
22
|
const onSelectRef = useRef(onSelect);
|
|
21
23
|
onSelectRef.current = onSelect;
|
|
22
|
-
const
|
|
24
|
+
const axisTooltipContextRef = useRef({
|
|
23
25
|
displaySeries: [],
|
|
24
|
-
|
|
26
|
+
categoryAxisData: [],
|
|
27
|
+
});
|
|
28
|
+
const themeSeriesRef = useRef(theme.series);
|
|
29
|
+
themeSeriesRef.current = theme.series;
|
|
30
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
31
|
+
const renderTooltipFn = useMemo(() => {
|
|
32
|
+
if (renderTooltip != null)
|
|
33
|
+
return renderTooltip;
|
|
34
|
+
if (tooltip === 'none')
|
|
35
|
+
return () => null;
|
|
36
|
+
return createAxisTooltipPreset(tooltip);
|
|
37
|
+
}, [renderTooltip, tooltip]);
|
|
38
|
+
const { attachAxisTooltipListeners, renderAxisTooltipOverlay } = useAxisTooltip({
|
|
39
|
+
active: tooltipOverlayActive,
|
|
40
|
+
renderTooltip: renderTooltipFn,
|
|
41
|
+
contextRef: axisTooltipContextRef,
|
|
42
|
+
themeSeriesRef,
|
|
43
|
+
width,
|
|
44
|
+
height,
|
|
25
45
|
});
|
|
26
46
|
// Derive smooth/step from type
|
|
27
47
|
const effectiveSmooth = type === 'smooth';
|
|
@@ -85,31 +105,16 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
85
105
|
: { data: normalizedData };
|
|
86
106
|
});
|
|
87
107
|
}, [normalizedSeries, stackNormalize]);
|
|
108
|
+
const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
|
|
109
|
+
const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
|
|
88
110
|
const xAxisData = useMemo(() => {
|
|
89
111
|
const dataPoints = normalizedSeries
|
|
90
112
|
.map(s => s.data.map(item => item[0]))
|
|
91
113
|
.flat();
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, [normalizedSeries, xAxisTicks]);
|
|
96
|
-
selectContextRef.current = { displaySeries, xAxisData };
|
|
114
|
+
return getAxis(dataPoints).map(String);
|
|
115
|
+
}, [normalizedSeries]);
|
|
116
|
+
axisTooltipContextRef.current = { displaySeries, categoryAxisData: xAxisData };
|
|
97
117
|
const option = useMemo(() => {
|
|
98
|
-
// Build tooltip config
|
|
99
|
-
// axisPointer with snap: true so the pointer snaps to data points and triggers
|
|
100
|
-
// series emphasis (circle) at the hovered position. See https://echarts.apache.org/en/option.html#tooltip.axisPointer
|
|
101
|
-
const tooltipConfig = showHighlighter ? {
|
|
102
|
-
trigger: 'axis',
|
|
103
|
-
axisPointer: {
|
|
104
|
-
type: 'line',
|
|
105
|
-
snap: true,
|
|
106
|
-
lineStyle: {
|
|
107
|
-
type: 'solid',
|
|
108
|
-
width: 1,
|
|
109
|
-
color: theme.series[0].color ?? '#999',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
} : null;
|
|
113
118
|
// Build xAxis config (category with data indices)
|
|
114
119
|
const xAxisConfig = {
|
|
115
120
|
type: 'category',
|
|
@@ -135,7 +140,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
135
140
|
show: false,
|
|
136
141
|
},
|
|
137
142
|
axisTick: {
|
|
138
|
-
show: showXAxisTicks,
|
|
143
|
+
show: showXAxis && showXAxisTicks,
|
|
139
144
|
lineStyle: {
|
|
140
145
|
color: theme.axis.x.tickColor,
|
|
141
146
|
width: theme.axis.x.tickWidth,
|
|
@@ -148,15 +153,15 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
148
153
|
width: theme.axis.x.splitLineWidth,
|
|
149
154
|
},
|
|
150
155
|
},
|
|
156
|
+
boundaryGap,
|
|
157
|
+
...(xAxisBounds ?? {}),
|
|
151
158
|
};
|
|
152
|
-
|
|
153
|
-
// Build yAxis config (value, auto-scale from data)
|
|
159
|
+
// Build yAxis config (value axis: optional min/max/interval; else ECharts auto-scale, except stack-normalized %)
|
|
154
160
|
const yAxisConfig = {
|
|
155
161
|
type: 'value',
|
|
156
|
-
...(stackNormalize && displaySeries.length > 1
|
|
157
|
-
min: 0,
|
|
158
|
-
|
|
159
|
-
}),
|
|
162
|
+
...(stackNormalize && displaySeries.length > 1
|
|
163
|
+
? { min: 0, max: 100 }
|
|
164
|
+
: (valueAxisBounds ?? {})),
|
|
160
165
|
...(yAxisLabel != null && yAxisLabel !== '' && {
|
|
161
166
|
name: yAxisLabel,
|
|
162
167
|
nameLocation: 'middle',
|
|
@@ -180,7 +185,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
180
185
|
show: false,
|
|
181
186
|
},
|
|
182
187
|
axisTick: {
|
|
183
|
-
show: showYAxisTicks,
|
|
188
|
+
show: showYAxis && showYAxisTicks,
|
|
184
189
|
lineStyle: {
|
|
185
190
|
color: theme.axis.y.tickColor,
|
|
186
191
|
width: theme.axis.y.tickWidth,
|
|
@@ -280,10 +285,23 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
280
285
|
return series;
|
|
281
286
|
});
|
|
282
287
|
const config = {
|
|
283
|
-
tooltip: tooltipConfig,
|
|
284
288
|
xAxis: xAxisConfig,
|
|
285
289
|
yAxis: yAxisConfig,
|
|
286
290
|
series: seriesConfig,
|
|
291
|
+
axisPointer: {
|
|
292
|
+
show: true,
|
|
293
|
+
type: 'line',
|
|
294
|
+
snap: true,
|
|
295
|
+
lineStyle: {
|
|
296
|
+
type: 'solid',
|
|
297
|
+
width: 1,
|
|
298
|
+
color: '#00000000',
|
|
299
|
+
show: false,
|
|
300
|
+
},
|
|
301
|
+
label: {
|
|
302
|
+
show: false,
|
|
303
|
+
}
|
|
304
|
+
}
|
|
287
305
|
};
|
|
288
306
|
// Add legend if configured
|
|
289
307
|
if (legendConfigFinal) {
|
|
@@ -319,14 +337,17 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
319
337
|
showLegend,
|
|
320
338
|
hasNamedSeries,
|
|
321
339
|
showHighlighter,
|
|
340
|
+
tooltipOverlayActive,
|
|
322
341
|
xAxisTickLabelFormatter,
|
|
323
342
|
yAxisTickLabelFormatter,
|
|
324
|
-
xAxisTicks,
|
|
325
343
|
xAxisLabel,
|
|
326
344
|
yAxisLabel,
|
|
345
|
+
valueAxisBounds,
|
|
346
|
+
xAxisBounds,
|
|
327
347
|
]);
|
|
328
348
|
useEffect(() => {
|
|
329
349
|
let chart;
|
|
350
|
+
let detachAxisTooltip = () => { };
|
|
330
351
|
if (chartRef.current) {
|
|
331
352
|
try {
|
|
332
353
|
chart = echarts.init(chartRef.current, 'light', {
|
|
@@ -334,6 +355,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
334
355
|
height: height,
|
|
335
356
|
});
|
|
336
357
|
chart.setOption(option);
|
|
358
|
+
detachAxisTooltip = attachAxisTooltipListeners(chart);
|
|
337
359
|
const handleSeriesClick = (params) => {
|
|
338
360
|
const cb = onSelectRef.current;
|
|
339
361
|
if (typeof cb !== 'function')
|
|
@@ -347,7 +369,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
347
369
|
dataIndex < 0) {
|
|
348
370
|
return;
|
|
349
371
|
}
|
|
350
|
-
const { displaySeries: ds,
|
|
372
|
+
const { displaySeries: ds, categoryAxisData: xd } = axisTooltipContextRef.current;
|
|
351
373
|
const s = ds[seriesIndex];
|
|
352
374
|
if (!s?.data || !Array.isArray(s.data))
|
|
353
375
|
return;
|
|
@@ -386,6 +408,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
386
408
|
}
|
|
387
409
|
}
|
|
388
410
|
return () => {
|
|
411
|
+
detachAxisTooltip();
|
|
389
412
|
if (chart) {
|
|
390
413
|
try {
|
|
391
414
|
chart.dispose();
|
|
@@ -395,8 +418,11 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
|
|
|
395
418
|
}
|
|
396
419
|
}
|
|
397
420
|
};
|
|
398
|
-
}, [option, width, height]);
|
|
399
|
-
return <
|
|
421
|
+
}, [option, width, height, attachAxisTooltipListeners]);
|
|
422
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
423
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
424
|
+
{renderAxisTooltipOverlay()}
|
|
425
|
+
</View>);
|
|
400
426
|
};
|
|
401
427
|
const AreaChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
402
428
|
export const AreaChart = Object.assign(AreaChartComponent, {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { CartesianChartProps, CartesianChartSelectEvent } from '../props/cartesian';
|
|
2
|
+
import type { ChartTooltipOption } from '../tooltip';
|
|
3
|
+
/** @deprecated Use {@link ChartTooltipOption} from `../tooltip`. */
|
|
4
|
+
export type AreaChartTooltip = ChartTooltipOption;
|
|
2
5
|
/**
|
|
3
6
|
* Area/line/bar series data shape:
|
|
4
7
|
* - Single series: number[]
|
|
@@ -14,6 +17,7 @@ export type SeriesData = number[] | [string | number, number][] | Array<{
|
|
|
14
17
|
}>;
|
|
15
18
|
/** @deprecated Use {@link CartesianChartSelectEvent} from `../props/cartesian`. */
|
|
16
19
|
export type AreaChartSelectEvent = CartesianChartSelectEvent;
|
|
20
|
+
export type { AxisTooltipParams as AreaChartAxisTooltipParams, AxisTooltipSeriesItem as AreaChartTooltipSeriesItem, } from '../cartesian/tooltip/axis-tooltip.types';
|
|
17
21
|
/**
|
|
18
22
|
* Props for AreaChart.
|
|
19
23
|
* common -> cartesian -> area
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"area-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/area/area-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"area-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/area/area-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,oEAAoE;AACpE,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,EAAE,GACR,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,GAC3B,KAAK,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,GACxC,KAAK,CAAC;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;CAAE,CAAC,CAAC;AAEhE,mFAAmF;AACnF,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,CAAC;AAE7D,YAAY,EACV,iBAAiB,IAAI,0BAA0B,EAC/C,qBAAqB,IAAI,0BAA0B,GACpD,MAAM,yCAAyC,CAAC;AAEjD;;;GAGG;AACH,MAAM,WAAW,cAAe,SAAQ,mBAAmB;IACzD;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;IAC1C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IACtG;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACzE;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,GAAG,aAAa,GAAG,OAAO,CAAC;CACjD"}
|
package/area/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { AreaChart } from './area-chart';
|
|
2
|
-
export type { AreaChartProps, AreaChartSelectEvent, SeriesData, } from './area-chart.props';
|
|
2
|
+
export type { AreaChartProps, AreaChartSelectEvent, AreaChartAxisTooltipParams, AreaChartTooltip, AreaChartTooltipSeriesItem, SeriesData, } from './area-chart.props';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/area/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/area/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/area/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,EAChB,0BAA0B,EAC1B,UAAU,GACX,MAAM,oBAAoB,CAAC"}
|
package/axis.d.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
export declare const getAxisByMinMax: (min?: number, max?: number, interval?: number) => number[];
|
|
2
2
|
export declare const getAxis: (data: number[]) => number[];
|
|
3
|
+
/**
|
|
4
|
+
* Maps explicit Cartesian Y (value) axis props to axis `min` / `max` / `interval`.
|
|
5
|
+
* When all three are omitted, returns `undefined` so the chart library chooses the scale.
|
|
6
|
+
*/
|
|
7
|
+
export declare function valueAxisBoundsFromProps(params: {
|
|
8
|
+
minY?: number;
|
|
9
|
+
maxY?: number;
|
|
10
|
+
intervalY?: number;
|
|
11
|
+
}): {
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
interval?: number;
|
|
15
|
+
} | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Maps explicit Cartesian X-axis props to axis `min` / `max` / `interval`.
|
|
18
|
+
* When all three are omitted, returns `undefined` so the chart library chooses the scale.
|
|
19
|
+
*/
|
|
20
|
+
export declare function xAxisBoundsFromProps(params: {
|
|
21
|
+
minX?: number;
|
|
22
|
+
maxX?: number;
|
|
23
|
+
intervalX?: number;
|
|
24
|
+
}): {
|
|
25
|
+
min?: number;
|
|
26
|
+
max?: number;
|
|
27
|
+
interval?: number;
|
|
28
|
+
} | undefined;
|
|
3
29
|
//# sourceMappingURL=axis.d.ts.map
|
package/axis.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../../components/chart/axis.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,YAAO,EAAE,YAAS,EAAE,WAAW,MAAM,aAUpE,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,aAIrC,CAAA"}
|
|
1
|
+
{"version":3,"file":"axis.d.ts","sourceRoot":"","sources":["../../../components/chart/axis.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,YAAO,EAAE,YAAS,EAAE,WAAW,MAAM,aAUpE,CAAA;AAED,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,aAIrC,CAAA;AAiBD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAMhE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAMhE"}
|
package/axis.js
CHANGED
|
@@ -14,3 +14,38 @@ export const getAxis = (data) => {
|
|
|
14
14
|
const max = Math.max(...data);
|
|
15
15
|
return getAxisByMinMax(min, max);
|
|
16
16
|
};
|
|
17
|
+
function axisMinMaxIntervalFromFields(params) {
|
|
18
|
+
const out = {};
|
|
19
|
+
if (params.min !== undefined)
|
|
20
|
+
out.min = params.min;
|
|
21
|
+
if (params.max !== undefined)
|
|
22
|
+
out.max = params.max;
|
|
23
|
+
if (params.interval !== undefined)
|
|
24
|
+
out.interval = params.interval;
|
|
25
|
+
if (out.min === undefined && out.max === undefined && out.interval === undefined) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Maps explicit Cartesian Y (value) axis props to axis `min` / `max` / `interval`.
|
|
32
|
+
* When all three are omitted, returns `undefined` so the chart library chooses the scale.
|
|
33
|
+
*/
|
|
34
|
+
export function valueAxisBoundsFromProps(params) {
|
|
35
|
+
return axisMinMaxIntervalFromFields({
|
|
36
|
+
min: params.minY,
|
|
37
|
+
max: params.maxY,
|
|
38
|
+
interval: params.intervalY,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Maps explicit Cartesian X-axis props to axis `min` / `max` / `interval`.
|
|
43
|
+
* When all three are omitted, returns `undefined` so the chart library chooses the scale.
|
|
44
|
+
*/
|
|
45
|
+
export function xAxisBoundsFromProps(params) {
|
|
46
|
+
return axisMinMaxIntervalFromFields({
|
|
47
|
+
min: params.minX,
|
|
48
|
+
max: params.maxX,
|
|
49
|
+
interval: params.intervalX,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bubble-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/bubble/bubble-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"bubble-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/bubble/bubble-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAS7D,OAAO,KAAqC,MAAM,OAAO,CAAC;AAQ1D,+CAA+C;AAC/C,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA6X/E,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
|
package/bubble/bubble-chart.js
CHANGED
|
@@ -5,6 +5,10 @@ import { ScatterChart as EChartsScatterChart } 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';
|
|
9
|
+
import { valueAxisBoundsFromProps, xAxisBoundsFromProps } from '../axis';
|
|
10
|
+
import { axisTooltipShowContentFlag } from '../cartesian/tooltip';
|
|
11
|
+
import { createScatterTooltipPreset, useScatterItemTooltip } from '../scatter/tooltip';
|
|
8
12
|
echarts.use([
|
|
9
13
|
TooltipComponent,
|
|
10
14
|
GridComponent,
|
|
@@ -18,12 +22,31 @@ function scaleSize(value, dataMin, dataMax, outMin, outMax) {
|
|
|
18
22
|
const t = (value - dataMin) / (dataMax - dataMin);
|
|
19
23
|
return outMin + t * (outMax - outMin);
|
|
20
24
|
}
|
|
21
|
-
const
|
|
25
|
+
const DEFAULT_SIZE_RANGE = [8, 50];
|
|
26
|
+
const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sizeRange = DEFAULT_SIZE_RANGE, showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = false, showHighlighter = true, tooltip = 'card', xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, minX, maxX, intervalX, minY, maxY, intervalY, onSelect, renderTooltip, ...props }) => {
|
|
22
27
|
const { theme } = useChartTheme(props.theme, props.colors);
|
|
23
28
|
const chartRef = useRef(null);
|
|
24
29
|
const onSelectRef = useRef(onSelect);
|
|
25
30
|
onSelectRef.current = onSelect;
|
|
26
31
|
const selectContextRef = useRef({ normalizedSeries: [] });
|
|
32
|
+
const themeSeriesRef = useRef(theme.series);
|
|
33
|
+
themeSeriesRef.current = theme.series;
|
|
34
|
+
const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
|
|
35
|
+
const renderTooltipFn = useMemo(() => {
|
|
36
|
+
if (renderTooltip != null)
|
|
37
|
+
return renderTooltip;
|
|
38
|
+
if (tooltip === 'none')
|
|
39
|
+
return () => null;
|
|
40
|
+
return createScatterTooltipPreset(tooltip);
|
|
41
|
+
}, [renderTooltip, tooltip]);
|
|
42
|
+
const { attachScatterItemTooltipListeners, renderScatterTooltipOverlay } = useScatterItemTooltip({
|
|
43
|
+
active: tooltipOverlayActive,
|
|
44
|
+
renderTooltip: renderTooltipFn,
|
|
45
|
+
contextRef: selectContextRef,
|
|
46
|
+
themeSeriesRef,
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
});
|
|
27
50
|
const normalizedSeries = useMemo(() => {
|
|
28
51
|
if (!Array.isArray(data) || data.length === 0)
|
|
29
52
|
return [];
|
|
@@ -52,42 +75,35 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
|
|
|
52
75
|
return [];
|
|
53
76
|
}, [data]);
|
|
54
77
|
const hasNamedSeries = useMemo(() => normalizedSeries.some((s) => 'name' in s && s.name), [normalizedSeries]);
|
|
55
|
-
selectContextRef.current = {
|
|
78
|
+
selectContextRef.current = {
|
|
79
|
+
normalizedSeries: normalizedSeries,
|
|
80
|
+
};
|
|
81
|
+
const valueAxisBounds = useMemo(() => valueAxisBoundsFromProps({ minY, maxY, intervalY }), [minY, maxY, intervalY]);
|
|
82
|
+
const xAxisBounds = useMemo(() => xAxisBoundsFromProps({ minX, maxX, intervalX }), [minX, maxX, intervalX]);
|
|
56
83
|
const option = useMemo(() => {
|
|
57
|
-
const tooltipConfig =
|
|
84
|
+
const tooltipConfig = tooltipOverlayActive
|
|
58
85
|
? {
|
|
59
86
|
trigger: 'item',
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
87
|
+
...axisTooltipShowContentFlag(true),
|
|
88
|
+
...(showHighlighter && {
|
|
89
|
+
axisPointer: {
|
|
63
90
|
type: 'line',
|
|
64
|
-
|
|
65
|
-
|
|
91
|
+
lineStyle: {
|
|
92
|
+
type: 'line',
|
|
93
|
+
width: 1,
|
|
94
|
+
color: '#00000000',
|
|
95
|
+
},
|
|
96
|
+
label: {
|
|
97
|
+
show: false,
|
|
98
|
+
},
|
|
66
99
|
},
|
|
67
|
-
},
|
|
68
|
-
formatter: (params) => {
|
|
69
|
-
const p = Array.isArray(params) ? params[0] : params;
|
|
70
|
-
const d = p?.data;
|
|
71
|
-
if (!d || !Array.isArray(d))
|
|
72
|
-
return '';
|
|
73
|
-
const name = p.seriesName ? `${p.seriesName}<br/>` : '';
|
|
74
|
-
return `${name}x: ${d[0]}, y: ${d[1]}${d[2] != null ? `, size: ${d[2]}` : ''}`;
|
|
75
|
-
},
|
|
100
|
+
}),
|
|
76
101
|
}
|
|
77
|
-
: {
|
|
78
|
-
trigger: 'item',
|
|
79
|
-
formatter: (params) => {
|
|
80
|
-
const p = Array.isArray(params) ? params[0] : params;
|
|
81
|
-
const d = p?.data;
|
|
82
|
-
if (!d || !Array.isArray(d))
|
|
83
|
-
return '';
|
|
84
|
-
const name = p.seriesName ? `${p.seriesName}<br/>` : '';
|
|
85
|
-
return `${name}x: ${d[0]}, y: ${d[1]}${d[2] != null ? `, size: ${d[2]}` : ''}`;
|
|
86
|
-
},
|
|
87
|
-
};
|
|
102
|
+
: { show: false };
|
|
88
103
|
const xAxisConfig = {
|
|
89
104
|
type: 'value',
|
|
90
105
|
boundaryGap,
|
|
106
|
+
...(xAxisBounds ?? {}),
|
|
91
107
|
...(xAxisLabel != null && xAxisLabel !== '' && {
|
|
92
108
|
name: xAxisLabel,
|
|
93
109
|
nameLocation: 'middle',
|
|
@@ -109,7 +125,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
|
|
|
109
125
|
}
|
|
110
126
|
: { show: false },
|
|
111
127
|
axisTick: {
|
|
112
|
-
show: showXAxisTicks,
|
|
128
|
+
show: showXAxis && showXAxisTicks,
|
|
113
129
|
lineStyle: {
|
|
114
130
|
color: theme.axis.x.tickColor,
|
|
115
131
|
width: theme.axis.x.tickWidth,
|
|
@@ -125,6 +141,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
|
|
|
125
141
|
};
|
|
126
142
|
const yAxisConfig = {
|
|
127
143
|
type: 'value',
|
|
144
|
+
...(valueAxisBounds ?? {}),
|
|
128
145
|
...(yAxisLabel != null && yAxisLabel !== '' && {
|
|
129
146
|
name: yAxisLabel,
|
|
130
147
|
nameLocation: 'middle',
|
|
@@ -146,7 +163,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
|
|
|
146
163
|
}
|
|
147
164
|
: { show: false },
|
|
148
165
|
axisTick: {
|
|
149
|
-
show: showYAxisTicks,
|
|
166
|
+
show: showYAxis && showYAxisTicks,
|
|
150
167
|
lineStyle: {
|
|
151
168
|
color: theme.axis.y.tickColor,
|
|
152
169
|
width: theme.axis.y.tickWidth,
|
|
@@ -193,7 +210,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
|
|
|
193
210
|
itemStyle: { color: seriesColor },
|
|
194
211
|
emphasis: showHighlighter
|
|
195
212
|
? {
|
|
196
|
-
focus: '
|
|
213
|
+
focus: 'none',
|
|
197
214
|
scale: true,
|
|
198
215
|
itemStyle: {
|
|
199
216
|
color: seriesColor,
|
|
@@ -234,17 +251,22 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
|
|
|
234
251
|
showLegend,
|
|
235
252
|
hasNamedSeries,
|
|
236
253
|
showHighlighter,
|
|
254
|
+
tooltipOverlayActive,
|
|
237
255
|
xAxisTickLabelFormatter,
|
|
238
256
|
yAxisTickLabelFormatter,
|
|
239
257
|
xAxisLabel,
|
|
240
258
|
yAxisLabel,
|
|
259
|
+
valueAxisBounds,
|
|
260
|
+
xAxisBounds,
|
|
241
261
|
]);
|
|
242
262
|
useEffect(() => {
|
|
243
263
|
let chart;
|
|
264
|
+
let detachScatterTooltip = () => { };
|
|
244
265
|
if (chartRef.current) {
|
|
245
266
|
try {
|
|
246
267
|
chart = echarts.init(chartRef.current, 'light', { width, height });
|
|
247
268
|
chart.setOption(option);
|
|
269
|
+
detachScatterTooltip = attachScatterItemTooltipListeners(chart);
|
|
248
270
|
const handleSeriesClick = (params) => {
|
|
249
271
|
const cb = onSelectRef.current;
|
|
250
272
|
if (typeof cb !== 'function')
|
|
@@ -287,6 +309,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
|
|
|
287
309
|
}
|
|
288
310
|
}
|
|
289
311
|
return () => {
|
|
312
|
+
detachScatterTooltip();
|
|
290
313
|
if (chart) {
|
|
291
314
|
try {
|
|
292
315
|
chart.dispose();
|
|
@@ -296,8 +319,11 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
|
|
|
296
319
|
}
|
|
297
320
|
}
|
|
298
321
|
};
|
|
299
|
-
}, [option, width, height]);
|
|
300
|
-
return <
|
|
322
|
+
}, [option, width, height, attachScatterItemTooltipListeners]);
|
|
323
|
+
return (<View style={{ width, height, position: 'relative' }}>
|
|
324
|
+
<SkiaChart ref={chartRef} useRNGH/>
|
|
325
|
+
{renderScatterTooltipOverlay()}
|
|
326
|
+
</View>);
|
|
301
327
|
};
|
|
302
328
|
const BubbleChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
|
|
303
329
|
export const BubbleChart = Object.assign(BubbleChartComponent, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candlestick-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/candlestick/candlestick-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAmB,MAAM,2BAA2B,CAAC;AASxF,OAAO,KAAqC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"candlestick-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/candlestick/candlestick-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAmB,MAAM,2BAA2B,CAAC;AASxF,OAAO,KAAqC,MAAM,OAAO,CAAC;AAI1D,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAsVzG,eAAO,MAAM,gBAAgB;;;;;;;CAE3B,CAAC"}
|