ravenous_typst/setup/analysis/alteration_report.typ

212 lines
6.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Descriptive presentation of alteration resistance metadata.
#import "@preview/primaviz:0.6.0": bar-chart, horizontal-bar-chart
#import "alteration_metrics.typ": *
#import "report_style.typ": chart-theme, metric-card, report-theme
#import "../theme/tables.typ" as tables
#let synthesis-bubble(label, value, note) = block(
width: 100%,
fill: report-theme.parchment,
stroke: 0.7pt + report-theme.border,
inset: 9pt,
radius: 5pt,
)[
#text(
size: 6.5pt,
tracking: 0.07em,
weight: "bold",
fill: report-theme.heading-subtle,
)[#upper(label)]
#v(2pt)
#text(size: 11pt, weight: "bold", fill: report-theme.heading)[#value]
#v(2pt)
#text(size: 7.2pt, fill: report-theme.muted-ink)[#note]
]
#let alteration-report() = {
pagebreak()
heading(level: 1)[Altérations]
heading(level: 2)[Altérations — Résistances et catégories]
grid(
columns: (1fr,) * 4,
column-gutter: 8pt,
metric-card("Entrées", alterations.len()),
metric-card(
"Documentées",
configured-alterations.len(),
note: [avec résistance],
),
metric-card("Méta-catégories", alteration-meta-categories.len()),
metric-card(
"Catégories",
alteration-categories.len(),
note: [classifications `custom.category`],
),
)
[Cette section restitue uniquement les métadonnées du glossaire : méta-catégorie (`group`), catégorie
(`custom.category`),
caractéristique de résistance et difficulté. Elle ne produit ni score de
puissance, ni pondération d’équilibrage.]
heading(level: 3)[Caractéristiques représentées]
grid(
columns: (1fr, 1fr),
column-gutter: 12pt,
horizontal-bar-chart(
(
labels: characteristic-counts.map(item => item.label),
values: characteristic-counts.map(item => item.count),
),
width: 100%,
height: 175pt,
title: [Résistances par caractéristique],
show-values: true,
theme: chart-theme,
),
horizontal-bar-chart(
(
labels: meta-category-counts.map(item => item.label),
values: meta-category-counts.map(item => item.count),
),
width: 100%,
height: 175pt,
title: [Altérations par méta-catégorie],
show-values: true,
theme: chart-theme,
),
)
heading(level: 3)[Composition des méta-catégories]
let matrix = ()
for meta-category in alteration-meta-categories {
matrix.push(meta-category)
for characteristic in resisting-characteristics {
let count = characteristic-count(
characteristic,
meta-category: meta-category,
)
let shade = if count == 0 { report-theme.parchment-light } else {
report-theme.chart-2.transparentize(calc.max(18%, 82% - count * 7%))
}
matrix.push(table.cell(fill: shade)[#count])
}
}
tables.set-table-style(
table(
columns: (1.45fr,) + (0.72fr,) * resisting-characteristics.len(),
align: (left,) + (center,) * resisting-characteristics.len(),
table.header([Méta-catégorie], ..resisting-characteristics),
..matrix,
),
table-theme: "steingrund",
text-size: 7pt,
)
heading(level: 3)[Synthèse descriptive]
grid(
columns: (1fr, 1fr, 1fr),
column-gutter: 10pt,
row-gutter: 10pt,
synthesis-bubble(
"Caractéristique dominante",
characteristic-leader.label + " · " + str(characteristic-leader.count),
[plus grand nombre d’altérations résistées],
),
synthesis-bubble(
"Méta-catégorie dominante",
meta-category-leader.label + " · " + str(meta-category-leader.count),
[plus grand nombre d’entrées du glossaire],
),
synthesis-bubble(
"Couples représentés",
str(represented-pairs),
[combinaisons méta-catégorie × caractéristique présentes],
),
synthesis-bubble(
"Difficultés présentes",
alteration-difficulties.map(str).join(" · "),
[valeurs distinctes déclarées],
),
synthesis-bubble(
"Métadonnées manquantes",
str(unconfigured-alterations.len()),
if unconfigured-alterations.len() == 0 { [aucune entrée] } else {
let names = unconfigured-alterations.map(item => item.name)
[#names.slice(0, calc.min(4, names.len())).join(", ")#if (
names.len() > 4
) { [ +#(names.len() - 4)] }]
},
),
synthesis-bubble(
"Difficulté la plus fréquente",
difficulty-counts.sorted(key: item => -item.count).first().label,
[#difficulty-counts.sorted(key: item => -item.count).first().count altérations],
),
)
heading(level: 3)[Catégories déclarées]
if category-counts.len() == 0 {
[Aucune catégorie `custom.category` n’est encore déclarée.]
} else {
grid(
columns: (1.2fr, 0.8fr),
column-gutter: 12pt,
horizontal-bar-chart(
(
labels: category-counts.map(item => item.label),
values: category-counts.map(item => item.count),
),
width: 100%,
height: calc.max(145pt, category-counts.len() * 13pt),
show-values: true,
theme: chart-theme,
),
synthesis-bubble(
"Couverture catégorielle",
str(categorized-alterations.len()) + " / " + str(alterations.len()),
[#uncategorized-alterations.len() altérations restent sans `custom.category`; une entrée multi-catégorie compte dans chaque barre],
),
)
}
heading(level: 3)[Difficultés déclarées]
bar-chart(
(
labels: difficulty-counts.map(item => item.label),
values: difficulty-counts.map(item => item.count),
),
width: 100%,
height: 145pt,
show-values: true,
theme: chart-theme,
)
heading(level: 3)[Inventaire complet]
let rows = alterations.map(item => (
item.name,
item.meta-category,
if item.categories.len() == 0 { [—] } else { item.categories.join(", ") },
if item.resisted-by == none { [—] } else { item.resisted-by },
if item.difficulty == none { [—] } else { str(item.difficulty) },
))
tables.set-table-style(
table(
columns: (1.15fr, 1.05fr, 1.25fr, 0.9fr, 0.55fr),
align: (left, left, left, left, right),
table.header(
[Altération],
[Méta-catégorie],
[Catégorie(s)],
[Résistée par],
[Difficulté],
),
..rows.flatten(),
),
table-theme: "steingrund",
text-size: 7.5pt,
)
}