@@ -149,8 +149,8 @@ var ApmDatasource = /** @class */ (function () {
149149 var metrics = { } ;
150150 var legendSeparator = "|" ;
151151 var aggregations = {
152- sum : function ( metricValues ) { return metricValues . reduce ( function ( sum , metricValue ) { return sum += metricValue ; } , 0 ) ; } ,
153- mean : function ( metricValues ) { return metricValues . reduce ( function ( sum , metricValue ) { return sum += metricValue ; } , 0 ) / metricValues . length ; } ,
152+ sum : function ( metricValues ) { return metricValues . reduce ( function ( sum , metricValue ) { return sum += metricValue ; } ) ; } ,
153+ mean : function ( metricValues ) { return metricValues . reduce ( function ( sum , metricValue ) { return sum += metricValue ; } ) / metricValues . length ; } ,
154154 max : function ( metricValues ) { return metricValues . reduce ( function ( a , b ) { return Math . max ( a , b ) ; } ) ; } ,
155155 min : function ( metricValues ) { return metricValues . reduce ( function ( a , b ) { return Math . min ( a , b ) ; } ) ; } ,
156156 median : function ( metricValues ) { return _this . quickselect_median ( metricValues ) ; }
@@ -203,7 +203,7 @@ var ApmDatasource = /** @class */ (function () {
203203 return dataPoints ;
204204 } , [ ] ) ;
205205 // post processing: if configured, aggregate all time series
206- if ( / ^ s u m | m e a n | m a x | m i n | m e d i a n $ / . test ( options . aggregationMode ) ) {
206+ if ( dataPoints . length > 0 && / ^ s u m | m e a n | m a x | m i n | m e d i a n $ / . test ( options . aggregationMode ) ) {
207207 var aggregate = aggregations [ options . aggregationMode ] ( dataPoints . map ( function ( dataPoint ) { return dataPoint . metricValue ; } ) ) ;
208208 dataPoints = [ {
209209 metricKey : ! options . seriesAlias || / ^ \s * $ / . test ( options . seriesAlias ) ? options . aggregationMode : options . seriesAlias ,
0 commit comments