NEZ-1544 fix:average添加后没有数据
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<div :title="item.alias ? item.alias : item.name" class="legend--table-cell">
|
||||
<span :style="{background: item.color}" class="legend-shape"></span>{{item.alias ? item.alias : item.name}}
|
||||
</div>
|
||||
<div v-for="(statistics, index) in item.statistics" :key="index" :class="{'legend-item--inactive': isGrey[index]}" class="legend--table-cell">{{statistics.value}}</div>
|
||||
<div v-for="(statistics, index) in item.statistics" :key="index" :class="{'legend-item--inactive': isGrey[index]}" class="legend--table-cell">{{(keepTwoDecimalFull(statistics.value))}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -194,6 +194,25 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
// 四舍五入保留2位小数(不够位数,则用0替补)
|
||||
keepTwoDecimalFull (num) {
|
||||
let result = parseFloat(num)
|
||||
if (isNaN(result)) {
|
||||
return '--'
|
||||
}
|
||||
// result = Math.round(num * 100) / 100
|
||||
// let decimal = result.toString()
|
||||
// let posDecimal = decimal.indexOf('.')
|
||||
// if (posDecimal < 0) {
|
||||
// posDecimal = decimal.length
|
||||
// decimal += '.'
|
||||
// }
|
||||
// while (decimal.length <= posDecimal + 2) {
|
||||
// decimal += '0'
|
||||
// }
|
||||
result = chartDataFormat.getUnit(this.chartInfo.unit ? this.chartInfo.unit : 2).compute(result, null, -1, 2)
|
||||
return result
|
||||
},
|
||||
getMaxValue (dataArg, chartInfo) {
|
||||
let maxValue = 0
|
||||
let minValue = 0
|
||||
|
||||
@@ -18,11 +18,11 @@ function short (value, index, type = 1, dot) {
|
||||
}
|
||||
}
|
||||
function percent01 (value, index) {
|
||||
value = parseFloat((Number(value)).toPrecision(12))
|
||||
value = parseFloat((Number(value)).toFixed(2))
|
||||
return `${value} %`
|
||||
}
|
||||
function percent02 (value, index) {
|
||||
value = parseFloat((Number(value) * 100).toPrecision(12))
|
||||
value = parseFloat((Number(value) * 100).toFixed(2))
|
||||
return `${value} %`
|
||||
}
|
||||
function localFormat (value, index) {
|
||||
|
||||
@@ -811,7 +811,7 @@ export function getMetricTypeValue (queryItem, type) {
|
||||
const max = copy.sort((x, y) => { return parseFloat(y[1]) - parseFloat(x[1]) })[0][1]
|
||||
return max
|
||||
}
|
||||
case 'avg': {
|
||||
case 'average': {
|
||||
copy = copy.map(t => parseFloat(t[1]))
|
||||
const sum = eval(copy.join('+'))
|
||||
const avg = sum / copy.length
|
||||
|
||||
Reference in New Issue
Block a user