Mostrar solo curvas de probabilidad disponibles

This commit is contained in:
2026-12-02 22:53:44 -06:00
parent a19874438b
commit a22ce12067
2 changed files with 17 additions and 86 deletions
+6 -72
View File
@@ -1,8 +1,5 @@
import { DecimalPipe } from '@angular/common';
import { Component, computed, input, signal } from '@angular/core';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import type { Parameters, ParametersParameter } from 'fhir/r4';
import { Plot } from '../plot';
import { curveFigure } from './risk-curve';
@@ -56,11 +53,10 @@ export function parseSeries(answer: Parameters): Series[] {
}));
}
/** The chosen series as bars at one horizon and as curves. Series are shown side by side; no
* difference between them is computed. */
/** The chosen series as curves. Series are shown side by side; no difference is computed. */
@Component({
selector: 'app-risk-series',
imports: [DecimalPipe, MatCheckboxModule, MatFormFieldModule, MatSelectModule, Plot],
imports: [MatCheckboxModule, Plot],
template: `
<p class="muted">Cada serie tiene su propio desenlace y población: no se restan entre sí.</p>
<div class="choices">
@@ -71,40 +67,11 @@ export function parseSeries(answer: Parameters): Series[] {
}
</div>
@if (selected().length) {
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Horizonte</mat-label>
<mat-select [value]="horizon()" (selectionChange)="picked.set($event.value)">
@for (h of horizons(); track h) {
<mat-option [value]="h">{{ h === 0 ? 'Al índice' : h + ' años' }}</mat-option>
}
</mat-select>
</mat-form-field>
<ul class="bars">
@for (b of bars(); track b.series.id) {
<li>
<span>{{ name(b.series) }}</span>
<small class="muted">{{ b.series.label }}</small>
@if (b.point; as p) {
<span class="track"><span class="fill" [style.width.%]="p.p * 100"></span></span>
<span>
{{ p.p * 100 | number: '1.1-2' }} %
@if (p.low !== undefined && p.high !== undefined) {
(IC 95 %: {{ p.low * 100 | number: '1.1-2' }}–{{
p.high * 100 | number: '1.1-2'
}})
} @else {
(IC 95 % no publicado)
}
</span>
} @else {
<span class="muted">No disponible en este horizonte.</span>
}
@for (a of b.series.assumptions; track a) {
<small class="muted">{{ a }}</small>
}
</li>
@for (s of selected(); track s.id) {
@for (assumption of s.assumptions; track assumption) {
<p class="muted">{{ name(s) }}: {{ assumption }}</p>
}
</ul>
}
<app-plot [figure]="figure()" [height]="340" />
}
@if (!available().length) {
@@ -121,24 +88,6 @@ export function parseSeries(answer: Parameters): Series[] {
gap: 0 16px;
margin-bottom: 8px;
}
.bars {
list-style: none;
padding: 0;
}
.bars li {
display: flex;
flex-direction: column;
margin-bottom: 10px;
}
.track {
background: var(--color-action-hover, #f1f6f6);
height: 10px;
}
.fill {
background: #4269a0;
display: block;
height: 100%;
}
`,
})
export class RiskSeries {
@@ -158,21 +107,6 @@ export class RiskSeries {
protected readonly selected = computed(() =>
this.available().filter((s) => this.chosen().has(s.id)),
);
protected readonly horizons = computed(() =>
[...new Set(this.selected().flatMap((s) => s.points.map((p) => p.years)))].sort(
(a, b) => a - b,
),
);
protected readonly picked = signal(5);
protected readonly horizon = computed(() =>
this.horizons().includes(this.picked()) ? this.picked() : this.horizons().at(-1)!,
);
protected readonly bars = computed(() =>
this.selected().map((series) => ({
series,
point: series.points.find((p) => p.years === this.horizon()),
})),
);
protected readonly figure = computed(() => {
const shown = this.selected().map((s) => ({
model: s.id,