fix: bps改为1000进制
This commit is contained in:
@@ -123,6 +123,7 @@ export const unitTypes = {
|
||||
time: 'time',
|
||||
number: 'number',
|
||||
byte: 'byte',
|
||||
bps: 'bps',
|
||||
string: 'string',
|
||||
percent: 'percent'
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import _ from 'lodash'
|
||||
|
||||
const numberUnit = ['', 'K', 'M', 'G', 'T', 'P', 'E']
|
||||
const byteUnit = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB']
|
||||
const bpsUnit = ['bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps']
|
||||
const timeUnit = [ // 时间单位步进倍数,以ms为基数
|
||||
{ unit: 'ms', step: 1 },
|
||||
{ unit: 's', step: 1000 },
|
||||
@@ -31,7 +32,10 @@ function asciiCompute (num, ascii = 1000, units, dot = 2) {
|
||||
export function numberUnitConvert (value, sourceUnit, targetUnit, dot = 2) {
|
||||
return asciiCompute(value, 1000, numberUnit, dot)
|
||||
}
|
||||
export function byteUnitConvert (value, sourceUnit = 'B', targetUnit, dot = 2) {
|
||||
export function bpsUnitConvert (value, sourceUnit, targetUnit, dot = 2) {
|
||||
return asciiCompute(value, 1000, bpsUnit, dot)
|
||||
}
|
||||
export function byteUnitConvert (value, unitType, sourceUnit = 'B', targetUnit, dot = 2) {
|
||||
return asciiCompute(value, 1024, byteUnit, dot)
|
||||
}
|
||||
/* 时间单位转换,例如将ms转为h */
|
||||
@@ -87,13 +91,21 @@ export default function unitConvert (value, unitType, sourceUnit, targetUnit, do
|
||||
return timeUnitFormatter(value, sourceUnit, targetUnit, dot)
|
||||
}
|
||||
case unitTypes.percent: {
|
||||
return [value, '%']
|
||||
const r = (value * 100).toFixed(dot)
|
||||
if (_.isNaN(r)) {
|
||||
return ['-', '']
|
||||
} else {
|
||||
return [r, '%']
|
||||
}
|
||||
}
|
||||
case unitTypes.number: {
|
||||
return numberUnitConvert(value, sourceUnit, targetUnit, dot)
|
||||
}
|
||||
case unitTypes.bps: {
|
||||
return bpsUnitConvert(value, sourceUnit, targetUnit, dot)
|
||||
}
|
||||
case unitTypes.byte: {
|
||||
return byteUnitConvert(value, sourceUnit, targetUnit, dot)
|
||||
return byteUnitConvert(value, unitType, sourceUnit, targetUnit, dot)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +143,7 @@ export function valueToRangeValue (value, unitType) {
|
||||
}
|
||||
case unitTypes.percent: {
|
||||
if (values[0] < 0.01) {
|
||||
return ['<0.01', '']
|
||||
return ['<0.01', '%']
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -102,11 +102,7 @@ export default {
|
||||
timeFilter: Object, // 时间范围
|
||||
isFullscreen: Boolean,
|
||||
panelLock: Boolean,
|
||||
entity: Object,
|
||||
showHeader: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
entity: Object
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
@@ -163,6 +159,9 @@ export default {
|
||||
},
|
||||
headerHPadding () {
|
||||
return this.$store.getters.getHeaderHPadding
|
||||
},
|
||||
showHeader () {
|
||||
return this.chartInfo.params && this.chartInfo.params.showHeader
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
<panel-chart
|
||||
:ref="'chart' + item.id"
|
||||
:chart-info="item"
|
||||
:show-header="true"
|
||||
:time-filter="timeFilter"
|
||||
:entity="entity"
|
||||
@groupShow="groupShow"
|
||||
|
||||
Reference in New Issue
Block a user