Files
WebApp/src/app/features/indicadores/indicador-figure-card.html
T
edgar 957f4cd024 feat(tea): botones para resaltar grupos y categorías en las figuras
- Leyenda con botones, como la distribución de resultados citológicos de
  cáncer cervicouterino: el grupo o la categoría elegida conserva su color,
  el resto se atenúa, «Volver» retrocede y un clic en la figura equivale al
  botón (indicadores-highlight.ts).
- M21, M22 y M24 con botones por grupo de edad; el centro de las donas
  muestra la selección.
- En TEA, la dona C2 de un periodo (M23) se dibuja con ambos anillos y
  botones, y sus barras también los tienen.
2026-11-03 21:22:51 +00:00

132 lines
8.4 KiB
HTML

<mat-card class="figure-card" [class.dark]="tema === 'oscuro'" [attr.data-render-source]="state.source" [attr.aria-label]="dominio + ', ' + selected?.id + ', ' + figuraId" [attr.aria-busy]="state.status === 'loading'">
@if (selected) {
<section class="interpretation" [class.expanded]="methodologyExpanded()">
<button mat-stroked-button type="button" class="methodology-toggle"
[attr.aria-label]="'Cómo leer esta figura: ' + selected.titulo + ', ' + dominio + ', ' + figuraId"
[attr.aria-expanded]="methodologyExpanded()" [attr.aria-controls]="methodologyId"
(click)="toggleMethodology()">
<mat-icon aria-hidden="true">help_outline</mat-icon>
Cómo leer
</button>
<div class="methodology-detail" [id]="methodologyId" [hidden]="!methodologyExpanded()">
<ul>
@for (line of interpretation; track $index) { <li>{{ line }}</li> }
</ul>
<p class="period-note">{{ periodInterpretation }}</p>
@if (state.status === 'ready' && state.footnotes?.length) {
<h3 class="footnotes-title">Notas de la figura</h3>
<section class="methodological-footnotes" aria-label="Notas de la figura">
@for (note of state.footnotes; track $index) { <p>{{ note }}</p> }
</section>
}
</div>
</section>
}
<div class="figure-heading">
@if (state.status === 'loading') {
<mat-progress-bar mode="indeterminate" aria-label="Cargando figura" />
<div class="figure-skeleton"><p class="state" role="status">Cargando figura…</p><div class="skeleton" aria-hidden="true"></div></div>
} @else if (state.status === 'deferred') {
<div class="figure-skeleton"><p class="state" role="status">{{ state.message }}</p><div class="skeleton" aria-hidden="true"></div></div>
} @else if (state.status === 'incompatible') {
<div class="state incompatible" role="status"><p>Filtro general incompatible con esta figura.</p><p>{{ state.message }}</p></div>
} @else if (state.status === 'error') {
<div class="state" role="alert"><p>{{ state.message }}</p>
<button mat-stroked-button (click)="retry.emit()">Reintentar solicitud</button></div>
} @else if (state.figure; as figure) {
@if (hasNoVisibleValues(figure)) {
<p class="state" role="status">{{ state.emptyMessage ?? 'No hay valores visibles para la selección. No se puede determinar la causa a partir de la figura recibida.' }}</p>
}
<h2 class="figure-title" [innerHTML]="figureTitle(figure, selected?.titulo ?? '')"></h2>
<p class="figure-id">Figura: {{ figureDisplayName(figuraId, selected?.figuras ?? []) }}</p>
} @else {
<p class="state" role="status">{{ !selected?.figuras?.length ? 'El indicador no tiene figuras disponibles.' : 'Completa una selección válida para consultar la figura.' }}</p>
}
</div>
@if (chartFigure) {
<div class="figure-legend">
@if (state.status === 'ready' && state.hierarchy; as hierarchy) {
<div #donutNavigation class="donut-navigation" tabindex="-1" aria-label="Explorar grupos de la dona">
<p class="donut-status" role="status">{{ activeParent ? 'Categorías de ' + activeParent + '. Anillo exterior: porcentajes dentro de este grupo. Anillo interior: todos los grupos.' : 'Selecciona un segmento para ver sus categorías. También puedes explorar los grupos con Tab y Enter o Espacio.' }}</p>
<div class="donut-toolbar">
<span class="donut-context">{{ activeParent ? 'Categorías' : 'Grupos' }}</span>
@if (activeParent) {
<button mat-icon-button type="button" class="donut-restore" matTooltip="Restaurar vista"
aria-label="Restaurar vista de la gráfica" (click)="returnToParents($event)">
<svg aria-hidden="true" focusable="false" viewBox="0 0 24 24" width="24" height="24">
<path d="M3 10a9 9 0 1 1 2.6 8.4M3 4v6h6" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</button>
}
</div>
<div class="donut-legend" aria-label="Leyenda de la dona">
<div #donutKeyboard class="donut-keyboard" role="group" aria-label="Explorar grupos con teclado">
@for (parent of hierarchy.parents; track parent) {
<button type="button" [attr.aria-pressed]="activeParent === parent" (click)="expandParent(parent)">
<span class="legend-swatch" [style.background]="legendColor(parent, true)" aria-hidden="true"></span>{{ parent }}
</button>
}
</div>
<div class="donut-children-region" [class.expanded]="!!activeParent"
[attr.aria-hidden]="activeParent ? null : 'true'" [attr.inert]="activeParent ? null : ''">
<div class="donut-children-content">
<h3 class="donut-children-title">Categorías</h3>
<div class="donut-children" role="group" [attr.aria-label]="'Categorías de ' + activeParent">
@for (child of visibleChildren; track child.label) {
<button type="button" [attr.aria-pressed]="activeCategory === child.label" (click)="selectCategory(child.label)">
<span class="legend-swatch" [style.background]="legendColor(child.label, false)" aria-hidden="true"></span>{{ child.label }}
</button>
}
</div>
</div>
</div>
</div>
</div>
}
@if (state.status === 'ready' && state.highlight; as h) {
<div class="highlight-legend" role="group" aria-label="Resaltar partes de la figura">
<p class="highlight-status" role="status" aria-live="polite">Selección: {{ highlightStatus }}</p>
<button type="button" class="highlight-back" (click)="highlightBack()" [disabled]="!highlightSelection.group && !highlightSelection.item">Volver</button>
@for (row of highlightRows(h); track row.group?.id ?? '') {
<div class="highlight-keys" role="group" [attr.aria-label]="row.group ? row.group.label + ' y sus categorías' : 'Categorías'">
@if (row.group; as g) {
<button type="button" class="highlight-group" [attr.aria-pressed]="highlightSelection.group === g.id" (click)="highlight('group', g.id)"><span class="legend-swatch" [style.background]="g.color" aria-hidden="true"></span>{{ g.label }}</button>
}
@for (c of row.items; track c.id) {
<button type="button" [attr.aria-pressed]="highlightSelection.item === c.id" [disabled]="!!highlightSelection.group && c.group !== highlightSelection.group"
[attr.aria-label]="c.short ? c.label : null" (click)="highlight('item', c.id)"><span class="legend-swatch" [style.background]="c.color" aria-hidden="true"></span>{{ c.short ?? c.label }}</button>
}
</div>
}
</div>
} @else if (state.status === 'ready' && state.donutLegend?.length) {
<div class="donut-static-legend" role="list" aria-label="Leyenda de la dona">
@for (entry of state.donutLegend; track entry.label) {
<span class="donut-static-legend__item" role="listitem">
<span class="legend-swatch" [style.background]="entry.color ?? 'currentColor'" aria-hidden="true"></span>{{ entry.label }}
</span>
}
</div>
}
</div>
<div class="plot-slot" [hidden]="state.status !== 'ready'">
<app-plotly-chart [style.--plot-height]="state.plotHeight ? state.plotHeight + 'px' : (state.hierarchy || state.donutLegend || state.highlight ? '440px' : null)" [style.--plot-min-width]="chartMinimumWidth ? chartMinimumWidth + 'px' : null" [showNotes]="false" [label]="dominio + ', ' + selected?.id + ', ' + figuraId" [figure]="chartFigure" (widthChanged)="reportPlotWidth($event)" (plotClick)="plotClicked($event)" />
</div>
}
<div class="figure-footer" [hidden]="state.status !== 'ready'">
@if (cutoffDate; as cutoff) { <p class="figure-cutoff">Fecha de corte: {{ cutoff }}</p> }
</div>
<div class="figure-labels" [hidden]="state.status !== 'ready'">
@if (state.categoryLabels?.length) {
<details class="category-labels">
<summary>Nombres completos de las categorías</summary>
<ul>
@for (label of state.categoryLabels; track $index) {
<li><span>{{ label.abbreviated }}</span>: {{ label.original }}</li>
}
</ul>
</details>
}
</div>
</mat-card>