@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
package/README.md CHANGED
@@ -1,16 +1,51 @@
1
- # @agions/taroviz
1
+ # TaroViz
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@agions/taroviz.svg)](https://www.npmjs.com/package/@agions/taroviz)
4
- [![npm downloads](https://img.shields.io/npm/dm/@agions/taroviz.svg)](https://www.npmjs.com/package/@agions/taroviz)
5
- [![GitHub](https://img.shields.io/github/license/Agions/TaroViz)](https://github.com/Agions/TaroViz/blob/main/LICENSE)
3
+ <div align="center">
4
+ <h1>TaroViz</h1>
5
+ <p>基于 Taro 和 ECharts 的多端图表组件库</p>
6
+ <p>
7
+ <a href="https://www.npmjs.com/package/@agions/taroviz">
8
+ <img src="https://img.shields.io/npm/v/@agions/taroviz.svg" alt="npm package">
9
+ </a>
10
+ <a href="https://www.npmjs.com/package/@agions/taroviz">
11
+ <img src="https://img.shields.io/npm/dm/@agions/taroviz.svg" alt="npm downloads">
12
+ </a>
13
+ <a href="https://github.com/agions/taroviz/blob/main/LICENSE">
14
+ <img src="https://img.shields.io/npm/l/@agions/taroviz.svg" alt="license">
15
+ </a>
16
+ </p>
17
+ </div>
6
18
 
7
- 基于 Taro ECharts 的多端图表组件库完整包,支持微信小程序、支付宝小程序、百度小程序、H5等多平台。
19
+ ## 📢 最新版本 v1.2.1
8
20
 
9
- ## 介绍
21
+ 我们很高兴地宣布 TaroViz v1.2.0 已正式发布!查看 [更新日志](./CHANGELOG.md) 了解详细信息。
10
22
 
11
- `@agions/taroviz` 是TaroViz组件库的主包,包含了所有子包的功能,提供完整的多端图表解决方案。如果您想使用TaroViz的全部功能,推荐直接安装此包。
23
+ ## 📚 文档
12
24
 
13
- ## 安装
25
+ - [在线文档](https://agions.github.io/TaroViz/)
26
+ - [快速开始](https://agions.github.io/TaroViz/guide/)
27
+ - [API文档](https://agions.github.io/TaroViz/api/)
28
+ - [示例](https://agions.github.io/TaroViz/examples/)
29
+ - [迁移指南](https://agions.github.io/TaroViz/migration/)
30
+
31
+ ## 特性
32
+
33
+ - 📊 **丰富的图表类型** - 支持折线图、柱状图、饼图、散点图、雷达图、热力图、仪表盘、漏斗图等多种图表类型
34
+ - 📱 **多端适配支持** - 支持微信小程序、支付宝小程序、百度小程序、字节跳动小程序、HarmonyOS 和 H5
35
+ - 🎨 **灵活的主题定制** - 内置多种主题,支持自定义主题
36
+ - 📦 **单包架构设计** - 简化依赖管理,方便使用
37
+ - 🚀 **高性能渲染** - 基于 ECharts 优化,确保流畅渲染
38
+ - ⚡ **性能分析工具** - 支持帧率监控和内存使用分析
39
+ - 🛠️ **强大的数据处理能力** - 内置数据处理工具,支持复杂数据转换
40
+ - 🎯 **易用的 React Hooks** - 提供便捷的 Hooks 简化开发
41
+ - 📖 **完善的类型定义** - 完整的 TypeScript 类型支持,提升开发体验
42
+ - 🛠️ **图表配置生成器** - 支持快速生成 ECharts 配置
43
+ - 🛠️ **代码示例生成器** - 支持 React、Vue、Vanilla 框架
44
+ - 📚 **完善的文档系统** - 包含在线示例和使用指南
45
+
46
+ ## 快速开始
47
+
48
+ ### 安装
14
49
 
15
50
  ```bash
16
51
  # npm
@@ -23,78 +58,314 @@ yarn add @agions/taroviz
23
58
  pnpm add @agions/taroviz
24
59
  ```
25
60
 
26
- ## 包依赖关系
61
+ ### 基础使用
62
+
63
+ ```typescript
64
+ import React from 'react';
65
+ import { LineChart } from '@agions/taroviz';
66
+
67
+ const App = () => {
68
+ // ECharts 配置项
69
+ const option = {
70
+ title: {
71
+ text: '折线图示例'
72
+ },
73
+ xAxis: {
74
+ type: 'category',
75
+ data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
76
+ },
77
+ yAxis: {
78
+ type: 'value'
79
+ },
80
+ series: [
81
+ {
82
+ data: [120, 200, 150, 80, 70, 110, 130],
83
+ type: 'line'
84
+ }
85
+ ]
86
+ };
87
+
88
+ return (
89
+ <LineChart
90
+ option={option}
91
+ width="100%"
92
+ height={400}
93
+ />
94
+ );
95
+ };
96
+
97
+ export default App;
98
+ ```
99
+
100
+ ## 支持的图表类型
101
+
102
+ TaroViz 支持以下图表类型:
103
+
104
+ | 图表类型 | 描述 | 组件名 |
105
+ | -------- | ---------------------------------- | -------------- |
106
+ | 折线图 | 用于展示数据随时间或类别变化的趋势 | `LineChart` |
107
+ | 柱状图 | 用于比较不同类别的数据大小 | `BarChart` |
108
+ | 饼图 | 用于展示数据占比关系 | `PieChart` |
109
+ | 散点图 | 用于展示两个变量之间的关系 | `ScatterChart` |
110
+ | 雷达图 | 用于展示多维度数据 | `RadarChart` |
111
+ | 热力图 | 用于展示数据密度和分布 | `HeatmapChart` |
112
+ | 仪表盘 | 用于展示单一指标的进度或状态 | `GaugeChart` |
113
+ | 漏斗图 | 用于展示流程中各阶段的数据转化 | `FunnelChart` |
27
114
 
28
- 该包整合了以下子包:
115
+ ## 架构说明
29
116
 
30
- - [`@agions/taroviz-core`](https://www.npmjs.com/package/@agions/taroviz-core) - 核心组件
31
- - [`@agions/taroviz-charts`](https://www.npmjs.com/package/@agions/taroviz-charts) - 图表组件
32
- - [`@agions/taroviz-adapters`](https://www.npmjs.com/package/@agions/taroviz-adapters) - 平台适配器
33
- - [`@agions/taroviz-themes`](https://www.npmjs.com/package/@agions/taroviz-themes) - 主题系统
34
- - [`@agions/taroviz-data`](https://www.npmjs.com/package/@agions/taroviz-data) - 数据处理
35
- - [`@agions/taroviz-hooks`](https://www.npmjs.com/package/@agions/taroviz-hooks) - React Hooks
117
+ TaroViz 采用单包架构设计,包含以下核心模块:
36
118
 
37
- ## 使用示例
119
+ | 模块 | 描述 |
120
+ | -------- | -------------------------------------- |
121
+ | core | 核心功能和类型定义 |
122
+ | adapters | 多平台适配器,处理不同平台的差异 |
123
+ | charts | 各种图表组件的实现 |
124
+ | hooks | React Hooks,提供便捷的状态管理 |
125
+ | themes | 主题系统,支持多种内置主题和自定义主题 |
126
+ | utils | 工具函数和数据处理工具 |
38
127
 
39
- ```jsx
128
+ ## 详细示例
129
+
130
+ ### 折线图
131
+
132
+ ```typescript
40
133
  import React from 'react';
41
134
  import { LineChart } from '@agions/taroviz';
42
135
 
43
- const App = () => {
44
- const data = {
45
- xAxis: ['周一', '周二', '周三', '周四', '周五'],
46
- series: [150, 230, 224, 218, 135]
136
+ const LineChartDemo = () => {
137
+ const option = {
138
+ title: {
139
+ text: '销售趋势'
140
+ },
141
+ tooltip: {
142
+ trigger: 'axis'
143
+ },
144
+ legend: {
145
+ data: ['线上', '线下']
146
+ },
147
+ xAxis: {
148
+ type: 'category',
149
+ boundaryGap: false,
150
+ data: ['1月', '2月', '3月', '4月', '5月', '6月']
151
+ },
152
+ yAxis: {
153
+ type: 'value'
154
+ },
155
+ series: [
156
+ {
157
+ name: '线上',
158
+ type: 'line',
159
+ data: [120, 200, 150, 80, 70, 110],
160
+ smooth: true
161
+ },
162
+ {
163
+ name: '线下',
164
+ type: 'line',
165
+ data: [90, 150, 120, 100, 80, 130],
166
+ smooth: true
167
+ }
168
+ ]
47
169
  };
48
170
 
49
171
  return (
50
172
  <LineChart
51
- data={data}
52
- width={350}
53
- height={250}
173
+ option={option}
174
+ width="100%"
175
+ height={400}
176
+ theme="dark"
177
+ autoResize={true}
54
178
  />
55
179
  );
56
180
  };
57
181
 
58
- export default App;
182
+ export default LineChartDemo;
59
183
  ```
60
184
 
61
- ## API文档
185
+ ### 饼图
62
186
 
63
- ### 导出的组件
187
+ ```typescript
188
+ import React from 'react';
189
+ import { PieChart } from '@agions/taroviz';
64
190
 
65
- 以下是主要的图表组件:
191
+ const PieChartDemo = () => {
192
+ const option = {
193
+ title: {
194
+ text: '销售渠道分布',
195
+ left: 'center'
196
+ },
197
+ tooltip: {
198
+ trigger: 'item'
199
+ },
200
+ legend: {
201
+ orient: 'vertical',
202
+ left: 'left'
203
+ },
204
+ series: [
205
+ {
206
+ name: '销售渠道',
207
+ type: 'pie',
208
+ radius: '50%',
209
+ data: [
210
+ { value: 350, name: '线上商城' },
211
+ { value: 250, name: '线下门店' },
212
+ { value: 200, name: '代理商' },
213
+ { value: 150, name: '其他' }
214
+ ],
215
+ emphasis: {
216
+ itemStyle: {
217
+ shadowBlur: 10,
218
+ shadowOffsetX: 0,
219
+ shadowColor: 'rgba(0, 0, 0, 0.5)'
220
+ }
221
+ }
222
+ }
223
+ ]
224
+ };
66
225
 
67
- - `LineChart` - 折线图
68
- - `BarChart` - 柱状图
69
- - `PieChart` - 饼图
70
- - `RadarChart` - 雷达图
71
- - `ScatterChart` - 散点图
72
- - `HeatmapChart` - 热力图
226
+ return (
227
+ <PieChart
228
+ option={option}
229
+ width={400}
230
+ height={400}
231
+ />
232
+ );
233
+ };
73
234
 
74
- 更多图表类型请参考完整文档。
235
+ export default PieChartDemo;
236
+ ```
75
237
 
76
- ### 导出的工具
238
+ ### 散点图
77
239
 
78
- - `Core` - 核心API
79
- - `Adapters` - 适配器API
80
- - `Charts` - 图表组件API
81
- - `Themes` - 主题系统API
82
- - `Data` - 数据处理API
83
- - `Hooks` - React Hooks API
240
+ ```typescript
241
+ import React from 'react';
242
+ import { ScatterChart } from '@agions/taroviz';
84
243
 
85
- ## 依赖要求
244
+ const ScatterChartDemo = () => {
245
+ const option = {
246
+ title: {
247
+ text: '身高体重分布'
248
+ },
249
+ xAxis: {
250
+ name: '身高 (cm)',
251
+ type: 'value'
252
+ },
253
+ yAxis: {
254
+ name: '体重 (kg)',
255
+ type: 'value'
256
+ },
257
+ series: [
258
+ {
259
+ type: 'scatter',
260
+ data: [
261
+ [161.2, 51.6],
262
+ [167.5, 59.0],
263
+ [159.5, 49.2],
264
+ [157.0, 63.0],
265
+ [155.8, 53.6],
266
+ [170.0, 59.0],
267
+ [159.1, 47.6],
268
+ [166.0, 69.8],
269
+ [176.2, 66.8],
270
+ [160.2, 75.2]
271
+ ]
272
+ }
273
+ ]
274
+ };
86
275
 
87
- - `@tarojs/components`: >=3.4.0
88
- - `@tarojs/taro`: >=3.4.0
89
- - `echarts`: >=5.4.0
90
- - `react`: >=16.13.0
276
+ return (
277
+ <ScatterChart
278
+ option={option}
279
+ width="100%"
280
+ height={400}
281
+ />
282
+ );
283
+ };
91
284
 
92
- ## 相关链接
285
+ export default ScatterChartDemo;
286
+ ```
287
+
288
+ ## 本地开发
289
+
290
+ ```bash
291
+ # 克隆仓库
292
+ git clone https://github.com/agions/taroviz.git
293
+
294
+ # 安装依赖
295
+ pnpm install
296
+
297
+ # 启动开发服务
298
+ pnpm dev
299
+
300
+ # 构建
301
+ pnpm build
302
+
303
+ # 运行测试
304
+ pnpm test
305
+
306
+ # 生成 API 文档
307
+ pnpm run docs:api
308
+ ```
309
+
310
+ ## 技术栈
93
311
 
94
- - [GitHub仓库](https://github.com/Agions/TaroViz)
95
- - [问题反馈](https://github.com/Agions/TaroViz/issues)
96
- - [更新日志](https://github.com/Agions/TaroViz/blob/main/CHANGELOG.md)
312
+ - [Taro](https://taro.jd.com/) - 多端统一开发框架
313
+ - [ECharts](https://echarts.apache.org/zh/index.html) - 强大的图表库
314
+ - [React](https://reactjs.org/) - 用户界面库
315
+ - [TypeScript](https://www.typescriptlang.org/) - 类型系统
316
+ - [pnpm](https://pnpm.io/) - 高效的包管理器
317
+ - [Webpack](https://webpack.js.org/) - 构建工具
318
+ - [Jest](https://jestjs.io/) - 测试框架
319
+ - [Cypress](https://www.cypress.io/) - 端到端测试工具
320
+
321
+ ## 兼容性
322
+
323
+ | 平台 | 支持情况 |
324
+ | -------------- | ----------- |
325
+ | 微信小程序 | ✅ 支持 |
326
+ | 支付宝小程序 | ✅ 支持 |
327
+ | 百度小程序 | ✅ 支持 |
328
+ | 字节跳动小程序 | ✅ 支持 |
329
+ | HarmonyOS | ✅ 支持 |
330
+ | H5 | ✅ 支持 |
331
+ | React Native | ⚠️ 部分支持 |
332
+
333
+ ## 贡献指南
334
+
335
+ 我们欢迎任何形式的贡献,包括但不限于:
336
+
337
+ - 提交问题和建议
338
+ - 改进文档
339
+ - 修复 bug
340
+ - 添加新功能
341
+ - 优化性能
342
+
343
+ 请查看 [贡献指南](./CONTRIBUTING.md) 了解详细信息。
344
+
345
+ ## 更新日志
346
+
347
+ 查看 [CHANGELOG.md](./CHANGELOG.md) 了解详细的更新历史。
97
348
 
98
349
  ## 许可证
99
350
 
100
- MIT © [Agions](https://github.com/Agions)
351
+ [MIT License](./LICENSE) © 2025 Agions
352
+
353
+ ## 支持
354
+
355
+ 如果您在使用过程中遇到问题,可以通过以下方式获取帮助:
356
+
357
+ - [GitHub Issues](https://github.com/agions/taroviz/issues) - 提交问题和建议
358
+ - [在线文档](https://agions.github.io/TaroViz/) - 查看详细文档
359
+ - [示例](https://agions.github.io/TaroViz/examples/) - 参考使用示例
360
+ - [贡献指南](https://agions.github.io/TaroViz/contributing/) - 了解如何贡献代码
361
+
362
+ ## 致谢
363
+
364
+ 感谢所有为 TaroViz 做出贡献的开发者!
365
+
366
+ ## 相关链接
367
+
368
+ - [Taro 官网](https://taro.jd.com/)
369
+ - [ECharts 官网](https://echarts.apache.org/zh/index.html)
370
+ - [GitHub 仓库](https://github.com/agions/taroviz)
371
+ - [npm 包](https://www.npmjs.com/package/@agions/taroviz)