Cosmetic pass: legends above plots, readable hovers and ticks, KPI qualifiers, a header that never wraps
This commit is contained in:
+38
-1
@@ -21,10 +21,22 @@
|
||||
|
||||
.title {
|
||||
flex: 1;
|
||||
min-width: 0; // gives way to the switcher and the sections, on one line
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
// Nothing in the header wraps or shrinks: the title gives way first, then hides.
|
||||
.domain,
|
||||
.sections a,
|
||||
.user {
|
||||
flex-shrink: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.domain {
|
||||
--mat-button-filled-container-color: var(--color-primary);
|
||||
--mat-button-filled-label-text-color: var(--color-text);
|
||||
@@ -67,10 +79,35 @@
|
||||
width: clamp(155px, 15vw, 185px);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
@media (max-width: 1100px) {
|
||||
.title {
|
||||
display: none;
|
||||
}
|
||||
.header {
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.sections {
|
||||
gap: var(--space-3);
|
||||
}
|
||||
// the account by its icon alone; the switcher's name cut short if it must be
|
||||
.user .who-name {
|
||||
display: none;
|
||||
}
|
||||
.domain {
|
||||
max-width: 15rem;
|
||||
}
|
||||
.domain ::ng-deep .mdc-button__label {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.header {
|
||||
flex-wrap: wrap;
|
||||
padding-block: var(--space-2);
|
||||
}
|
||||
}
|
||||
|
||||
.user {
|
||||
|
||||
@@ -108,6 +108,8 @@ export function nestedDonut(r: Reading, catalog: Catalog, center: string): Figur
|
||||
labels: catalog.categories.map((c) => c.label),
|
||||
hole: 0.74,
|
||||
domain: { x: [0, 1], y: [0, 1] },
|
||||
// along the thin ring, so a label fits its slice
|
||||
insidetextorientation: 'tangential',
|
||||
text: values.map((n, i) => (total && n / total >= 0.05 ? catalog.categories[i].label : '')),
|
||||
marker: {
|
||||
colors: catalog.categories.map((c) => rgba(c.color, faded.has(c.code) ? 0.3 : 1)),
|
||||
@@ -150,7 +152,8 @@ export function scenarioBars(
|
||||
xaxis: {
|
||||
title: { text: '% de pacientes del escenario con resultado' },
|
||||
ticksuffix: ' %',
|
||||
range: [0, 100],
|
||||
range: [0, 100.5],
|
||||
dtick: 20,
|
||||
},
|
||||
yaxis: {
|
||||
type: 'category',
|
||||
@@ -159,7 +162,6 @@ export function scenarioBars(
|
||||
categoryarray: y,
|
||||
automargin: true,
|
||||
},
|
||||
legend: { orientation: 'h', y: -0.25 },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,7 +53,13 @@
|
||||
@if (reports.isLoading() && k.measure) {
|
||||
<app-loading [what]="k.title.toLowerCase()" />
|
||||
} @else {
|
||||
<div class="kpi-value" [class.pending]="!k.measure">{{ kpiValue(k) }}</div>
|
||||
<div class="kpi-value" [class.pending]="!k.measure">
|
||||
@let v = kpiParts(kpiValue(k));
|
||||
{{ v[0] }}
|
||||
@if (v[1]) {
|
||||
<span class="kpi-qualifier">{{ v[1] }}</span>
|
||||
}
|
||||
</div>
|
||||
<div class="kpi-detail">{{ kpiNote(k) }}</div>
|
||||
}
|
||||
</mat-card-content>
|
||||
@@ -177,7 +183,13 @@
|
||||
<mat-card appearance="outlined" class="kpi closing" [attr.data-measure]="section.measure">
|
||||
<mat-card-content>
|
||||
<h3 class="kpi-title">{{ section.title }}</h3>
|
||||
<div class="kpi-value">{{ kpiValue(section) }}</div>
|
||||
<div class="kpi-value">
|
||||
@let w = kpiParts(kpiValue(section));
|
||||
{{ w[0] }}
|
||||
@if (w[1]) {
|
||||
<span class="kpi-qualifier">{{ w[1] }}</span>
|
||||
}
|
||||
</div>
|
||||
<div class="kpi-detail">{{ kpiNote(section) }}</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
@@ -61,6 +61,14 @@ h2 {
|
||||
font-size: 2rem;
|
||||
font-weight: 500;
|
||||
margin: var(--space-2) 0;
|
||||
line-height: 1.15;
|
||||
}
|
||||
|
||||
.kpi-qualifier {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.kpi-detail {
|
||||
|
||||
@@ -202,6 +202,12 @@ export class TabIndicadores {
|
||||
return this.byName().get(code);
|
||||
}
|
||||
/** A card's value and note, from its templates (a card with no measure: its words). */
|
||||
/** "27 días (mediana)" as the value and its qualifier, shown smaller beneath it. */
|
||||
protected kpiParts(text: string): [string, string] {
|
||||
const found = /^(.*?)\s*(\([^)]*\))$/.exec(text);
|
||||
return found ? [found[1], found[2]] : [text, ''];
|
||||
}
|
||||
|
||||
protected kpiValue(k: Kpi): string {
|
||||
if (!k.measure) return k.value ?? '';
|
||||
const r = this.rd(k.measure);
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
margin-bottom: var(--space-4);
|
||||
}
|
||||
|
||||
// a field as wide as its label ("Horizonte de la probabilidad")
|
||||
.filters mat-form-field {
|
||||
min-width: 14.5rem;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
overflow-x: auto;
|
||||
padding: 0;
|
||||
@@ -43,6 +48,7 @@ a {
|
||||
|
||||
.worklist td small {
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
+39
-7
@@ -21,8 +21,45 @@ const LAYOUT: Partial<Plotly.Layout> = {
|
||||
margin: { t: 24, r: 16, b: 48, l: 56 },
|
||||
paper_bgcolor: 'rgba(0,0,0,0)',
|
||||
plot_bgcolor: 'rgba(0,0,0,0)',
|
||||
legend: { orientation: 'h', y: -0.2 },
|
||||
// Above the plot, left-aligned: Plotly reserves its room, so it never meets an axis title.
|
||||
legend: { orientation: 'h', x: 0, xanchor: 'left', y: 1.02, yanchor: 'bottom' },
|
||||
hoverlabel: { font: { family: 'Roboto, Arial, sans-serif', size: 13 } },
|
||||
};
|
||||
// Axes make room for their labels and titles; a title keeps clear of the tick labels.
|
||||
// (`ticklabelstandoff` is Plotly's, newer than its published types.)
|
||||
const AXIS = {
|
||||
automargin: true,
|
||||
title: { standoff: 12 },
|
||||
ticklabelstandoff: 4, // the lowest y label and the first x label never touch
|
||||
} as Partial<Plotly.LayoutAxis>;
|
||||
|
||||
/** The platform's layout under a figure's own: legend, margins and axes merged key by key,
|
||||
* so a figure that sets one of their keys keeps the others. */
|
||||
export function layoutOf(layout: Partial<Plotly.Layout> = {}): Partial<Plotly.Layout> {
|
||||
const axes = Object.fromEntries(
|
||||
Object.entries(layout)
|
||||
.filter(([k]) => /^[xy]axis\d*$/.test(k))
|
||||
.map(([k, v]) => {
|
||||
const axis = (v ?? {}) as Partial<Plotly.LayoutAxis>;
|
||||
const title = typeof axis.title === 'string' ? { text: axis.title } : axis.title;
|
||||
return [k, { ...AXIS, ...axis, title: { ...AXIS.title, ...title } }];
|
||||
}),
|
||||
);
|
||||
return {
|
||||
...LAYOUT,
|
||||
xaxis: AXIS,
|
||||
yaxis: AXIS,
|
||||
...layout,
|
||||
...axes,
|
||||
legend: { ...LAYOUT.legend, ...layout.legend },
|
||||
margin: { ...LAYOUT.margin, ...layout.margin },
|
||||
};
|
||||
}
|
||||
|
||||
/** Pie labels that sit outside take the room they need instead of being clipped. */
|
||||
function withRoom(data: Partial<Plotly.Data>[]): Plotly.Data[] {
|
||||
return data.map((d) => (d.type === 'pie' ? { automargin: true, ...d } : d)) as Plotly.Data[];
|
||||
}
|
||||
const CONFIG: Partial<Plotly.Config> = {
|
||||
responsive: true,
|
||||
displaylogo: false,
|
||||
@@ -43,12 +80,7 @@ export class Plot implements OnDestroy {
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const { data, layout } = this.figure();
|
||||
void Plotly.react(
|
||||
this.host().nativeElement,
|
||||
data as Plotly.Data[],
|
||||
{ ...LAYOUT, ...layout },
|
||||
CONFIG,
|
||||
);
|
||||
void Plotly.react(this.host().nativeElement, withRoom(data), layoutOf(layout), CONFIG);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ table.plain td {
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
padding: 6px 8px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
table.plain th {
|
||||
|
||||
Reference in New Issue
Block a user