From 18a896d7767f2566e1982a8c625b9f049cbb8f88 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 16 Nov 2021 15:31:29 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-1246=20fix:=20Chart=20perview=20=E6=97=B6?= =?UTF-8?q?=E5=B9=B6=E6=9C=AA=E5=B8=A6=20=E8=AE=BE=E7=BD=AE=E7=9A=84=20nul?= =?UTF-8?q?lType=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/charts/chartPreview.vue | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/nezha-fronted/src/components/charts/chartPreview.vue b/nezha-fronted/src/components/charts/chartPreview.vue index f67512486..99c8278e8 100644 --- a/nezha-fronted/src/components/charts/chartPreview.vue +++ b/nezha-fronted/src/components/charts/chartPreview.vue @@ -422,7 +422,12 @@ export default { // if(chartItem.type === 'table'&&chartItem.param&&chartItem.param.last == 1){ // return this.$get('/prom/api/v1/query_range?query=' + query + "&start=" + this.$stringTimeParseToUnix(endTime) + "&end=" + this.$stringTimeParseToUnix(endTime) + '&step=' + step); // } - return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + let str = '' + if ((chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 'table') && chartItem.param) { // 如果是这三个 默认给null + chartItem.param.nullType = chartItem.param.nullType || 'null' + str += '&nullType=' + chartItem.param.nullType + } + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) }) // 一个图表的所有element单独获取数据 axios.all(axiosArr).then((res) => { @@ -1658,10 +1663,15 @@ export default { axiosArr = this.chart.elements.map((ele) => { const filterItem = ele const query = filterItem.expression - if (chartItem.type === 'table' && chartItem.param && chartItem.param.last == 1) { - return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(endTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + let str = '' + if ((chartItem.type === 'line' || chartItem.type === 'bar' || chartItem.type === 'stackArea' || chartItem.type === 'table') && chartItem.param) { // 如果是这三个 默认给null + chartItem.param.nullType = chartItem.param.nullType || 'null' + str += '&nullType=' + chartItem.param.nullType } - return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) + if (chartItem.type === 'table' && chartItem.param && chartItem.param.last == 1) { + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(endTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) + } + return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step + str) }) // 一个图表 axios.all(axiosArr).then(res => {