From 15f8ab4a40efcaae7ed1ba579bc6e8df5c3dcf1b Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 19 Oct 2021 11:37:09 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E6=94=B9=20chart-group=20?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=8A=98=E5=8F=A0=20=E6=89=93=E5=BC=80?= =?UTF-8?q?=E5=90=8E=20=E5=9B=BE=E8=A1=A8x=E8=BD=B4=E5=88=BB=E5=BA=A6?= =?UTF-8?q?=E4=B8=8D=E5=AF=B9=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/charts/line-chart-block.vue | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 6d4d6e87b..b597410f1 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -1985,6 +1985,37 @@ export default { if (getChart(this.chartIndex)) { const divHeight = this.$refs.legendArea.offsetHeight getChart(this.chartIndex).resize({ height: (this.data.height * this.stepWidth - divHeight - chartResizeTool.titleHeight - chartResizeTool.chartBlankHeight) }) + let minInterval = '' + let splitNumber = '' + if (this.fromTopo) { + const panelTime = localStorage.getItem('panelTime') ? JSON.parse(localStorage.getItem('panelTime')) : ['', ''] + if (panelTime[0]) { + const numInterval = new Date(panelTime[1]).getTime() - new Date(panelTime[0]).getTime() + if (numInterval >= 60 * 60 * 1000) { + minInterval = 20 * 60 * 1000 + } else if (numInterval >= 30 * 60 * 1000 && numInterval < 60 * 60 * 1000) { + minInterval = 10 * 60 * 1000 + } else if (numInterval >= 15 * 60 * 1000 && numInterval < 30 * 60 * 1000) { + minInterval = 5 * 60 * 1000 + } else if (numInterval >= 5 * 60 * 1000 && numInterval < 15 * 60 * 1000) { + minInterval = 1 * 60 * 1000 + } else { + minInterval = 15 * 1000 + } + } else { + minInterval = 20 * 60 * 1000 + } + getChart(this.chartIndex).setOption({ xAxis: { minInterval: minInterval } }) + } else { + if (this.$refs.resizeBox.offsetWidth < 200) { + splitNumber = 1 + } else if (this.$refs.resizeBox.offsetWidth < 300) { + splitNumber = 3 + } else if (this.$refs.resizeBox.offsetWidth < 500) { + splitNumber = 5 + } + getChart(this.chartIndex).setOption({ xAxis: { splitNumber: splitNumber } }) + } } } },