fix: networkoverview的曲线图去掉尾部最多4个0值点

This commit is contained in:
chenjinsong
2023-09-28 13:23:28 +08:00
parent ccd2b3d08b
commit fc56a1fc0c

View File

@@ -464,8 +464,7 @@ export default {
newData.push(obj)
})
}
if (data !== undefined && data.length > 0) {
if (data && data.length > 0) {
newData.forEach((item) => {
item.type = getLineType(item.type)
if (item.type === val) {
@@ -478,6 +477,24 @@ export default {
})
}
lineData.splice(0, 1)
// TODO 下面的逻辑是判断total曲线的尾部数据从尾往前数0值的个数若个数大于0所有曲线都从尾部去掉相同数量的点最多4个
const totalData = lineData[0]
if (totalData.values.length > 4) {
let count = 0
for (let i = totalData.values.length - 1; i >= totalData.values.length - 4; i--) {
if (totalData.values[i].length > 1 && totalData.values[i][1] === 0) {
count++
} else {
break
}
}
if (count > 0) {
lineData.forEach(l => {
l.values.splice(l.values.length - count, count)
})
}
}
if (val === 'Sessions/s') {
const tabs = _.cloneDeep(this.tabsTemplate)
lineData.forEach((d, i) => {