sort/filter by max average ratio

This commit is contained in:
2020-12-01 17:10:40 +01:00
parent 5498be6a86
commit 3763d09fa8
5 changed files with 34 additions and 1 deletions

View File

@@ -53,7 +53,22 @@ export class PlotService {
sendPlotRequest(plotRequest: PlotRequest): Observable<PlotResponse>{
//console.log("send plot request: "+ JSON.stringify(plotRequest));
return this.http.post<PlotResponse>('//'+window.location.hostname+':'+window.location.port+'/api/plots', plotRequest);
const result = this.http.post<PlotResponse>('//'+window.location.hostname+':'+window.location.port+'/api/plots', plotRequest);
return result.pipe(map(this.enrichStats));
}
enrichStats(response: PlotResponse): PlotResponse {
let maxAvgRatio = 0;
let x : DataSeriesStats[] = response.stats.dataSeriesStats;
for (const row in x){
for (const col in x){
maxAvgRatio = Math.max(maxAvgRatio, x[row].average / x[col].average);
}
}
response.stats.maxAvgRatio = maxAvgRatio;
return response;
}
getFilterDefaults(): Observable<FilterDefaults>{
@@ -223,6 +238,7 @@ export class PlotResponseStats {
values : number;
average : number ;
plottedValues : number;
maxAvgRatio: number;
dataSeriesStats : Array<DataSeriesStats>;
}