Merge branch 'cherry-pick-fc56a1fc' into 'dev'

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

See merge request cyber-narrator/cn-ui!41
This commit is contained in:
陈劲松
2023-09-28 05:25:06 +00:00

View File

@@ -464,8 +464,7 @@ export default {
newData.push(obj) newData.push(obj)
}) })
} }
if (data && data.length > 0) {
if (data !== undefined && data.length > 0) {
newData.forEach((item) => { newData.forEach((item) => {
item.type = getLineType(item.type) item.type = getLineType(item.type)
if (item.type === val) { if (item.type === val) {
@@ -478,6 +477,24 @@ export default {
}) })
} }
lineData.splice(0, 1) 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') { if (val === 'Sessions/s') {
const tabs = _.cloneDeep(this.tabsTemplate) const tabs = _.cloneDeep(this.tabsTemplate)
lineData.forEach((d, i) => { lineData.forEach((d, i) => {