diff --git a/src/app/indicadores/figures.ts b/src/app/indicadores/figures.ts
index 208d068..4b8ae2f 100644
--- a/src/app/indicadores/figures.ts
+++ b/src/app/indicadores/figures.ts
@@ -4,6 +4,8 @@ import type { Catalog, Category, HistoryPanel } from './pages';
const OLIVE = '#A8C243';
const ROSE = '#C24269';
+export const SHORT = '.1~f';
+export const percentAxis = { ticksuffix: ' %', tickformat: '.0f', hoverformat: SHORT };
const count = (n: number) => n.toLocaleString('es-MX');
const percent = (n: number) => (Math.round(n * 10) / 10).toLocaleString('es-MX');
@@ -32,12 +34,17 @@ export function routeFigure(steps: { label: string; r: Reading | undefined }[]):
array: shown.map((s) => (s.r!.high ?? s.r!.score!) - s.r!.score!),
arrayminus: shown.map((s) => s.r!.score! - (s.r!.low ?? s.r!.score!)),
},
- hovertemplate: '%{y}
mediana %{x} días',
+ hovertemplate: `%{y}
mediana %{x:${SHORT}} días`,
} as Partial,
],
layout: {
showlegend: false,
- xaxis: { title: { text: 'Días' }, rangemode: 'tozero', zeroline: false },
+ xaxis: {
+ title: { text: 'Días' },
+ rangemode: 'tozero',
+ zeroline: false,
+ ...valueAxis(shown.flatMap((s) => [s.r!.score, s.r!.high])),
+ },
yaxis: { autorange: 'reversed', type: 'category', automargin: true },
},
};
@@ -96,7 +103,7 @@ export function nestedDonut(r: Reading, catalog: Catalog, center: string): Figur
),
line: { color: '#FFFFFF', width: 2 },
},
- hovertemplate: '%{label}
%{value} (%{percent})',
+ hovertemplate: '%{label}
%{value:d} (%{percent:.1~%})',
},
{
...common,
@@ -111,7 +118,7 @@ export function nestedDonut(r: Reading, catalog: Catalog, center: string): Figur
colors: catalog.categories.map((c) => rgba(c.color, faded.has(c.code) ? 0.3 : 1)),
line: { color: '#FFFFFF', width: 2 },
},
- hovertemplate: '%{label}
%{value} (%{percent})',
+ hovertemplate: '%{label}
%{value:d} (%{percent:.1~%})',
},
] as Partial[],
layout: { margin: { t: 10, l: 10, r: 10, b: 10 } },
@@ -140,13 +147,13 @@ export function scenarioBars(
x: scenarios.map((s, i) => (totals[i] ? (100 * n(s, c.code)) / totals[i] : 0)),
customdata: scenarios.map((s) => n(s, c.code)),
marker: { color: c.color },
- hovertemplate: `${c.label}
%{y}: %{customdata} (%{x:.1f} %)`,
+ hovertemplate: `${c.label}
%{y}: %{customdata} (%{x:.1~f} %)`,
})) as Partial[],
layout: {
barmode: 'stack',
xaxis: {
title: { text: '% de pacientes del escenario con resultado' },
- ticksuffix: ' %',
+ ...percentAxis,
range: [0, 100.5],
dtick: 20,
},
@@ -206,7 +213,7 @@ export function rateDots(
array: rows.map((x) => (x.rate === null ? 0 : x.high! - x.rate)),
arrayminus: rows.map((x) => (x.rate === null ? 0 : x.rate - x.low!)),
},
- hovertemplate: '%{y}: %{x:.1f} %',
+ hovertemplate: '%{y}: %{x:.1~f} %',
} as Partial,
],
layout: {
@@ -218,7 +225,7 @@ export function rateDots(
categoryarray: [...y].reverse(),
automargin: true,
},
- xaxis: { range: [0, 100], ticksuffix: ' %', zeroline: false, title: { text: spec.axis } },
+ xaxis: { range: [0, 100], ...percentAxis, zeroline: false, title: { text: spec.axis } },
annotations: rows.map((x) => ({
x: 1,
xref: 'paper',
@@ -274,7 +281,10 @@ export function boxFigure(r: Reading, period: string): Figure {
hovertemplate: `Q1 ${decimal(q1)} · mediana ${decimal(r.score!)} · Q3 ${decimal(q3)} días`,
} as Partial,
],
- layout: { showlegend: false, yaxis: { title: { text: 'días' }, rangemode: 'tozero' } },
+ layout: {
+ showlegend: false,
+ yaxis: { title: { text: 'días' }, rangemode: 'tozero', ...valueAxis([q1, r.score!, q3]) },
+ },
};
}
@@ -294,9 +304,9 @@ export function shareDonut(r: Reading, catalog: Catalog, center: string): Figure
colors: catalog.categories.map((c) => c.color),
line: { color: '#FFFFFF', width: 2 },
},
- texttemplate: values.map((v) => (v ? '%{label}
%{percent}' : '')),
+ texttemplate: values.map((v) => (v ? '%{label}
%{percent:.1~%}' : '')),
textposition: 'outside',
- hovertemplate: '%{label}
%{value} (%{percent})',
+ hovertemplate: '%{label}
%{value:d} (%{percent:.1~%})',
} as Partial,
],
layout: {
@@ -327,9 +337,9 @@ export function countBars(r: Reading, catalog: Catalog, axis: string, period: st
y,
x: catalog.categories.map((c) => counted(r, c.code)),
marker: { color: catalog.categories.map((c) => c.color) },
- texttemplate: '%{x}',
+ texttemplate: '%{x:d}',
textposition: 'outside',
- hovertemplate: '%{y}: %{x}',
+ hovertemplate: '%{y}: %{x:d}',
} as Partial,
],
layout: {
@@ -377,13 +387,21 @@ export function ageStack(r: Reading, names: [string, string]): Figure {
marker: { color: i ? rgba(color, 0.25) : color },
text: y.map((n, j) => (n ? `${n} (${percent((100 * n) / totals[j])} %)` : '')),
textposition: 'inside',
- hovertemplate: '%{x}
%{fullData.name}: %{y} pacientes',
+ hovertemplate: '%{x}
%{fullData.name}: %{y:d} pacientes',
})) as Partial[];
}),
layout: {
barmode: 'stack',
xaxis: { title: { text: 'Grupo de edad' }, type: 'category' },
- yaxis: { title: { text: 'Pacientes' }, rangemode: 'tozero' },
+ yaxis: {
+ title: { text: 'Pacientes' },
+ rangemode: 'tozero',
+ ...valueAxis(
+ bands.flatMap((band) =>
+ TEA_SEXES.map(({ code }) => cells[`${band}|${code}`]?.['denominator'] ?? 0),
+ ),
+ ),
+ },
},
};
}
@@ -402,14 +420,14 @@ export function ageShare(r: Reading, axis: string): Figure {
return row?.['denominator'] ? (100 * (row['numerator'] ?? 0)) / row['denominator'] : null;
}),
marker: { color },
- texttemplate: '%{y:.1f} %',
+ texttemplate: '%{y:.1~f} %',
textposition: 'outside',
- hovertemplate: '%{x}: %{y:.1f} %%{fullData.name}',
+ hovertemplate: '%{x}: %{y:.1~f} %%{fullData.name}',
})),
layout: {
barmode: 'group',
xaxis: { title: { text: 'Grupo de edad' }, type: 'category' },
- yaxis: { title: { text: axis }, range: [0, 100], ticksuffix: ' %' },
+ yaxis: { title: { text: axis }, range: [0, 100], ...percentAxis },
},
};
}
@@ -420,7 +438,8 @@ export function valueAxis(values: Iterable) {
const narrow = found.length > 0 && Math.max(...found) - Math.min(...found) <= 5;
return {
type: 'linear' as const,
- tickformat: counts ? 'd' : '.1~f',
+ tickformat: counts ? 'd' : SHORT,
+ hoverformat: counts ? 'd' : SHORT,
...(counts && narrow ? { dtick: 1 } : {}),
};
}
@@ -499,7 +518,7 @@ export function sexCountBars(r: Reading, catalog: Catalog, axis: string, period:
name: name(code),
marker: { color },
x: catalog.categories.map((c) => cells[`${code}|${c.code}`]?.['initial-population'] ?? 0),
- hovertemplate: '%{y}: %{x}%{fullData.name}',
+ hovertemplate: '%{y}: %{x:d}%{fullData.name}',
})) as Partial[],
layout: { ...base.layout, barmode: 'group', showlegend: true },
};
@@ -592,13 +611,19 @@ export function teaSexBars(r: Reading, selectedSex?: string): Figure {
return [percent(total ? (100 * y[j]) / total : 0), total];
}),
hovertemplate:
- '%{x} · %{fullData.name}
%{y} niños, %{customdata[0]} % de %{customdata[1]}',
+ '%{x} · %{fullData.name}
%{y:d} niños, %{customdata[0]} % de %{customdata[1]}',
};
}),
layout: {
barmode: 'group',
xaxis: { title: { text: 'Sexo' }, type: 'category' },
- yaxis: { title: { text: 'Niños' }, rangemode: 'tozero' },
+ yaxis: {
+ title: { text: 'Niños' },
+ rangemode: 'tozero',
+ ...valueAxis(
+ TEA_SEXES.map(({ code }) => r.strata['sex']?.[code]?.['initial-population'] ?? 0),
+ ),
+ },
},
};
}
@@ -626,7 +651,7 @@ export function teaAlterations(r: Reading): Figure {
xaxis: { type: 'category', title: { text: 'Alteración del EEG' } },
yaxis: {
range: [0, 100],
- ticksuffix: ' %',
+ ...percentAxis,
title: { text: '% de niños con EEG de buena calidad' },
},
},
diff --git a/src/app/paciente/paciente.ts b/src/app/paciente/paciente.ts
index 8488f85..cbeb6b6 100644
--- a/src/app/paciente/paciente.ts
+++ b/src/app/paciente/paciente.ts
@@ -32,6 +32,7 @@ import {
} from '../fhir';
import { scenarioFigure } from '../gobernanza/figures';
import { ageGroup, CAMA_AGE_GROUPS, camaRows } from '../indicadores/follow-up';
+import { SHORT } from '../indicadores/figures';
import { LABELS, name, PRIORITY } from '../indicadores/measures';
import { Figure, PALETTE, Plot } from '../plot';
import { Loading } from '../loading';
@@ -273,7 +274,8 @@ export class Paciente {
yaxis: {
title: { text: 'Probabilidad (%)' },
range: [0, Math.max(5, this.top() * 110)],
- tickformat: '.1f',
+ tickformat: SHORT,
+ hoverformat: SHORT,
},
},
};
diff --git a/src/app/paciente/tea-figures.ts b/src/app/paciente/tea-figures.ts
index b375751..ae33455 100644
--- a/src/app/paciente/tea-figures.ts
+++ b/src/app/paciente/tea-figures.ts
@@ -249,7 +249,7 @@ export function ageNorm(rows: Centile[], metric: Metric, age: number): Figure {
},
],
layout: {
- xaxis: { title: { text: 'Edad (meses)' } },
+ xaxis: { title: { text: 'Edad (meses)' }, ...valueAxis([age]) },
yaxis: {
title: { text: metric.unit ?? 'Valor' },
...valueAxis([metric.value, ...rows.flatMap(({ p5, median, p95 }) => [p5, median, p95])]),
@@ -390,7 +390,7 @@ export function probabilityCurve(
return {
data,
layout: {
- xaxis: { title: { text: 'Puntuación z' } },
+ xaxis: { title: { text: 'Puntuación z' }, ...valueAxis([pair.z, 0]) },
yaxis: { title: { text: 'Probabilidad (%)' }, ...valueAxis([0, 100]), range: [0, 100] },
},
};