fix(图表): 修复柱线组合图空值处理不生效的问题

This commit is contained in:
ulleo 2024-06-26 10:02:50 +08:00
parent 7c347b4ffb
commit 0b7753ea2a

View File

@ -238,12 +238,19 @@ export const quotaViews = ['label', 'richTextView', 'indicator', 'gauge', 'liqui
export function handleEmptyDataStrategy<O extends PickOptions>(chart: Chart, options: O): O {
const { data } = options as unknown as Options
const isChartMix = chart.type.includes('chart-mix')
if (!data?.length) {
return options
}
const strategy = parseJson(chart.senior).functionCfg.emptyDataStrategy
if (strategy === 'ignoreData') {
if (isChartMix) {
for (let i = 0; i < data.length; i++) {
handleIgnoreData(data[i] as Record<string, any>[])
}
} else {
handleIgnoreData(data)
}
return options
}
const { yAxis, xAxisExt, extStack } = chart
@ -252,8 +259,14 @@ export function handleEmptyDataStrategy<O extends PickOptions>(chart: Chart, opt
case 'breakLine': {
if (multiDimension) {
// 多维度保持空
if (isChartMix) {
for (let i = 0; i < data.length; i++) {
handleBreakLineMultiDimension(data[i] as Record<string, any>[])
}
} else {
handleBreakLineMultiDimension(data)
}
}
return {
...options,
connectNulls: false
@ -262,11 +275,23 @@ export function handleEmptyDataStrategy<O extends PickOptions>(chart: Chart, opt
case 'setZero': {
if (multiDimension) {
// 多维度置0
if (isChartMix) {
for (let i = 0; i < data.length; i++) {
handleSetZeroMultiDimension(data[i] as Record<string, any>[])
}
} else {
handleSetZeroMultiDimension(data)
}
} else {
// 单维度置0
if (isChartMix) {
for (let i = 0; i < data.length; i++) {
handleSetZeroSingleDimension(data[i] as Record<string, any>[])
}
} else {
handleSetZeroSingleDimension(data)
}
}
break
}
}