preliminary release
This commit is contained in:
@@ -5,6 +5,10 @@ import { PlotlyFigure } from '../../features/indicadores/indicadores.models';
|
||||
import { PlotlyController } from './plotly-controller';
|
||||
import { PLOTLY_LOADER } from './plotly-runtime';
|
||||
|
||||
function prefersReducedMotion(): boolean {
|
||||
return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-plotly-chart',
|
||||
imports: [MatButtonModule, MatProgressBarModule],
|
||||
@@ -14,7 +18,7 @@ import { PLOTLY_LOADER } from './plotly-runtime';
|
||||
<div role="alert"><p>No se pudo representar la figura. Puedes reintentar.</p>
|
||||
<button mat-stroked-button (click)="retry()">Reintentar renderizado</button></div>
|
||||
}
|
||||
<div class="plot-viewport" tabindex="0" role="region" [attr.aria-label]="label + ' · Área de figura'"><div #host class="plot" role="img" [attr.aria-label]="label" [attr.aria-hidden]="status() !== 'ready'"></div></div>
|
||||
<div class="plot-viewport" tabindex="0" role="region" [attr.aria-label]="label + ', área de figura'"><div #host class="plot" role="img" [attr.aria-label]="label" [attr.aria-hidden]="status() !== 'ready'"></div></div>
|
||||
@if (showNotes && status() === 'ready' && notes.length) {
|
||||
<section class="notes" aria-label="Notas completas de la figura">
|
||||
<h2>Notas de la figura</h2>
|
||||
@@ -27,6 +31,8 @@ import { PLOTLY_LOADER } from './plotly-runtime';
|
||||
export class PlotlyChart implements AfterViewInit, OnChanges, OnDestroy {
|
||||
@Input() showNotes = true;
|
||||
@Input() label = 'Figura estadística';
|
||||
// Opt-in: updates of the same visible figure move smoothly instead of redrawing.
|
||||
@Input() animated = false;
|
||||
@Input({ required: true }) figure!: PlotlyFigure;
|
||||
@ViewChild('host', { static: true }) host!: ElementRef<HTMLElement>;
|
||||
readonly renderError = output<void>();
|
||||
@@ -57,7 +63,7 @@ export class PlotlyChart implements AfterViewInit, OnChanges, OnDestroy {
|
||||
this.controller = new PlotlyController(this.host.nativeElement, this.loadPlotly, state => {
|
||||
this.status.set(state);
|
||||
if (state === 'error') this.renderError.emit();
|
||||
}, event => this.plotClick.emit(event));
|
||||
}, event => this.plotClick.emit(event), { animate: () => this.animated && !prefersReducedMotion() });
|
||||
if (typeof ResizeObserver !== 'undefined') {
|
||||
this.observer = new ResizeObserver(this.windowResize);
|
||||
this.observer.observe(this.host.nativeElement);
|
||||
|
||||
Reference in New Issue
Block a user