From a0af36b7c06cc92a2aa926e720a7008f01c0a462 Mon Sep 17 00:00:00 2001 From: hanyuxia Date: Fri, 17 Nov 2023 14:13:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:1=20=E6=A3=80=E6=B5=8B->=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=A5=BC=E5=9B=BElegend=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E9=9A=8F=E5=88=86=E8=BE=A8=E7=8E=87=E8=80=8C=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/detections/Index.vue | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/views/detections/Index.vue b/src/views/detections/Index.vue index 0c47b1bb..81fa77f1 100644 --- a/src/views/detections/Index.vue +++ b/src/views/detections/Index.vue @@ -443,13 +443,13 @@ export default { securityTypeOption.series[0].data = data.map(d => { return { value: d.count, name: d.eventType } }) - if (data.length > 6) { - const dom = document.getElementById('eventSeverityPiesecurityEvent') - if (dom) { - const oneColumnWidth = (dom.clientWidth * 0.56) / 2 - 30 - securityTypeOption.legend.formatter = function (name) { - return format.truncateText(name, oneColumnWidth, '12px') - } + if (chartDom) { + let oneColumnWidth = (chartDom.clientWidth * 0.56) - 30 + if (data.length > 6) { + oneColumnWidth = (chartDom.clientWidth * 0.56) / 2 - 30 + } + securityTypeOption.legend.formatter = function (name) { + return format.truncateText(name, oneColumnWidth, '12px') } } detectionChart.setOption(securityTypeOption) @@ -496,13 +496,13 @@ export default { securityTypeOption.series[0].data = data.map(d => { return { value: d.count, name: d.eventType, itemStyle: { color: getAttackColor(d.eventType) } } }) - if (data.length > 6) { - const dom = document.getElementById('detectionCategoryPersecurityEvent') - if (dom) { - const oneColumnWidth = (dom.clientWidth * 0.56) / 2 - 30 - securityTypeOption.legend.formatter = function (name) { - return format.truncateText(name, oneColumnWidth, '12px') - } + if (chartDom) { + let oneColumnWidth = (chartDom.clientWidth * 0.56) - 30 + if (data.length > 6) { + oneColumnWidth = (chartDom.clientWidth * 0.56) / 2 - 30 + } + securityTypeOption.legend.formatter = function (name) { + return format.truncateText(name, oneColumnWidth, '12px') } } detectionChart.setOption(securityTypeOption)