From 1396310b294e3bd2f8aa1613bc9a5346e29c4b58 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 9 Nov 2023 10:35:03 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20=E5=A4=84=E7=90=86chart=20nullva?= =?UTF-8?q?lue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/chart/uplot/chartTimeSeries.vue | 2 +- .../chart/chart/uplot/chartTimeSeriesMixin.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeries.vue b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeries.vue index f3dbfef98..1119cd84f 100644 --- a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeries.vue +++ b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeries.vue @@ -484,7 +484,7 @@ export default { } else { u.axes[2].grid.show = false } - u.redraw(false, true) + u.redraw(false, true) } }, mounted () { diff --git a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js index 3c84375b9..bd7dc6ad5 100644 --- a/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js +++ b/nezha-fronted/src/components/chart/chart/uplot/chartTimeSeriesMixin.js @@ -33,6 +33,7 @@ export default { initSeriesData (chartData) { // 处理数据 以及 series let time = [] this.legends = [] + const nullValueMode = this.chartInfo.param.nullType const seriesData = [] // 返回的数据 const seriesAll = [ // 返回的 series @@ -66,7 +67,15 @@ export default { } item.statistics = statistics 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 seriesObjTime = { @@ -111,7 +120,7 @@ export default { values: (u, v) => series.elements.name + JSON.stringify(series.metric), stroke: this.seriesColor[chartIndex], width: 1 / devicePixelRatio, - expressionIndex: series.expressionIndex, + expressionIndex: series.expressionIndex } if (chartType === 'area') { obj.fill = this.seriesColor[chartIndex] + '20' // 面积图使用