Files
aiot-platform-ui/packages/effects/plugins/src/echarts/echarts.ts

83 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-06-23 23:18:55 +08:00
import type {
// 系列类型的定义后缀都为 SeriesOption
BarSeriesOption,
2025-04-07 22:00:14 +08:00
GaugeSeriesOption,
2025-04-24 17:55:30 +08:00
LineSeriesOption,
2025-06-24 12:51:38 +08:00
MapSeriesOption,
2024-06-23 23:18:55 +08:00
} from 'echarts/charts';
import type {
DatasetComponentOption,
2025-06-24 12:51:38 +08:00
GeoComponentOption,
2024-06-23 23:18:55 +08:00
GridComponentOption,
// 组件类型的定义后缀都为 ComponentOption
TitleComponentOption,
TooltipComponentOption,
2025-06-24 12:51:38 +08:00
VisualMapComponentOption,
2024-06-23 23:18:55 +08:00
} from 'echarts/components';
import type { ComposeOption } from 'echarts/core';
2025-04-24 17:55:30 +08:00
import {
BarChart,
2025-10-22 12:29:44 +08:00
FunnelChart,
2025-04-24 17:55:30 +08:00
GaugeChart,
LineChart,
2025-06-24 12:51:38 +08:00
MapChart,
2025-04-24 17:55:30 +08:00
PieChart,
RadarChart,
} from 'echarts/charts';
2024-06-23 23:18:55 +08:00
import {
// 数据集组件
DatasetComponent,
2025-06-24 12:51:38 +08:00
GeoComponent,
2024-06-23 23:18:55 +08:00
GridComponent,
LegendComponent,
TitleComponent,
ToolboxComponent,
TooltipComponent,
// 内置数据转换器组件 (filter, sort)
TransformComponent,
2025-06-24 12:51:38 +08:00
VisualMapComponent,
2024-06-23 23:18:55 +08:00
} 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
2025-04-24 17:55:30 +08:00
| GaugeSeriesOption
2025-06-24 12:51:38 +08:00
| GeoComponentOption
2024-06-23 23:18:55 +08:00
| GridComponentOption
| LineSeriesOption
2025-06-24 12:51:38 +08:00
| MapSeriesOption
2024-06-23 23:18:55 +08:00
| TitleComponentOption
| TooltipComponentOption
2025-06-24 12:51:38 +08:00
| VisualMapComponentOption
2024-06-23 23:18:55 +08:00
>;
// 注册必须的组件
echarts.use([
TitleComponent,
PieChart,
RadarChart,
TooltipComponent,
GridComponent,
DatasetComponent,
TransformComponent,
BarChart,
LineChart,
2025-10-22 12:29:44 +08:00
FunnelChart,
2025-04-07 22:00:14 +08:00
GaugeChart,
2024-06-23 23:18:55 +08:00
LabelLayout,
UniversalTransition,
CanvasRenderer,
LegendComponent,
ToolboxComponent,
2025-06-24 12:51:38 +08:00
VisualMapComponent,
MapChart,
GeoComponent,
2024-06-23 23:18:55 +08:00
]);
2024-06-29 14:45:02 +08:00
export default echarts;