From e75f3246045ede272d080b5d82849b6c66881dfd Mon Sep 17 00:00:00 2001 From: zhangyu Date: Wed, 29 Dec 2021 15:57:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=20=E4=BF=AE=E6=94=B9=20stat=20resi?= =?UTF-8?q?ze=E6=97=B6=20=E6=9C=89=E6=97=B6=E5=9B=BE=E5=BD=A2=E4=BC=9A?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/chart/chart/chartHexagonD3.vue | 15 +++++++++++---- .../src/components/chart/chart/chartStat.vue | 17 ++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue b/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue index f0163660b..a1380ef59 100644 --- a/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue +++ b/nezha-fronted/src/components/chart/chart/chartHexagonD3.vue @@ -41,7 +41,8 @@ export default { show: false }, svgDom: null, - spaceBetweenHexa: 3 + spaceBetweenHexa: 3, + hexagonTimer: null } }, methods: { @@ -376,9 +377,15 @@ export default { }) }, resize () { - this.getLayout().then(layout => { - this.initHexagon(layout) - }) + if (this.hexagonTimer) { + clearTimeout(this.hexagonTimer) + this.hexagonTimer = null + } + this.hexagonTimer = setTimeout(() => { + this.getLayout().then(layout => { + this.initHexagon(layout) + }) + }, 50) } }, created () { diff --git a/nezha-fronted/src/components/chart/chart/chartStat.vue b/nezha-fronted/src/components/chart/chart/chartStat.vue index faf397f5b..bd4ad0be0 100644 --- a/nezha-fronted/src/components/chart/chart/chartStat.vue +++ b/nezha-fronted/src/components/chart/chart/chartStat.vue @@ -32,7 +32,7 @@ import chartFormat from '@/components/chart/chartFormat' import { getMetricTypeValue } from '@/components/common/js/tools' import chartDataFormat from '@/components/charts/chartDataFormat' import { randomcolor } from '@/components/common/js/radomcolor/randomcolor' -import {initColor} from "@/components/chart/chart/tools"; +import { initColor } from '@/components/chart/chart/tools' export default { name: 'chart-stat', @@ -42,7 +42,8 @@ export default { statData: [], boxWidth: 0, boxHeight: 0, - boxPadding: 5 + boxPadding: 5, + statTimer: null } }, methods: { @@ -140,9 +141,15 @@ export default { this.isInit = false }, resize () { - this.getLayout().then(layout => { - this.renderStat(layout) - }) + if (this.statTimer) { + clearTimeout(this.statTimer) + this.statTimer = null + } + this.statTimer = setTimeout(() => { + this.getLayout().then(layout => { + this.renderStat(layout) + }) + }, 50) } }, mounted () {