diff --git a/src/views/detections/options/detectionOptions.js b/src/views/detections/options/detectionOptions.js index 1cec708c..3572cacd 100644 --- a/src/views/detections/options/detectionOptions.js +++ b/src/views/detections/options/detectionOptions.js @@ -4,6 +4,7 @@ import { import unitConvert from '@/utils/unit-convert' import _ from 'lodash' import { dateFormatByAppearance } from '@/utils/date-util' +import { unitTypes } from '@/utils/constants' const severitySeriesIndexMappings = [ { value: 'critical', index: '0' }, @@ -301,9 +302,16 @@ export const metricOption = { str += ` ${item.seriesName} ` - str += ` - ${unitConvert(item.data[1], item.data[2]).join(' ')} + if (item.seriesName === 'dns response time') { + str += ` + ${unitConvert(item.data[1], unitTypes.time).join(' ')} ` + } else { + str += ` + ${unitConvert(item.data[1], unitTypes.percent, '', '', 0).join(' ')} + ` + } + str += '' return str }, @@ -335,7 +343,7 @@ export const metricOption = { }, series: [ { - name: 'metric', + name: 'http error ratio', type: 'line', legendHoverLink: false, lineStyle: { @@ -347,7 +355,7 @@ export const metricOption = { showSymbol: false }, { - name: 'metric', + name: 'http error ratio', type: 'line', legendHoverLink: false, lineStyle: { @@ -362,7 +370,7 @@ export const metricOption = { showSymbol: false }, { - name: 'metric', + name: 'http error ratio', type: 'line', legendHoverLink: false, lineStyle: { diff --git a/src/views/detections/overview/DetectionPerformanceEventIpOverview.vue b/src/views/detections/overview/DetectionPerformanceEventIpOverview.vue index 60b82e64..fb759428 100644 --- a/src/views/detections/overview/DetectionPerformanceEventIpOverview.vue +++ b/src/views/detections/overview/DetectionPerformanceEventIpOverview.vue @@ -54,7 +54,7 @@
{{$t('detections.metric')}}
-
{{detection.eventType || '-'}}
+
{{getNameByType(detection.eventType) || '-'}}
@@ -155,7 +155,6 @@ export default { }, 250) }) }, - initChart () { this.metricChart = markRaw(echarts.init(document.getElementById(`detectionMetricChartIp${this.detection.serverIp}`))) this.chartOptionMetric = _.cloneDeep(this.chartOption) @@ -174,10 +173,11 @@ export default { this.chartOptionMetric.series[1].data = this.metricList.slice(startIndex - 1, endIndex).map(v => [Number(v[0]) * 1000, Number(v[1]), unitTypes.number]) this.chartOptionMetric.series[2].data = this.metricList.slice(endIndex - 1, this.metricList.length).map(v => [Number(v[0]) * 1000, Number(v[1]), unitTypes.number]) } - + this.chartOptionMetric.series.forEach(item => { + item.name = this.getNameByType(this.detection.eventType) + }) this.chartOptionMetric && this.metricChart.setOption(this.chartOptionMetric) }, - queryMetric () { return new Promise((resolve, reject) => { try { @@ -214,7 +214,6 @@ export default { } }) }, - queryBasic () { return new Promise((resolve, reject) => { try { @@ -237,6 +236,25 @@ export default { } }) window.open(href, '_blank') + }, + /** + * 通过事件类型转换对应名称 + * @param type + * @returns {string} + */ + getNameByType (type) { + switch (type) { + case 'http error': { + return 'http error ratio' + } + case 'dns error': { + return 'dns error ratio' + } + case 'high dns response time': + default: { + return 'dns response time' + } + } } }, mounted () {