From 371d6e4a206bea31f3eb504815d40f6eedcb427f Mon Sep 17 00:00:00 2001 From: wangwenrui Date: Thu, 28 May 2020 18:53:41 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E5=9B=BE=E8=A1=A8=E9=98=88=E5=80=BClabel?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nezha-fronted/src/components/charts/chart-list.vue | 13 +++++++++---- .../src/components/common/rightBox/cabinetBox.vue | 6 +----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue index 09cf6a3be..a019249ef 100644 --- a/nezha-fronted/src/components/charts/chart-list.vue +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -1135,10 +1135,15 @@ export default { } } }, - computeDistance:function(value){ - let temp=value+''; - let length=temp.length *12 -20; - return Number('-'+length) + computeDistance:function(str){ + var width = 0; + var html = document.createElement('span'); + html.innerText = str; + html.className = 'getTextWidth'; + document.querySelector('body').appendChild(html); + width = document.querySelector('.getTextWidth').offsetWidth; + document.querySelector('.getTextWidth').remove(); + return Number('-'+width); }, modelStaticData(chartInfo, filterType) { let series = []; diff --git a/nezha-fronted/src/components/common/rightBox/cabinetBox.vue b/nezha-fronted/src/components/common/rightBox/cabinetBox.vue index 2c66b4469..606a76947 100644 --- a/nezha-fronted/src/components/common/rightBox/cabinetBox.vue +++ b/nezha-fronted/src/components/common/rightBox/cabinetBox.vue @@ -202,9 +202,5 @@ } } - -