The country map's live poster prints its legend: it read rows the legend composable never had

countries-map's print path set the poster's legend from legend.rows, but useLegendData returns items,
never rows, so the renderer got an empty list and page 1's live map printed with no legend. It now
takes the items, with their child tiers flattened in, as research-map's poster does since A1.
check:legend-data-contract FAILED on this file and PASSES now; it goes into gates:pre with this round.
This commit is contained in:
Doxa Maps 2026-09-29 02:08:01 +00:00
parent 24f965b6a4
commit b8166218b9

View file

@ -1332,7 +1332,14 @@ async function openPacket() {
// separate document and an object URL created here would be revoked out from under it.
const spec = defaultPosterSpec({ widthIn: 8.27, heightIn: 11.69, dpi: 150, orientation: 'portrait' })
spec.slots.title = { ...spec.slots.title, text: legendTitle.value || 'Doxa Map' }
spec.slots.legend = { ...spec.slots.legend, rows: legend?.rows?.value || [] }
// ★ useLegendData returns `items`, not `rows`: `legend.rows` was undefined, so `|| []` handed the
// renderer an empty list and this page printed its live map with no legend. Child tiers flattened in,
// as research-map's poster does, so the printed legend names every band the map draws.
const legendRows = (legend?.items?.value || [])
.flatMap((it) => [it, ...(it.children || [])])
.map((r) => ({ label: r.label, color: r.color }))
.filter((r) => r.label)
spec.slots.legend = { ...spec.slots.legend, rows: legendRows }
let mapSvg = ''
try {
const mapBlob = await useMapPoster(() => map.value).render(spec, 'png')