O /simplify da escala relativa do mapa achou um bug semantico real em computeAggregateTerritorialClass — somava o headroom dos slugs e comparava contra a mediana de UMA unidade, classificando um grupo grande como expansao quando ele e marginal. A mediana agora escala por slugs.length, com teste. As bolhas sairam do centro do bounding box para o centroide real e ganharam pane proprio (z-index 450), porque o bringToFront do hover as escondia atras do poligono. Legenda e pintura passaram a compartilhar o mesmo predicado, a copy dos quantis parou de prometer faixas de igual largura, e o subtitulo do painel parou de dizer "em 2026" com 2022 selecionado (defeito do B11). Fonte unica onde havia duas: NO_DATA_FILL, o raio das bolhas e formatPlacementOrdinal (ex-formatMunicipalityVoteRank, agora client-safe em electionFormat.ts). Os quatro debitos maiores que o cleanup viraram o fill-in B13+ (docs/plans/escala-dry-pos-b13.md); a flakiness dos e2e, reproduzida em main limpo, foi para o ledger com a causa afinada.
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { choroplethGradientCss } from '@/lib/choroplethColorScale'
|
|
import { formatElectionNumber } from '@/lib/electionFormat'
|
|
|
|
type ChoroplethLegendProps = {
|
|
max: number
|
|
metricLabel: string
|
|
formatMax?: (max: number) => string
|
|
/** What the colour means, in the caller's words. */
|
|
note: string
|
|
/** Ties the note to the scale selector through `aria-describedby`. */
|
|
noteId: string
|
|
}
|
|
|
|
export const ChoroplethLegend = ({
|
|
max,
|
|
metricLabel,
|
|
formatMax = formatElectionNumber,
|
|
noteId,
|
|
note,
|
|
}: ChoroplethLegendProps) => (
|
|
<div className="flex flex-col gap-1.5">
|
|
<div className="flex items-center gap-2">
|
|
<span className="w-8 shrink-0 text-right text-xs tabular-nums text-muted-foreground">0</span>
|
|
<div
|
|
className="h-2.5 min-w-0 flex-1 rounded-full ring-1 ring-foreground/10"
|
|
style={{ background: choroplethGradientCss }}
|
|
role="img"
|
|
aria-label={`Escala de cor de 0 a ${formatMax(max)} para ${metricLabel}`}
|
|
/>
|
|
<span className="w-12 shrink-0 text-xs tabular-nums text-muted-foreground">
|
|
{formatMax(max)}
|
|
</span>
|
|
</div>
|
|
<p id={noteId} className="text-xs text-muted-foreground">
|
|
{note}
|
|
</p>
|
|
</div>
|
|
)
|