diff --git a/src/hooks/chart/data/bar.ts b/src/hooks/chart/data/bar.ts new file mode 100644 index 0000000..034e5f4 --- /dev/null +++ b/src/hooks/chart/data/bar.ts @@ -0,0 +1,22 @@ +export const barOption = { + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' + } + }, + legend: {}, + yAxis: { + type: 'category', + data: [] + }, + xAxis: { + type: 'value' + }, + series: [ + { + data: [], + type: 'bar' + } + ] +}; diff --git a/src/utils/echarts/index.ts b/src/utils/echarts/index.ts index 15e26e4..fdc902f 100644 --- a/src/utils/echarts/index.ts +++ b/src/utils/echarts/index.ts @@ -1,9 +1,9 @@ // 引入 echarts 核心模块,核心模块提供了 echarts 使用必须要的接口。 import type { ComposeOption } from 'echarts/core'; import * as echarts from 'echarts/core'; -import type { PieSeriesOption } from 'echarts/charts'; +import type { BarSeriesOption, PieSeriesOption } from 'echarts/charts'; // 引入 饼状图 -import { PieChart } from 'echarts/charts'; +import { PieChart, BarChart} from 'echarts/charts'; // 组件类型的定义后缀都为 ComponentOption import type { DatasetComponentOption, @@ -30,6 +30,7 @@ import { SVGRenderer } from 'echarts/renderers'; // 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型 type ECOption = ComposeOption< | PieSeriesOption + | BarSeriesOption | TitleComponentOption | TooltipComponentOption | GridComponentOption @@ -48,6 +49,7 @@ echarts.use([ UniversalTransition, SVGRenderer, PieChart, + BarChart, LegendComponent ]);