Blame view

Yi.Vben5.Vue3/packages/effects/plugins/src/echarts/echarts.ts 1.51 KB
515fceeb   “wangming”   框架初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  import type {
    // 系列类型的定义后缀都为 SeriesOption
    BarSeriesOption,
    LineSeriesOption,
  } from 'echarts/charts';
  import type {
    DatasetComponentOption,
    GridComponentOption,
    // 组件类型的定义后缀都为 ComponentOption
    TitleComponentOption,
    TooltipComponentOption,
  } from 'echarts/components';
  import type { ComposeOption } from 'echarts/core';
  
  import {
    BarChart,
    GaugeChart,
    LineChart,
    MapChart,
    PieChart,
    RadarChart,
  } from 'echarts/charts';
  import {
    // 数据集组件
    DatasetComponent,
    GridComponent,
    LegendComponent,
    TitleComponent,
    ToolboxComponent,
    TooltipComponent,
    // 内置数据转换器组件 (filter, sort)
    TransformComponent,
    VisualMapComponent,
  } from 'echarts/components';
  import * as echarts from 'echarts/core';
  import { LabelLayout, UniversalTransition } from 'echarts/features';
  import { CanvasRenderer } from 'echarts/renderers';
  
  // 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
  export type ECOption = ComposeOption<
    | BarSeriesOption
    | DatasetComponentOption
    | GridComponentOption
    | LineSeriesOption
    | TitleComponentOption
    | TooltipComponentOption
  >;
  
  // 注册必须的组件
  echarts.use([
    TitleComponent,
    PieChart,
    RadarChart,
    TooltipComponent,
    GridComponent,
    DatasetComponent,
    TransformComponent,
    BarChart,
    LineChart,
    LabelLayout,
    UniversalTransition,
    CanvasRenderer,
    LegendComponent,
    ToolboxComponent,
    GaugeChart,
    VisualMapComponent,
    MapChart,
  ]);
  
  export default echarts;