From 0173b0b05e3ca7a487588e1a2bc6e73b8dc3ce4d Mon Sep 17 00:00:00 2001 From: Huangzhe Date: Thu, 29 May 2025 15:15:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=9D=A1=E5=BD=A2?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=9B=BE=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/chart/data/bar.ts | 22 ++++++++++++++++++++++ src/utils/echarts/index.ts | 6 ++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/hooks/chart/data/bar.ts 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 ]);