KPIs page draws durations as boxes and reads a composition's categories from its first stratifier
This commit is contained in:
@@ -3,8 +3,8 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { forkJoin, map, of, switchMap } from 'rxjs';
|
||||
import { PlotlyChart } from '../../shared/plotly/plotly-chart';
|
||||
import { PlotlyFigure } from './indicadores.models';
|
||||
import { compositionFigure, proportionFigure } from './measure-report';
|
||||
import { MeasureReportService } from './measure-report.service';
|
||||
import { compositionFigure, durationFigure, proportionFigure } from './measure-report';
|
||||
import { KpiEntry, MeasureReportService } from './measure-report.service';
|
||||
|
||||
const PERIODOS = ['2025-S1', '2025-S2'];
|
||||
|
||||
@@ -28,12 +28,23 @@ export class KpisPage implements OnInit {
|
||||
|
||||
ngOnInit() {
|
||||
this.service.list('cacu').pipe(
|
||||
switchMap(kpis => kpis.length === 0 ? of([]) : forkJoin(kpis.map(kpi => kpi.scoring === 'composition'
|
||||
? this.service.composition('cacu', kpi.id, PERIODOS).pipe(map(s => ({ id: kpi.id, figure: compositionFigure(s, kpi.id) })))
|
||||
: this.service.series('cacu', kpi.id, PERIODOS).pipe(map(s => ({ id: kpi.id, figure: proportionFigure(s, kpi.id) })))))),
|
||||
switchMap(kpis => kpis.length === 0 ? of([]) : forkJoin(kpis.map(kpi => this.figureOf(kpi)))),
|
||||
).subscribe({
|
||||
next: figures => { this.figures.set(figures); this.status.set('ready'); },
|
||||
error: () => this.status.set('error'),
|
||||
});
|
||||
}
|
||||
|
||||
/** Drawn by its scoring, from the one contract: nothing here is per measure. */
|
||||
private figureOf(kpi: KpiEntry) {
|
||||
const drawn = (figure: PlotlyFigure) => ({ id: kpi.id, figure });
|
||||
switch (kpi.scoring) {
|
||||
case 'composition':
|
||||
return this.service.composition('cacu', kpi.id, PERIODOS).pipe(map(s => drawn(compositionFigure(s, kpi.id))));
|
||||
case 'continuous-variable':
|
||||
return this.service.duration('cacu', kpi.id, PERIODOS).pipe(map(s => drawn(durationFigure(s, kpi.id))));
|
||||
default:
|
||||
return this.service.series('cacu', kpi.id, PERIODOS).pipe(map(s => drawn(proportionFigure(s, kpi.id))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user