@agions/taroviz 1.1.1 → 1.2.1

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 (81) hide show
  1. package/README.md +324 -53
  2. package/dist/cjs/index.js +1 -0
  3. package/dist/esm/index.js +82979 -0
  4. package/package.json +160 -30
  5. package/src/__tests__/integration.test.tsx +168 -0
  6. package/src/adapters/__tests__/index.test.ts +91 -0
  7. package/src/adapters/h5/__tests__/index.test.ts +156 -0
  8. package/src/adapters/h5/index.ts +301 -0
  9. package/src/adapters/harmony/index.ts +274 -0
  10. package/src/adapters/index.ts +166 -0
  11. package/src/adapters/swan/index.ts +274 -0
  12. package/src/adapters/tt/index.ts +274 -0
  13. package/src/adapters/types.ts +162 -0
  14. package/src/adapters/weapp/index.ts +237 -0
  15. package/src/charts/bar/__tests__/index.test.tsx +113 -0
  16. package/src/charts/bar/index.tsx +18 -0
  17. package/src/charts/common/BaseChartWrapper.tsx +136 -0
  18. package/src/charts/funnel/index.tsx +18 -0
  19. package/src/charts/gauge/index.tsx +18 -0
  20. package/src/charts/heatmap/index.tsx +18 -0
  21. package/src/charts/index.ts +21 -0
  22. package/src/charts/line/__tests__/index.test.tsx +107 -0
  23. package/src/charts/line/index.tsx +18 -0
  24. package/src/charts/pie/__tests__/index.test.tsx +112 -0
  25. package/src/charts/pie/index.tsx +19 -0
  26. package/src/charts/radar/index.tsx +18 -0
  27. package/src/charts/scatter/index.tsx +18 -0
  28. package/src/charts/types.ts +619 -0
  29. package/src/charts/utils.ts +56 -0
  30. package/src/core/__tests__/platform.test.ts +48 -0
  31. package/src/core/animation/AnimationManager.ts +391 -0
  32. package/src/core/animation/index.ts +20 -0
  33. package/src/core/animation/types.ts +248 -0
  34. package/src/core/components/BaseChart.tsx +1313 -0
  35. package/src/core/components/ErrorBoundary.tsx +458 -0
  36. package/src/core/echarts.ts +58 -0
  37. package/src/core/index.ts +22 -0
  38. package/src/core/types/chart.ts +66 -0
  39. package/src/core/types/common.ts +224 -0
  40. package/src/core/types/index.ts +281 -0
  41. package/src/core/types/platform.ts +325 -0
  42. package/src/core/utils/__tests__/common.test.ts +52 -0
  43. package/src/core/utils/__tests__/environment.test.ts +94 -0
  44. package/src/core/utils/__tests__/i18n.test.ts +247 -0
  45. package/src/core/utils/__tests__/index.test.ts +219 -0
  46. package/src/core/utils/__tests__/uuid.test.ts +78 -0
  47. package/src/core/utils/chartInstances.ts +69 -0
  48. package/src/core/utils/codeGenerator/CodeGenerator.ts +655 -0
  49. package/src/core/utils/codeGenerator/index.ts +13 -0
  50. package/src/core/utils/codeGenerator/types.ts +198 -0
  51. package/src/core/utils/common.ts +58 -0
  52. package/src/core/utils/configGenerator/ConfigGenerator.ts +583 -0
  53. package/src/core/utils/configGenerator/index.ts +13 -0
  54. package/src/core/utils/configGenerator/types.ts +445 -0
  55. package/src/core/utils/debug/DebugPanel.tsx +637 -0
  56. package/src/core/utils/debug/debugger.ts +322 -0
  57. package/src/core/utils/debug/index.ts +21 -0
  58. package/src/core/utils/debug/types.ts +142 -0
  59. package/src/core/utils/i18n.ts +452 -0
  60. package/src/core/utils/index.ts +162 -0
  61. package/src/core/utils/performance/PerformanceAnalyzer.ts +586 -0
  62. package/src/core/utils/performance/index.ts +13 -0
  63. package/src/core/utils/performance/types.ts +180 -0
  64. package/src/core/utils/uuid.ts +30 -0
  65. package/src/editor/ThemeEditor.tsx +449 -0
  66. package/src/editor/index.ts +10 -0
  67. package/src/hooks/__tests__/index.test.tsx +333 -0
  68. package/src/hooks/index.ts +594 -0
  69. package/src/index.ts +75 -0
  70. package/src/main.tsx +247 -0
  71. package/src/react-dom.d.ts +7 -0
  72. package/src/themes/__tests__/index.test.ts +91 -0
  73. package/src/themes/index.ts +860 -0
  74. package/dist/389.index.esm.js +0 -1
  75. package/dist/389.index.js +0 -1
  76. package/dist/633.index.esm.js +0 -1
  77. package/dist/633.index.js +0 -1
  78. package/dist/967.index.esm.js +0 -1
  79. package/dist/967.index.js +0 -1
  80. package/dist/index.esm.js +0 -1
  81. package/dist/index.js +0 -1
@@ -0,0 +1,224 @@
1
+ /**
2
+ * ECharts 类型定义
3
+ */
4
+ export type EChartsOption = any;
5
+
6
+ /**
7
+ * 图表事件监听器
8
+ */
9
+ export type ChartEventListener = Record<string, (params: any) => void>;
10
+
11
+ /**
12
+ * 图表渲染器类型
13
+ */
14
+ export type ChartRenderer = 'canvas' | 'svg';
15
+
16
+ /**
17
+ * DataURL选项
18
+ */
19
+ export interface DataURLOption {
20
+ /**
21
+ * 导出的图片类型
22
+ */
23
+ type?: 'png' | 'jpeg';
24
+
25
+ /**
26
+ * 设备像素比
27
+ */
28
+ pixelRatio?: number;
29
+
30
+ /**
31
+ * 背景色
32
+ */
33
+ backgroundColor?: string;
34
+
35
+ /**
36
+ * 排除的组件列表
37
+ */
38
+ excludeComponents?: string[];
39
+ }
40
+
41
+ /**
42
+ * 图表尺寸类型
43
+ */
44
+ export interface ChartSize {
45
+ /**
46
+ * 宽度
47
+ */
48
+ width?: number | string;
49
+
50
+ /**
51
+ * 高度
52
+ */
53
+ height?: number | string;
54
+ }
55
+
56
+ /**
57
+ * 图表动画设置
58
+ */
59
+ export interface ChartAnimation {
60
+ /**
61
+ * 是否启用动画
62
+ */
63
+ enabled?: boolean;
64
+
65
+ /**
66
+ * 动画时长
67
+ */
68
+ duration?: number;
69
+
70
+ /**
71
+ * 动画缓动效果
72
+ */
73
+ easing?: string;
74
+
75
+ /**
76
+ * 初始动画时长
77
+ */
78
+ animationDuration?: number;
79
+
80
+ /**
81
+ * 更新动画时长
82
+ */
83
+ animationDurationUpdate?: number;
84
+ }
85
+
86
+ /**
87
+ * 图表主题设置
88
+ */
89
+ export interface ChartTheme {
90
+ /**
91
+ * 主题名称或配置
92
+ */
93
+ theme?: string | object;
94
+
95
+ /**
96
+ * 背景色
97
+ */
98
+ backgroundColor?: string;
99
+
100
+ /**
101
+ * 文本颜色
102
+ */
103
+ textColor?: string;
104
+
105
+ /**
106
+ * 轴线颜色
107
+ */
108
+ axisLineColor?: string;
109
+
110
+ /**
111
+ * 分割线颜色
112
+ */
113
+ splitLineColor?: string;
114
+ }
115
+
116
+ /**
117
+ * 图表加载状态配置
118
+ */
119
+ export interface ChartLoadingOptions {
120
+ /**
121
+ * 加载提示文本
122
+ */
123
+ text?: string;
124
+
125
+ /**
126
+ * 加载动画颜色
127
+ */
128
+ color?: string;
129
+
130
+ /**
131
+ * 文本颜色
132
+ */
133
+ textColor?: string;
134
+
135
+ /**
136
+ * 遮罩颜色
137
+ */
138
+ maskColor?: string;
139
+
140
+ /**
141
+ * z层级
142
+ */
143
+ zlevel?: number;
144
+
145
+ /**
146
+ * 字体大小
147
+ */
148
+ fontSize?: number;
149
+
150
+ /**
151
+ * 是否显示旋转器
152
+ */
153
+ showSpinner?: boolean;
154
+
155
+ /**
156
+ * 旋转器半径
157
+ */
158
+ spinnerRadius?: number;
159
+
160
+ /**
161
+ * 线宽
162
+ */
163
+ lineWidth?: number;
164
+
165
+ /**
166
+ * 字体粗细
167
+ */
168
+ fontWeight?: number | string;
169
+
170
+ /**
171
+ * 字体样式
172
+ */
173
+ fontStyle?: string;
174
+
175
+ /**
176
+ * 字体族
177
+ */
178
+ fontFamily?: string;
179
+ }
180
+
181
+ /**
182
+ * 图表事件声明
183
+ */
184
+ export enum ChartEventType {
185
+ CLICK = 'click',
186
+ MOUSEMOVE = 'mousemove',
187
+ MOUSEUP = 'mouseup',
188
+ MOUSEDOWN = 'mousedown',
189
+ MOUSEOVER = 'mouseover',
190
+ MOUSEOUT = 'mouseout',
191
+ GLOBALOUT = 'globalout',
192
+ LEGENDSELECTED = 'legendselected',
193
+ LEGENDUNSELECTED = 'legendunselected',
194
+ LEGENDSELECTCHANGED = 'legendselectchanged',
195
+ LEGENDSCROLL = 'legendscroll',
196
+ DATAZOOM = 'datazoom',
197
+ DATARANGESELECTED = 'datarangeselected',
198
+ TIMELINECHANGED = 'timelinechanged',
199
+ TIMELINEPLAYCHANGED = 'timelineplaychanged',
200
+ RESTORE = 'restore',
201
+ DATAVIEWCHANGED = 'dataviewchanged',
202
+ MAGICTYPECHANGED = 'magictypechanged',
203
+ GEOSELECTCHANGED = 'geoselectchanged',
204
+ GEOSELECTED = 'geoselected',
205
+ GEOUNSELECTED = 'geounselected',
206
+ PIESELECTCHANGED = 'pieselectchanged',
207
+ PIESELECTED = 'pieselected',
208
+ PIEUNSELECTED = 'pieunselected',
209
+ MAPSELECTCHANGED = 'mapselectchanged',
210
+ MAPSELECTED = 'mapselected',
211
+ MAPUNSELECTED = 'mapunselected',
212
+ AXISAREASELECTED = 'axisareaselected',
213
+ FOCUSNODEADJACENCY = 'focusnodeadjacency',
214
+ UNFOCUSNODEADJACENCY = 'unfocusnodeadjacency',
215
+ BRUSH = 'brush',
216
+ BRUSHSELECTED = 'brushselected',
217
+ RENDERED = 'rendered',
218
+ FINISHED = 'finished',
219
+ // 自定义事件
220
+ CHART_READY = 'chartReady',
221
+ CHART_RESIZE = 'chartResize',
222
+ CHART_ERROR = 'chartError',
223
+ CHART_DISPOSE = 'chartDispose',
224
+ }
@@ -0,0 +1,281 @@
1
+ // 公共类型
2
+ export * from './common';
3
+
4
+ // 平台类型
5
+ export * from './platform';
6
+
7
+ export * from './chart';
8
+
9
+ // ECharts相关类型
10
+ import type { EChartsType } from 'echarts';
11
+
12
+ import { ChartOptions } from './chart';
13
+
14
+ /**
15
+ * TaroViz核心类型定义
16
+ */
17
+
18
+ /**
19
+ * ECharts类型定义
20
+ */
21
+ export { EChartsType };
22
+
23
+ // 导出动画相关类型
24
+ export * from '../animation';
25
+
26
+ /**
27
+ * ECharts选项类型定义
28
+ */
29
+ export type EChartsOption = ChartOptions;
30
+
31
+ /**
32
+ * 动画缓动函数类型
33
+ */
34
+ export type AnimationEasing =
35
+ | 'linear'
36
+ | 'quadraticIn'
37
+ | 'quadraticOut'
38
+ | 'quadraticInOut'
39
+ | 'cubicIn'
40
+ | 'cubicOut'
41
+ | 'cubicInOut'
42
+ | 'quarticIn'
43
+ | 'quarticOut'
44
+ | 'quarticInOut'
45
+ | 'quinticIn'
46
+ | 'quinticOut'
47
+ | 'quinticInOut'
48
+ | 'sinusoidalIn'
49
+ | 'sinusoidalOut'
50
+ | 'sinusoidalInOut'
51
+ | 'exponentialIn'
52
+ | 'exponentialOut'
53
+ | 'exponentialInOut'
54
+ | 'circularIn'
55
+ | 'circularOut'
56
+ | 'circularInOut'
57
+ | 'elasticIn'
58
+ | 'elasticOut'
59
+ | 'elasticInOut'
60
+ | 'backIn'
61
+ | 'backOut'
62
+ | 'backInOut'
63
+ | 'bounceIn'
64
+ | 'bounceOut'
65
+ | 'bounceInOut';
66
+
67
+ /**
68
+ * 渲染器类型
69
+ */
70
+ export type RendererType = 'canvas' | 'svg';
71
+
72
+ /**
73
+ * 图表事件回调类型
74
+ */
75
+ export type ChartEventCallback = (params: any) => void;
76
+
77
+ /**
78
+ * 图表事件处理器映射
79
+ */
80
+ export interface ChartEventHandlers {
81
+ [key: string]: ChartEventCallback;
82
+ }
83
+
84
+ /**
85
+ * 主题类型
86
+ */
87
+ export interface ThemeType {
88
+ color?: string[];
89
+ backgroundColor?: string;
90
+ textStyle?: {
91
+ color?: string;
92
+ fontFamily?: string;
93
+ fontSize?: number;
94
+ };
95
+ title?: {
96
+ textStyle?: {
97
+ color?: string;
98
+ fontFamily?: string;
99
+ fontSize?: number;
100
+ fontWeight?: string | number;
101
+ };
102
+ subtextStyle?: {
103
+ color?: string;
104
+ fontFamily?: string;
105
+ fontSize?: number;
106
+ fontWeight?: string | number;
107
+ };
108
+ };
109
+ legend?: {
110
+ textStyle?: {
111
+ color?: string;
112
+ fontFamily?: string;
113
+ fontSize?: number;
114
+ };
115
+ };
116
+ tooltip?: {
117
+ backgroundColor?: string;
118
+ borderColor?: string;
119
+ textStyle?: {
120
+ color?: string;
121
+ fontFamily?: string;
122
+ fontSize?: number;
123
+ };
124
+ };
125
+ [key: string]: any;
126
+ }
127
+
128
+ /**
129
+ * 渲染性能优化配置
130
+ */
131
+ export interface RenderOptimizationConfig {
132
+ /**
133
+ * 是否开启渐进式渲染
134
+ */
135
+ progressive?: boolean;
136
+
137
+ /**
138
+ * 渐进式渲染的阈值
139
+ */
140
+ progressiveThreshold?: number;
141
+
142
+ /**
143
+ * 是否启用懒更新
144
+ */
145
+ lazyUpdate?: boolean;
146
+
147
+ /**
148
+ * 是否启用动画
149
+ */
150
+ animation?: boolean;
151
+
152
+ /**
153
+ * 是否启用硬件加速
154
+ */
155
+ hardwareAcceleration?: boolean;
156
+
157
+ /**
158
+ * 帧率限制
159
+ */
160
+ frameRate?: number;
161
+ }
162
+
163
+ /**
164
+ * 适配器接口定义
165
+ */
166
+ export interface Adapter {
167
+ /**
168
+ * 初始化图表
169
+ */
170
+ init(options?: any): EChartsType;
171
+
172
+ /**
173
+ * 设置图表配置
174
+ */
175
+ setOption(option: any, notMerge?: boolean): void;
176
+
177
+ /**
178
+ * 获取图表实例
179
+ */
180
+ getInstance(): EChartsType | null;
181
+
182
+ /**
183
+ * 设置组件实例
184
+ */
185
+ setComponent?(component: any): void;
186
+
187
+ /**
188
+ * 绑定事件
189
+ */
190
+ on(eventName: string, handler: (params: any) => void): void;
191
+
192
+ /**
193
+ * 解绑事件
194
+ */
195
+ off(eventName: string, handler?: (params: any) => void): void;
196
+
197
+ /**
198
+ * 调整图表大小
199
+ */
200
+ resize(): void;
201
+
202
+ /**
203
+ * 显示加载中
204
+ */
205
+ showLoading(options?: any): void;
206
+
207
+ /**
208
+ * 隐藏加载中
209
+ */
210
+ hideLoading(): void;
211
+
212
+ /**
213
+ * 清空图表
214
+ */
215
+ clear(): void;
216
+
217
+ /**
218
+ * 销毁图表
219
+ */
220
+ dispose(): void;
221
+
222
+ /**
223
+ * 获取DataURL
224
+ */
225
+ getDataURL?(opts?: any): string | undefined;
226
+
227
+ /**
228
+ * 转换为DataURL
229
+ */
230
+ convertToDataURL?(opts?: any): string | undefined;
231
+
232
+ /**
233
+ * 渲染图表
234
+ */
235
+ render(): JSX.Element;
236
+ }
237
+
238
+ /**
239
+ * 适配器配置选项
240
+ */
241
+ export interface AdapterConfig {
242
+ /**
243
+ * 平台类型
244
+ */
245
+ platformType?: string;
246
+
247
+ /**
248
+ * 目标canvas元素ID
249
+ */
250
+ canvasId?: string;
251
+
252
+ /**
253
+ * 图表主题
254
+ */
255
+ theme?: string;
256
+
257
+ /**
258
+ * 渲染器类型
259
+ */
260
+ renderer?: 'canvas' | 'svg';
261
+
262
+ /**
263
+ * 设备像素比
264
+ */
265
+ devicePixelRatio?: number;
266
+
267
+ /**
268
+ * 宽度
269
+ */
270
+ width?: number;
271
+
272
+ /**
273
+ * 高度
274
+ */
275
+ height?: number;
276
+
277
+ /**
278
+ * 额外选项
279
+ */
280
+ [key: string]: any;
281
+ }