diff --git a/src/app/features/indicadores/indicadores-cacu-estratos.spec.ts b/src/app/features/indicadores/indicadores-cacu-estratos.spec.ts
index fad6a86..88c37a1 100644
--- a/src/app/features/indicadores/indicadores-cacu-estratos.spec.ts
+++ b/src/app/features/indicadores/indicadores-cacu-estratos.spec.ts
@@ -8,7 +8,7 @@
import { Bundle, resources } from './fhir';
import { categorias, datosDeReportes, gruposDeCategoria, indicadorDeMeasure, Measure, Report } from './indicadores-fhir';
import { barras, dona, modelo } from './indicadores-eu7-escenario';
-import { modeloConfirmacion } from './indicadores-confirmacion-citologia';
+import { donaConfirmacion, modeloConfirmacion } from './indicadores-confirmacion-citologia';
import { declaraEstrato, stratifiedCapabilities } from './indicadores-stratified';
import { IndicadorDatos } from './indicadores.models';
import measuresData from './fixtures/cacu_fhir_measures.json';
@@ -126,6 +126,28 @@ describe('Vistas propias de CaCu con los datos de FHIR', () => {
expect(barras(m, {}, 'claro').data.length).toBeGreaterThan(0);
});
+ it('EU7: el texto emergente de cada sector de la dona nombra la categoría, los pacientes y el porcentaje', () => {
+ // Pins down: both rings carry one pre-formatted hover text per sector («2 pacientes, 2.1 % del total con
+ // resultado» for LIEAG, 2 of the 95 patients with a result) and their template reads it by name. A pie wraps
+ // `customdata` in an extra array, so a template that indexes it printed «2,2.1 pacientes, - %». Fails if the
+ // template goes back to indexing `customdata` or a sector loses its text.
+ const general = datosDeReportes(measure(EU7), reports('eu7_2025S2'), 'semestre') as IndicadorDatos;
+ const escenarios = datosDeReportes(measure(EU7), reports('eu7_2025S2'), 'semestre', { estrato: 'estatus_seguimiento' }) as IndicadorDatos;
+ const m = modelo(general, escenarios, '2025-S2');
+ const anillos = dona(m, {}, 'claro').data.filter(t => t['name'] === 'grupos' || t['name'] === 'categorias');
+ expect(anillos.length).toBe(2);
+ for (const anillo of anillos) {
+ expect(anillo['hovertemplate']).not.toContain('customdata');
+ expect(anillo['hovertemplate']).toContain('%{hovertext}');
+ expect((anillo['hovertext'] as string[]).length).toBe((anillo['values'] as number[]).length);
+ }
+ const exterior = anillos.find(t => t['name'] === 'categorias')!;
+ const etiquetas = exterior['labels'] as string[], textos = exterior['hovertext'] as string[];
+ expect(m.total).toBe(95);
+ expect(textos[etiquetas.indexOf('LIEAG')]).toBe('2 pacientes, 2.1 % del total con resultado');
+ expect(textos.every(t => /^\d+ pacientes, \d+(\.\d)? % del total con resultado$/.test(t))).toBe(true);
+ });
+
it('EU7: un periodo sin pacientes es un periodo vacío, no una respuesta incompatible', () => {
// Pins down: for 2021-S1 FHIR publishes the general distribution as explicit zeros and no scenario; the view reads
// it as empty. A positive count without scenarios is still rejected. Fails if an empty period shows
@@ -167,6 +189,26 @@ describe('Vistas propias de CaCu con los datos de FHIR', () => {
expect((datos['totales_estrato'] as { n: number }[]).reduce((s, t) => s + t.n, 0)).toBe(6);
});
+ it('confirmación: el texto emergente de cada sector de la dona nombra el grado, las mujeres con biopsia y el porcentaje', () => {
+ // Pins down: both rings carry one pre-formatted hover text per sector («3 mujeres con biopsia, 75.0 %» for the
+ // grades LIEAG o más… of the 4 women with a biopsy in 2025-S2) and their template reads it by name, because a pie
+ // wraps `customdata` in an extra array and indexing it printed «3,75.0 % mujeres con biopsia, -». Fails if the
+ // template goes back to indexing `customdata` or a sector loses its text.
+ const datos = datosDeReportes(measure(CONF), reports('confirmacion_2025S2'), 'semestre', { estrato: 'citologia_alto_grado' }) as IndicadorDatos;
+ const m = modeloConfirmacion(datos, '2025-S2');
+ const anillos = donaConfirmacion(m, { grupo: m.base }, 'claro').data.filter(t => t['name'] === 'grupos' || t['name'] === 'categorias');
+ expect(anillos.length).toBe(2);
+ for (const anillo of anillos) {
+ expect(anillo['hovertemplate']).not.toContain('customdata');
+ expect(anillo['hovertemplate']).toContain('%{hovertext}');
+ expect((anillo['hovertext'] as string[]).length).toBe((anillo['values'] as number[]).length);
+ }
+ const exterior = anillos.find(t => t['name'] === 'categorias')!;
+ const etiquetas = exterior['labels'] as string[], textos = exterior['hovertext'] as string[];
+ expect(textos[etiquetas.indexOf('LIEAG (CIN 2 y 3)')]).toBe('3 mujeres con biopsia, 75.0 %');
+ expect(textos.every(t => /^\d+ mujeres con biopsia, \d+(\.\d)? %$/.test(t))).toBe(true);
+ });
+
it('la compuerta de EU7 usa los estratos que declara la Measure y no activa filtros para otras composiciones', () => {
// Pins down: EU7 declares `estatus_seguimiento`, so its view opens without local filters; the stratified
// capabilities of the generic figure panel stay empty for every CaCu and CaMa measure. Fails if the gate is lost
diff --git a/src/app/features/indicadores/indicadores-confirmacion-citologia.ts b/src/app/features/indicadores/indicadores-confirmacion-citologia.ts
index 2f6b2ec..2d4f425 100644
--- a/src/app/features/indicadores/indicadores-confirmacion-citologia.ts
+++ b/src/app/features/indicadores/indicadores-confirmacion-citologia.ts
@@ -228,17 +228,18 @@ export function donaConfirmacion(m: ModeloConfirmacion, sel: SeleccionConfirmaci
const interior = m.grupos.map(g => g.grados.reduce((s, c) => s + m.totales[c]!, 0));
const exterior = m.grados.map(g => m.totales[g.id]!);
const comun = { type: 'pie', sort: false, direction: 'clockwise', rotation: 0, showlegend: false, textinfo: 'none' };
- const hover = { hovertemplate: '%{label}
%{customdata[0]} mujeres con biopsia, %{customdata[1]}' };
- const custom = (values: number[]) => values.map(n => [miles(n), shareText(n, total)]);
+ // A pie wraps `customdata` in one more array in its hover template, so the text is formatted per point instead.
+ const hover = { hovertemplate: '%{label}
%{hovertext}' };
+ const hoverText = (values: number[]) => values.map(n => `${miles(n)} mujeres con biopsia, ${shareText(n, total)}`);
return { data: [
{ ...comun, name: 'centro', values: [1], labels: ['centro'], domain: { x: [.32, .68], y: [.32, .68] }, textinfo: 'text', textposition: 'inside',
text: [`${miles(k)}
de ${miles(total)} con biopsia`], textfont: { size: 16, color: p.text },
marker: { colors: [p.background] }, hovertemplate: 'Volver a ' + escapar(m.grupos.find(g => g.id === m.base)!.etiqueta) + '' },
{ ...comun, ...hover, name: 'grupos', values: interior, hole: .62, domain: { x: [.16, .84], y: [.16, .84] },
- labels: m.grupos.map(g => escapar(g.etiqueta)), customdata: custom(interior),
+ labels: m.grupos.map(g => escapar(g.etiqueta)), hovertext: hoverText(interior),
marker: { colors: m.grupos.map(g => rgba(g.color, g.grados.some(c => activos.has(c)) ? 1 : .3)), line: { color: p.background, width: 2 } } },
{ ...comun, ...hover, name: 'categorias', values: exterior, hole: .74, domain: { x: [0, 1], y: [0, 1] },
- labels: m.grados.map(g => escapar(g.etiqueta)), customdata: custom(exterior),
+ labels: m.grados.map(g => escapar(g.etiqueta)), hovertext: hoverText(exterior),
marker: { colors: m.grados.map(g => rgba(g.color, activos.has(g.id) ? 1 : .3)), line: { color: p.background, width: 2 } } },
], layout: { autosize: true, height: 360, margin: { t: 10, l: 10, r: 10, b: 10 }, paper_bgcolor: p.background, font: { color: p.text } },
config: { displayModeBar: false } };
diff --git a/src/app/features/indicadores/indicadores-eu7-escenario.ts b/src/app/features/indicadores/indicadores-eu7-escenario.ts
index 499d2ad..fad4698 100644
--- a/src/app/features/indicadores/indicadores-eu7-escenario.ts
+++ b/src/app/features/indicadores/indicadores-eu7-escenario.ts
@@ -200,19 +200,20 @@ export function dona(m: Modelo, sel: Seleccion, tema: Tema): PlotlyFigure {
};
const comun = { type: 'pie', sort: false, direction: 'clockwise', rotation: 0, textinfo: 'text',
insidetextorientation: 'horizontal', showlegend: false, textposition: 'inside' };
- const hover = { hovertemplate: '%{label}
%{customdata[0]} pacientes, %{customdata[1]} % del total con resultado' };
- const custom = (values: number[]) => values.map(n => [miles(n), percentNumber(100 * n / m.total!)]);
+ // A pie wraps `customdata` in one more array in its hover template, so the text is formatted per point instead.
+ const hover = { hovertemplate: '%{label}
%{hovertext}' };
+ const hoverText = (values: number[]) => values.map(n => `${miles(n)} pacientes, ${percentNumber(100 * n / m.total!)} % del total con resultado`);
return { data: [
{ ...comun, name: 'centro', values: [1], labels: ['centro'], domain: { x: [.32, .68], y: [.32, .68] },
text: [`${miles(centro)}
${escapar(seleccionEtiqueta(m, sel))}`], textfont: { size: 18, color: p.text },
marker: { colors: [p.background] }, hovertemplate: (sel.grupo || sel.categoria ? 'Volver' : 'Pacientes con resultado') + '' },
{ ...comun, ...hover, name: 'grupos', values: interior, hole: .62, domain: { x: [.16, .84], y: [.16, .84] },
labels: m.grupos.map(g => escapar(g.etiqueta)), text: rotulos(interior, m.grupos.map(g => g.etiqueta), false),
- textfont: { color: '#FFFFFF' }, customdata: custom(interior),
+ textfont: { color: '#FFFFFF' }, hovertext: hoverText(interior),
marker: { colors: m.grupos.map(g => rgba(g.color, sel.categoria ? .3 : 1)), line: { color: p.background, width: 2 } } },
{ ...comun, ...hover, name: 'categorias', values: exterior, hole: .74, domain: { x: [0, 1], y: [0, 1] },
labels: m.categorias.map(c => escapar(c.etiqueta)), text: rotulos(exterior, m.categorias.map(c => c.etiqueta), true),
- textfont: { size: 11 }, customdata: custom(exterior),
+ textfont: { size: 11 }, hovertext: hoverText(exterior),
marker: { colors: m.categorias.map(c => rgba(c.color, sel.categoria && c.id !== sel.categoria ? .3 : 1)), line: { color: p.background, width: 2 } } },
], layout: { autosize: true, height: 440, margin: { t: 10, l: 10, r: 10, b: 10 }, paper_bgcolor: p.background, font: { color: p.text } },
config: { displayModeBar: false } };