Skip to content

Commit

Permalink
feat: ✨ 清空图表的默认展示数据
Browse files Browse the repository at this point in the history
  • Loading branch information
dizuncainiao committed Aug 10, 2023
1 parent f4aa25a commit f2f4bec
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/bi-chart/components/basic-chart/echarts-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,23 @@ export type AllChartOptions = typeof allEchartsOptions

export type ChartType = keyof AllChartOptions

// 清空图表的默认数据
export function wipeOptionData(options: any) {
const option = cloneDeep(options)
if (Array.isArray(option.series)) {
option.series.forEach((item: any) => {
item.data = []
})
} else if (
Object.prototype.toString.call(option.series) === '[object Object]'
) {
option.series.data = []
}
return option
}

export function getChartOption(type: ChartType) {
const option = cloneDeep(Reflect.get(allEchartsOptions, type))
const option = wipeOptionData(Reflect.get(allEchartsOptions, type))
return ref(option)
}

Expand Down

0 comments on commit f2f4bec

Please sign in to comment.