Merge pull request #1557 from ZhaoYandong00/patch-3

修复无法单独选择显示下载上传网络速率问题
pull/1560/head
648540858 2024-08-04 20:36:50 +08:00 committed by GitHub
commit 241e29f705
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 44 additions and 2 deletions

View File

@ -1,6 +1,6 @@
<template>
<div id="ConsoleNet" style="width: 100%; height: 100%; background: #FFFFFF; text-align: center">
<ve-line ref="ConsoleNet" :data="chartData" :extend="extend" :settings="chartSettings" width="100%" height="100%" ></ve-line>
<ve-line ref="ConsoleNet" :data="chartData" :extend="extend" :settings="chartSettings" :events="chartEvents" width="100%" height="100%" ></ve-line>
</div>
</template>
@ -59,12 +59,54 @@ export default {
tooltip: {
trigger: 'axis',
formatter: (data)=>{
return data[1].marker + "下载:" + parseFloat(data[1].data[1]).toFixed(2) + "Mbps" + "</br> "+ data[0].marker +" 上传:" + parseFloat(data[0].data[1]).toFixed(2) + "Mbps";
let in_sel = true;
let out_sel = true;
for (let key in this.extend.legend.selected) {
if (key == "上传") {
out_sel = this.extend.legend.selected[key];
}
if (key == "下载") {
in_sel = this.extend.legend.selected[key];
}
}
if (out_sel && in_sel) {
return (
data[1].marker +
"下载:" +
parseFloat(data[1].data[1]).toFixed(2) +
"Mbps" +
"</br> " +
data[0].marker +
"上传:" +
parseFloat(data[0].data[1]).toFixed(2) +
"Mbps"
);
} else if (out_sel)
return (
data[0].marker +
"上传:" +
parseFloat(data[0].data[1]).toFixed(2) +
"Mbps"
);
else if (in_sel)
return (
data[0].marker +
"下载:" +
parseFloat(data[0].data[1]).toFixed(2) +
"Mbps"
);
return "";
}
},
legend: {
left: "center",
bottom: "15px",
selected: {},
}
}
chartEvents: {
legendselectchanged: (item) => {
this.extend.legend.selected = item.selected;
}
}
};