From ea53838c8ba303cea39b23732f245efde987822c Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期三, 25 九月 2024 11:07:05 +0800 Subject: [PATCH] 默认 chartType --- src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue | 8 ++------ src/components/chat/chatComponents/types.ts | 7 +++---- src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts | 12 +++++------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue b/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue index 70dab88..b4454a9 100644 --- a/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue +++ b/src/components/chat/chatComponents/summaryCom/components/recordSet/RecordSet.vue @@ -45,7 +45,6 @@ import { ChartTypeEnum } from '../../../types'; const chartRef = ref<HTMLDivElement>(null); -const defaultDisplayType = 'line'; const yRange = ref({ min: null as number, max: null as number, @@ -117,8 +116,7 @@ let preData = null; -let activeChartType: ChartTypeEnum = ChartTypeEnum.Line; - +let activeChartType: ChartTypeEnum = props.data.chart_type ?? ChartTypeEnum.Line; const getChartTypeSeriesOption = (type: ChartTypeEnum) => { let result = {}; switch (type) { @@ -161,9 +159,7 @@ return { name: item === 'default' ? '' : item, data: values.map((item) => [item[timeIndex], item[valueIndex]]), - type: defaultDisplayType, - symbol: 'none', - smooth: true, + ...getChartTypeSeriesOption(activeChartType) }; }); } diff --git a/src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts b/src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts index 7bf7638..9f86559 100644 --- a/src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts +++ b/src/components/chat/chatComponents/summaryCom/components/recordSet/types.ts @@ -1,6 +1,7 @@ import List from './components/List.vue'; import Timestamp from './components/Timestamp.vue'; import TimeRange from './components/TimeRange.vue'; +import { ChartTypeEnum } from '../../../types'; export const enum RecordSetParamsType { List = 'list', @@ -37,10 +38,7 @@ } & BaseParam; //#endregion //#region ====================== 鏁村悎 start 鍜� end锛屽緱鍒板墠绔牸寮� ====================== -export type TimeRangeParamValue = [ - string, - string -] +export type TimeRangeParamValue = [string, string]; export type TimeRangeParam = { type: RecordSetParamsType.TimeRange; value: TimeRangeParamValue; @@ -50,15 +48,15 @@ } & BaseParam; //#endregion - export type RecordSetParamsItem = ListParam | TimeRangeParam | TimeRangeBackEndParam; export type RecordSet = { params?: RecordSetParamsItem[]; + chartType?: ChartTypeEnum; } & Record<string, any>; export const recordSetMapCom = { [RecordSetParamsType.List]: List, [RecordSetParamsType.TimeRange]: TimeRange, - [RecordSetParamsType.StartTime]:Timestamp, - [RecordSetParamsType.EndTime]:Timestamp + [RecordSetParamsType.StartTime]: Timestamp, + [RecordSetParamsType.EndTime]: Timestamp, }; diff --git a/src/components/chat/chatComponents/types.ts b/src/components/chat/chatComponents/types.ts index a98a373..fd95684 100644 --- a/src/components/chat/chatComponents/types.ts +++ b/src/components/chat/chatComponents/types.ts @@ -1,8 +1,7 @@ - export const enum ChartTypeEnum { - Scatter, - Line, - Bar, + Scatter = 'scatter', + Line = 'line', + Bar = 'bar', } export const chartTypeMapName = { -- Gitblit v1.9.3