@@ -38,21 +38,40 @@ export class DailyActivityChartComponent implements OnInit, OnChanges {
3838 '.COM Chats' : this . targets ?. user . dailyDotComChats . target || 0
3939 } ;
4040
41+ // NEW: mapping for typical ranges (from, to)
42+ const typicalRangeMapping : Record < string , [ number , number ] > = {
43+ 'IDE Suggestions' : [ 50 , 90 ] ,
44+ 'IDE Accepts' : [ 20 , 40 ] ,
45+ 'IDE Chats' : [ 25 , 40 ] ,
46+ '.COM Chats' : [ 4 , 8 ]
47+ } ;
48+
49+ // the code below is to set the target line on the chart, based on the series name
50+ // and the target value from the targets service. Target line only shows if the series is visible and other series are not
4151 let newTarget = 1000 ;
52+ let newTypicalFrom = 50 ;
53+ let newTypicalTo = 90 ;
4254 const visibleSeries = this . chart . series . filter ( s => s . visible ) ;
4355
4456 if ( visibleSeries . length === 1 ) {
4557 const series = visibleSeries [ 0 ] ;
4658 if ( series . name && targetMapping [ series . name ] ) {
4759 newTarget = targetMapping [ series . name ] ;
4860 }
61+ // NEW: select typical range limits
62+ if ( series . name && typicalRangeMapping [ series . name ] ) {
63+ [ newTypicalFrom , newTypicalTo ] = typicalRangeMapping [ series . name ] ;
64+ }
4965 }
5066
5167 // Use chart instance to access yAxis
5268 const yAxis = this . chart . yAxis [ 0 ] ;
5369 const plotLineId = 'target-line' ;
70+ const plotBandId = 'typical-range' ;
5471
5572 yAxis . removePlotLine ( plotLineId ) ;
73+ yAxis . removePlotBand ?.( plotBandId ) ;
74+
5675 yAxis . addPlotLine ( {
5776 id : plotLineId ,
5877 value : newTarget ,
@@ -68,26 +87,42 @@ export class DailyActivityChartComponent implements OnInit, OnChanges {
6887 } ,
6988 zIndex : 2
7089 } ) ;
90+
91+ // also show typical range band only when one series is visible
92+ if ( visibleSeries . length === 1 ) {
93+ yAxis . addPlotBand ( {
94+ id : plotBandId ,
95+ from : newTypicalFrom ,
96+ to : newTypicalTo ,
97+ color : 'var(--sys-surface-variant)' ,
98+ label : {
99+ text : 'Typical Range' ,
100+ style : { color : 'var(--sys-on-surface-variant)' }
101+ } ,
102+ zIndex : 1
103+ } ) ;
104+
105+ // NEW: tighten y-axis max for the lone series
106+ const dataMax = Math . max (
107+ ...visibleSeries [ 0 ] . data . filter ( v => typeof v === 'number' ) as number [ ]
108+ ) ;
109+ const proposedMax = Math . max ( dataMax , newTarget , newTypicalTo ) * 1.15 ; // 15 % head-room
110+
111+ yAxis . setExtremes ( undefined , proposedMax , false ) ;
112+ } else {
113+ // reset to auto when multiple series are active
114+ yAxis . setExtremes ( undefined , undefined , false ) ;
115+ }
71116 }
72117 }
73118 } ,
74119 yAxis : {
75120 title : {
76- text : 'Daily Activity Per Avg User'
121+ text : 'Daily Activity (per Avg User) '
77122 } ,
78123 min : 0 ,
79- maxPadding : 1.7 ,
80- plotBands : [ {
81- from : 500 ,
82- to : 750 ,
83- color : 'var(--sys-surface-variant)' ,
84- label : {
85- text : 'Typical Range' ,
86- style : {
87- color : 'var(--sys-on-surface-variant)'
88- }
89- }
90- } ]
124+ maxPadding : 0.2 , // was 1.2 – shrink default empty space
125+ plotBands : [ ] // start with no typical-range band
91126 } ,
92127 tooltip : {
93128 headerFormat : '<b>{point.x:%b %d, %Y}</b><br/>' ,
0 commit comments