From 8837c4ef24401bc18fadb43d5ef42b6b8415a0ac Mon Sep 17 00:00:00 2001 From: "@changcode" Date: Mon, 10 Jan 2022 10:41:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=92=9F?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E7=9A=84=E5=8D=A1=E9=A1=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chart/chart/chartClock.vue | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/nezha-fronted/src/components/chart/chart/chartClock.vue b/nezha-fronted/src/components/chart/chart/chartClock.vue index 3d907aa2b..3141398d9 100644 --- a/nezha-fronted/src/components/chart/chart/chartClock.vue +++ b/nezha-fronted/src/components/chart/chart/chartClock.vue @@ -93,7 +93,34 @@ export default { /* 使用setTimeout延迟渲染图表,避免样式错乱 */ this.setTimer = setTimeout(() => { const myChart = this.isInit ? echarts.init(document.getElementById(`chart-canvas-${this.chartId}`)) : getChart(this.chartId) - myChart.setOption(chartOption) + if (this.chartInfo.param && this.chartInfo.param.timeType === 'local') { + const date = new Date() + const second = date.getSeconds() + const minute = date.getMinutes() + second / 60 + const hour = (date.getHours() % 12) + minute / 60 + chartOption.series.map(e => { + if (e.name === 'hour') { + e.data[0].value = hour + } else if (e.name === 'minute') { + e.data[0].value = minute + } else { + e.data[0].value = second + } + }) + myChart.setOption(chartOption) + } else { + _soft.querySystemState() + chartOption.series.map(e => { + if (e.name === 'hour') { + e.data[0].value = this.sysTime.hour + } else if (e.name === 'minute') { + e.data[0].value = this.sysTime.minute + } else { + e.data[0].value = this.sysTime.second + } + }) + myChart.setOption(chartOption) + } this.isInit && setChart(this.chartId, myChart) // 缓存;不使用vue的data是为避免整个chart被监听导致卡顿 this.isInit = false if (this.chartInfo.param && this.chartInfo.param.timeType === 'local') { @@ -149,6 +176,7 @@ export default { } }, mounted () { + this.querySystemState() // eslint-disable-next-line vue/no-mutating-props this.chartOption.color || (this.chartOption.color = initColor(20)) this.colorList = this.chartOption.color