fix: bug#19087

This commit is contained in:
XieYongHong 2023-10-19 18:08:56 +08:00
parent 283baa6816
commit 564ab3a0ea
2 changed files with 16 additions and 8 deletions

View File

@ -395,6 +395,7 @@ const setDevMesChartOption = (
y: Array<number>,
maxY: number,
): void => {
const yLen = String(Math.ceil(maxY)).length
devMegOptions.value = {
xAxis: {
type: 'category',
@ -412,7 +413,7 @@ const setDevMesChartOption = (
grid: {
top: '2%',
bottom: '5%',
left: maxY > 100000 ? '50px' : '70px',
left: maxY < 900000 ? '60px' : (yLen * 7.5 + Math.floor(yLen/3) * 1.2 + 10) + 'px',
right: '50px',
},
series: [
@ -596,8 +597,9 @@ const getEcharts = (data: any) => {
const y = res.result.map((item: any) => item.data.value).reverse();
const maxY = Math.max.apply(
null,
messageChartYData.value.length ? messageChartYData.value : [0],
y.length ? y : [0],
);
setDevMesChartOption(x, y, maxY);
}
});
@ -623,4 +625,4 @@ getDevice();
height: 500px;
width: 100%;
}
</style>
</style>

View File

@ -111,7 +111,7 @@ const pickerTimeChange = (value: any) => {
};
const changeType = (value:any) =>{
getNetworkEcharts(data.value);
}
}
const getNetworkEcharts = async (val: any) => {
loading.value = true;
const resp: any = await dashboard(networkParams(val));
@ -149,10 +149,16 @@ const getNetworkEcharts = async (val: any) => {
const formatterData = (value: any) => {
let _data = '';
if (value >= 1024 && value < 1024 * 1024) {
_data = `${Number((value / 1024).toFixed(2))}KB`;
} else if (value >= 1024 * 1024) {
_data = `${Number((value / 1024 / 1024).toFixed(2))}M`;
const kb = 1024
const mb = kb**2
const gb = kb**3
if (value >= kb && value < mb) {
_data = `${Number((value / kb).toFixed(2))}KB`;
} else if (value >= mb && value < gb) {
_data = `${Number((value / mb).toFixed(2))}M`;
} else if (value >= gb) {
_data = `${Number((value / gb).toFixed(2))}G`;
} else {
_data = `${value}B`;
}