@@ -219,28 +219,51 @@ export const getTopOptions = ({ core, memory }) => {
219219 } ;
220220} ;
221221
222- export const getLineOptions = ( { data = [ ] , unit = '%' } ) => {
222+ export const getLineOptions = ( { data = [ ] , unit = '%' , seriesName , animation = true } ) => {
223223 return {
224+ animation,
224225 tooltip : {
225226 trigger : 'axis' ,
226227 axisPointer : {
227- type : 'cross' ,
228+ type : 'line' ,
229+ lineStyle : {
230+ type : 'dashed' ,
231+ color : '#8A8A8A' ,
232+ } ,
228233 } ,
229234 formatter : function ( params ) {
230- var res = params [ 0 ] . name + '<br/>' ;
231- for ( var i = 0 ; i < params . length ; i ++ ) {
232- res +=
233- params [ i ] . marker + ( + params [ i ] . value ) . toFixed ( 0 ) + ` ${ unit } <br/>` ;
235+ if ( ! Array . isArray ( params ) || params . length === 0 ) return '' ;
236+
237+ let result = `<div style="margin-bottom:5px;">${ params [ 0 ] ?. name ?? '' } </div>` ;
238+ for ( let i = 0 ; i < params . length ; i ++ ) {
239+ const item = params [ i ] ;
240+ const raw = Array . isArray ( item ?. value ) ? item . value [ item . value . length - 1 ] : item ?. value ;
241+ const num = Number ( raw ) ;
242+ const value = Number . isFinite ( num ) ? `${ num . toFixed ( 1 ) } ${ unit } ` : '-' ;
243+ result += `
244+ <div style="display:flex;align-items:center;font-size:14px;line-height:22px;">
245+ <span style="display:inline-block;width:10px;height:10px;border-radius:50%;background-color:${ item ?. color || '#5B8FF9' } ;margin-right:5px;"></span>
246+ <span>${ item ?. seriesName || '-' } : </span>
247+ <span style="font-weight:bold;">${ value } </span>
248+ </div>
249+ ` ;
234250 }
235- return res ;
251+ return result ;
236252 } ,
237253 } ,
238254 grid : {
239- top : 7 , // 上边距
240- bottom : 20 , // 下边距
241- left : '7%' , // 左边距
242- right : 10 , // 右边距
255+ top : 20 , // 上边距
256+ bottom : 30 , // 下边距
257+ left : 30 , // 左边距
258+ right : 30 , // 右边距
243259 } ,
260+ dataZoom : [
261+ {
262+ type : 'inside' ,
263+ xAxisIndex : 0 ,
264+ filterMode : 'none' ,
265+ } ,
266+ ] ,
244267 xAxis : {
245268 type : 'category' ,
246269 data : data . map ( ( item ) => timeParse ( + item . timestamp ) ) ,
@@ -255,10 +278,19 @@ export const getLineOptions = ({ data = [], unit = '%' }) => {
255278 } ,
256279 series : [
257280 {
281+ name : seriesName || '' ,
258282 data : data . map ( ( item ) => {
259283 return item . value . toFixed ( 1 ) ;
260284 } ) ,
261285 type : 'line' ,
286+ lineStyle : {
287+ width : 3 ,
288+ color : '#5B8FF9' ,
289+ } ,
290+ itemStyle : {
291+ color : '#5B8FF9' ,
292+ borderColor : '#5B8FF9' ,
293+ } ,
262294 } ,
263295 ] ,
264296 } ;
0 commit comments