From 39b21c517837f832af1b662d86f51d100cc5f301 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Thu, 14 Jul 2022 15:26:19 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-2024=20fix=EF=BC=9A{{A.$labels}}=20?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=B1=95=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chart/chart/chartTable.vue | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartTable.vue b/nezha-fronted/src/components/chart/chart/chartTable.vue index d51ccb0f1..c791787b5 100644 --- a/nezha-fronted/src/components/chart/chart/chartTable.vue +++ b/nezha-fronted/src/components/chart/chart/chartTable.vue @@ -212,7 +212,23 @@ export default { value = chartDataFormat.getUnit(column.unit ? column.unit : 2).compute(value, null, -1, 2) } if (!((typeof value) == 'string' && value.constructor == String)) { - value = JSON.stringify(lodash.get(params, label)) + let legend = '' + if (value.__name__) { + legend += `${value.__name__}{` + } else { + legend += '{' + } + const tagKeysArr = Object.keys(value) + tagKeysArr.forEach(tagKey => { + if (tagKey !== '__name__') { + legend += `${tagKey}="${value[tagKey]}",` + } + }) + if (legend.endsWith(',')) { + legend = legend.substr(0, legend.length - 1) + } + legend += '}' + value = legend } } return value || '' @@ -242,7 +258,23 @@ export default { if (lodash.get(params, label)) { value = lodash.get(params, label) if (!((typeof value) == 'string' && value.constructor == String)) { - value = JSON.stringify(lodash.get(params, label)) + let legend = '' + if (value.__name__) { + legend += `${value.__name__}{` + } else { + legend += '{' + } + const tagKeysArr = Object.keys(value) + tagKeysArr.forEach(tagKey => { + if (tagKey !== '__name__') { + legend += `${tagKey}="${value[tagKey]}",` + } + }) + if (legend.endsWith(',')) { + legend = legend.substr(0, legend.length - 1) + } + legend += '}' + value = legend } } return value || label