feat(tea): pestaña Evolución y paleta con el verde de ISSSTELEON
- Pestaña Evolución (solo TEA), entre Resumen y Seguimiento: una figura por indicador con todos los periodos publicados, mensual o semestral. Barras apiladas para C2, línea con intervalo de confianza para C1 y mediana con cuartiles para C3r. Los periodos suprimidos se sombrean, no se dibujan como cero. - Paleta: verde #A8C243 y rojo ladrillo #B8433A, comprobados para daltonismo. Las líneas usan un verde más oscuro sobre fondo claro. - «Sin EEG» conserva su color en M21 y M22. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Categoria, dona, Grupo, Modelo } from './indicadores-eu7-escenario';
|
||||
import { percentNumber, shareText } from './indicadores-format';
|
||||
import { donaHighlight, FigureHighlight } from './indicadores-highlight';
|
||||
import { c2Theme } from './indicadores-c2-palette';
|
||||
import { C2_PALETTE, c2Theme } from './indicadores-c2-palette';
|
||||
import { FigureSelection, IndicadorDatos, PlotlyFigure } from './indicadores.models';
|
||||
|
||||
// Figures by age group for a C1 proportion over one semester, built from the age-stratified C1 rows:
|
||||
@@ -20,8 +20,10 @@ const EVENT_LABELS: Readonly<Record<string, readonly [string, string]>> = {
|
||||
M22_diagnosticados_sin_eeg: ['Sin EEG', 'Con EEG'],
|
||||
M24_confirmacion_diagnostico: ['Con diagnóstico positivo de TEA', 'Sin diagnóstico de TEA'],
|
||||
};
|
||||
// The CaCu ring colours: blue for the event, orange for its complement; age groups get lighter shades.
|
||||
const RING_COLORS = ['#2F6DB3', '#D9822B'] as const;
|
||||
// Green for the event, red for its complement; age groups get lighter shades.
|
||||
const RING_COLORS = [C2_PALETTE.series[0], C2_PALETTE.series[1]] as const;
|
||||
// M22's event is M21's complement: «Sin EEG» keeps its colour across both indicators.
|
||||
const ringColors = (indicador: string): readonly [string, string] => indicador === 'M22_diagnosticados_sin_eeg' ? [RING_COLORS[1], RING_COLORS[0]] : RING_COLORS;
|
||||
|
||||
export type C1DonutResult = { status: 'unsupported'; reason: string }
|
||||
| { status: 'supported'; figure: PlotlyFigure; highlight: FigureHighlight; total: number; notes: string[] };
|
||||
@@ -63,14 +65,15 @@ export function c1DonutFigure(data: IndicadorDatos, selection: FigureSelection):
|
||||
const title = { text: escape(String(data['titulo'] ?? data.id)) + ', ' + period };
|
||||
const total = strata.reduce((sum, s) => sum + (s.denominador as number), 0);
|
||||
if (selection.figura === C1_AGE_BARS) {
|
||||
const figure = ageBars(strata, labels[0], selection);
|
||||
const colors = ringColors(data.id);
|
||||
const figure = ageBars(strata, labels[0], colors[0], selection);
|
||||
figure.layout = { ...figure.layout, title };
|
||||
const highlight: FigureHighlight = { groups: [], traces: [0], allLabel: 'Todos los grupos de edad',
|
||||
items: strata.map((s, i) => ({ id: s.id, label: s.label, color: RING_COLORS[0], points: [{ trace: 0, index: i }] })) };
|
||||
items: strata.map((s, i) => ({ id: s.id, label: s.label, color: colors[0], points: [{ trace: 0, index: i }] })) };
|
||||
return { status: 'supported', figure, highlight, total, notes };
|
||||
}
|
||||
|
||||
const grupos: Grupo[] = labels.map((etiqueta, g) => ({ id: g ? 'SIN' : 'CON', etiqueta, color: RING_COLORS[g] }));
|
||||
const grupos: Grupo[] = labels.map((etiqueta, g) => ({ id: g ? 'SIN' : 'CON', etiqueta, color: ringColors(data.id)[g] }));
|
||||
const categorias: Categoria[] = [], celdas: Modelo['celdas'] = {};
|
||||
grupos.forEach((g, gi) => strata.forEach((s, i) => {
|
||||
const id = g.id + ':' + s.id, n = gi ? (s.denominador as number) - (s.numerador as number) : s.numerador as number;
|
||||
@@ -120,11 +123,11 @@ export function c1DonutFigure(data: IndicadorDatos, selection: FigureSelection):
|
||||
// "Con EEG" -> "con EEG", to follow «pacientes».
|
||||
const what = (label: string) => label.charAt(0).toLowerCase() + label.slice(1);
|
||||
// One bar per age group: the share of its patients with the event.
|
||||
function ageBars(strata: readonly { label: string; numerador: unknown; denominador: unknown }[], event: string, selection: FigureSelection): PlotlyFigure {
|
||||
function ageBars(strata: readonly { label: string; numerador: unknown; denominador: unknown }[], event: string, color: string, selection: FigureSelection): PlotlyFigure {
|
||||
const theme = c2Theme(selection.tema);
|
||||
const x = strata.map(s => escape(s.label));
|
||||
const y = strata.map(s => (s.denominador as number) ? 100 * (s.numerador as number) / (s.denominador as number) : null);
|
||||
return { data: [{ type: 'bar', x, y, marker: { color: RING_COLORS[0], line: { color: theme.background, width: 1 } },
|
||||
return { data: [{ type: 'bar', x, y, marker: { color, line: { color: theme.background, width: 1 } },
|
||||
text: y.map(v => v === null ? '' : percentNumber(v) + ' %'), textposition: 'outside', cliponaxis: false,
|
||||
customdata: strata.map(s => [s.numerador, s.denominador]),
|
||||
hovertemplate: '%{x}<br>%{y:.1f} % (%{customdata[0]} de %{customdata[1]} pacientes)<extra></extra>' }],
|
||||
|
||||
Reference in New Issue
Block a user