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 () {