@@ -88,11 +88,12 @@ const MetricGraph = ({ name } : { name: MetricName }) => {
8888 const points = buckets . length > width ? buckets . slice ( buckets . length - width ) : buckets ;
8989 let minPoint : PlotPoint = { x : 0 , y : 0 , value : 0 } ;
9090 let maxPoint : PlotPoint = { x : 0 , y : 99999999 , value : 0 } ;
91+ let lastPoint : PlotPoint = { x : 0 , y : 0 , value : 0 } ;
9192
9293 ctx . lineWidth = 1.5 ;
9394 ctx . strokeStyle = Theme . palette . secondary ;
9495 ctx . beginPath ( ) ;
95- points . forEach ( ( p : DataPoint , i : number ) => {
96+ points . forEach ( ( p : DataPoint , i : number , arr ) => {
9697 const { value } = p ;
9798 const pHeight = ( ( value - minValue ) * height ) / range ;
9899 const x = i ;
@@ -106,6 +107,11 @@ const MetricGraph = ({ name } : { name: MetricName }) => {
106107 }
107108
108109 ctx . lineTo ( x , y ) ;
110+
111+ // Record last value
112+ if ( i === arr . length - 1 ) {
113+ lastPoint = { x, y, value } ;
114+ }
109115 } ) ;
110116 ctx . stroke ( ) ;
111117
@@ -114,6 +120,13 @@ const MetricGraph = ({ name } : { name: MetricName }) => {
114120 ctx . fillStyle = 'white' ;
115121 ctx . fillText ( minPoint . value . toFixed ( 1 ) , minPoint . x + LABEL_OFFSET , minPoint . y - LABEL_OFFSET ) ;
116122 ctx . fillText ( maxPoint . value . toFixed ( 1 ) , maxPoint . x + LABEL_OFFSET , maxPoint . y - LABEL_OFFSET ) ;
123+
124+ // Most recent value
125+ ctx . fillText (
126+ lastPoint . value . toFixed ( 1 ) ,
127+ lastPoint . x + LABEL_OFFSET ,
128+ lastPoint . y - LABEL_OFFSET ,
129+ ) ;
117130 } ;
118131
119132 return fabricate ( 'div' )
0 commit comments