Usar barras comunes en confirmación y renombrar la serie de ingreso del NCI
This commit is contained in:
@@ -54,6 +54,8 @@ export type Mode = {
|
||||
hidden?: Hidden;
|
||||
}
|
||||
| { kind: 'days'; steps: { label: string; measure: string }[]; tint?: Tint }
|
||||
/** A proportion as one bar of 0 to 100 %, its 95 % interval as the two marks on it */
|
||||
| { kind: 'ratio'; measure: string; colors?: Colors }
|
||||
| { kind: 'days-by'; measure: string; stratum: string; tint?: Tint }
|
||||
/** A proportion as its two parts (what counted and what did not), in units, with the shares */
|
||||
| { kind: 'split'; measure: string; yes: string; no: string; colors?: [string, string] }
|
||||
@@ -70,7 +72,7 @@ export type Mode = {
|
||||
| {
|
||||
kind: 'figure';
|
||||
measure: string;
|
||||
figure: 'donut' | 'scenarios' | 'interval';
|
||||
figure: 'donut' | 'scenarios';
|
||||
/** a donut's colour by part (a category, or numerator and rest); none: the page's palette */
|
||||
colors?: Colors;
|
||||
catalog?: Category[];
|
||||
@@ -204,6 +206,25 @@ const days = (n: number) => (Math.round(n * 10) / 10).toLocaleString('es-MX');
|
||||
/** The bars of a mode; none when the period has nothing to draw. */
|
||||
export function bars(mode: Mode, of: (measure: string) => Reading | undefined): Bars | undefined {
|
||||
switch (mode.kind) {
|
||||
case 'ratio': {
|
||||
const r = of(mode.measure);
|
||||
const n = r?.populations['numerator'] ?? 0;
|
||||
const total = r?.populations['denominator'] ?? 0;
|
||||
if (r?.score === undefined || !total) return undefined;
|
||||
const ends = r.low !== undefined && r.high !== undefined ? [r.low, r.high] : [];
|
||||
return {
|
||||
head: ['n/N', '%', 'IC 95 %'],
|
||||
rows: [
|
||||
{
|
||||
label: 'Total',
|
||||
color: mode.colors?.['numerator'],
|
||||
width: 100 * r.score,
|
||||
marks: ends.map((v) => 100 * v),
|
||||
cells: [`${n}/${total}`, pct(n, total), ends.map((v) => pct(v, 1)).join('–') || '—'],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
case 'counts': {
|
||||
const cells = of(mode.measure)?.strata['category'] ?? {};
|
||||
const total = Object.values(cells).reduce((n, c) => n + size(c), 0);
|
||||
|
||||
Reference in New Issue
Block a user