@@ -48,6 +48,9 @@ export class WidgetLinechart extends LitElement {
4848 @property ( { type : Object } )
4949 theme ?: Theme
5050
51+ @property ( { type : Object } )
52+ timeRange ?: { start : number ; end : number }
53+
5154 @state ( )
5255 private canvasList : Map <
5356 string ,
@@ -463,16 +466,25 @@ export class WidgetLinechart extends LitElement {
463466 option . xAxis . type = this . xAxisType ( )
464467 option . xAxis . show = showXAxis
465468 if ( this . xAxisType ( ) === 'time' ) {
466- const axisMax = chart . series . map ( ( s ) => s . maxDate ?? 0 ) . reduce ( ( a , b ) => Math . max ( a , b ) , 0 )
467- const axisMin = chart . series
469+ // Use provided timeRange if available and valid, otherwise calculate from data
470+ const dataMin = chart . series
468471 . map ( ( s ) => s . minDate ?? Infinity )
469472 . reduce ( ( a , b ) => Math . min ( a , b ) , Infinity )
473+ const dataMax = chart . series . map ( ( s ) => s . maxDate ?? 0 ) . reduce ( ( a , b ) => Math . max ( a , b ) , 0 )
474+
475+ const timeRangeStart = Number ( this . timeRange ?. start )
476+ const timeRangeEnd = Number ( this . timeRange ?. end )
477+
478+ const axisMin = ! isNaN ( timeRangeStart ) ? timeRangeStart : dataMin
479+ const axisMax = ! isNaN ( timeRangeEnd ) ? timeRangeEnd : dataMax
480+
470481 option . xAxis = {
471482 ...option . xAxis ,
472- min : axisMin ?? new Date ( ) . getTime ( ) - 1 * 24 * 60 * 60 * 1000 ,
473- max : axisMax ?? new Date ( ) . getTime ( )
483+ min : axisMin !== Infinity ? axisMin : new Date ( ) . getTime ( ) - 1 * 24 * 60 * 60 * 1000 ,
484+ max : axisMax !== 0 ? axisMax : new Date ( ) . getTime ( )
474485 }
475486 }
487+
476488 option . dataZoom [ 0 ] . show = this . inputData ?. axis ?. xAxisZoom ?? false
477489 option . toolbox . show = this . inputData ?. axis ?. xAxisZoom ?? false
478490
@@ -484,6 +496,7 @@ export class WidgetLinechart extends LitElement {
484496 option . yAxis . show = showYAxis
485497 option . yAxis . nameLocation = 'end'
486498 option . yAxis . nameGap = 10
499+ option . yAxis . nameTextStyle = { align : 'left' }
487500 option . yAxis . axisLine = { show : true }
488501 if ( [ 'value' , 'log' ] . includes ( option . yAxis . type ) )
489502 option . yAxis . axisLabel = {
@@ -511,7 +524,7 @@ export class WidgetLinechart extends LitElement {
511524 }
512525
513526 // Calculate animation duration based on update frequency
514- const animationDuration = this . calculateAnimationDuration ( chart , label )
527+ const animationDuration = this . updateThresholdMs //this. calculateAnimationDuration(chart, label)
515528 option . animation = true
516529 option . animationEasing = 'linear'
517530 option . animationDuration = animationDuration
0 commit comments