@trismegisto/maps 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -86,8 +86,10 @@ tamanhos por nível) — ver o README de lá. O formato é TopoJSON com os arcos
|
|
|
86
86
|
## Mapa coroplético
|
|
87
87
|
|
|
88
88
|
`<hm-map-choropleth [layer] [data] [joinBy] [valueKey]>` pinta cada região pelo valor numa escala de dados do
|
|
89
|
-
tema: `scale="sequential"` (`--hm-data-sequential-1…5`)
|
|
90
|
-
`midpoint`)
|
|
89
|
+
tema: `scale="sequential"` (`--hm-data-sequential-1…5`), `"diverging"` (`--hm-data-diverging-1…7`, neutro em
|
|
90
|
+
`midpoint`) ou `"status"` — semáforo de até 3 classes, do menor ao maior valor `--hm-success`, `--hm-warning` e
|
|
91
|
+
`--hm-danger`, para indicador com limiar de negócio (ex.: `% fora` com `[breaks]="[50, 100]"`: verde abaixo de 50,
|
|
92
|
+
amarelo de 50 até 100, vermelho em 100). Classes: `classes`, `method` (`equal`/`quantile`), `domain` ou `breaks` explícitos. `data` aceita
|
|
91
93
|
linhas ou um mapa chave → valor; `joinBy` é `'id'` (código oficial), uma propriedade da região (`'sigla'`) ou
|
|
92
94
|
`[propriedade, campo]`. `format` formata o valor em todo lugar; `label` nomeia legenda, tabela e lista.
|
|
93
95
|
|
|
@@ -1703,14 +1703,16 @@ const STEPS = {
|
|
|
1703
1703
|
6: [1, 2, 3, 5, 6, 7],
|
|
1704
1704
|
7: [1, 2, 3, 4, 5, 6, 7],
|
|
1705
1705
|
},
|
|
1706
|
+
status: { 1: [1], 2: [1, 3], 3: [1, 2, 3] },
|
|
1706
1707
|
};
|
|
1708
|
+
const STATUS_TOKENS = { 1: '--hm-success', 2: '--hm-warning', 3: '--hm-danger' };
|
|
1707
1709
|
/** Maior número de classes da escala (passos de token disponíveis). */
|
|
1708
1710
|
function maxClasses(scale) {
|
|
1709
|
-
return scale === 'diverging' ? 7 : 5;
|
|
1711
|
+
return scale === 'diverging' ? 7 : scale === 'status' ? 3 : 5;
|
|
1710
1712
|
}
|
|
1711
1713
|
/** Cor (token) do passo da escala. */
|
|
1712
1714
|
function scaleColor(scale, step) {
|
|
1713
|
-
return `var(--hm-data-${scale}-${step})`;
|
|
1715
|
+
return scale === 'status' ? `var(${STATUS_TOKENS[step] ?? STATUS_TOKENS[1]})` : `var(--hm-data-${scale}-${step})`;
|
|
1714
1716
|
}
|
|
1715
1717
|
/** Classes para os valores. Sem valores finitos (e sem `domain`), nenhuma classe. */
|
|
1716
1718
|
function choroplethClasses(values, options = {}) {
|