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