CN-1456 feat: 折线图参考线等国际化

This commit is contained in:
chenjinsong
2023-11-21 14:33:16 +08:00
parent 6c1f1ed71b
commit e26d2b40ab
6 changed files with 34 additions and 14 deletions

View File

@@ -80,15 +80,15 @@ export const dataForNetworkOverviewLine = {
options2: [ options2: [
{ {
value: 'Average', value: 'Average',
label: 'Average' label: 'overall.average'
}, },
{ {
value: '95th Percentile', value: '95th Percentile',
label: '95th Percentile' label: ['overall.percentileNumber', { number: 95 }]
}, },
{ {
value: 'Maximum', value: 'Maximum',
label: 'Maximum' label: 'overall.maximum'
} }
], ],
tabsTemplate: [ tabsTemplate: [
@@ -200,15 +200,15 @@ export const dataForDnsTrafficLine = {
options2: [ options2: [
{ {
value: 'Average', value: 'Average',
label: 'Average' label: 'overall.average'
}, },
{ {
value: '95th Percentile', value: '95th Percentile',
label: '95th Percentile' label: ['overall.percentileNumber', { number: 95 }]
}, },
{ {
value: 'Maximum', value: 'Maximum',
label: 'Maximum' label: 'overall.maximum'
} }
], ],
tabs: [ tabs: [

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="panel-box2" :class="{'panel-box2--entity-detail': entity && entity.entityType}"> <div class="panel-box2" :class="{'panel-box2--entity-detail': entity && entity.entityType}">
<div class="panel__header" v-if="!entity"> <div class="panel__header" v-if="!entity">
<div class="panel__title">{{panelName?panelName:(panel.i18n ? $t(panel.i18n) : panel.name)}} <div class="panel__title">{{panelName ? panelName:(panel.i18n ? $t(panel.i18n) : panel.name)}}
<div v-if="showScore" class="score"> <div v-if="showScore" class="score">
<div class="circle-icon" v-if="score <= 2 || score === '-'" :class="{'data-score-red': score <= 2 || score === '-'}" ></div> <div class="circle-icon" v-if="score <= 2 || score === '-'" :class="{'data-score-red': score <= 2 || score === '-'}" ></div>
<div class="circle-icon" v-else-if="score <= 4" :class="{'data-score-yellow': score <= 4}" ></div> <div class="circle-icon" v-else-if="score <= 4" :class="{'data-score-yellow': score <= 4}" ></div>
@@ -31,7 +31,7 @@
@change="metricChange" @change="metricChange"
> >
<template #prefix> <template #prefix>
<span class="select-prefix">Metric:</span> <span class="select-prefix">{{$t('detections.metric')}}:</span>
</template> </template>
<el-option v-for="item in metricOptions" :key="item.value" :label="item.label" :value="item.value"></el-option> <el-option v-for="item in metricOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select> </el-select>

View File

@@ -43,7 +43,7 @@
</div> </div>
</div>--> </div>-->
<div class="line-select-reference-line"> <div class="line-select-reference-line">
<span>{{$t('network.referenceLine')}}:</span> <span>{{$t('network.referenceLine')}}&nbsp;:&nbsp;</span>
<div class="line-select__operation"> <div class="line-select__operation">
<el-select <el-select
size="mini" size="mini"
@@ -54,7 +54,9 @@
:popper-append-to-body="false" :popper-append-to-body="false"
@change="referenceSelectChange" @change="referenceSelectChange"
> >
<el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value"></el-option> <el-option :key="options2[0].value" :label="$t(options2[0].label)" :value="options2[0].value"></el-option>
<el-option :key="options2[1].value" :label="$t(options2[1].label[0], options2[1].label[1])" :value="options2[1].value"></el-option>
<el-option :key="options2[2].value" :label="$t(options2[2].label)" :value="options2[2].value"></el-option>
</el-select> </el-select>
</div> </div>
</div> </div>
@@ -255,6 +257,14 @@ export default {
label: { label: {
formatter (params) { formatter (params) {
const arr = unitConvert(params.value, unitTypes.number).join('') const arr = unitConvert(params.value, unitTypes.number).join('')
const referIndex = _this.options2.findIndex(o => o.value === _this.lineRefer)
if (referIndex > -1) {
if (referIndex === 1) {
return _this.$t(_this.options2[1].label[0], _this.options2[1].label[1]) + '(' + arr + echartsData[0].unitType + ')'
} else {
return _this.$t(_this.options2[referIndex].label) + '(' + arr + echartsData[0].unitType + ')'
}
}
return _this.lineRefer + '(' + arr + echartsData[0].unitType + ')' return _this.lineRefer + '(' + arr + echartsData[0].unitType + ')'
}, },
position: 'insideStartTop', position: 'insideStartTop',

View File

@@ -37,7 +37,7 @@
</div> </div>
<div class="line-select line-header-right"> <div class="line-select line-header-right">
<div class="line-select-metric"> <div class="line-select-metric">
<span>{{$t('network.metric')}}:</span> <span>{{$t('detections.metric')}}:</span>
<div class="line-select__operation"> <div class="line-select__operation">
<el-select <el-select
size="mini" size="mini"

View File

@@ -32,7 +32,7 @@
</div> </div>
<div class="line-select line-header-right"> <div class="line-select line-header-right">
<div class="line-select-reference-line"> <div class="line-select-reference-line">
<span>{{ $t('network.referenceLine') }}:</span> <span>{{ $t('network.referenceLine') }}&nbsp;:&nbsp;</span>
<div class="line-select__operation"> <div class="line-select__operation">
<el-select <el-select
size="mini" size="mini"
@@ -43,7 +43,9 @@
:popper-append-to-body="false" :popper-append-to-body="false"
@change="referenceSelectChange" @change="referenceSelectChange"
> >
<el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value"></el-option> <el-option :key="options2[0].value" :label="$t(options2[0].label)" :value="options2[0].value"></el-option>
<el-option :key="options2[1].value" :label="$t(options2[1].label[0], options2[1].label[1])" :value="options2[1].value"></el-option>
<el-option :key="options2[2].value" :label="$t(options2[2].label)" :value="options2[2].value"></el-option>
</el-select> </el-select>
</div> </div>
</div> </div>
@@ -274,6 +276,14 @@ export default {
label: { label: {
formatter (params) { formatter (params) {
const arr = valueToRangeValue(params.value, unitTypes.number).join('') const arr = valueToRangeValue(params.value, unitTypes.number).join('')
const referIndex = _this.options2.findIndex(o => o.value === _this.lineRefer)
if (referIndex > -1) {
if (referIndex === 1) {
return _this.$t(_this.options2[1].label[0], _this.options2[1].label[1]) + '(' + arr + echartsData[0].unitType + ')'
} else {
return _this.$t(_this.options2[referIndex].label) + '(' + arr + echartsData[0].unitType + ')'
}
}
return _this.lineRefer + '(' + arr + echartsData[0].unitType + ')' return _this.lineRefer + '(' + arr + echartsData[0].unitType + ')'
}, },
position: 'insideStartTop', position: 'insideStartTop',

View File

@@ -3,7 +3,7 @@
<div class="npm-traffic-line-header"> <div class="npm-traffic-line-header">
<div class="npm-traffic-line-title"></div> <div class="npm-traffic-line-title"></div>
<div class="line-select-metric"> <div class="line-select-metric">
<span>{{$t('network.metric')}}:</span> <span>{{$t('detections.metric')}}:</span>
<div class="line-select__operation"> <div class="line-select__operation">
<el-select <el-select
size="mini" size="mini"