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
| /**
| * 按需引入 echarts
| * 指引文档 https://echarts.apache.org/handbook/zh/basics/import
| * **/
|
| import * as echarts from 'echarts/core'
| import {
| BarChart,
| // 系列类型的定义后缀都为 SeriesOption
| BarSeriesOption,
| // LineChart,
| LineSeriesOption
| } from 'echarts/charts'
| import {
| TitleComponent,
| // 组件类型的定义后缀都为 ComponentOption
| TitleComponentOption,
| TooltipComponent,
| TooltipComponentOption,
| GridComponent,
| GridComponentOption,
| // 数据集组件
| DatasetComponent,
| DatasetComponentOption,
| // 内置数据转换器组件 (filter, sort)
| TransformComponent,
| LegendComponent
| } from 'echarts/components'
| import { LabelLayout, UniversalTransition } from 'echarts/features'
| import { CanvasRenderer } from 'echarts/renderers'
|
| // 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
| export type ECOption = echarts.ComposeOption<
| | BarSeriesOption
| | LineSeriesOption
| | TitleComponentOption
| | TooltipComponentOption
| | GridComponentOption
| | DatasetComponentOption
| >
|
| // 注册必须的组件
| echarts.use([
| TitleComponent,
| TooltipComponent,
| GridComponent,
| DatasetComponent,
| TransformComponent,
| BarChart,
| LabelLayout,
| UniversalTransition,
| CanvasRenderer,
| LegendComponent
| ])
|
| export const $echarts = echarts
|
|