From 97fcb377611354e9d2326abf8adf70046789f2ab Mon Sep 17 00:00:00 2001 From: Manuel Aurrecoechea Castillo Date: Wed, 18 Nov 2026 15:43:23 -0600 Subject: [PATCH] 20261118 Sharts Colors --- .../indicadores/indicador-figure-card.ts | 4 +++- .../indicadores-c2-adapter.spec.ts | 8 ++++--- .../indicadores-c2-palette.spec.ts | 21 ++++++++----------- .../indicadores/indicadores-c2-palette.ts | 19 +++++++++++++---- .../indicadores/indicadores-cama-f4c.spec.ts | 7 ++++--- .../indicadores-conteos-pareados.ts | 9 +++++--- .../indicadores-histopatologia-cama.spec.ts | 3 ++- .../indicadores-histopatologia-cama.ts | 7 ++++--- .../indicadores-historico-figures.spec.ts | 3 ++- src/app/shared/plotly/plotly-chart.ts | 7 ++++--- 10 files changed, 54 insertions(+), 34 deletions(-) diff --git a/src/app/features/indicadores/indicador-figure-card.ts b/src/app/features/indicadores/indicador-figure-card.ts index 775ebc9..dc6f8cc 100644 --- a/src/app/features/indicadores/indicador-figure-card.ts +++ b/src/app/features/indicadores/indicador-figure-card.ts @@ -13,6 +13,7 @@ import { PlotlyChart } from '../../shared/plotly/plotly-chart'; import { figureInterpretation, PERIOD_INTERPRETATION } from './indicadores-methodology'; import { DonutHierarchy, DonutLegendEntry, DonutSelection, donutSimpleView, donutView } from './indicadores-donut-drilldown'; import { FigureHighlight, highlightAt, highlightFigure, highlightLabel, highlightRows, HighlightSelection, toggleHighlight } from './indicadores-highlight'; +import { recolorFigure } from './indicadores-c2-palette'; // The panel owns requests; the card receives the original and its presentation copy. export interface FigureState { @@ -62,7 +63,8 @@ export class IndicadorFigureCard implements OnChanges { } get visibleChildren() { return this.state.hierarchy?.children.filter(c => c.parent === this.activeParent) ?? []; } legendColor(label: string, parent: boolean): string { - const trace = this.chartFigure?.data[parent && this.activeParent ? 1 : 0]; + const painted = this.chartFigure ? recolorFigure(this.chartFigure) : undefined; + const trace = painted?.data[parent && this.activeParent ? 1 : 0]; const labels = trace?.['labels'], marker = trace?.['marker'] as { colors?: unknown[] } | undefined; const color = Array.isArray(labels) ? marker?.colors?.[labels.indexOf(label)] : undefined; return typeof color === 'string' && /^#[0-9a-f]{6}$/i.test(color) ? color : 'currentColor'; diff --git a/src/app/features/indicadores/indicadores-c2-adapter.spec.ts b/src/app/features/indicadores/indicadores-c2-adapter.spec.ts index c36c164..4a314e1 100644 --- a/src/app/features/indicadores/indicadores-c2-adapter.spec.ts +++ b/src/app/features/indicadores/indicadores-c2-adapter.spec.ts @@ -161,14 +161,16 @@ describe('paleta C2 institucional y semántica', () => { it.each(['claro','oscuro'] as const)('sustituye tonos ajenos al logo en %s y separa interfaz, series y estados', tema => { const data = c2Fixture(); (data['categorias'] as Record>)['A']['color'] = '#D98E4A'; const figure = supported(data, { ...selection, tema }).figure; - expect((figure.data[0]['marker'] as Record)['colors']).toEqual(['#D98E4A', C2_PALETTE.series[1], C2_PALETTE.series[2]]); - expect(seriesColors(['#D98E4A', undefined, undefined])).toEqual(['#D98E4A', C2_PALETTE.series[1], C2_PALETTE.series[2]]); + expect((figure.data[0]['marker'] as Record)['colors']).toEqual([C2_PALETTE.series[0], C2_PALETTE.series[1], C2_PALETTE.series[2]]); + expect(seriesColors(['#D98E4A', undefined, undefined])).toEqual([C2_PALETTE.series[0], C2_PALETTE.series[1], C2_PALETTE.series[2]]); expect(figure.layout['paper_bgcolor']).toBe(C2_PALETTE[tema].background); expect(figure.layout['font']).toMatchObject({ color: C2_PALETTE[tema].text }); expect(C2_PALETTE.states.noData).toBe('#C9CDD2'); expect(c2Color('#C9CDD2',0)).toBe('#C9CDD2'); expect(c2Color(undefined, 0)).toBe(C2_PALETTE.series[0]); expect(c2Color(undefined, 1)).toBe(C2_PALETTE.series[1]); expect(c2Color(undefined, 2)).toBe(C2_PALETTE.series[2]); expect(c2Color(undefined, 3)).toBe(C2_PALETTE.series[3]); - expect(c2Color('#D98E4A', 0)).toBe('#D98E4A'); + expect(c2Color('#D98E4A', 0)).toBe(C2_PALETTE.series[0]); + expect(c2Color('#B55A1F', 2)).toBe(C2_PALETTE.series[2]); + expect(c2Color('#9DBFE3', 1)).toBe('#9DBFE3'); expect(c2Color(C2_PALETTE.edades[0], 0)).toBe(C2_PALETTE.edades[0]); expect(figure.config?.['responsive']).not.toBe(false); expect(figure.layout['width']).toBeUndefined(); }); diff --git a/src/app/features/indicadores/indicadores-c2-palette.spec.ts b/src/app/features/indicadores/indicadores-c2-palette.spec.ts index 1db8031..b4dec35 100644 --- a/src/app/features/indicadores/indicadores-c2-palette.spec.ts +++ b/src/app/features/indicadores/indicadores-c2-palette.spec.ts @@ -8,13 +8,15 @@ describe('paleta del logo ISSSTELEON', () => { expect(C2_PALETTE.series[0]).not.toBe(C2_PALETTE.series[1]); }); - it('reemplaza mezclas de partido por entradas distintas y conserva el gris de sin dato', () => { - const [azul, rojo, naranja, amarillo, guinda, sinDato, edad] = institutionalize([ - '#0044CC', '#C41E3A', '#FF6B00', '#FFD100', '#7A2E0E', '#C9CDD2', '#2F6DB3', + it('cambia el café y el anaranjado por la serie, y deja azul, rojo, gris y edad', () => { + const [cafe, otroCafe, rojo, azul, sinDato, edad] = institutionalize([ + '#B55A1F', '#D9822B', '#C41E3A', '#0044CC', '#C9CDD2', '#2F6DB3', ]); - expect([azul, rojo, naranja, amarillo, guinda]).toEqual(C2_PALETTE.series.slice(0, 5)); - expect(edad).toBe('#2F6DB3'); + expect([cafe, otroCafe]).toEqual(C2_PALETTE.series.slice(0, 2)); + expect(rojo).toBe('#C41E3A'); + expect(azul).toBe('#0044CC'); expect(sinDato).toBe('#C9CDD2'); + expect(edad).toBe('#2F6DB3'); }); it('da a cada grupo un matiz y a sus categorías pasos distintos de ese matiz', () => { @@ -34,8 +36,7 @@ describe('paleta del logo ISSSTELEON', () => { layout: { font: { color: '#081839' }, paper_bgcolor: '#FFFFFF', colorway: ['#EF553B', '#636efa'] }, }); expect((figure.data[0]['marker'] as { color: string }).color).toBe(C2_PALETTE.series[0]); - expect(figure.data[0]['error_x']).toMatchObject({ color: expect.stringMatching(/^rgba\(\d+,\d+,\d+,0\.4\)$/) }); - expect((figure.data[0]['error_x'] as { color: string }).color).not.toContain('0,68,204'); + expect((figure.data[0]['error_x'] as { color: string }).color).toBe('rgba(0,68,204,0.4)'); expect((figure.data[0]['line'] as { color: string }).color).toBe('#C9CDD2'); const scale = figure.data[0]['colorscale'] as [number, string][]; expect(scale.map(stop => stop[0])).toEqual([0, 0.5, 1]); @@ -43,11 +44,7 @@ describe('paleta del logo ISSSTELEON', () => { expect(scale[0][1]).not.toBe(scale[1][1]); expect(figure.layout['font']).toEqual({ color: '#081839' }); expect(figure.layout['paper_bgcolor']).toBe('#FFFFFF'); - expect(figure.layout['colorway']).toEqual(C2_PALETTE.series.slice(2, 4)); - expect(new Set([ - (figure.data[0]['marker'] as { color: string }).color, - ...(figure.layout['colorway'] as string[]), - ]).size).toBe(3); + expect(figure.layout['colorway']).toEqual([C2_PALETTE.series[1], '#636efa']); expect(recolorFigure(figure)).toBe(figure); }); }); diff --git a/src/app/features/indicadores/indicadores-c2-palette.ts b/src/app/features/indicadores/indicadores-c2-palette.ts index 61f71a1..ab29928 100644 --- a/src/app/features/indicadores/indicadores-c2-palette.ts +++ b/src/app/features/indicadores/indicadores-c2-palette.ts @@ -23,9 +23,20 @@ export function isAgeColor(color: string): boolean { const key = parseColor(color)?.key; return !!key && ageKeys.has(key); } +/** Orange, tan and coffee. Age gold and the palette's own stone are not included. */ +function isCoffeeParsed(item: Parsed | undefined): boolean { + if (!item || item.kind === 'neutral' || ageKeys.has(item.key)) return false; + return item.hue >= 8 && item.hue <= 46 && item.sat >= 0.28; +} +export function isCoffeeColor(color: string): boolean { + return isCoffeeParsed(parseColor(color)); +} export function c2Color(published: string | undefined, index: number): string { - // A published swatch stays. The series only fills a category that arrived without one. - if (published && (/^#[0-9a-f]{6}$/i.test(published) || isAgeColor(published))) return published; + // Coffee and orange-brown published swatches take the shared series. Other published colours stay. + if (published && isAgeColor(published)) return published; + if (published && isNeutralColor(published)) return published; + if (published && isCoffeeColor(published)) return C2_PALETTE.series[index % C2_PALETTE.series.length]; + if (published && /^#[0-9a-f]{6}$/i.test(published)) return published; return C2_PALETTE.series[index % C2_PALETTE.series.length]; } @@ -51,7 +62,7 @@ export function institutionalize(colors: readonly string[]): string[] { const foreign: string[] = []; const seen = new Set(); for (const item of parsed) { - if (!item || item.kind !== 'foreign' || ageKeys.has(item.key) || seen.has(item.key)) continue; + if (!item || !isCoffeeParsed(item) || seen.has(item.key)) continue; seen.add(item.key); foreign.push(item.key); } @@ -63,7 +74,7 @@ export function institutionalize(colors: readonly string[]): string[] { }); } -/** Keep a published colour; only a missing one takes the next series entry. */ +/** Coffee published colours take the series; other published colours stay. */ export function seriesColors(published: readonly (string | undefined)[]): string[] { return published.map((color, index) => c2Color(color, index)); } diff --git a/src/app/features/indicadores/indicadores-cama-f4c.spec.ts b/src/app/features/indicadores/indicadores-cama-f4c.spec.ts index 20febaa..dcaa9ef 100644 --- a/src/app/features/indicadores/indicadores-cama-f4c.spec.ts +++ b/src/app/features/indicadores/indicadores-cama-f4c.spec.ts @@ -10,6 +10,7 @@ import { provideRouter } from '@angular/router'; import { By } from '@angular/platform-browser'; import { MatDialog } from '@angular/material/dialog'; import { PlotlyChart } from '../../shared/plotly/plotly-chart'; +import { C2_PALETTE } from './indicadores-c2-palette'; import tasaVisible from './fixtures/cama_tasa_deteccion_visible.json'; import tasaSuprimida from './fixtures/cama_tasa_deteccion_suprimido.json'; import diasVisible from './fixtures/cama_dias_resultado_visible.json'; @@ -86,7 +87,7 @@ describe('CAM-01, CAM-02 y CAM-03: histórico con las respuestas reales', () => expect(f.contrato).toBe('C2'); expect(f.suprimidos).toEqual([]); expect(f.sinDato).toEqual([]); expect(f.figure.data.map(t => [t['name'], (t['y'] as number[])[0]])).toEqual([ ['Benigno', 7], ['Lesión de riesgo (B3)', 5], ['Carcinoma in situ', 6], ['Carcinoma invasor', 7], ['Sin biopsia reportada', 6], ['Sin dato', 6]]); - expect(f.figure.data.map(t => (t['marker'] as { color: string }).color)).toEqual(['#9DBFE3', '#2F6DB3', '#D9822B', '#B5482E', '#C9CDD2', '#C9CDD2']); + expect(f.figure.data.map(t => (t['marker'] as { color: string }).color)).toEqual(['#9DBFE3', '#2F6DB3', C2_PALETTE.series[2], C2_PALETTE.series[3], '#C9CDD2', '#C9CDD2']); expect(f.figure.layout['barmode']).toBe('stack'); expect(f.comoLeer).toContain('pacientes'); }); @@ -138,8 +139,8 @@ describe('CAM-01, CAM-02 y CAM-03 en el panel histórico', () => { '/cama/indicadores/cama_dias_resultado_diagnostico/datos?periodos=2025-S1', '/cama/indicadores/cama_tasa_deteccion_histopatologica/datos?periodos=2025-S1'].sort((a, b) => pedidos.indexOf(a) - pedidos.indexOf(b))); const titulos = paneles().map(p => [p.querySelector('h2')!.textContent, p.textContent!.includes('Integración pendiente') ? 'pendiente' : 'dibujado']); - expect(titulos.filter(([t]) => ['Resultado histopatológico por categoría BI-RADS', 'Días del resultado de la mastografía al diagnóstico', 'Tasa de detección histopatológica'].includes(t!))) - .toEqual([['Resultado histopatológico por categoría BI-RADS', 'dibujado'], ['Días del resultado de la mastografía al diagnóstico', 'dibujado'], ['Tasa de detección histopatológica', 'dibujado']]); + expect(titulos.filter(([t]) => ['Resultado histopatológico', 'Días del resultado de la mastografía al diagnóstico', 'Tasa de detección histopatológica'].includes(t!))) + .toEqual([['Resultado histopatológico', 'dibujado'], ['Días del resultado de la mastografía al diagnóstico', 'dibujado'], ['Tasa de detección histopatológica', 'dibujado']]); expect(graficas()).toHaveLength(3); expect(graficas().map(g => g.figure!.data.length)).toEqual([6, 2, 2]); }); diff --git a/src/app/features/indicadores/indicadores-conteos-pareados.ts b/src/app/features/indicadores/indicadores-conteos-pareados.ts index c7298ae..a38e027 100644 --- a/src/app/features/indicadores/indicadores-conteos-pareados.ts +++ b/src/app/features/indicadores/indicadores-conteos-pareados.ts @@ -1,5 +1,5 @@ import { Dominio, IndicadorDatos, PlotlyFigure, Tema } from './indicadores.models'; -import { c2Theme } from './indicadores-c2-palette'; +import { c2Color, c2Theme } from './indicadores-c2-palette'; import { percentNumber } from './indicadores-format'; // Two C2 indicators of the same finding: the exams by BI-RADS category and the patients by their most severe one. @@ -80,7 +80,10 @@ export function modelosConteos(par: ParConteos, examenes: IndicadorDatos, pacien const publicada = registro(cat[id]) && typeof cat[id]['etiqueta'] === 'string' ? cat[id]['etiqueta'] as string : ''; return publicada && publicada !== id ? publicada : ETIQUETA_RESPALDO[id] ?? id; }; - const color = (id: string) => registro(catExamenes[id]) && typeof catExamenes[id]['color'] === 'string' ? catExamenes[id]['color'] as string : COLOR_RESPALDO[id] ?? COLOR_NEUTRO; + const color = (id: string, index: number) => { + const publicado = registro(catExamenes[id]) && typeof catExamenes[id]['color'] === 'string' ? catExamenes[id]['color'] as string : COLOR_RESPALDO[id] ?? COLOR_NEUTRO; + return c2Color(publicado, index); + }; const todas = par.grupos.flatMap(g => g.categorias); if (par.categoriasExamen.some(id => !OPCIONALES.has(id) && !Object.hasOwn(catExamenes, id)) || todas.some(id => !OPCIONALES.has(id) && (!Object.hasOwn(catPacientes, id) || !Object.hasOwn(catExamenes, id)))) { @@ -93,7 +96,7 @@ export function modelosConteos(par: ParConteos, examenes: IndicadorDatos, pacien OPCIONALES.has(id) && !Object.hasOwn(cat, id) ? 0 : cuenta(filas, periodo, id); return periodos.map(periodo => ({ periodo, - examenes: par.categoriasExamen.map(id => ({ id, etiqueta: etiqueta(catExamenes, id), color: color(id), n: de(filasE, catExamenes, periodo, id) })), + examenes: par.categoriasExamen.map((id, index) => ({ id, etiqueta: etiqueta(catExamenes, id), color: color(id, index), n: de(filasE, catExamenes, periodo, id) })), // Only the exams the response reports apart; an indicator that lists no such category has none. sinDato: Object.hasOwn(catExamenes, 'SIN_DATO') ? cuenta(filasE, periodo, 'SIN_DATO') : 0, filas: par.grupos.map(g => ({ diff --git a/src/app/features/indicadores/indicadores-histopatologia-cama.spec.ts b/src/app/features/indicadores/indicadores-histopatologia-cama.spec.ts index 268a5a3..8959210 100644 --- a/src/app/features/indicadores/indicadores-histopatologia-cama.spec.ts +++ b/src/app/features/indicadores/indicadores-histopatologia-cama.spec.ts @@ -11,6 +11,7 @@ import estratoFixture from './fixtures/cama_histopatologia_birads_estrato.json'; import generalFixture from './fixtures/cama_histopatologia_birads_general.json'; import catalogoFixture from './fixtures/cama_catalogo_f4c.json'; import { IndicadorHistopatologiaCama } from './indicador-histopatologia-cama'; +import { C2_PALETTE } from './indicadores-c2-palette'; import { IndicadorCatalogCard } from './indicador-catalog-card'; import { IndicadorFigurePanel } from './indicador-figure-panel'; import { PlotlyChart } from '../../shared/plotly/plotly-chart'; @@ -34,7 +35,7 @@ describe('Histopatología por BI-RADS: modelo', () => { expect(m.filas.map(f => f.id)).toEqual(['BIRADS_4', 'BIRADS_4A', 'BIRADS_4B', 'BIRADS_4C', 'BIRADS_5', 'BIRADS_6']); expect(m.filas.map(f => f.etiqueta)).toEqual(['BI-RADS 4 sin subtipo', 'BI-RADS 4A', 'BI-RADS 4B', 'BI-RADS 4C', 'BI-RADS 5', 'BI-RADS 6']); expect(m.categorias.map(c => c.id)).toEqual(['BENIGNO', 'RIESGO_B3', 'IN_SITU', 'INVASOR']); - expect(m.categorias.map(c => c.color)).toEqual(['#9DBFE3', '#2F6DB3', '#D9822B', '#B5482E']); + expect(m.categorias.map(c => c.color)).toEqual(['#9DBFE3', '#2F6DB3', C2_PALETTE.series[2], C2_PALETTE.series[3]]); expect(m.grupos.map(g => [g.id, g.etiqueta, g.categorias])).toEqual([ ['NO_MALIGNO', 'No maligno', ['BENIGNO', 'RIESGO_B3']], ['MALIGNO', 'Maligno', ['IN_SITU', 'INVASOR']]]); expect(m.base).toBe('MALIGNO'); diff --git a/src/app/features/indicadores/indicadores-histopatologia-cama.ts b/src/app/features/indicadores/indicadores-histopatologia-cama.ts index e79a3b9..c61ab85 100644 --- a/src/app/features/indicadores/indicadores-histopatologia-cama.ts +++ b/src/app/features/indicadores/indicadores-histopatologia-cama.ts @@ -1,5 +1,5 @@ import { IndicadorDatos, PlotlyFigure, Tema } from './indicadores.models'; -import { c2Theme } from './indicadores-c2-palette'; +import { c2Color, c2Theme } from './indicadores-c2-palette'; import { Celda, wilson } from './indicadores-confirmacion-citologia'; import { percentNumber, shareText } from './indicadores-format'; import { ID_HISTOPATOLOGIA_CAMA } from './indicadores-kpi'; @@ -105,11 +105,12 @@ export function modeloHistopatologia(datos: IndicadorDatos, periodo: string): Mo if (Object.keys(cats).some(id => !conocidas.includes(id)) || OBLIGATORIAS.some(id => !Object.hasOwn(cats, id))) { return fail('El catálogo no publica las categorías esperadas de la biopsia.'); } - const categorias: Categoria[] = CON_RESULTADO.filter(id => Object.hasOwn(cats, id)).map(id => { + const categorias: Categoria[] = CON_RESULTADO.filter(id => Object.hasOwn(cats, id)).map((id, index) => { const c = cats[id]; if (!registro(c) || !texto(c['etiqueta']) || (c['color'] !== null && c['color'] !== undefined && (typeof c['color'] !== 'string' || !/^#[0-9a-f]{6}$/i.test(c['color']))) || typeof c['grupo'] !== 'string' || !etiquetaGrupo(nombres[c['grupo']])) return fail('Categorías de biopsia incompatibles.'); - return { id, etiqueta: c['etiqueta'], color: (c['color'] as string | null | undefined) ?? COLOR_RESPALDO, grupo: c['grupo'] }; + const publicado = (c['color'] as string | null | undefined) ?? COLOR_RESPALDO; + return { id, etiqueta: c['etiqueta'], color: c2Color(publicado, index), grupo: c['grupo'] }; }); const grupos: GrupoCategorias[] = [...new Set(categorias.map(c => c.grupo))].map(id => { const propias = categorias.filter(c => c.grupo === id); diff --git a/src/app/features/indicadores/indicadores-historico-figures.spec.ts b/src/app/features/indicadores/indicadores-historico-figures.spec.ts index 10e52a2..ed42717 100644 --- a/src/app/features/indicadores/indicadores-historico-figures.spec.ts +++ b/src/app/features/indicadores/indicadores-historico-figures.spec.ts @@ -1,6 +1,7 @@ // Covers how the history charts read each contract: what is drawn, what is shaded as suppressed, and what is // never turned into a number. Fixtures are synthetic rows shaped like /cama/indicadores//datos. import { etiquetaPeriodo, cronologico, historicoFigura } from './indicadores-historico-figures'; +import { C2_PALETTE } from './indicadores-c2-palette'; import { IndicadorDatos } from './indicadores.models'; type Fig = { data: Record[]; layout: Record }; @@ -76,7 +77,7 @@ describe('Histórico: C2 (conteos por categoría)', () => { it('apila las categorías en el orden que publica el indicador, con sus colores y etiquetas', () => { const f = fig(d(completo)); expect(f.data.map(t => t['name'])).toEqual(['BI-RADS 5', 'BI-RADS 4 (sin subcategoría)', 'Sin dato']); - expect((f.data[0]['marker'] as { color: string }).color).toBe('#B55A1F'); + expect((f.data[0]['marker'] as { color: string }).color).toBe(C2_PALETTE.series[0]); expect(f.data[0]['y']).toEqual([4, 4, 4, 4]); expect(f.layout['barmode']).toBe('stack'); expect((f.layout['yaxis'] as { title: { text: string } }).title.text).toBe('Pacientes'); diff --git a/src/app/shared/plotly/plotly-chart.ts b/src/app/shared/plotly/plotly-chart.ts index 2212a1b..26c23ce 100644 --- a/src/app/shared/plotly/plotly-chart.ts +++ b/src/app/shared/plotly/plotly-chart.ts @@ -2,6 +2,7 @@ import { AfterViewInit, Component, inject, ElementRef, Input, OnChanges, OnDestr import { MatButtonModule } from '@angular/material/button'; import { MatProgressBarModule } from '@angular/material/progress-bar'; import { PlotlyFigure } from '../../features/indicadores/indicadores.models'; +import { recolorFigure } from '../../features/indicadores/indicadores-c2-palette'; import { PlotlyController } from './plotly-controller'; import { PLOTLY_LOADER } from './plotly-runtime'; @@ -68,12 +69,12 @@ export class PlotlyChart implements AfterViewInit, OnChanges, OnDestroy { this.observer = new ResizeObserver(this.windowResize); this.observer.observe(this.host.nativeElement); } else window.addEventListener('resize', this.windowResize); - this.controller.setFigure(this.figure); + this.controller.setFigure(recolorFigure(this.figure)); // Also supply the initial width in browsers without ResizeObserver. this.windowResize(); } - ngOnChanges() { if (this.figure) this.controller?.setFigure(this.figure); } - retry() { this.controller?.setFigure(this.figure); } + ngOnChanges() { if (this.figure) this.controller?.setFigure(recolorFigure(this.figure)); } + retry() { this.controller?.setFigure(recolorFigure(this.figure)); } ngOnDestroy() { this.observer?.disconnect(); if (this.widthFrame !== undefined) cancelAnimationFrame(this.widthFrame);