@@ -218,12 +218,12 @@ const loadCharts = async () => {
218
218
}
219
219
} ]
220
220
221
- let options = getLineBarChartOptions ( [ ] , series [ my_series ] . labels , data_series , 'Time' , series [ my_series ] . unit , 'category' , null , false , null , true , false ) ;
221
+ let options = getLineBarChartOptions ( [ ] , series [ my_series ] . labels , data_series , 'Time' , series [ my_series ] . unit , 'category' , null , false , null , true , false , true ) ;
222
222
223
223
options . tooltip = {
224
224
trigger : 'item' ,
225
225
formatter : function ( params , ticket , callback ) {
226
- if ( params . componentType != 'series' ) return ; // no notes for the MovingAverage
226
+ if ( series [ params . seriesName ] ?. notes == null ) return ; // no notes for the MovingAverage
227
227
return `<strong>${ series [ params . seriesName ] . notes [ params . dataIndex ] . run_name } </strong><br>
228
228
date: ${ series [ params . seriesName ] . notes [ params . dataIndex ] . created_at } <br>
229
229
metric_name: ${ params . seriesName } <br>
@@ -243,9 +243,31 @@ const loadCharts = async () => {
243
243
244
244
} ) ;
245
245
246
+ options . dataZoom = {
247
+ show : false ,
248
+ start : 0 ,
249
+ end : 100 ,
250
+ } ;
251
+
246
252
247
253
chart_instance . setOption ( options ) ;
248
254
chart_instances . push ( chart_instance ) ;
255
+ chart_instance . on ( 'datazoom' , function ( e , f ) {
256
+ const data = chart_instance . getOption ( ) . series [ 0 ] . data
257
+ const dataZoomOption = chart_instance . getOption ( ) . dataZoom [ 0 ] ;
258
+ const startPercent = dataZoomOption . start ;
259
+ const endPercent = dataZoomOption . end ;
260
+ const totalDataPoints = data . length ;
261
+ const startIndex = Math . floor ( startPercent / 100 * totalDataPoints ) ;
262
+ const endIndex = Math . ceil ( endPercent / 100 * totalDataPoints ) - 1 ;
263
+ const { mean, stddev } = calculateStatistics ( data . slice ( startIndex , endIndex + 1 ) ) ;
264
+
265
+ let options = chart_instance . getOption ( )
266
+ options . series [ 2 ] . markArea . data [ 0 ] [ 0 ] . name = `StdDev: ${ ( stddev / mean * 100 ) . toFixed ( 2 ) } %`
267
+ options . series [ 2 ] . markArea . data [ 0 ] [ 0 ] . yAxis = mean + stddev
268
+ options . series [ 2 ] . markArea . data [ 0 ] [ 1 ] . yAxis = mean - stddev ;
269
+ chart_instance . setOption ( options )
270
+ } ) ;
249
271
250
272
}
251
273
0 commit comments