@wavemaker/react-native-echarts 1.0.0-dev.0

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 (145) hide show
  1. package/.npmignore +4 -0
  2. package/LICENSE +21 -0
  3. package/README.md +39 -0
  4. package/area/area-chart.d.ts +12 -0
  5. package/area/area-chart.d.ts.map +1 -0
  6. package/area/area-chart.js +404 -0
  7. package/area/area-chart.props.d.ts +64 -0
  8. package/area/area-chart.props.d.ts.map +1 -0
  9. package/area/area-chart.props.js +0 -0
  10. package/area/index.d.ts +3 -0
  11. package/area/index.d.ts.map +1 -0
  12. package/area/index.js +1 -0
  13. package/axis.d.ts +3 -0
  14. package/axis.d.ts.map +1 -0
  15. package/axis.js +16 -0
  16. package/bar/bar-chart.d.ts +11 -0
  17. package/bar/bar-chart.d.ts.map +1 -0
  18. package/bar/bar-chart.js +6 -0
  19. package/bar/bar-chart.props.d.ts +7 -0
  20. package/bar/bar-chart.props.d.ts.map +1 -0
  21. package/bar/bar-chart.props.js +0 -0
  22. package/bar/index.d.ts +3 -0
  23. package/bar/index.d.ts.map +1 -0
  24. package/bar/index.js +1 -0
  25. package/bubble/bubble-chart.d.ts +13 -0
  26. package/bubble/bubble-chart.d.ts.map +1 -0
  27. package/bubble/bubble-chart.js +305 -0
  28. package/bubble/bubble-chart.props.d.ts +26 -0
  29. package/bubble/bubble-chart.props.d.ts.map +1 -0
  30. package/bubble/bubble-chart.props.js +0 -0
  31. package/bubble/index.d.ts +3 -0
  32. package/bubble/index.d.ts.map +1 -0
  33. package/bubble/index.js +1 -0
  34. package/candlestick/candlestick-chart.d.ts +12 -0
  35. package/candlestick/candlestick-chart.d.ts.map +1 -0
  36. package/candlestick/candlestick-chart.js +292 -0
  37. package/candlestick/candlestick-chart.props.d.ts +51 -0
  38. package/candlestick/candlestick-chart.props.d.ts.map +1 -0
  39. package/candlestick/candlestick-chart.props.js +0 -0
  40. package/candlestick/index.d.ts +3 -0
  41. package/candlestick/index.d.ts.map +1 -0
  42. package/candlestick/index.js +1 -0
  43. package/chart-container.d.ts +6 -0
  44. package/chart-container.d.ts.map +1 -0
  45. package/chart-container.js +63 -0
  46. package/chart-theme.context.d.ts +191 -0
  47. package/chart-theme.context.d.ts.map +1 -0
  48. package/chart-theme.context.js +276 -0
  49. package/column/column-chart.d.ts +13 -0
  50. package/column/column-chart.d.ts.map +1 -0
  51. package/column/column-chart.js +481 -0
  52. package/column/column-chart.props.d.ts +83 -0
  53. package/column/column-chart.props.d.ts.map +1 -0
  54. package/column/column-chart.props.js +0 -0
  55. package/column/index.d.ts +3 -0
  56. package/column/index.d.ts.map +1 -0
  57. package/column/index.js +1 -0
  58. package/gauge/digital/digital.gauge.d.ts +28 -0
  59. package/gauge/digital/digital.gauge.d.ts.map +1 -0
  60. package/gauge/digital/digital.gauge.js +213 -0
  61. package/gauge/gauge.types.d.ts +51 -0
  62. package/gauge/gauge.types.d.ts.map +1 -0
  63. package/gauge/gauge.types.js +0 -0
  64. package/gauge/index.d.ts +6 -0
  65. package/gauge/index.d.ts.map +1 -0
  66. package/gauge/index.js +4 -0
  67. package/gauge/radial/radial.gauge.d.ts +18 -0
  68. package/gauge/radial/radial.gauge.d.ts.map +1 -0
  69. package/gauge/radial/radial.gauge.js +284 -0
  70. package/gauge/simple/simple.gauge.d.ts +28 -0
  71. package/gauge/simple/simple.gauge.d.ts.map +1 -0
  72. package/gauge/simple/simple.gauge.js +102 -0
  73. package/gauge/speedometer/speedometer.gauge.d.ts +35 -0
  74. package/gauge/speedometer/speedometer.gauge.d.ts.map +1 -0
  75. package/gauge/speedometer/speedometer.gauge.js +241 -0
  76. package/geo/geo-chart.d.ts +15 -0
  77. package/geo/geo-chart.d.ts.map +1 -0
  78. package/geo/geo-chart.js +200 -0
  79. package/geo/geo-chart.props.d.ts +96 -0
  80. package/geo/geo-chart.props.d.ts.map +1 -0
  81. package/geo/geo-chart.props.js +0 -0
  82. package/geo/index.d.ts +7 -0
  83. package/geo/index.d.ts.map +1 -0
  84. package/geo/index.js +3 -0
  85. package/geo/us-chart.d.ts +15 -0
  86. package/geo/us-chart.d.ts.map +1 -0
  87. package/geo/us-chart.js +15 -0
  88. package/geo/world-chart.d.ts +15 -0
  89. package/geo/world-chart.d.ts.map +1 -0
  90. package/geo/world-chart.js +10 -0
  91. package/index.d.ts +17 -0
  92. package/index.d.ts.map +1 -0
  93. package/index.js +15 -0
  94. package/line/index.d.ts +3 -0
  95. package/line/index.d.ts.map +1 -0
  96. package/line/index.js +1 -0
  97. package/line/line-chart.d.ts +9 -0
  98. package/line/line-chart.d.ts.map +1 -0
  99. package/line/line-chart.js +8 -0
  100. package/line/line-chart.props.d.ts +12 -0
  101. package/line/line-chart.props.d.ts.map +1 -0
  102. package/line/line-chart.props.js +0 -0
  103. package/package.json +39 -0
  104. package/pie/index.d.ts +4 -0
  105. package/pie/index.d.ts.map +1 -0
  106. package/pie/index.js +2 -0
  107. package/pie/pie-chart.d.ts +13 -0
  108. package/pie/pie-chart.d.ts.map +1 -0
  109. package/pie/pie-chart.js +222 -0
  110. package/pie/pie-chart.props.d.ts +97 -0
  111. package/pie/pie-chart.props.d.ts.map +1 -0
  112. package/pie/pie-chart.props.js +12 -0
  113. package/props/cartesian.d.ts +120 -0
  114. package/props/cartesian.d.ts.map +1 -0
  115. package/props/cartesian.js +0 -0
  116. package/props/common.d.ts +28 -0
  117. package/props/common.d.ts.map +1 -0
  118. package/props/common.js +0 -0
  119. package/radar/index.d.ts +3 -0
  120. package/radar/index.d.ts.map +1 -0
  121. package/radar/index.js +1 -0
  122. package/radar/radar-chart.d.ts +12 -0
  123. package/radar/radar-chart.d.ts.map +1 -0
  124. package/radar/radar-chart.js +197 -0
  125. package/radar/radar-chart.props.d.ts +80 -0
  126. package/radar/radar-chart.props.d.ts.map +1 -0
  127. package/radar/radar-chart.props.js +0 -0
  128. package/radial/index.d.ts +3 -0
  129. package/radial/index.d.ts.map +1 -0
  130. package/radial/index.js +1 -0
  131. package/radial/radial-chart.d.ts +12 -0
  132. package/radial/radial-chart.d.ts.map +1 -0
  133. package/radial/radial-chart.js +235 -0
  134. package/radial/radial-chart.props.d.ts +74 -0
  135. package/radial/radial-chart.props.d.ts.map +1 -0
  136. package/radial/radial-chart.props.js +0 -0
  137. package/scatter/index.d.ts +3 -0
  138. package/scatter/index.d.ts.map +1 -0
  139. package/scatter/index.js +1 -0
  140. package/scatter/scatter-chart.d.ts +13 -0
  141. package/scatter/scatter-chart.d.ts.map +1 -0
  142. package/scatter/scatter-chart.js +310 -0
  143. package/scatter/scatter-chart.props.d.ts +36 -0
  144. package/scatter/scatter-chart.props.d.ts.map +1 -0
  145. package/scatter/scatter-chart.props.js +0 -0
@@ -0,0 +1,96 @@
1
+ import type { CommonChartProps } from '../props/common';
2
+ /** Emitted when the user taps/clicks a map region. */
3
+ export interface GeoChartSelectEvent {
4
+ name: string;
5
+ value: number;
6
+ }
7
+ /**
8
+ * GeoJSON Feature Collection (map geometry).
9
+ * Used with echarts.registerMap() so region names in data match feature properties.
10
+ */
11
+ export interface GeoJSONMap {
12
+ type: 'FeatureCollection';
13
+ features: Array<{
14
+ type: string;
15
+ geometry: {
16
+ type: string;
17
+ coordinates: unknown;
18
+ };
19
+ properties?: Record<string, unknown>;
20
+ }>;
21
+ crs?: unknown;
22
+ }
23
+ /**
24
+ * Single region data item: region name (must match map feature name) and value for color scale.
25
+ */
26
+ export interface GeoDataItem {
27
+ /** Region name; must match the name in the map GeoJSON (e.g. "United States", "China"). */
28
+ name: string;
29
+ /** Numeric value used for visual encoding (e.g. color scale). */
30
+ value: number;
31
+ }
32
+ /**
33
+ * Props for GeoChart.
34
+ * Extends common chart props (width, height, theme, colors).
35
+ */
36
+ export interface GeoChartProps extends CommonChartProps {
37
+ /**
38
+ * Chart data: array of { name, value } for each region.
39
+ * Region names must match the map GeoJSON feature names.
40
+ */
41
+ data: GeoDataItem[];
42
+ /**
43
+ * GeoJSON map to display. Pass the FeatureCollection; it will be registered with mapName.
44
+ */
45
+ mapJson?: GeoJSONMap;
46
+ /**
47
+ * Name used when registering the map. Use the same value in the chart option.
48
+ * @default 'world'
49
+ */
50
+ mapName?: string;
51
+ /**
52
+ * Whether to show the legend for the color scale (visual map).
53
+ * @default true
54
+ */
55
+ showLegend?: boolean;
56
+ /**
57
+ * Whether to emphasize (highlight) the hovered region.
58
+ * @default true
59
+ */
60
+ showHighlighter?: boolean;
61
+ /**
62
+ * Formatter for tooltip. (params) => string. Params include name, value.
63
+ */
64
+ tooltipFormatter?: (params: {
65
+ name: string;
66
+ value: number;
67
+ }) => string;
68
+ /**
69
+ * Minimum value for the visual map scale. Auto-derived from data if not set.
70
+ */
71
+ visualMapMin?: number;
72
+ /**
73
+ * Maximum value for the visual map scale. Auto-derived from data if not set.
74
+ */
75
+ visualMapMax?: number;
76
+ /**
77
+ * Visual map mode: 'continuous' (gradient) or 'piecewise' (distinct bands, e.g. Democrat / Competitive / Republican).
78
+ * @default 'continuous'
79
+ */
80
+ visualMapMode?: 'continuous' | 'piecewise';
81
+ /**
82
+ * When visualMapMode is 'piecewise', define bands: [{ min, max, label, color }].
83
+ * Example: [{ min: 0, max: 45, label: 'Democrat', color: '#3b82f6' }, { min: 45, max: 55, label: 'Competitive', color: '#94a3b8' }, { min: 55, max: 100, label: 'Republican', color: '#dc2626' }].
84
+ */
85
+ piecewisePieces?: Array<{
86
+ min: number;
87
+ max: number;
88
+ label: string;
89
+ color: string;
90
+ }>;
91
+ /**
92
+ * Called when the user selects (taps/clicks) a region on the map.
93
+ */
94
+ onSelect?: (event: GeoChartSelectEvent) => void;
95
+ }
96
+ //# sourceMappingURL=geo-chart.props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/geo-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,sDAAsD;AACtD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,OAAO,CAAA;SAAE,CAAC;QACjD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACtC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2FAA2F;IAC3F,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD;;;OAGG;IACH,IAAI,EAAE,WAAW,EAAE,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;IACvE;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;IAC3C;;;OAGG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpF;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACjD"}
File without changes
package/geo/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { GeoChart, GeoMapJsonContext } from './geo-chart';
2
+ export { USChart } from './us-chart';
3
+ export { WorldChart } from './world-chart';
4
+ export type { GeoChartProps, GeoChartSelectEvent, GeoDataItem, GeoJSONMap, } from './geo-chart.props';
5
+ export type { USChartProps } from './us-chart';
6
+ export type { WorldChartProps } from './world-chart';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
package/geo/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { GeoChart, GeoMapJsonContext } from './geo-chart';
2
+ export { USChart } from './us-chart';
3
+ export { WorldChart } from './world-chart';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { GeoChartProps } from './geo-chart.props';
3
+ export type USChartProps = Omit<GeoChartProps, 'mapJson' | 'mapName'> & {
4
+ /** @default 'usa' */
5
+ mapName?: string;
6
+ };
7
+ /**
8
+ * Wrapper around GeoChart with the US states map pre-loaded.
9
+ * Pass data with state names matching us-states.json (e.g. "Alabama", "California").
10
+ */
11
+ export declare function USChart(props: USChartProps): React.JSX.Element;
12
+ export declare namespace USChart {
13
+ var displayName: string;
14
+ }
15
+ //# sourceMappingURL=us-chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"us-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/us-chart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,mBAAmB,CAAC;AAKnE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG;IACtE,qBAAqB;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,qBAM1C;yBANe,OAAO"}
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import usStatesRaw from '../../../data/us-states.json';
3
+ import { GeoChart, GeoMapJsonContext } from './geo-chart';
4
+ /** US states GeoJSON — bundled once for USChart (static import avoids top-level await in Vite builds). */
5
+ const usStatesMapJson = usStatesRaw;
6
+ /**
7
+ * Wrapper around GeoChart with the US states map pre-loaded.
8
+ * Pass data with state names matching us-states.json (e.g. "Alabama", "California").
9
+ */
10
+ export function USChart(props) {
11
+ return (<GeoMapJsonContext.Provider value={usStatesMapJson}>
12
+ <GeoChart mapName='usa' {...props}/>
13
+ </GeoMapJsonContext.Provider>);
14
+ }
15
+ USChart.displayName = 'USChart';
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { GeoChartProps } from './geo-chart.props';
3
+ export type WorldChartProps = Omit<GeoChartProps, 'mapJson'> & {
4
+ /** @default 'world' */
5
+ mapName?: string;
6
+ };
7
+ /**
8
+ * Wrapper around GeoChart with the world map pre-loaded (uses default in GeoChart).
9
+ * Pass data with country/region names matching world.json (e.g. "United States", "China").
10
+ */
11
+ export declare function WorldChart({ mapName, ...props }: WorldChartProps): React.JSX.Element;
12
+ export declare namespace WorldChart {
13
+ var displayName: string;
14
+ }
15
+ //# sourceMappingURL=world-chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/geo/world-chart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,GAAG;IAC7D,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAiB,EAAE,GAAG,KAAK,EAAE,EAAE,eAAe,qBAE1E;yBAFe,UAAU"}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { GeoChart } from './geo-chart';
3
+ /**
4
+ * Wrapper around GeoChart with the world map pre-loaded (uses default in GeoChart).
5
+ * Pass data with country/region names matching world.json (e.g. "United States", "China").
6
+ */
7
+ export function WorldChart({ mapName = 'world', ...props }) {
8
+ return <GeoChart mapName={mapName} {...props}/>;
9
+ }
10
+ WorldChart.displayName = 'WorldChart';
package/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ export type { CartesianChartSelectEvent } from './props/cartesian';
2
+ export * from './area';
3
+ export * from './bar';
4
+ export * from './column';
5
+ export * from './line';
6
+ export * from './pie';
7
+ export * from './scatter';
8
+ export * from './radar';
9
+ export * from './radial';
10
+ export * from './gauge';
11
+ export * from './geo';
12
+ export * from './bubble';
13
+ export * from './candlestick';
14
+ export * from './axis';
15
+ export * from './chart-theme.context';
16
+ export * from './chart-container';
17
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../components/chart/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
package/index.js ADDED
@@ -0,0 +1,15 @@
1
+ export * from './area';
2
+ export * from './bar';
3
+ export * from './column';
4
+ export * from './line';
5
+ export * from './pie';
6
+ export * from './scatter';
7
+ export * from './radar';
8
+ export * from './radial';
9
+ export * from './gauge';
10
+ export * from './geo';
11
+ export * from './bubble';
12
+ export * from './candlestick';
13
+ export * from './axis';
14
+ export * from './chart-theme.context';
15
+ export * from './chart-container';
@@ -0,0 +1,3 @@
1
+ export { LineChart } from './line-chart';
2
+ export type { LineChartProps } from './line-chart.props';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
package/line/index.js ADDED
@@ -0,0 +1 @@
1
+ export { LineChart } from './line-chart';
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { LineChartProps } from './line-chart.props';
3
+ /** common -> cartesian -> area -> line */
4
+ export type { LineChartProps } from './line-chart.props';
5
+ declare function LineChartComponent(props: LineChartProps): React.JSX.Element;
6
+ export declare const LineChart: typeof LineChartComponent & {
7
+ displayName: string;
8
+ };
9
+ //# sourceMappingURL=line-chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/line-chart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,0CAA0C;AAC1C,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,iBAAS,kBAAkB,CAAC,KAAK,EAAE,cAAc,qBAEhD;AAED,eAAO,MAAM,SAAS;;CAEpB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { AreaChart } from '../area/area-chart';
3
+ function LineChartComponent(props) {
4
+ return <AreaChart {...props} areaOpacity={0} areaFill="transparent"/>;
5
+ }
6
+ export const LineChart = Object.assign(LineChartComponent, {
7
+ displayName: 'LineChart',
8
+ });
@@ -0,0 +1,12 @@
1
+ import type { AreaChartProps } from '../area/area-chart.props';
2
+ import type { CartesianChartSelectEvent } from '../props/cartesian';
3
+ /**
4
+ * Props for LineChart.
5
+ * Line chart is AreaChart with no fill (areaOpacity=0, areaFill='transparent').
6
+ * Inherits Cartesian chart props (axes, grid, legend, {@link CartesianChartProps#onSelect | onSelect}, …).
7
+ * common -> cartesian -> area -> line
8
+ */
9
+ export type LineChartProps = Omit<AreaChartProps, 'areaOpacity' | 'areaFill'>;
10
+ /** Selection payload for {@link LineChartProps} / `onSelect` (same as {@link CartesianChartSelectEvent}). */
11
+ export type LineChartSelectEvent = CartesianChartSelectEvent;
12
+ //# sourceMappingURL=line-chart.props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-chart.props.d.ts","sourceRoot":"","sources":["../../../../components/chart/line/line-chart.props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,aAAa,GAAG,UAAU,CAAC,CAAC;AAE9E,6GAA6G;AAC7G,MAAM,MAAM,oBAAoB,GAAG,yBAAyB,CAAC"}
File without changes
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@wavemaker/react-native-echarts",
3
+ "version": "1.0.0-dev.0",
4
+ "description": "React Native chart components built on using e-charts library.",
5
+ "license": "MIT",
6
+ "repository": {},
7
+ "keywords": [
8
+ "react-native",
9
+ "echarts",
10
+ "widgets",
11
+ "charting",
12
+ "charts",
13
+ "charts",
14
+ "gauges",
15
+ "geo",
16
+ "maps",
17
+ "visualization",
18
+ "data-visualization",
19
+ "data-analysis",
20
+ "data-visualization",
21
+ "data-analysis"
22
+ ],
23
+ "main": "index.js",
24
+ "types": "index.d.ts",
25
+ "files": [
26
+ "*"
27
+ ],
28
+ "peerDependencies": {
29
+ "react": "*",
30
+ "react-native": "*",
31
+ "@shopify/react-native-skia": "*",
32
+ "@wuba/react-native-echarts": "*",
33
+ "echarts": "*",
34
+ "zrender": "*",
35
+ "react-native-svg": "*"
36
+ },
37
+ "dependencies": {},
38
+ "private": false
39
+ }
package/pie/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { PieChart } from './pie-chart';
2
+ export { isConcentricPieData } from './pie-chart.props';
3
+ export type { PieChartProps, PieChartData, PieChartSelectEvent, PieDataItem, PieRingData, } from './pie-chart.props';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../components/chart/pie/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EACV,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,WAAW,GACZ,MAAM,mBAAmB,CAAC"}
package/pie/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { PieChart } from './pie-chart';
2
+ export { isConcentricPieData } from './pie-chart.props';
@@ -0,0 +1,13 @@
1
+ import type { PieChartProps } from './pie-chart.props';
2
+ import React from 'react';
3
+ export type { PieChartProps, PieChartSelectEvent, PieDataItem, PieRingData, PieChartData, } from './pie-chart.props';
4
+ export { isConcentricPieData } from './pie-chart.props';
5
+ export declare const PieChart: ((props: PieChartProps & {
6
+ theme?: Partial<import("..").ChartTheme>;
7
+ } & {
8
+ width?: number | string;
9
+ height?: number | string;
10
+ }) => React.JSX.Element) & {
11
+ displayName: string;
12
+ };
13
+ //# sourceMappingURL=pie-chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pie-chart.d.ts","sourceRoot":"","sources":["../../../../components/chart/pie/pie-chart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EAId,MAAM,mBAAmB,CAAC;AAS3B,OAAO,KAAqC,MAAM,OAAO,CAAC;AAG1D,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAmQxD,eAAO,MAAM,QAAQ;;;;;;;CAEnB,CAAC"}
@@ -0,0 +1,222 @@
1
+ import { withResponsiveContainer } from '../chart-container';
2
+ import { useChartTheme, withChartTheme } from '../chart-theme.context';
3
+ import { isConcentricPieData } from './pie-chart.props';
4
+ import { SkiaChart, SkiaRenderer } from '@wuba/react-native-echarts';
5
+ import { PieChart as EChartsPieChart } from 'echarts/charts';
6
+ import { LegendComponent, TooltipComponent, } from 'echarts/components';
7
+ import * as echarts from 'echarts/core';
8
+ import React, { useEffect, useMemo, useRef } from 'react';
9
+ export { isConcentricPieData } from './pie-chart.props';
10
+ echarts.use([
11
+ TooltipComponent,
12
+ LegendComponent,
13
+ SkiaRenderer,
14
+ EChartsPieChart,
15
+ ]);
16
+ const ChartComponent = ({ data, width = 220, height = 350, radius = '75%', showLegend = false, showLabel = true, labelPosition = 'outside', showLabelLine = true, showHighlighter = true, tooltipFormatter, onSelect, ...props }) => {
17
+ const { theme } = useChartTheme(props.theme, props.colors);
18
+ const chartRef = useRef(null);
19
+ const onSelectRef = useRef(onSelect);
20
+ onSelectRef.current = onSelect;
21
+ const option = useMemo(() => {
22
+ if (!Array.isArray(data) || data.length === 0) {
23
+ return { series: [] };
24
+ }
25
+ const seriesColors = theme.series.map(s => s.color);
26
+ const labelStyle = {
27
+ color: theme.legend.textColor,
28
+ fontSize: theme.legend.fontSize,
29
+ };
30
+ const buildSeriesConfig = (pieData, seriesRadius, ringName) => {
31
+ const total = pieData.reduce((sum, d) => sum + d.value, 0);
32
+ const labelConfig = showLabel
33
+ ? {
34
+ show: true,
35
+ position: labelPosition,
36
+ formatter: (params) => {
37
+ const pct = total > 0 ? ((params.value / total) * 100).toFixed(1) : '0';
38
+ return `${params.name}\n${pct}%`;
39
+ },
40
+ ...labelStyle,
41
+ }
42
+ : { show: false };
43
+ return {
44
+ type: 'pie',
45
+ name: ringName,
46
+ radius: Array.isArray(seriesRadius) ? seriesRadius : seriesRadius,
47
+ data: pieData,
48
+ label: labelConfig,
49
+ labelLine: {
50
+ show: showLabel && (labelPosition === 'outside' ? showLabelLine : false),
51
+ lineStyle: { color: theme.legend.textColor },
52
+ },
53
+ emphasis: showHighlighter
54
+ ? {
55
+ scale: true,
56
+ scaleSize: 5,
57
+ itemStyle: {
58
+ shadowBlur: 10,
59
+ shadowOffsetX: 0,
60
+ shadowColor: 'rgba(0, 0, 0, 0.2)',
61
+ },
62
+ }
63
+ : { disabled: true },
64
+ };
65
+ };
66
+ if (isConcentricPieData(data)) {
67
+ const rings = data;
68
+ let colorIndex = 0;
69
+ const seriesConfigs = rings.map((ring) => {
70
+ const pieData = ring.data.map((item) => ({
71
+ name: item.name,
72
+ value: item.value,
73
+ itemStyle: item.itemStyle?.color
74
+ ? { color: item.itemStyle.color }
75
+ : { color: seriesColors[colorIndex++ % seriesColors.length] },
76
+ }));
77
+ return buildSeriesConfig(pieData, ring.radius, ring.name);
78
+ });
79
+ const legendData = showLegend
80
+ ? Array.from(new Set(rings.flatMap((r) => r.data.map((d) => d.name))))
81
+ : undefined;
82
+ const tooltipConfig = {
83
+ trigger: 'item',
84
+ backgroundColor: theme.tooltip.backgroundColor,
85
+ borderColor: theme.tooltip.borderColor,
86
+ borderWidth: theme.tooltip.borderWidth,
87
+ borderRadius: theme.tooltip.borderRadius,
88
+ padding: theme.tooltip.padding,
89
+ textStyle: { color: theme.tooltip.valueColor },
90
+ formatter: tooltipFormatter
91
+ ? (params) => tooltipFormatter({
92
+ name: params.name,
93
+ value: params.value,
94
+ percent: params.percent,
95
+ })
96
+ : undefined,
97
+ };
98
+ const config = {
99
+ tooltip: tooltipConfig,
100
+ series: seriesConfigs,
101
+ };
102
+ if (legendData?.length) {
103
+ config.legend = {
104
+ orient: 'horizontal',
105
+ left: 'center',
106
+ bottom: 0,
107
+ data: legendData,
108
+ textStyle: labelStyle,
109
+ backgroundColor: theme.legend.backgroundColor,
110
+ };
111
+ }
112
+ return config;
113
+ }
114
+ const flatData = data;
115
+ const pieData = flatData.map((item, index) => ({
116
+ name: item.name,
117
+ value: item.value,
118
+ itemStyle: item.itemStyle?.color
119
+ ? { color: item.itemStyle.color }
120
+ : { color: seriesColors[index % seriesColors.length] },
121
+ }));
122
+ const seriesConfig = buildSeriesConfig(pieData, radius);
123
+ const tooltipConfig = {
124
+ trigger: 'item',
125
+ backgroundColor: theme.tooltip.backgroundColor,
126
+ borderColor: theme.tooltip.borderColor,
127
+ borderWidth: theme.tooltip.borderWidth,
128
+ borderRadius: theme.tooltip.borderRadius,
129
+ padding: theme.tooltip.padding,
130
+ textStyle: { color: theme.tooltip.valueColor },
131
+ formatter: tooltipFormatter
132
+ ? (params) => tooltipFormatter({
133
+ name: params.name,
134
+ value: params.value,
135
+ percent: params.percent,
136
+ })
137
+ : undefined,
138
+ };
139
+ const legendConfig = showLegend
140
+ ? {
141
+ orient: 'horizontal',
142
+ left: 'center',
143
+ bottom: 0,
144
+ data: pieData.map((d) => d.name),
145
+ textStyle: labelStyle,
146
+ backgroundColor: theme.legend.backgroundColor,
147
+ }
148
+ : undefined;
149
+ const config = {
150
+ tooltip: tooltipConfig,
151
+ series: [seriesConfig],
152
+ };
153
+ if (legendConfig) {
154
+ config.legend = legendConfig;
155
+ }
156
+ return config;
157
+ }, [
158
+ data,
159
+ radius,
160
+ showLegend,
161
+ showLabel,
162
+ labelPosition,
163
+ showLabelLine,
164
+ showHighlighter,
165
+ tooltipFormatter,
166
+ theme,
167
+ ]);
168
+ useEffect(() => {
169
+ let chart;
170
+ if (chartRef.current) {
171
+ try {
172
+ chart = echarts.init(chartRef.current, 'light', {
173
+ width,
174
+ height,
175
+ });
176
+ chart.setOption(option);
177
+ const handlePieClick = (params) => {
178
+ const cb = onSelectRef.current;
179
+ if (typeof cb !== 'function')
180
+ return;
181
+ if (params.componentType !== 'series')
182
+ return;
183
+ if (params.seriesType !== 'pie')
184
+ return;
185
+ if (typeof params.dataIndex !== 'number' ||
186
+ params.dataIndex < 0 ||
187
+ params.name == null) {
188
+ return;
189
+ }
190
+ const event = {
191
+ seriesIndex: params.seriesIndex ?? 0,
192
+ dataIndex: params.dataIndex,
193
+ name: String(params.name),
194
+ value: Number(params.value ?? 0),
195
+ seriesName: params.seriesName,
196
+ percent: params.percent,
197
+ };
198
+ cb(event);
199
+ };
200
+ chart.on('click', handlePieClick);
201
+ }
202
+ catch (error) {
203
+ console.warn('Pie chart initialization error:', error);
204
+ }
205
+ }
206
+ return () => {
207
+ if (chart) {
208
+ try {
209
+ chart.dispose();
210
+ }
211
+ catch (error) {
212
+ console.warn('Pie chart disposal error:', error);
213
+ }
214
+ }
215
+ };
216
+ }, [option, width, height]);
217
+ return <SkiaChart ref={chartRef} useRNGH/>;
218
+ };
219
+ const PieChartComponent = withResponsiveContainer(withChartTheme(ChartComponent), 'data');
220
+ export const PieChart = Object.assign(PieChartComponent, {
221
+ displayName: 'PieChart',
222
+ });