@agions/taroviz 1.2.0 → 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 (37) hide show
  1. package/README.md +42 -36
  2. package/dist/cjs/index.js +1 -0
  3. package/dist/{index.esm.js → esm/index.js} +73473 -59179
  4. package/package.json +67 -8
  5. package/src/adapters/__tests__/index.test.ts +2 -2
  6. package/src/adapters/h5/index.ts +1 -1
  7. package/src/adapters/index.ts +99 -167
  8. package/src/charts/bar/index.tsx +2 -11
  9. package/src/charts/common/BaseChartWrapper.tsx +2 -2
  10. package/src/charts/funnel/index.tsx +2 -17
  11. package/src/charts/gauge/index.tsx +2 -17
  12. package/src/charts/heatmap/index.tsx +2 -17
  13. package/src/charts/line/index.tsx +2 -11
  14. package/src/charts/pie/index.tsx +3 -6
  15. package/src/charts/radar/index.tsx +2 -17
  16. package/src/charts/scatter/index.tsx +2 -17
  17. package/src/charts/types.ts +503 -30
  18. package/src/charts/utils.ts +1 -1
  19. package/src/core/__tests__/platform.test.ts +1 -1
  20. package/src/core/animation/AnimationManager.ts +2 -2
  21. package/src/core/components/BaseChart.tsx +12 -18
  22. package/src/core/components/ErrorBoundary.tsx +458 -0
  23. package/src/core/echarts.ts +58 -0
  24. package/src/core/index.ts +4 -1
  25. package/src/core/utils/__tests__/common.test.ts +1 -1
  26. package/src/core/utils/chartInstances.ts +2 -2
  27. package/src/core/utils/codeGenerator/CodeGenerator.ts +2 -2
  28. package/src/core/utils/codeGenerator/types.ts +0 -2
  29. package/src/core/utils/configGenerator/ConfigGenerator.ts +12 -12
  30. package/src/core/utils/debug/DebugPanel.tsx +1 -1
  31. package/src/core/utils/debug/debugger.ts +1 -1
  32. package/src/core/utils/index.ts +1 -1
  33. package/src/core/utils/performance/PerformanceAnalyzer.ts +5 -5
  34. package/src/editor/ThemeEditor.tsx +9 -9
  35. package/src/hooks/index.ts +441 -61
  36. package/src/main.tsx +1 -1
  37. package/src/themes/index.ts +651 -256
@@ -264,7 +264,7 @@ export class ConfigGenerator {
264
264
  * 根据图表类型获取模板
265
265
  */
266
266
  public getTemplatesByChartType(chartType: ChartType): ChartConfigTemplate[] {
267
- return Array.from(this.templates.values()).filter(template =>
267
+ return Array.from(this.templates.values()).filter((template) =>
268
268
  template.chartTypes.includes(chartType)
269
269
  );
270
270
  }
@@ -301,13 +301,13 @@ export class ConfigGenerator {
301
301
 
302
302
  // 合并所有配置,排除非ECharts配置
303
303
  const {
304
- chartType,
305
- subtitle,
306
- template,
307
- responsive,
308
- width,
309
- height,
310
- title: optionsTitle,
304
+ chartType: _chartType,
305
+ subtitle: _subtitle,
306
+ template: _template,
307
+ responsive: _responsive,
308
+ width: _width,
309
+ height: _height,
310
+ title: _optionsTitle,
311
311
  ...echartsOptions
312
312
  } = mergedOptions;
313
313
  // 使用类型断言确保TypeScript接受生成的配置
@@ -410,7 +410,7 @@ export class ConfigGenerator {
410
410
  private generateSeriesConfig(options: ConfigGeneratorOptions): EChartsOption {
411
411
  const series = options.series.map((seriesConfig, index) => {
412
412
  // 处理数据,转换为ECharts支持的格式
413
- const processedData = seriesConfig.data.map(item => {
413
+ const processedData = seriesConfig.data.map((item) => {
414
414
  if (typeof item.value === 'number') {
415
415
  return { name: item.name, value: item.value };
416
416
  }
@@ -445,7 +445,7 @@ export class ConfigGenerator {
445
445
  // 处理X轴配置
446
446
  if (options.xAxis) {
447
447
  axisConfig.xAxis = Array.isArray(options.xAxis)
448
- ? options.xAxis.map(axis => this.normalizeAxisConfig(axis))
448
+ ? options.xAxis.map((axis) => this.normalizeAxisConfig(axis))
449
449
  : this.normalizeAxisConfig(options.xAxis);
450
450
  } else if (this.needsAxis(options.chartType)) {
451
451
  // 为需要坐标轴的图表类型生成默认X轴
@@ -455,7 +455,7 @@ export class ConfigGenerator {
455
455
  // 处理Y轴配置
456
456
  if (options.yAxis) {
457
457
  axisConfig.yAxis = Array.isArray(options.yAxis)
458
- ? options.yAxis.map(axis => this.normalizeAxisConfig(axis))
458
+ ? options.yAxis.map((axis) => this.normalizeAxisConfig(axis))
459
459
  : this.normalizeAxisConfig(options.yAxis);
460
460
  } else if (this.needsAxis(options.chartType)) {
461
461
  // 为需要坐标轴的图表类型生成默认Y轴
@@ -565,7 +565,7 @@ export class ConfigGenerator {
565
565
  */
566
566
  private emit(eventType: ConfigGeneratorEventType, data?: any): void {
567
567
  const handlers = this.eventHandlers.get(eventType);
568
- handlers?.forEach(handler => {
568
+ handlers?.forEach((handler) => {
569
569
  try {
570
570
  handler({ type: eventType, data });
571
571
  } catch (error) {
@@ -2,7 +2,7 @@
2
2
  * TaroViz 调试面板组件
3
3
  * 提供图表调试和监控功能
4
4
  */
5
- import React, { useState, useEffect, useRef } from 'react';
5
+ import React, { useState, useRef } from 'react';
6
6
 
7
7
  import { DebugPanelOptions, DebugTabType, DebugInfo, DebugPanelEventType } from './types';
8
8
 
@@ -216,7 +216,7 @@ class DebugManager {
216
216
  private emitEvent(eventType: string, data: any): void {
217
217
  const handlers = this.eventHandlers.get(eventType);
218
218
  if (handlers) {
219
- handlers.forEach(handler => {
219
+ handlers.forEach((handler) => {
220
220
  try {
221
221
  handler(data);
222
222
  } catch (error) {
@@ -27,7 +27,7 @@ export function deepMerge<T extends Record<string, any>>(
27
27
  ): T {
28
28
  const result: any = { ...target };
29
29
 
30
- Object.keys(source).forEach(key => {
30
+ Object.keys(source).forEach((key) => {
31
31
  if (source[key] instanceof Object && key in target && target[key] instanceof Object) {
32
32
  result[key] = deepMerge(target[key], source[key]);
33
33
  } else {
@@ -42,7 +42,7 @@ export class PerformanceAnalyzer {
42
42
  };
43
43
 
44
44
  // 初始化指标存储
45
- this.config.metrics?.forEach(metricType => {
45
+ this.config.metrics?.forEach((metricType) => {
46
46
  this.metrics.set(metricType, []);
47
47
  });
48
48
 
@@ -100,7 +100,7 @@ export class PerformanceAnalyzer {
100
100
  */
101
101
  private emit(eventType: PerformanceEventType, data?: any): void {
102
102
  const handlers = this.eventHandlers.get(eventType);
103
- handlers?.forEach(handler => {
103
+ handlers?.forEach((handler) => {
104
104
  try {
105
105
  handler({ type: eventType, data });
106
106
  } catch (error) {
@@ -325,10 +325,10 @@ export class PerformanceAnalyzer {
325
325
  averages[metricType] = parseFloat((sum / metricList.length).toFixed(2));
326
326
 
327
327
  // 计算最大值
328
- maxValues[metricType] = Math.max(...metricList.map(metric => metric.value));
328
+ maxValues[metricType] = Math.max(...metricList.map((metric) => metric.value));
329
329
 
330
330
  // 计算最小值
331
- minValues[metricType] = Math.min(...metricList.map(metric => metric.value));
331
+ minValues[metricType] = Math.min(...metricList.map((metric) => metric.value));
332
332
  });
333
333
 
334
334
  // 计算性能评分和建议
@@ -518,7 +518,7 @@ export class PerformanceAnalyzer {
518
518
  <div class="suggestions">
519
519
  <h2>性能建议</h2>
520
520
  <ul>`;
521
- result.suggestions.forEach(suggestion => {
521
+ result.suggestions.forEach((suggestion) => {
522
522
  html += `
523
523
  <li>${suggestion}</li>`;
524
524
  });
@@ -71,7 +71,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
71
71
  // 当选中主题变化时,更新当前主题
72
72
  useEffect(() => {
73
73
  if (selectedTheme) {
74
- const theme = themes.find(t => t.name === selectedTheme);
74
+ const theme = themes.find((t) => t.name === selectedTheme);
75
75
  if (theme) {
76
76
  setCurrentTheme(theme);
77
77
  setColors(theme.colors || []);
@@ -197,7 +197,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
197
197
  <div style={{ marginBottom: '20px' }}>
198
198
  <h4>选择主题</h4>
199
199
  <div style={{ display: 'flex', flexWrap: 'wrap', gap: '10px', marginTop: '10px' }}>
200
- {themes.map(theme => (
200
+ {themes.map((theme) => (
201
201
  <button
202
202
  key={theme.name}
203
203
  onClick={() => handleThemeSelect(theme)}
@@ -249,7 +249,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
249
249
  <input
250
250
  type="text"
251
251
  value={newThemeName}
252
- onChange={e => setNewThemeName(e.target.value)}
252
+ onChange={(e) => setNewThemeName(e.target.value)}
253
253
  disabled={disabled}
254
254
  style={{
255
255
  padding: '8px',
@@ -297,7 +297,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
297
297
  <input
298
298
  type="color"
299
299
  value={color}
300
- onChange={e => handleColorChange(index, e.target.value)}
300
+ onChange={(e) => handleColorChange(index, e.target.value)}
301
301
  disabled={disabled}
302
302
  style={{
303
303
  width: '50px',
@@ -310,7 +310,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
310
310
  <input
311
311
  type="text"
312
312
  value={color}
313
- onChange={e => handleColorChange(index, e.target.value)}
313
+ onChange={(e) => handleColorChange(index, e.target.value)}
314
314
  disabled={disabled}
315
315
  style={{
316
316
  width: '80px',
@@ -351,7 +351,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
351
351
  <input
352
352
  type="color"
353
353
  value={backgroundColor}
354
- onChange={e => handleBackgroundColorChange(e.target.value)}
354
+ onChange={(e) => handleBackgroundColorChange(e.target.value)}
355
355
  disabled={disabled}
356
356
  style={{
357
357
  width: '50px',
@@ -364,7 +364,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
364
364
  <input
365
365
  type="text"
366
366
  value={backgroundColor}
367
- onChange={e => handleBackgroundColorChange(e.target.value)}
367
+ onChange={(e) => handleBackgroundColorChange(e.target.value)}
368
368
  disabled={disabled}
369
369
  style={{
370
370
  width: '120px',
@@ -384,7 +384,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
384
384
  <input
385
385
  type="color"
386
386
  value={textColor}
387
- onChange={e => handleTextColorChange(e.target.value)}
387
+ onChange={(e) => handleTextColorChange(e.target.value)}
388
388
  disabled={disabled}
389
389
  style={{
390
390
  width: '50px',
@@ -397,7 +397,7 @@ const ThemeEditor: React.FC<ThemeEditorProps> = ({
397
397
  <input
398
398
  type="text"
399
399
  value={textColor}
400
- onChange={e => handleTextColorChange(e.target.value)}
400
+ onChange={(e) => handleTextColorChange(e.target.value)}
401
401
  disabled={disabled}
402
402
  style={{
403
403
  width: '120px',