From 10840aa96dd3b55376b4ed3ea9346726ea55f8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Thu, 15 Aug 2024 10:01:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Ddetection=E8=81=9A?= =?UTF-8?q?=E5=90=88=E4=BA=8B=E4=BB=B6=E8=AF=A6=E6=83=85=E6=8A=98=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE=E4=B8=8D=E9=9A=8F=E6=97=B6=E9=97=B4=E8=BD=B4=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E5=88=87=E6=8D=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../overview/detectionDetailMixin.js | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/views/detections/overview/detectionDetailMixin.js b/src/views/detections/overview/detectionDetailMixin.js index 1d08145f..751c1e58 100644 --- a/src/views/detections/overview/detectionDetailMixin.js +++ b/src/views/detections/overview/detectionDetailMixin.js @@ -87,9 +87,6 @@ export default { this.isGroup = 0 } - if (this.myChart) { - this.myChart.dispose() - } const params = { startTime: getSecond(this.timeFilter.startTime), endTime: getSecond(this.timeFilter.endTime), @@ -104,23 +101,7 @@ export default { if (this.detection.ruleType === detectionRuleType.threshold.key) { const data = res.data.data.result if (data && data.length > 0) { - const seriesData = [] - data.forEach(item => { - seriesData.push([getMillisecond(JSON.parse(item.statTime)), item.recordsNums]) - }) - this.lineOption.series[0].data = seriesData - this.lineOption.series[0].color = getSeverityNumberColor(res.data.data.result[0].severity) || '#ff9a79' - - this.seriesDataNum = seriesData.length - if (this.seriesDataNum <= 1) { - this.lineOption.series[0].symbol = 'circle' - this.lineOption.series[0].symbolSize = 9 - } else { - this.lineOption.series[0].symbol = 'none' - } - - this.myChart = markRaw(echarts.init(document.getElementById('myChart' + this.detection.eventId))) - this.myChart.setOption(this.lineOption) + this.handleLineChart(data) } } else { const data = res.data.data.result @@ -150,6 +131,9 @@ export default { if (res.status === 200) { const data = res.data.data.result if (data && data.length > 0) { + if (this.detection.ruleType === detectionRuleType.threshold.key) { + this.handleLineChart(data) + } const detailData = data[0] if (detailData.eventInfo) { detailData.eventInfoList = JSON.parse(detailData.eventInfo) @@ -160,6 +144,29 @@ export default { }).catch(e => { this.$message.error(this.errorMsgHandler(e)) }) + }, + // 挂载echarts折线图 + handleLineChart (data) { + if (this.myChart) { + this.myChart.dispose() + } + const seriesData = [] + data.forEach(item => { + seriesData.push([getMillisecond(JSON.parse(item.statTime)), item.recordsNums]) + }) + this.lineOption.series[0].data = seriesData + this.lineOption.series[0].color = getSeverityNumberColor(data[0].severity) || '#ff9a79' + + this.seriesDataNum = seriesData.length + if (this.seriesDataNum <= 1) { + this.lineOption.series[0].symbol = 'circle' + this.lineOption.series[0].symbolSize = 9 + } else { + this.lineOption.series[0].symbol = 'none' + } + + this.myChart = markRaw(echarts.init(document.getElementById('myChart' + this.detection.eventId))) + this.myChart.setOption(this.lineOption) } } }