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

View File

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