@@ -6,11 +6,11 @@ class ControlRenderer extends ScatterplotRenderer {
66 timeScale = 'linear' ;
77 connectDots = false ;
88
9- constructor ( data , avgMovingRange , chartName ) {
9+ constructor ( data , avgMovingRangeFunc , chartName ) {
1010 super ( data ) ;
1111 this . chartName = chartName ;
1212 this . chartType = 'CONTROL' ;
13- this . avgMovingRange = avgMovingRange ;
13+ this . avgMovingRangeFunc = avgMovingRangeFunc ;
1414 this . dotClass = 'control-dot' ;
1515 this . yAxisLabel = 'Days' ;
1616 }
@@ -27,6 +27,7 @@ class ControlRenderer extends ScatterplotRenderer {
2727 drawGraphLimits ( yScale ) {
2828 this . drawHorizontalLine ( yScale , this . topLimit , 'purple' , 'top-pb' , `UPL=${ this . topLimit } ` ) ;
2929 this . drawHorizontalLine ( yScale , this . avgLeadTime , 'orange' , 'mid-pb' , `Avg=${ this . avgLeadTime } ` ) ;
30+
3031 if ( this . bottomLimit > 0 ) {
3132 this . drawHorizontalLine ( yScale , this . bottomLimit , 'purple' , 'bottom-pb' , `LPL=${ this . bottomLimit } ` ) ;
3233 } else {
@@ -36,9 +37,10 @@ class ControlRenderer extends ScatterplotRenderer {
3637
3738 computeGraphLimits ( ) {
3839 this . avgLeadTime = this . getAvgLeadTime ( ) ;
39- this . topLimit = Math . ceil ( this . avgLeadTime + this . avgMovingRange * 2.66 ) ;
40+ const avgMovingRange = this . avgMovingRangeFunc ( this . baselineStartDate , this . baselineEndDate ) ;
41+ this . topLimit = Math . ceil ( this . avgLeadTime + avgMovingRange * 2.66 ) ;
4042
41- this . bottomLimit = Math . ceil ( this . avgLeadTime - this . avgMovingRange * 2.66 ) ;
43+ this . bottomLimit = Math . ceil ( this . avgLeadTime - avgMovingRange * 2.66 ) ;
4244 const maxY = this . y . domain ( ) [ 1 ] > this . topLimit ? this . y . domain ( ) [ 1 ] : this . topLimit + 5 ;
4345 let minY = this . y . domain ( ) [ 0 ] ;
4446 if ( this . bottomLimit > 5 ) {
@@ -106,6 +108,7 @@ class ControlRenderer extends ScatterplotRenderer {
106108 . y ( ( d ) => this . applyYScale ( this . currentYScale , d . leadTime ) ) ;
107109 this . chartArea . selectAll ( '.dot-line' ) . attr ( 'd' , line ) ;
108110 }
111+ this . computeGraphLimits ( ) ;
109112 this . drawGraphLimits ( this . currentYScale ) ;
110113 this . displayObservationMarkers ( this . observations ) ;
111114 }
0 commit comments