From 439a039ff48c65d87d6567cc1f6ca8462897f57a Mon Sep 17 00:00:00 2001 From: Angel Capetillo Zavala Date: Wed, 18 Nov 2026 14:58:54 -0600 Subject: [PATCH] =?UTF-8?q?fix(cama):=20recuperar=20el=20tama=C3=B1o=20res?= =?UTF-8?q?ponsivo=20de=20la=20dona=20BI-RADS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indicador-conteos-pareados.html | 2 +- .../indicador-conteos-pareados.scss | 2 +- .../indicadores/indicador-conteos-pareados.ts | 9 ++++++- .../indicadores-conteos-pareados.ts | 26 ++++++++++++------- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/app/features/indicadores/indicador-conteos-pareados.html b/src/app/features/indicadores/indicador-conteos-pareados.html index 18eb9ea..d4d0fcd 100644 --- a/src/app/features/indicadores/indicador-conteos-pareados.html +++ b/src/app/features/indicadores/indicador-conteos-pareados.html @@ -34,7 +34,7 @@

{{ par.unidades.examenes | titlecase }} por categoría, {{ m.periodo }}

@if (total) { - + } @else {

{{ total === null ? 'Dona no disponible: hay celdas suprimidas o sin dato.' : 'Sin ' + par.unidades.examenes + ' en el periodo.' }}

} @if (m.sinDato) {

Fuera de la dona: {{ texto(m.sinDato) }} {{ par.unidades.examenes }} sin categoría.

}
diff --git a/src/app/features/indicadores/indicador-conteos-pareados.scss b/src/app/features/indicadores/indicador-conteos-pareados.scss index 4f3a5e0..2707cca 100644 --- a/src/app/features/indicadores/indicador-conteos-pareados.scss +++ b/src/app/features/indicadores/indicador-conteos-pareados.scss @@ -15,7 +15,7 @@ h3 { font-size: 1rem; font-weight: 500; line-height: 1.5; } @media (min-width: 1100px) { .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } } app-plotly-chart { --plot-height: 400px; } // Keep space for the outside labels and let the existing plot viewport scroll on very narrow cards. -.donut-chart { --plot-min-width: 390px; } +.donut-chart { --plot-min-width: 230px; } summary { cursor: pointer; padding-block: .75rem; } summary:focus-visible, .table-scroll:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 3px; } .table-scroll { overflow: auto; } diff --git a/src/app/features/indicadores/indicador-conteos-pareados.ts b/src/app/features/indicadores/indicador-conteos-pareados.ts index 3ae0ebf..d08333e 100644 --- a/src/app/features/indicadores/indicador-conteos-pareados.ts +++ b/src/app/features/indicadores/indicador-conteos-pareados.ts @@ -38,6 +38,7 @@ export class IndicadorConteosPareados implements OnChanges, OnDestroy { private subscription?: Subscription; private key = ''; private loaded = false; + private anchoDona = 390; get model(): ModeloConteos | undefined { return this.pages[this.periodIndex]; } get total() { return this.model ? totalExamenes(this.model) : null; } @@ -104,10 +105,16 @@ export class IndicadorConteosPareados implements OnChanges, OnDestroy { if (![1, -1].includes(step) || !this.pages[this.periodIndex + step]) return; this.periodIndex += step; this.draw(); } + ajustarAnchoDona(ancho: number) { + if (ancho === this.anchoDona) return; + this.anchoDona = ancho; + const m = this.model; + if (m) this.donutFigure = donaConteos(m, this.par, this.tema, ancho); + } private draw() { const m = this.model; if (!m) return; - this.donutFigure = donaConteos(m, this.par, this.tema); + this.donutFigure = donaConteos(m, this.par, this.tema, this.anchoDona); this.barsFigure = barrasConteos(m, this.par, this.tema); this.changeDetector.markForCheck(); } diff --git a/src/app/features/indicadores/indicadores-conteos-pareados.ts b/src/app/features/indicadores/indicadores-conteos-pareados.ts index e57de8b..c7298ae 100644 --- a/src/app/features/indicadores/indicadores-conteos-pareados.ts +++ b/src/app/features/indicadores/indicadores-conteos-pareados.ts @@ -108,12 +108,20 @@ export function modelosConteos(par: ParConteos, examenes: IndicadorDatos, pacien export const totalExamenes = (m: ModeloConteos) => sumar(m.examenes.map(c => c.n)); const ALTO_DONA = 400, MARGEN_DONA = 8; -const RADIO_DONA = (ALTO_DONA - 2 * MARGEN_DONA) * .2; +const DIAMETRO_MAXIMO_DONA = 270; -export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema): PlotlyFigure { +export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema, ancho = 390): PlotlyFigure { const total = totalExamenes(m); if (!total) return { data: [], layout: {} }; const p = c2Theme(tema), n = m.examenes.map(c => c.n!); + // Fit both label columns before sizing the ring. Use the same radius for Plotly and the guide lines. + const margenEtiquetas = Math.min(90, 59 + Math.max(0, ancho - 230) * .2); + const diametro = Math.max(1, Math.min(DIAMETRO_MAXIMO_DONA, ancho - 2 * (MARGEN_DONA + margenEtiquetas))); + const radio = diametro / 2; + const fraccionVertical = radio / (ALTO_DONA - 2 * MARGEN_DONA); + const fuenteEtiqueta = Math.round(8 + (margenEtiquetas - 59) / 10); + const fuenteUnidad = Math.min(11, Math.max(7, Math.round(radio / 7))); + const separacionCentro = fuenteUnidad === 7 ? 6 : fuenteUnidad < 11 ? 7 : 8; const etiquetas = m.examenes.map(c => escapar(c.etiqueta)); const porcentajes = n.map(v => percentNumber(100 * v / total)); const centro = { x: .5, y: .5, xref: 'paper', yref: 'paper', showarrow: false }; @@ -124,7 +132,7 @@ export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema): Plot const angulo = 2 * Math.PI * (acumulado + valor / 2) / total; acumulado += valor; if (!valor) return []; - const x = RADIO_DONA * Math.sin(angulo), y = RADIO_DONA * Math.cos(angulo); + const x = radio * Math.sin(angulo), y = radio * Math.cos(angulo); return [{ i, x, y }]; }); const llamadas = [-1, 1].flatMap(lado => { @@ -133,26 +141,26 @@ export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema): Plot const altura = (columna.length - 1 - 2 * fila) * 24; const texto = etiquetas[i].replace(' (sin subcategoría)', '
(sin
subcategoría)'); return { - annotation: { ...centro, xshift: lado * 105, yshift: altura, + annotation: { ...centro, xshift: lado * (radio + 10), yshift: altura, xanchor: lado < 0 ? 'right' : 'left', align: lado < 0 ? 'right' : 'left', - font: { size: 11, color: p.text }, text: texto + '
' + porcentajes[i] + ' %' }, + font: { size: fuenteEtiqueta, color: p.text }, text: texto + '
' + porcentajes[i] + ' %' }, shape: { type: 'path', xref: 'paper', yref: 'paper', xsizemode: 'pixel', ysizemode: 'pixel', xanchor: .5, yanchor: .5, line: { color: p.text, width: 1 }, - path: 'M ' + Math.round(x) + ',' + Math.round(y) + ' L ' + lado * 86 + ',' + y + ' L ' + lado * 101 + ',' + altura }, + path: 'M ' + Math.round(x) + ',' + Math.round(y) + ' L ' + lado * (radio + 3) + ',' + y + ' L ' + lado * (radio + 8) + ',' + altura }, }; }); }); return { data: [{ type: 'pie', hole: .54, sort: false, direction: 'clockwise', values: n, labels: etiquetas, marker: { colors: m.examenes.map(c => c.color), line: { color: p.background, width: 2 } }, textinfo: 'none', - domain: { x: [0, 1], y: [.3, .7] }, + domain: { x: [0, 1], y: [.5 - fraccionVertical, .5 + fraccionVertical] }, customdata: n.map((v, i) => [miles(v), porcentajes[i]]), hovertemplate: '%{value}' }], layout: { autosize: true, height: ALTO_DONA, showlegend: false, paper_bgcolor: p.background, font: { color: p.text }, margin: { t: MARGEN_DONA, b: MARGEN_DONA, l: MARGEN_DONA, r: MARGEN_DONA }, shapes: llamadas.map(({ shape }) => shape), annotations: [ - { ...centro, yshift: 8, font: { size: 14, color: p.text }, text: `${miles(total)}` }, - { ...centro, yshift: -8, font: { size: 11, color: p.text }, text: par.unidades.examenes }, + { ...centro, yshift: separacionCentro, font: { size: fuenteUnidad + 3, color: p.text }, text: `${miles(total)}` }, + { ...centro, yshift: -separacionCentro, font: { size: fuenteUnidad, color: p.text }, text: par.unidades.examenes }, ...llamadas.map(({ annotation }) => annotation), ] }, config: { displayModeBar: false } }; }