fix: 处理chart nullvalue

This commit is contained in:
zhangyu
2023-11-09 10:35:03 +08:00
parent ae39e5c62d
commit 1396310b29
2 changed files with 12 additions and 3 deletions

View File

@@ -484,7 +484,7 @@ export default {
} else { } else {
u.axes[2].grid.show = false u.axes[2].grid.show = false
} }
u.redraw(false, true) u.redraw(false, true)
} }
}, },
mounted () { mounted () {

View File

@@ -33,6 +33,7 @@ export default {
initSeriesData (chartData) { // 处理数据 以及 series initSeriesData (chartData) { // 处理数据 以及 series
let time = [] let time = []
this.legends = [] this.legends = []
const nullValueMode = this.chartInfo.param.nullType
const seriesData = [] // 返回的数据 const seriesData = [] // 返回的数据
const seriesAll = [ // 返回的 series const seriesAll = [ // 返回的 series
@@ -66,7 +67,15 @@ export default {
} }
item.statistics = statistics item.statistics = statistics
item.values.forEach(value => { item.values.forEach(value => {
seriesObjTime[value[0]] = value[1] let itemValue = value[1]
if (itemValue === null && nullValueMode !== 'null') {
if (nullValueMode === 'zero') {
itemValue = 0
} else {
itemValue = undefined
}
}
seriesObjTime[value[0]] = itemValue
}) })
// 处理统计数据 statistics // 处理统计数据 statistics
seriesObjTime = { seriesObjTime = {
@@ -111,7 +120,7 @@ export default {
values: (u, v) => series.elements.name + JSON.stringify(series.metric), values: (u, v) => series.elements.name + JSON.stringify(series.metric),
stroke: this.seriesColor[chartIndex], stroke: this.seriesColor[chartIndex],
width: 1 / devicePixelRatio, width: 1 / devicePixelRatio,
expressionIndex: series.expressionIndex, expressionIndex: series.expressionIndex
} }
if (chartType === 'area') { if (chartType === 'area') {
obj.fill = this.seriesColor[chartIndex] + '20' // 面积图使用 obj.fill = this.seriesColor[chartIndex] + '20' // 面积图使用