CaCu indicators: one selector for the cytology and HPV genotype views, grouped bars and genotype labels
This commit is contained in:
@@ -2,7 +2,7 @@ import { Component, computed, input, signal } from '@angular/core';
|
||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||
import { Loading } from '../loading';
|
||||
import { Figure, Plot } from '../plot';
|
||||
import { bars, Mode, unavailable } from './bars';
|
||||
import { bars, grouped, hiddenNote, Mode, unavailable } from './bars';
|
||||
import { Reading } from './measures';
|
||||
|
||||
/** A card read one mode at a time: its title, its headline, the toggle and the bars. */
|
||||
@@ -17,7 +17,7 @@ import { Reading } from './measures';
|
||||
@if (note()) {
|
||||
<p class="state">{{ note() }}</p>
|
||||
}
|
||||
@if (modes().length > 1) {
|
||||
@if (modes().length > 1 && !view()) {
|
||||
<mat-button-toggle-group
|
||||
[attr.aria-label]="title()"
|
||||
[value]="mode().label"
|
||||
@@ -35,8 +35,47 @@ import { Reading } from './measures';
|
||||
<app-loading what="la figura" [figure]="true" />
|
||||
} @else if (missing(); as why) {
|
||||
<p class="state" role="status">{{ why }}</p>
|
||||
} @else if (groups(); as g) {
|
||||
<div class="axis" aria-hidden="true">
|
||||
<span></span>
|
||||
<span class="ticks">
|
||||
<span style="left: 0">0 %</span><span style="left: 25%">25 %</span
|
||||
><span style="left: 50%">50 %</span><span style="left: 75%">75 %</span
|
||||
><span style="left: 100%">100 %</span>
|
||||
</span>
|
||||
<span></span>
|
||||
</div>
|
||||
@for (group of g.groups; track group.code) {
|
||||
<section class="group" [attr.data-group]="group.code" [attr.aria-label]="group.label">
|
||||
<h4>
|
||||
{{ group.label }} <span class="n">n = {{ group.total }}</span>
|
||||
@if (group.hint) {
|
||||
<span class="hint">{{ group.hint }}</span>
|
||||
}
|
||||
</h4>
|
||||
@for (row of group.rows; track row.label) {
|
||||
<div class="row" [attr.data-category]="row.label">
|
||||
<span class="name">{{ row.label }}</span>
|
||||
<span class="track" aria-hidden="true">
|
||||
<span
|
||||
class="fill"
|
||||
[style.width.%]="row.percent ?? 0"
|
||||
[style.background]="row.color"
|
||||
></span>
|
||||
</span>
|
||||
<span class="value">{{ row.text }}</span>
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
@if (g.note) {
|
||||
<p class="state">{{ g.note }}</p>
|
||||
}
|
||||
} @else if (figure(); as f) {
|
||||
<app-plot [figure]="f" [height]="height()" />
|
||||
@if (hidden(); as why) {
|
||||
<p class="state">{{ why }}</p>
|
||||
}
|
||||
} @else if (table(); as t) {
|
||||
<table [attr.aria-label]="mode().label">
|
||||
<thead>
|
||||
@@ -111,6 +150,98 @@ import { Reading } from './measures';
|
||||
white-space: normal;
|
||||
width: 60%;
|
||||
}
|
||||
.axis {
|
||||
column-gap: 8px;
|
||||
display: grid;
|
||||
font-size: 12px;
|
||||
grid-template-columns: var(--name-width) 1fr var(--value-width);
|
||||
margin: 12px 0 2px;
|
||||
}
|
||||
.ticks {
|
||||
height: 1.2em;
|
||||
position: relative;
|
||||
}
|
||||
.ticks span {
|
||||
white-space: nowrap;
|
||||
position: absolute;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
.ticks span:first-child {
|
||||
transform: none;
|
||||
}
|
||||
.ticks span:last-child {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
.group {
|
||||
margin: 6px 0 14px;
|
||||
}
|
||||
.group h4 {
|
||||
font-size: 0.95rem;
|
||||
margin: 0 0 4px;
|
||||
}
|
||||
.group .n,
|
||||
.group .hint {
|
||||
color: var(--mat-sys-on-surface-variant, #5f6368);
|
||||
font-size: 0.8em;
|
||||
font-weight: 400;
|
||||
margin-left: 8px;
|
||||
}
|
||||
.row {
|
||||
align-items: center;
|
||||
column-gap: 8px;
|
||||
display: grid;
|
||||
font-size: 0.9rem;
|
||||
grid-template-columns: var(--name-width) 1fr var(--value-width);
|
||||
min-height: 22px;
|
||||
}
|
||||
.row .track {
|
||||
background:
|
||||
linear-gradient(to right, #d8dde1 1px, transparent 1px) 25% 0 / 1px 100% no-repeat,
|
||||
linear-gradient(to right, #d8dde1 1px, transparent 1px) 50% 0 / 1px 100% no-repeat,
|
||||
linear-gradient(to right, #d8dde1 1px, transparent 1px) 75% 0 / 1px 100% no-repeat,
|
||||
rgba(0, 0, 0, 0.06);
|
||||
display: block;
|
||||
height: 10px;
|
||||
}
|
||||
.row .fill {
|
||||
display: block;
|
||||
height: 100%;
|
||||
}
|
||||
.row .value {
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
:host {
|
||||
--name-width: 8.5rem;
|
||||
--value-width: 8.5rem;
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
:host {
|
||||
--name-width: 0px;
|
||||
--value-width: 0px;
|
||||
}
|
||||
.axis {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.axis > span:not(.ticks) {
|
||||
display: none;
|
||||
}
|
||||
.row {
|
||||
grid-template-areas: 'name value' 'track track';
|
||||
grid-template-columns: 1fr auto;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
.row .name {
|
||||
grid-area: name;
|
||||
}
|
||||
.row .value {
|
||||
grid-area: value;
|
||||
}
|
||||
.row .track {
|
||||
grid-area: track;
|
||||
}
|
||||
}
|
||||
.hint {
|
||||
color: var(--mat-sys-on-surface-variant, #5f6368);
|
||||
display: block;
|
||||
@@ -141,6 +272,8 @@ export class Readings {
|
||||
readonly headline = input('');
|
||||
readonly note = input('');
|
||||
readonly modes = input.required<Mode[]>();
|
||||
/** The label of the mode a section's selector chose, for the cards that follow it. */
|
||||
readonly view = input<string>();
|
||||
readonly loading = input(false);
|
||||
/** A measure's reading in the applied period, and the figure of a mode that has one. */
|
||||
readonly read = input.required<(measure: string) => Reading | undefined>();
|
||||
@@ -148,14 +281,19 @@ export class Readings {
|
||||
|
||||
protected readonly chosen = signal('');
|
||||
protected readonly mode = computed(
|
||||
() => this.modes().find((m) => m.label === this.chosen()) ?? this.modes()[0],
|
||||
() => this.modes().find((m) => m.label === (this.view() || this.chosen())) ?? this.modes()[0],
|
||||
);
|
||||
protected readonly groups = computed(() => grouped(this.mode(), this.read()));
|
||||
protected readonly table = computed(() => bars(this.mode(), this.read()));
|
||||
/** The bars of a scenarios figure need more room than a donut. */
|
||||
protected readonly height = computed(() => {
|
||||
const m = this.mode();
|
||||
return m.kind === 'figure' && m.figure === 'scenarios' ? 360 : 300;
|
||||
if (m.kind !== 'figure' || m.figure !== 'scenarios') return 300;
|
||||
const groups = (this.figure()?.data[0] as { y?: unknown[] } | undefined)?.y?.length ?? 3;
|
||||
return Math.max(360, 190 + 44 * groups); // a slim bar per group, and room for legend and axis
|
||||
});
|
||||
/** What the card says about the categories it does not draw. */
|
||||
protected readonly hidden = computed(() => hiddenNote(this.mode(), this.read()));
|
||||
/** Patients in the period but no classification published: say it, do not draw nothing. */
|
||||
protected readonly missing = computed(() => unavailable(this.mode(), this.read()));
|
||||
protected readonly figure = computed(() =>
|
||||
|
||||
Reference in New Issue
Block a user