@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.
Files changed (179) hide show
  1. package/README.md +29 -3
  2. package/area/area-chart.d.ts +1 -1
  3. package/area/area-chart.d.ts.map +1 -1
  4. package/area/area-chart.js +48 -23
  5. package/area/area-chart.props.d.ts +4 -0
  6. package/area/area-chart.props.d.ts.map +1 -1
  7. package/area/index.d.ts +1 -1
  8. package/area/index.d.ts.map +1 -1
  9. package/bubble/bubble-chart.d.ts.map +1 -1
  10. package/bubble/bubble-chart.js +50 -31
  11. package/cartesian/tooltip/axis-tooltip-presets.d.ts +5 -0
  12. package/cartesian/tooltip/axis-tooltip-presets.d.ts.map +1 -0
  13. package/cartesian/tooltip/axis-tooltip-presets.js +46 -0
  14. package/cartesian/tooltip/axis-tooltip.types.d.ts +38 -0
  15. package/cartesian/tooltip/axis-tooltip.types.d.ts.map +1 -0
  16. package/cartesian/tooltip/axis-tooltip.types.js +4 -0
  17. package/cartesian/tooltip/axis-tooltip.utils.d.ts +10 -0
  18. package/cartesian/tooltip/axis-tooltip.utils.d.ts.map +1 -0
  19. package/cartesian/tooltip/axis-tooltip.utils.js +121 -0
  20. package/cartesian/tooltip/default-axis-tooltip.d.ts +9 -0
  21. package/cartesian/tooltip/default-axis-tooltip.d.ts.map +1 -0
  22. package/cartesian/tooltip/default-axis-tooltip.js +53 -0
  23. package/cartesian/tooltip/index.d.ts +7 -0
  24. package/cartesian/tooltip/index.d.ts.map +1 -0
  25. package/cartesian/tooltip/index.js +4 -0
  26. package/cartesian/tooltip/use-axis-tooltip.d.ts +38 -0
  27. package/cartesian/tooltip/use-axis-tooltip.d.ts.map +1 -0
  28. package/cartesian/tooltip/use-axis-tooltip.js +54 -0
  29. package/column/column-chart.d.ts.map +1 -1
  30. package/column/column-chart.js +73 -20
  31. package/geo/geo-chart.d.ts.map +1 -1
  32. package/geo/geo-chart.js +56 -24
  33. package/geo/geo-chart.props.d.ts +11 -5
  34. package/geo/geo-chart.props.d.ts.map +1 -1
  35. package/geo/index.d.ts +1 -0
  36. package/geo/index.d.ts.map +1 -1
  37. package/geo/index.js +1 -0
  38. package/geo/tooltip/default-geo-tooltip.d.ts +6 -0
  39. package/geo/tooltip/default-geo-tooltip.d.ts.map +1 -0
  40. package/geo/tooltip/default-geo-tooltip.js +47 -0
  41. package/geo/tooltip/geo-item-tooltip-presets.d.ts +5 -0
  42. package/geo/tooltip/geo-item-tooltip-presets.d.ts.map +1 -0
  43. package/geo/tooltip/geo-item-tooltip-presets.js +35 -0
  44. package/geo/tooltip/geo-item-tooltip.types.d.ts +19 -0
  45. package/geo/tooltip/geo-item-tooltip.types.d.ts.map +1 -0
  46. package/geo/tooltip/geo-item-tooltip.types.js +3 -0
  47. package/geo/tooltip/geo-item-tooltip.utils.d.ts +14 -0
  48. package/geo/tooltip/geo-item-tooltip.utils.d.ts.map +1 -0
  49. package/geo/tooltip/geo-item-tooltip.utils.js +220 -0
  50. package/geo/tooltip/index.d.ts +7 -0
  51. package/geo/tooltip/index.d.ts.map +1 -0
  52. package/geo/tooltip/index.js +4 -0
  53. package/geo/tooltip/use-geo-item-tooltip.d.ts +26 -0
  54. package/geo/tooltip/use-geo-item-tooltip.d.ts.map +1 -0
  55. package/geo/tooltip/use-geo-item-tooltip.js +59 -0
  56. package/geo/us-chart.js +1 -1
  57. package/geo/us-states.json +54 -0
  58. package/geo/world.json +1 -0
  59. package/index.d.ts +2 -0
  60. package/index.d.ts.map +1 -1
  61. package/index.js +2 -0
  62. package/line/index.d.ts +1 -1
  63. package/line/index.d.ts.map +1 -1
  64. package/line/line-chart.d.ts +1 -1
  65. package/line/line-chart.d.ts.map +1 -1
  66. package/line/line-chart.props.d.ts +5 -0
  67. package/line/line-chart.props.d.ts.map +1 -1
  68. package/package.json +1 -1
  69. package/pie/index.d.ts +1 -0
  70. package/pie/index.d.ts.map +1 -1
  71. package/pie/index.js +1 -0
  72. package/pie/pie-chart.d.ts.map +1 -1
  73. package/pie/pie-chart.js +59 -36
  74. package/pie/pie-chart.props.d.ts +12 -6
  75. package/pie/pie-chart.props.d.ts.map +1 -1
  76. package/pie/tooltip/default-pie-tooltip.d.ts +5 -0
  77. package/pie/tooltip/default-pie-tooltip.d.ts.map +1 -0
  78. package/pie/tooltip/default-pie-tooltip.js +57 -0
  79. package/pie/tooltip/index.d.ts +7 -0
  80. package/pie/tooltip/index.d.ts.map +1 -0
  81. package/pie/tooltip/index.js +4 -0
  82. package/pie/tooltip/pie-item-tooltip-presets.d.ts +5 -0
  83. package/pie/tooltip/pie-item-tooltip-presets.d.ts.map +1 -0
  84. package/pie/tooltip/pie-item-tooltip-presets.js +39 -0
  85. package/pie/tooltip/pie-item-tooltip.types.d.ts +28 -0
  86. package/pie/tooltip/pie-item-tooltip.types.d.ts.map +1 -0
  87. package/pie/tooltip/pie-item-tooltip.types.js +3 -0
  88. package/pie/tooltip/pie-item-tooltip.utils.d.ts +9 -0
  89. package/pie/tooltip/pie-item-tooltip.utils.d.ts.map +1 -0
  90. package/pie/tooltip/pie-item-tooltip.utils.js +139 -0
  91. package/pie/tooltip/use-pie-item-tooltip.d.ts +24 -0
  92. package/pie/tooltip/use-pie-item-tooltip.d.ts.map +1 -0
  93. package/pie/tooltip/use-pie-item-tooltip.js +45 -0
  94. package/props/cartesian.d.ts +18 -2
  95. package/props/cartesian.d.ts.map +1 -1
  96. package/radar/index.d.ts +1 -0
  97. package/radar/index.d.ts.map +1 -1
  98. package/radar/index.js +1 -0
  99. package/radar/radar-chart.d.ts.map +1 -1
  100. package/radar/radar-chart.js +52 -10
  101. package/radar/radar-chart.props.d.ts +13 -0
  102. package/radar/radar-chart.props.d.ts.map +1 -1
  103. package/radar/tooltip/default-radar-tooltip.d.ts +6 -0
  104. package/radar/tooltip/default-radar-tooltip.d.ts.map +1 -0
  105. package/radar/tooltip/default-radar-tooltip.js +47 -0
  106. package/radar/tooltip/index.d.ts +7 -0
  107. package/radar/tooltip/index.d.ts.map +1 -0
  108. package/radar/tooltip/index.js +4 -0
  109. package/radar/tooltip/radar-item-tooltip-presets.d.ts +5 -0
  110. package/radar/tooltip/radar-item-tooltip-presets.d.ts.map +1 -0
  111. package/radar/tooltip/radar-item-tooltip-presets.js +50 -0
  112. package/radar/tooltip/radar-item-tooltip.types.d.ts +28 -0
  113. package/radar/tooltip/radar-item-tooltip.types.d.ts.map +1 -0
  114. package/radar/tooltip/radar-item-tooltip.types.js +3 -0
  115. package/radar/tooltip/radar-item-tooltip.utils.d.ts +9 -0
  116. package/radar/tooltip/radar-item-tooltip.utils.d.ts.map +1 -0
  117. package/radar/tooltip/radar-item-tooltip.utils.js +77 -0
  118. package/radar/tooltip/use-radar-item-tooltip.d.ts +22 -0
  119. package/radar/tooltip/use-radar-item-tooltip.d.ts.map +1 -0
  120. package/radar/tooltip/use-radar-item-tooltip.js +43 -0
  121. package/radial/index.d.ts +1 -0
  122. package/radial/index.d.ts.map +1 -1
  123. package/radial/index.js +1 -0
  124. package/radial/radial-chart.d.ts.map +1 -1
  125. package/radial/radial-chart.js +42 -10
  126. package/radial/radial-chart.props.d.ts +14 -1
  127. package/radial/radial-chart.props.d.ts.map +1 -1
  128. package/radial/tooltip/default-radial-tooltip.d.ts +6 -0
  129. package/radial/tooltip/default-radial-tooltip.d.ts.map +1 -0
  130. package/radial/tooltip/default-radial-tooltip.js +52 -0
  131. package/radial/tooltip/index.d.ts +7 -0
  132. package/radial/tooltip/index.d.ts.map +1 -0
  133. package/radial/tooltip/index.js +4 -0
  134. package/radial/tooltip/radial-item-tooltip-presets.d.ts +5 -0
  135. package/radial/tooltip/radial-item-tooltip-presets.d.ts.map +1 -0
  136. package/radial/tooltip/radial-item-tooltip-presets.js +43 -0
  137. package/radial/tooltip/radial-item-tooltip.types.d.ts +23 -0
  138. package/radial/tooltip/radial-item-tooltip.types.d.ts.map +1 -0
  139. package/radial/tooltip/radial-item-tooltip.types.js +3 -0
  140. package/radial/tooltip/radial-item-tooltip.utils.d.ts +9 -0
  141. package/radial/tooltip/radial-item-tooltip.utils.d.ts.map +1 -0
  142. package/radial/tooltip/radial-item-tooltip.utils.js +122 -0
  143. package/radial/tooltip/use-radial-item-tooltip.d.ts +22 -0
  144. package/radial/tooltip/use-radial-item-tooltip.d.ts.map +1 -0
  145. package/radial/tooltip/use-radial-item-tooltip.js +43 -0
  146. package/scatter/index.d.ts +1 -0
  147. package/scatter/index.d.ts.map +1 -1
  148. package/scatter/index.js +1 -0
  149. package/scatter/scatter-chart.d.ts.map +1 -1
  150. package/scatter/scatter-chart.js +46 -12
  151. package/scatter/scatter-chart.props.d.ts +7 -1
  152. package/scatter/scatter-chart.props.d.ts.map +1 -1
  153. package/scatter/tooltip/default-scatter-tooltip.d.ts +8 -0
  154. package/scatter/tooltip/default-scatter-tooltip.d.ts.map +1 -0
  155. package/scatter/tooltip/default-scatter-tooltip.js +57 -0
  156. package/scatter/tooltip/index.d.ts +7 -0
  157. package/scatter/tooltip/index.d.ts.map +1 -0
  158. package/scatter/tooltip/index.js +4 -0
  159. package/scatter/tooltip/scatter-item-tooltip-presets.d.ts +5 -0
  160. package/scatter/tooltip/scatter-item-tooltip-presets.d.ts.map +1 -0
  161. package/scatter/tooltip/scatter-item-tooltip-presets.js +49 -0
  162. package/scatter/tooltip/scatter-item-tooltip.types.d.ts +22 -0
  163. package/scatter/tooltip/scatter-item-tooltip.types.d.ts.map +1 -0
  164. package/scatter/tooltip/scatter-item-tooltip.types.js +3 -0
  165. package/scatter/tooltip/scatter-item-tooltip.utils.d.ts +9 -0
  166. package/scatter/tooltip/scatter-item-tooltip.utils.d.ts.map +1 -0
  167. package/scatter/tooltip/scatter-item-tooltip.utils.js +83 -0
  168. package/scatter/tooltip/use-scatter-item-tooltip.d.ts +25 -0
  169. package/scatter/tooltip/use-scatter-item-tooltip.d.ts.map +1 -0
  170. package/scatter/tooltip/use-scatter-item-tooltip.js +46 -0
  171. package/tooltip/chart-pointer-tooltip-overlay.d.ts +11 -0
  172. package/tooltip/chart-pointer-tooltip-overlay.d.ts.map +1 -0
  173. package/tooltip/chart-pointer-tooltip-overlay.js +88 -0
  174. package/tooltip/chart-tooltip-preset-shells.d.ts +66 -0
  175. package/tooltip/chart-tooltip-preset-shells.d.ts.map +1 -0
  176. package/tooltip/chart-tooltip-preset-shells.js +409 -0
  177. package/tooltip/index.d.ts +7 -0
  178. package/tooltip/index.d.ts.map +1 -0
  179. 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
- This repo is an Expo app. To run the app and Storybook:
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 # for mobile preview
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
@@ -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
  } & {
@@ -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,EAAc,MAAM,oBAAoB,CAAC;AASrE,OAAO,KAAqC,MAAM,OAAO,CAAC;AAI1D,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,oBAAoB,CAAC;AAsc5B,eAAO,MAAM,SAAS;;;;;;;CAEpB,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;AA+d5B,eAAO,MAAM,SAAS;;;;;;;CAEpB,CAAC"}
@@ -1,10 +1,12 @@
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';
9
+ import { View } from 'react-native';
8
10
  import { getAxis } from '../axis';
9
11
  // Register necessary components for this chart
10
12
  echarts.use([
@@ -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, xAxisTicks, xAxisLabel, yAxisLabel, onSelect, ...props }) => {
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, xAxisTicks, xAxisLabel, yAxisLabel, 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 selectContextRef = useRef({
24
+ const axisTooltipContextRef = useRef({
23
25
  displaySeries: [],
24
- xAxisData: [],
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';
@@ -93,23 +113,8 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
93
113
  ? xAxisTicks
94
114
  : getAxis(dataPoints).map(String);
95
115
  }, [normalizedSeries, xAxisTicks]);
96
- selectContextRef.current = { displaySeries, xAxisData };
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',
@@ -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,6 +337,7 @@ 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
343
  xAxisTicks,
@@ -327,6 +346,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
327
346
  ]);
328
347
  useEffect(() => {
329
348
  let chart;
349
+ let detachAxisTooltip = () => { };
330
350
  if (chartRef.current) {
331
351
  try {
332
352
  chart = echarts.init(chartRef.current, 'light', {
@@ -334,6 +354,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
334
354
  height: height,
335
355
  });
336
356
  chart.setOption(option);
357
+ detachAxisTooltip = attachAxisTooltipListeners(chart);
337
358
  const handleSeriesClick = (params) => {
338
359
  const cb = onSelectRef.current;
339
360
  if (typeof cb !== 'function')
@@ -347,7 +368,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
347
368
  dataIndex < 0) {
348
369
  return;
349
370
  }
350
- const { displaySeries: ds, xAxisData: xd } = selectContextRef.current;
371
+ const { displaySeries: ds, categoryAxisData: xd } = axisTooltipContextRef.current;
351
372
  const s = ds[seriesIndex];
352
373
  if (!s?.data || !Array.isArray(s.data))
353
374
  return;
@@ -386,6 +407,7 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
386
407
  }
387
408
  }
388
409
  return () => {
410
+ detachAxisTooltip();
389
411
  if (chart) {
390
412
  try {
391
413
  chart.dispose();
@@ -395,8 +417,11 @@ const ChartComponent = ({ data, width = 220, height = 350, type = 'default', ste
395
417
  }
396
418
  }
397
419
  };
398
- }, [option, width, height]);
399
- return <SkiaChart ref={chartRef} useRNGH/>;
420
+ }, [option, width, height, attachAxisTooltipListeners]);
421
+ return (<View style={{ width, height, position: 'relative' }}>
422
+ <SkiaChart ref={chartRef} useRNGH/>
423
+ {renderAxisTooltipOverlay()}
424
+ </View>);
400
425
  };
401
426
  const AreaChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
402
427
  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;AAEzF;;;;;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;;;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"}
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
@@ -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"}
@@ -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;AAG1D,+CAA+C;AAC/C,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAkV/E,eAAO,MAAM,WAAW;;;;;;;CAEtB,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;AAO1D,+CAA+C;AAC/C,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAyW/E,eAAO,MAAM,WAAW;;;;;;;CAEtB,CAAC"}
@@ -5,6 +5,9 @@ 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 { axisTooltipShowContentFlag } from '../cartesian/tooltip';
10
+ import { createScatterTooltipPreset, useScatterItemTooltip } from '../scatter/tooltip';
8
11
  echarts.use([
9
12
  TooltipComponent,
10
13
  GridComponent,
@@ -18,12 +21,31 @@ function scaleSize(value, dataMin, dataMax, outMin, outMax) {
18
21
  const t = (value - dataMin) / (dataMax - dataMin);
19
22
  return outMin + t * (outMax - outMin);
20
23
  }
21
- const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', sizeRange = [8, 50], showXAxis = true, showXAxisTicks = true, showYAxis = true, showYAxisTicks = true, showXAxisSplitLines = true, showYAxisSplitLines = true, boundaryGap = false, grid, showLegend = false, showHighlighter = true, xAxisTickLabelFormatter, yAxisTickLabelFormatter, xAxisLabel, yAxisLabel, onSelect, ...props }) => {
24
+ const DEFAULT_SIZE_RANGE = [8, 50];
25
+ 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, onSelect, renderTooltip, ...props }) => {
22
26
  const { theme } = useChartTheme(props.theme, props.colors);
23
27
  const chartRef = useRef(null);
24
28
  const onSelectRef = useRef(onSelect);
25
29
  onSelectRef.current = onSelect;
26
30
  const selectContextRef = useRef({ normalizedSeries: [] });
31
+ const themeSeriesRef = useRef(theme.series);
32
+ themeSeriesRef.current = theme.series;
33
+ const tooltipOverlayActive = renderTooltip != null || tooltip !== 'none';
34
+ const renderTooltipFn = useMemo(() => {
35
+ if (renderTooltip != null)
36
+ return renderTooltip;
37
+ if (tooltip === 'none')
38
+ return () => null;
39
+ return createScatterTooltipPreset(tooltip);
40
+ }, [renderTooltip, tooltip]);
41
+ const { attachScatterItemTooltipListeners, renderScatterTooltipOverlay } = useScatterItemTooltip({
42
+ active: tooltipOverlayActive,
43
+ renderTooltip: renderTooltipFn,
44
+ contextRef: selectContextRef,
45
+ themeSeriesRef,
46
+ width,
47
+ height,
48
+ });
27
49
  const normalizedSeries = useMemo(() => {
28
50
  if (!Array.isArray(data) || data.length === 0)
29
51
  return [];
@@ -52,39 +74,29 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
52
74
  return [];
53
75
  }, [data]);
54
76
  const hasNamedSeries = useMemo(() => normalizedSeries.some((s) => 'name' in s && s.name), [normalizedSeries]);
55
- selectContextRef.current = { normalizedSeries };
77
+ selectContextRef.current = {
78
+ normalizedSeries: normalizedSeries,
79
+ };
56
80
  const option = useMemo(() => {
57
- const tooltipConfig = showHighlighter
81
+ const tooltipConfig = tooltipOverlayActive
58
82
  ? {
59
83
  trigger: 'item',
60
- axisPointer: {
61
- type: 'cross',
62
- lineStyle: {
84
+ ...axisTooltipShowContentFlag(true),
85
+ ...(showHighlighter && {
86
+ axisPointer: {
63
87
  type: 'line',
64
- width: 1,
65
- color: theme.series[0]?.color ?? '#999',
88
+ lineStyle: {
89
+ type: 'line',
90
+ width: 1,
91
+ color: '#00000000',
92
+ },
93
+ label: {
94
+ show: false,
95
+ },
66
96
  },
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
- },
97
+ }),
76
98
  }
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
- };
99
+ : { show: false };
88
100
  const xAxisConfig = {
89
101
  type: 'value',
90
102
  boundaryGap,
@@ -193,7 +205,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
193
205
  itemStyle: { color: seriesColor },
194
206
  emphasis: showHighlighter
195
207
  ? {
196
- focus: 'self',
208
+ focus: 'none',
197
209
  scale: true,
198
210
  itemStyle: {
199
211
  color: seriesColor,
@@ -234,6 +246,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
234
246
  showLegend,
235
247
  hasNamedSeries,
236
248
  showHighlighter,
249
+ tooltipOverlayActive,
237
250
  xAxisTickLabelFormatter,
238
251
  yAxisTickLabelFormatter,
239
252
  xAxisLabel,
@@ -241,10 +254,12 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
241
254
  ]);
242
255
  useEffect(() => {
243
256
  let chart;
257
+ let detachScatterTooltip = () => { };
244
258
  if (chartRef.current) {
245
259
  try {
246
260
  chart = echarts.init(chartRef.current, 'light', { width, height });
247
261
  chart.setOption(option);
262
+ detachScatterTooltip = attachScatterItemTooltipListeners(chart);
248
263
  const handleSeriesClick = (params) => {
249
264
  const cb = onSelectRef.current;
250
265
  if (typeof cb !== 'function')
@@ -287,6 +302,7 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
287
302
  }
288
303
  }
289
304
  return () => {
305
+ detachScatterTooltip();
290
306
  if (chart) {
291
307
  try {
292
308
  chart.dispose();
@@ -296,8 +312,11 @@ const ChartComponent = ({ data, width = 220, height = 350, symbol = 'circle', si
296
312
  }
297
313
  }
298
314
  };
299
- }, [option, width, height]);
300
- return <SkiaChart ref={chartRef} useRNGH/>;
315
+ }, [option, width, height, attachScatterItemTooltipListeners]);
316
+ return (<View style={{ width, height, position: 'relative' }}>
317
+ <SkiaChart ref={chartRef} useRNGH/>
318
+ {renderScatterTooltipOverlay()}
319
+ </View>);
301
320
  };
302
321
  const BubbleChartComponent = withResponsiveContainer(withChartTheme(ChartComponent));
303
322
  export const BubbleChart = Object.assign(BubbleChartComponent, {
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { ChartTooltipPreset } from '../../tooltip';
3
+ import type { AxisTooltipParams } from './axis-tooltip.types';
4
+ export declare function createAxisTooltipPreset(preset: ChartTooltipPreset): (params: AxisTooltipParams) => React.ReactElement;
5
+ //# sourceMappingURL=axis-tooltip-presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axis-tooltip-presets.d.ts","sourceRoot":"","sources":["../../../../../components/chart/cartesian/tooltip/axis-tooltip-presets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAOxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA0D9D,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,kBAAkB,GACzB,CAAC,MAAM,EAAE,iBAAiB,KAAK,KAAK,CAAC,YAAY,CAYnD"}
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { TooltipPresetCard, TooltipPresetCompact, TooltipPresetKpi, TooltipPresetStriped, } from '../../tooltip/chart-tooltip-preset-shells';
3
+ function axisCardFromParams({ axisValue, series }) {
4
+ return (<TooltipPresetCard categoryTitle={String(axisValue)} seriesRows={series.map((s) => ({
5
+ key: s.seriesIndex,
6
+ swatchColor: s.color ?? '#94a3b8',
7
+ label: s.seriesName,
8
+ value: s.value,
9
+ }))}/>);
10
+ }
11
+ function axisCompactFromParams({ axisValue, series }) {
12
+ const detail = series.map((s) => `${s.seriesName} ${s.value}`).join(' · ');
13
+ return <TooltipPresetCompact emphasis={String(axisValue)} detail={detail} wrap/>;
14
+ }
15
+ function axisKpiFromParams({ axisValue, series }) {
16
+ const primary = series[0];
17
+ const rest = series.slice(1);
18
+ return (<TooltipPresetKpi accentColor={primary?.color ?? '#3b82f6'} minWidth={160} overline={String(axisValue)} metric={primary?.value ?? ''} caption={primary?.seriesName} footerRows={rest.length > 0
19
+ ? rest.map((s) => ({
20
+ key: s.seriesIndex,
21
+ left: s.seriesName,
22
+ right: s.value,
23
+ }))
24
+ : undefined}/>);
25
+ }
26
+ function axisStripedFromParams({ axisValue, series }) {
27
+ return (<TooltipPresetStriped headerTitle={String(axisValue)} rows={series.map((s) => ({
28
+ key: `s-${s.seriesIndex}`,
29
+ leftLabel: s.seriesName,
30
+ leftSwatchColor: s.color ?? '#64748b',
31
+ right: s.value,
32
+ }))}/>);
33
+ }
34
+ export function createAxisTooltipPreset(preset) {
35
+ switch (preset) {
36
+ case 'card':
37
+ return (p) => axisCardFromParams(p);
38
+ case 'compact':
39
+ return (p) => axisCompactFromParams(p);
40
+ case 'kpi':
41
+ return (p) => axisKpiFromParams(p);
42
+ case 'striped':
43
+ return (p) => axisStripedFromParams(p);
44
+ }
45
+ throw new Error(`Unknown tooltip preset: ${String(preset)}`);
46
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Types for axis-triggered tooltips (category axis + one value per series).
3
+ * Used by area, line, column, and bar charts.
4
+ */
5
+ /** One series row at the hovered category index. */
6
+ export interface AxisTooltipSeriesItem {
7
+ seriesName: string;
8
+ value: number;
9
+ seriesIndex: number;
10
+ color?: string;
11
+ }
12
+ /** Axis tooltip fields without pointer position. */
13
+ export interface AxisTooltipContentParams {
14
+ axisValue: string | number;
15
+ dataIndex: number;
16
+ series: AxisTooltipSeriesItem[];
17
+ }
18
+ /** Payload for `renderTooltip` (includes pointer in chart pixel space). */
19
+ export interface AxisTooltipParams extends AxisTooltipContentParams {
20
+ pointerX: number;
21
+ pointerY: number;
22
+ }
23
+ /**
24
+ * Ref snapshot read when `showTip` fires. Keep `categoryAxisData` in sync with the chart’s category axis `data`.
25
+ */
26
+ export interface AxisTooltipContext {
27
+ displaySeries: Array<{
28
+ name?: string;
29
+ data: [string | number, number][] | number[];
30
+ }>;
31
+ categoryAxisData: (string | number)[];
32
+ /**
33
+ * Set when the category axis is Y (horizontal column/bar). `showTip` lists that axis in `dataByAxis`;
34
+ * reading `[0]` would be the value axis and yields a stuck `dataIndex`.
35
+ */
36
+ categoryAxisIsY?: boolean;
37
+ }
38
+ //# sourceMappingURL=axis-tooltip.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axis-tooltip.types.d.ts","sourceRoot":"","sources":["../../../../../components/chart/cartesian/tooltip/axis-tooltip.types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oDAAoD;AACpD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,oDAAoD;AACpD,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,qBAAqB,EAAE,CAAC;CACjC;AAED,2EAA2E;AAC3E,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACtF,gBAAgB,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IACtC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Types for axis-triggered tooltips (category axis + one value per series).
3
+ * Used by area, line, column, and bar charts.
4
+ */
@@ -0,0 +1,10 @@
1
+ import type { AxisTooltipContext, AxisTooltipParams } from './axis-tooltip.types';
2
+ /** Build axis tooltip params from an ECharts `showTip` dispatch payload. */
3
+ export declare function axisTooltipParamsFromShowTipEvent(evt: any, ctx: AxisTooltipContext, seriesTheme: Array<{
4
+ color: string;
5
+ }>): AxisTooltipParams | null;
6
+ /** Spread onto ECharts `tooltip` when using an RN overlay (`showTip` / `hideTip` still fire). */
7
+ export declare function axisTooltipShowContentFlag(useCustomTooltipOverlay: boolean): {
8
+ showContent: boolean;
9
+ };
10
+ //# sourceMappingURL=axis-tooltip.utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axis-tooltip.utils.d.ts","sourceRoot":"","sources":["../../../../../components/chart/cartesian/tooltip/axis-tooltip.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAyB,MAAM,sBAAsB,CAAC;AAsEzG,4EAA4E;AAC5E,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EACvB,WAAW,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GACpC,iBAAiB,GAAG,IAAI,CAsD1B;AAED,iGAAiG;AACjG,wBAAgB,0BAA0B,CACxC,uBAAuB,EAAE,OAAO,GAC/B;IAAE,WAAW,EAAE,OAAO,CAAA;CAAE,CAE1B"}
@@ -0,0 +1,121 @@
1
+ function isCategoryAxisEntry(a) {
2
+ return String(a?.axisType ?? '').toLowerCase() === 'category';
3
+ }
4
+ function hasSeriesIndices(a) {
5
+ return Array.isArray(a?.seriesDataIndices) && a.seriesDataIndices.length > 0;
6
+ }
7
+ /** First numeric `dataIndex` carried on the axis tooltip batch (the authoritative index for that axis). */
8
+ function dataIndexFromSeriesDataIndices(indices) {
9
+ if (!Array.isArray(indices))
10
+ return undefined;
11
+ for (const item of indices) {
12
+ const d = item?.dataIndex;
13
+ if (typeof d === 'number' && !Number.isNaN(d))
14
+ return d;
15
+ }
16
+ return undefined;
17
+ }
18
+ function seriesDataIndicesFromShowTipEvt(evt, categoryAxisIsY) {
19
+ const axes = evt?.dataByCoordSys?.[0]?.dataByAxis;
20
+ if (!Array.isArray(axes) || axes.length === 0)
21
+ return null;
22
+ const categoryAxes = axes.filter(isCategoryAxisEntry);
23
+ if (categoryAxes.length === 1) {
24
+ const axisEntry = categoryAxes[0];
25
+ return {
26
+ indices: Array.isArray(axisEntry.seriesDataIndices) ? axisEntry.seriesDataIndices : [],
27
+ axisEntry,
28
+ };
29
+ }
30
+ if (categoryAxes.length > 1 && categoryAxisIsY != null) {
31
+ const dim = categoryAxisIsY ? 'y' : 'x';
32
+ const axisEntry = categoryAxes.find((a) => a?.axisDim === dim && hasSeriesIndices(a)) ??
33
+ categoryAxes.find((a) => a?.axisDim === dim) ??
34
+ categoryAxes[0];
35
+ return {
36
+ indices: Array.isArray(axisEntry.seriesDataIndices) ? axisEntry.seriesDataIndices : [],
37
+ axisEntry,
38
+ };
39
+ }
40
+ if (categoryAxisIsY === true) {
41
+ const yWith = axes.find((a) => a?.axisDim === 'y' && hasSeriesIndices(a));
42
+ if (yWith)
43
+ return { indices: yWith.seriesDataIndices, axisEntry: yWith };
44
+ const yAxis = axes.find((a) => a?.axisDim === 'y');
45
+ if (yAxis)
46
+ return { indices: Array.isArray(yAxis.seriesDataIndices) ? yAxis.seriesDataIndices : [], axisEntry: yAxis };
47
+ return null;
48
+ }
49
+ if (categoryAxisIsY === false) {
50
+ const xWith = axes.find((a) => a?.axisDim === 'x' && hasSeriesIndices(a));
51
+ if (xWith)
52
+ return { indices: xWith.seriesDataIndices, axisEntry: xWith };
53
+ const xAxis = axes.find((a) => a?.axisDim === 'x');
54
+ if (xAxis)
55
+ return { indices: Array.isArray(xAxis.seriesDataIndices) ? xAxis.seriesDataIndices : [], axisEntry: xAxis };
56
+ return null;
57
+ }
58
+ const preferred = axes.find((a) => a?.axisDim === 'x' && hasSeriesIndices(a));
59
+ const fallback = axes.find((a) => hasSeriesIndices(a));
60
+ const axisEntry = preferred ?? fallback ?? axes[0];
61
+ const indices = axisEntry?.seriesDataIndices;
62
+ if (!Array.isArray(indices) || indices.length === 0)
63
+ return null;
64
+ return { indices, axisEntry };
65
+ }
66
+ /** Build axis tooltip params from an ECharts `showTip` dispatch payload. */
67
+ export function axisTooltipParamsFromShowTipEvent(evt, ctx, seriesTheme) {
68
+ const pointerX = evt?.x;
69
+ const pointerY = evt?.y;
70
+ if (typeof pointerX !== 'number' || typeof pointerY !== 'number')
71
+ return null;
72
+ if (Number.isNaN(pointerX) || Number.isNaN(pointerY))
73
+ return null;
74
+ const picked = seriesDataIndicesFromShowTipEvt(evt, ctx.categoryAxisIsY);
75
+ if (picked == null)
76
+ return null;
77
+ const { indices, axisEntry } = picked;
78
+ const dataIndexRaw = dataIndexFromSeriesDataIndices(indices) ??
79
+ (typeof axisEntry?.dataIndex === 'number' && !Number.isNaN(axisEntry.dataIndex)
80
+ ? axisEntry.dataIndex
81
+ : undefined) ??
82
+ (typeof evt?.dataIndex === 'number' && !Number.isNaN(evt.dataIndex) ? evt.dataIndex : undefined) ??
83
+ 0;
84
+ const { displaySeries: ds, categoryAxisData: cats } = ctx;
85
+ if (!ds?.length || dataIndexRaw < 0)
86
+ return null;
87
+ const indicesForSeries = Array.isArray(indices) && indices.length > 0
88
+ ? indices
89
+ : ds.map((_, seriesIndex) => ({ seriesIndex, dataIndex: dataIndexRaw }));
90
+ const axisValue = cats[dataIndexRaw] ?? dataIndexRaw;
91
+ const themeLen = Math.max(seriesTheme.length, 1);
92
+ const series = indicesForSeries.map((item) => {
93
+ const seriesIndex = typeof item.seriesIndex === 'number' ? item.seriesIndex : 0;
94
+ const s = ds[seriesIndex];
95
+ const seriesName = s?.name != null && s.name !== '' ? String(s.name) : `Series ${seriesIndex + 1}`;
96
+ let value = 0;
97
+ const pt = s?.data?.[dataIndexRaw];
98
+ if (typeof pt === 'number')
99
+ value = pt;
100
+ else if (Array.isArray(pt) && pt.length >= 2)
101
+ value = Number(pt[1]);
102
+ const color = seriesTheme[seriesIndex % themeLen]?.color;
103
+ return {
104
+ seriesName,
105
+ value,
106
+ seriesIndex,
107
+ ...(typeof color === 'string' ? { color } : {}),
108
+ };
109
+ });
110
+ return {
111
+ axisValue,
112
+ dataIndex: dataIndexRaw,
113
+ series,
114
+ pointerX,
115
+ pointerY,
116
+ };
117
+ }
118
+ /** Spread onto ECharts `tooltip` when using an RN overlay (`showTip` / `hideTip` still fire). */
119
+ export function axisTooltipShowContentFlag(useCustomTooltipOverlay) {
120
+ return { showContent: !useCustomTooltipOverlay };
121
+ }