11import { timeParse } from '@/utils' ;
22
3- export const getRangeOptions = ( { core = [ ] , memory = [ ] } , t = ( v ) => v ) => {
3+ export const getRangeOptions = ( { allocation = [ ] , usage = [ ] } , t = ( v ) => v ) => {
4+ const xDataSource = allocation ?. length ? allocation : usage ;
45 return {
56 legend : {
6- bottom : 0 ,
7- orient : 'horizontal ' ,
7+ bottom : 10 ,
8+ left : 'center ' ,
89 } ,
910 tooltip : {
1011 trigger : 'axis' ,
1112 axisPointer : {
1213 type : 'cross' ,
1314 } ,
1415 formatter : function ( params ) {
16+ if ( ! params || params . length === 0 ) return '' ;
1517 var res = params [ 0 ] . name + '<br/>' ;
1618 for ( var i = 0 ; i < params . length ; i ++ ) {
1719 res +=
1820 params [ i ] . marker +
1921 params [ i ] . seriesName +
2022 ' : ' +
2123 ( + params [ i ] . value ) . toFixed ( 0 ) +
22- `% <br/>` ;
24+ ' <br/>' ;
2325 }
2426
2527 return res ;
@@ -28,12 +30,12 @@ export const getRangeOptions = ({ core = [], memory = [] }, t = (v) => v) => {
2830 grid : {
2931 top : 20 , // 上边距
3032 bottom : 60 , // 下边距
31- left : '8 %' , // 左边距
33+ left : '7 %' , // 左边距
3234 right : 10 , // 右边距
3335 } ,
3436 xAxis : {
3537 type : 'category' ,
36- data : core . map ( ( item ) => timeParse ( + item . timestamp ) ) ,
38+ data : xDataSource . map ( ( item ) => timeParse ( + item . timestamp ) ) ,
3739 axisLabel : {
3840 formatter : function ( value ) {
3941 return timeParse ( value , 'HH:mm' ) ;
@@ -44,31 +46,31 @@ export const getRangeOptions = ({ core = [], memory = [] }, t = (v) => v) => {
4446 type : 'value' ,
4547 axisLabel : {
4648 formatter : function ( value ) {
47- return `${ value } % ` ;
49+ return `${ value } ` ;
4850 } ,
4951 } ,
5052 } ,
5153 series : [
5254 {
53- name : t ( 'dashboard.compute ' ) ,
54- data : core ,
55+ name : t ( 'dashboard.allocRateLegend ' ) ,
56+ data : allocation ,
5557 type : 'line' ,
5658 itemStyle : {
57- color : 'rgb(84, 112, 198)' , // 设置线条颜色为橙色
59+ color : 'rgb(84, 112, 198)' ,
5860 } ,
5961 lineStyle : {
60- color : 'rgb(84, 112, 198)' , // 设置线条颜色为橙色
62+ color : 'rgb(84, 112, 198)' ,
6163 } ,
6264 } ,
6365 {
64- name : t ( 'dashboard.memory ' ) ,
65- data : memory ,
66+ name : t ( 'dashboard.usageRateLegend ' ) ,
67+ data : usage ,
6668 type : 'line' ,
6769 itemStyle : {
68- color : 'rgb(145, 204, 117)' , // 设置线条颜色为橙色
70+ color : 'rgb(145, 204, 117)' ,
6971 } ,
7072 lineStyle : {
71- color : 'rgb(145, 204, 117)' , // 设置线条颜色为橙色
73+ color : 'rgb(145, 204, 117)' ,
7274 } ,
7375 } ,
7476 ] ,
0 commit comments