feat(indicadores): agregar prototipo de dashboard TEA

Implementa el prototipo del dashboard de indicadores TEA.

- Integra catálogo y figuras mediante WebApi.
- Incorpora visualizaciones interactivas con Plotly.js.
- Agrega controles de indicadores, figuras, periodos y temas.
- Implementa estados de carga, errores y diseño responsive.
- Incluye explicaciones para los contratos C1, C2 y C3r.
- Incorpora pruebas unitarias y de integración de componentes.

Prototipo para investigación con datos sintéticos.
This commit is contained in:
Angel Capetillo Zavala
2026-10-12 10:43:00 -06:00
parent 3605d23fc0
commit a66205b725
22 changed files with 990 additions and 3 deletions
+61
View File
@@ -0,0 +1,61 @@
import { AfterViewInit, Component, inject, ElementRef, Input, OnChanges, OnDestroy, output, signal, ViewChild } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { PlotlyFigure } from '../../features/indicadores/indicadores.models';
import { PlotlyController } from './plotly-controller';
import { PLOTLY_LOADER } from './plotly-runtime';
@Component({
selector: 'app-plotly-chart',
imports: [MatButtonModule, MatProgressBarModule],
template: `
@if (status() === 'loading') { <mat-progress-bar mode="indeterminate" aria-label="Representando figura" /> }
@if (status() === 'error') {
<div role="alert"><p>No se pudo representar la figura. Puedes reintentar.</p>
<button mat-stroked-button (click)="retry()">Reintentar renderizado</button></div>
}
<div #host class="plot" role="img" aria-label="Figura del indicador seleccionado" [attr.aria-hidden]="status() !== 'ready'"></div>
@if (status() === 'ready' && notes.length) {
<section class="notes" aria-label="Notas completas de la figura">
<h2>Notas de la figura</h2>
@for (note of notes; track $index) { <p [innerHTML]="note"></p> }
</section>
}
`,
styles: `:host { display: block; min-width: 0; } .plot { width: 100%; min-height: 620px; visibility: hidden; } [role=alert] { padding: 1rem; } .notes { display: none; padding: 1rem; overflow-wrap: anywhere; } .notes h2 { font-size: 1rem; } .notes p { line-height: 1.5; } @media (max-width: 850px) { .notes { display: block; } }`,
})
export class PlotlyChart implements AfterViewInit, OnChanges, OnDestroy {
@Input({ required: true }) figure!: PlotlyFigure;
@ViewChild('host', { static: true }) host!: ElementRef<HTMLElement>;
readonly renderError = output<void>();
readonly status = signal<'loading' | 'ready' | 'error'>('loading');
get notes(): string[] {
const annotations = this.figure?.layout['annotations'];
if (!Array.isArray(annotations)) return [];
return annotations.flatMap(annotation =>
annotation && typeof annotation.text === 'string' ? [annotation.text] : []);
}
private readonly loadPlotly = inject(PLOTLY_LOADER);
private controller?: PlotlyController;
private observer?: ResizeObserver;
private readonly windowResize = () => this.controller?.resize();
ngAfterViewInit() {
this.controller = new PlotlyController(this.host.nativeElement, this.loadPlotly, state => {
this.status.set(state);
if (state === 'error') this.renderError.emit();
});
if (typeof ResizeObserver !== 'undefined') {
this.observer = new ResizeObserver(this.windowResize);
this.observer.observe(this.host.nativeElement);
} else window.addEventListener('resize', this.windowResize);
this.controller.setFigure(this.figure);
}
ngOnChanges() { if (this.figure) this.controller?.setFigure(this.figure); }
retry() { this.controller?.setFigure(this.figure); }
ngOnDestroy() {
this.observer?.disconnect();
window.removeEventListener('resize', this.windowResize);
this.controller?.destroy();
}
}