@toclocoinc/lattice-grid 1.8.0 → 1.9.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 +88 -14
- package/docs/API.html +261 -19
- package/docs/CHART-CODES.md +381 -0
- package/lattice-grid.d.ts +437 -8
- package/lattice-grid.esm.min.js +2461 -155
- package/lattice-grid.min.cjs +2460 -155
- package/lattice-grid.min.js +2460 -155
- package/modules/charts.esm.min.js +581 -36
- package/modules/devtools.esm.min.js +2 -2
- package/modules/dhtmlx-compat.esm.min.js +2460 -155
- package/modules/htmx.esm.min.js +2459 -155
- package/modules/htmx.min.cjs +2459 -155
- package/modules/htmx.min.js +2459 -155
- package/modules/react.esm.min.js +2 -2
- package/modules/svelte.esm.min.js +2 -2
- package/modules/vue.esm.min.js +2 -2
- package/modules/webcomponent.esm.min.js +2460 -155
- package/package.json +5 -2
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
# Chart codes reference
|
|
2
|
+
|
|
3
|
+
The codes the `geomap` chart joins data to shapes with. Generated from
|
|
4
|
+
`packages/modules/charts/geo.js`, which is the source of truth — if the two ever
|
|
5
|
+
disagree, the module is right and this file is stale.
|
|
6
|
+
|
|
7
|
+
## How the join works
|
|
8
|
+
|
|
9
|
+
A geomap reads two columns: one holding a code, one holding a value.
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
createChart({
|
|
13
|
+
grid,
|
|
14
|
+
container: '#map',
|
|
15
|
+
type: 'geomap',
|
|
16
|
+
code: 'country', // the column holding ISO codes
|
|
17
|
+
y: { col: 'revenue', fn: 'sum' }, // the measure
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Three code forms are accepted** and normalised to ISO 3166-1 alpha-2, because
|
|
22
|
+
a grid's data will hold whichever one its source used:
|
|
23
|
+
|
|
24
|
+
| Form | Example | Notes |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| alpha-2 | `GB` | ISO 3166-1 alpha-2. The canonical form here. |
|
|
27
|
+
| alpha-3 | `GBR` | ISO 3166-1 alpha-3. |
|
|
28
|
+
| numeric | `826` | ISO 3166-1 numeric. A string or a number; leading zeros are ignored. |
|
|
29
|
+
|
|
30
|
+
Codes are matched case-insensitively and trimmed, so `gb`, `GB ` and `Gb` are
|
|
31
|
+
one country. Anything that is not a code — a country *name*, an internal
|
|
32
|
+
identifier, an empty cell — is not guessed at. Those rows are counted and the
|
|
33
|
+
count is drawn on the map, because a map quietly missing half its data looks
|
|
34
|
+
exactly like a map of a world where half the data is zero.
|
|
35
|
+
|
|
36
|
+
## Continents
|
|
37
|
+
|
|
38
|
+
Two-letter codes, following the UN geoscheme. A value carrying a continent code
|
|
39
|
+
lands on that continent directly; a value carrying a *country* code lands on the
|
|
40
|
+
continent that country belongs to, so a grid of country data needs no second
|
|
41
|
+
column to produce a continent map.
|
|
42
|
+
|
|
43
|
+
| Code | Continent |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `AF` | Africa |
|
|
46
|
+
| `AN` | Antarctica |
|
|
47
|
+
| `AS` | Asia |
|
|
48
|
+
| `EU` | Europe |
|
|
49
|
+
| `NA` | North America |
|
|
50
|
+
| `OC` | Oceania |
|
|
51
|
+
| `SA` | South America |
|
|
52
|
+
|
|
53
|
+
**Two codes are ambiguous.** `NA` is both North America and Namibia, and `AS` is
|
|
54
|
+
both Asia and American Samoa. On a continent map the continent reading wins: a
|
|
55
|
+
column of two-letter codes containing `NA` a hundred times is not a hundred rows
|
|
56
|
+
about Namibia, and reading it as such is the more damaging mistake. A grid that
|
|
57
|
+
genuinely means Namibia should use `NAM` or `516`.
|
|
58
|
+
|
|
59
|
+
## What ships, and what does not
|
|
60
|
+
|
|
61
|
+
**Continent outlines ship** with the module — seven coarse polygons, a few
|
|
62
|
+
hundred bytes. They are *schematic, not cartographic*: recognisable, the right
|
|
63
|
+
shape for "which continent is biggest", and not a basemap. Nothing should be
|
|
64
|
+
measured off them.
|
|
65
|
+
|
|
66
|
+
**Country outlines do not ship.** That is a size decision: a usable world at
|
|
67
|
+
country resolution is several hundred kilobytes of path data, larger than the
|
|
68
|
+
whole charts module, and it would be paid for by every page that draws a bar
|
|
69
|
+
chart. A country map is drawn from shapes the host supplies, at whatever
|
|
70
|
+
resolution that host actually needs:
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
// GeoJSON — a FeatureCollection or a single feature. Projected for you.
|
|
74
|
+
createChart({
|
|
75
|
+
grid, container: '#map', type: 'geomap',
|
|
76
|
+
code: 'country', y: 'revenue',
|
|
77
|
+
shapes: worldGeoJson,
|
|
78
|
+
codeProperty: 'iso_a2', // which feature property carries the code
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Or ready-made SVG paths, already in the plot's coordinates. The escape hatch
|
|
82
|
+
// for a host with its own projection.
|
|
83
|
+
createChart({
|
|
84
|
+
grid, container: '#map', type: 'geomap',
|
|
85
|
+
code: 'country', y: 'revenue',
|
|
86
|
+
shapes: { GB: 'M…Z', FR: 'M…Z' },
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Supplying shapes switches the map from continents to countries: the regions
|
|
91
|
+
drawn are the ones supplied, and a value whose code is not among them is
|
|
92
|
+
reported as unplaced rather than rolled up.
|
|
93
|
+
|
|
94
|
+
## The projection
|
|
95
|
+
|
|
96
|
+
Equirectangular — longitude and latitude map linearly onto x and y. The least
|
|
97
|
+
arithmetic and the most distortion at the poles, which is the right trade for
|
|
98
|
+
shading regions by value: nothing here measures area, and a reader comparing
|
|
99
|
+
Greenland with Africa by eye is misled by every rectangular projection equally.
|
|
100
|
+
Anything better belongs in the host's own GeoJSON, projected before it arrives.
|
|
101
|
+
|
|
102
|
+
The map keeps its 2:1 proportions and is centred in the plot — pillarboxed in a
|
|
103
|
+
wide panel, letterboxed in a tall one — rather than being stretched to fill.
|
|
104
|
+
|
|
105
|
+
## Colour
|
|
106
|
+
|
|
107
|
+
Values are shaded with a sequential ramp: monotone lightness, so darker always
|
|
108
|
+
means larger. Pass `diverging: true` for a measure with a meaningful midpoint —
|
|
109
|
+
profit and loss, change against a baseline — which centres the ramp on **zero**
|
|
110
|
+
rather than on the middle of the data, because a neutral colour at the mean
|
|
111
|
+
claims the mean is neutral.
|
|
112
|
+
|
|
113
|
+
A region with no data is left in the empty colour rather than the ramp's low
|
|
114
|
+
end: "no reading" and "the smallest reading" are different facts and must not
|
|
115
|
+
share a shade.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Country codes
|
|
120
|
+
|
|
121
|
+
Grouped by the continent each lands on.
|
|
122
|
+
|
|
123
|
+
### Africa — `AF`
|
|
124
|
+
|
|
125
|
+
| alpha-2 | alpha-3 | numeric |
|
|
126
|
+
|---|---|---|
|
|
127
|
+
| `AO` | `AGO` | `24` |
|
|
128
|
+
| `BF` | `BFA` | — |
|
|
129
|
+
| `BI` | `BDI` | `108` |
|
|
130
|
+
| `BJ` | `BEN` | `204` |
|
|
131
|
+
| `BW` | `BWA` | `72` |
|
|
132
|
+
| `CD` | `COD` | `180` |
|
|
133
|
+
| `CF` | `CAF` | `140` |
|
|
134
|
+
| `CG` | `COG` | `178` |
|
|
135
|
+
| `CI` | `CIV` | `384` |
|
|
136
|
+
| `CM` | `CMR` | `120` |
|
|
137
|
+
| `CV` | `CPV` | `132` |
|
|
138
|
+
| `DJ` | `DJI` | `262` |
|
|
139
|
+
| `DZ` | `DZA` | `12` |
|
|
140
|
+
| `EG` | `EGY` | `818` |
|
|
141
|
+
| `ER` | `ERI` | `232` |
|
|
142
|
+
| `ET` | `ETH` | `231` |
|
|
143
|
+
| `GA` | `GAB` | `266` |
|
|
144
|
+
| `GH` | `GHA` | `288` |
|
|
145
|
+
| `GM` | `GMB` | `270` |
|
|
146
|
+
| `GN` | `GIN` | `324` |
|
|
147
|
+
| `GQ` | `GNQ` | `226` |
|
|
148
|
+
| `GW` | `GNB` | `624` |
|
|
149
|
+
| `KE` | `KEN` | `404` |
|
|
150
|
+
| `KM` | `COM` | `174` |
|
|
151
|
+
| `LR` | `LBR` | `430` |
|
|
152
|
+
| `LS` | `LSO` | `426` |
|
|
153
|
+
| `LY` | `LBY` | `434` |
|
|
154
|
+
| `MA` | `MAR` | `504` |
|
|
155
|
+
| `MG` | `MDG` | `450` |
|
|
156
|
+
| `ML` | `MLI` | `466` |
|
|
157
|
+
| `MR` | `MRT` | `478` |
|
|
158
|
+
| `MU` | `MUS` | `480` |
|
|
159
|
+
| `MW` | `MWI` | `454` |
|
|
160
|
+
| `MZ` | `MOZ` | `508` |
|
|
161
|
+
| `NA` | `NAM` | `516` |
|
|
162
|
+
| `NE` | `NER` | `562` |
|
|
163
|
+
| `NG` | `NGA` | `566` |
|
|
164
|
+
| `RE` | — | — |
|
|
165
|
+
| `RW` | `RWA` | `646` |
|
|
166
|
+
| `SC` | `SYC` | `690` |
|
|
167
|
+
| `SD` | `SDN` | `729` |
|
|
168
|
+
| `SL` | `SLE` | `694` |
|
|
169
|
+
| `SN` | `SEN` | `686` |
|
|
170
|
+
| `SO` | `SOM` | `706` |
|
|
171
|
+
| `SS` | `SSD` | `728` |
|
|
172
|
+
| `ST` | `STP` | — |
|
|
173
|
+
| `SZ` | `SWZ` | `748` |
|
|
174
|
+
| `TD` | `TCD` | `148` |
|
|
175
|
+
| `TG` | `TGO` | `768` |
|
|
176
|
+
| `TN` | `TUN` | `788` |
|
|
177
|
+
| `TZ` | `TZA` | `834` |
|
|
178
|
+
| `UG` | `UGA` | `800` |
|
|
179
|
+
| `YT` | — | — |
|
|
180
|
+
| `ZA` | `ZAF` | `710` |
|
|
181
|
+
| `ZM` | `ZMB` | `894` |
|
|
182
|
+
| `ZW` | `ZWE` | `716` |
|
|
183
|
+
|
|
184
|
+
### Antarctica — `AN`
|
|
185
|
+
|
|
186
|
+
| alpha-2 | alpha-3 | numeric |
|
|
187
|
+
|---|---|---|
|
|
188
|
+
| `AQ` | — | — |
|
|
189
|
+
|
|
190
|
+
### Asia — `AS`
|
|
191
|
+
|
|
192
|
+
| alpha-2 | alpha-3 | numeric |
|
|
193
|
+
|---|---|---|
|
|
194
|
+
| `AE` | `ARE` | `784` |
|
|
195
|
+
| `AF` | `AFG` | `4` |
|
|
196
|
+
| `AM` | `ARM` | `51` |
|
|
197
|
+
| `AZ` | `AZE` | — |
|
|
198
|
+
| `BD` | `BGD` | `50` |
|
|
199
|
+
| `BH` | `BHR` | `48` |
|
|
200
|
+
| `BN` | `BRN` | `96` |
|
|
201
|
+
| `BT` | `BTN` | `64` |
|
|
202
|
+
| `CN` | `CHN` | `156` |
|
|
203
|
+
| `CY` | `CYP` | `196` |
|
|
204
|
+
| `GE` | `GEO` | `268` |
|
|
205
|
+
| `HK` | `HKG` | `344` |
|
|
206
|
+
| `ID` | `IDN` | `360` |
|
|
207
|
+
| `IL` | `ISR` | `376` |
|
|
208
|
+
| `IN` | `IND` | `356` |
|
|
209
|
+
| `IQ` | `IRQ` | `368` |
|
|
210
|
+
| `IR` | `IRN` | `364` |
|
|
211
|
+
| `JO` | `JOR` | `400` |
|
|
212
|
+
| `JP` | `JPN` | `392` |
|
|
213
|
+
| `KG` | `KGZ` | `417` |
|
|
214
|
+
| `KH` | `KHM` | `116` |
|
|
215
|
+
| `KP` | `PRK` | `408` |
|
|
216
|
+
| `KR` | `KOR` | `410` |
|
|
217
|
+
| `KW` | `KWT` | `414` |
|
|
218
|
+
| `KZ` | `KAZ` | `398` |
|
|
219
|
+
| `LA` | `LAO` | `418` |
|
|
220
|
+
| `LB` | `LBN` | `422` |
|
|
221
|
+
| `LK` | `LKA` | `144` |
|
|
222
|
+
| `MM` | `MMR` | `104` |
|
|
223
|
+
| `MN` | `MNG` | `496` |
|
|
224
|
+
| `MO` | — | — |
|
|
225
|
+
| `MV` | `MDV` | `462` |
|
|
226
|
+
| `MY` | `MYS` | `458` |
|
|
227
|
+
| `NP` | `NPL` | `524` |
|
|
228
|
+
| `OM` | `OMN` | `512` |
|
|
229
|
+
| `PH` | `PHL` | `608` |
|
|
230
|
+
| `PK` | `PAK` | `586` |
|
|
231
|
+
| `PS` | `PSE` | — |
|
|
232
|
+
| `QA` | `QAT` | `634` |
|
|
233
|
+
| `SA` | `SAU` | `682` |
|
|
234
|
+
| `SG` | `SGP` | `702` |
|
|
235
|
+
| `SY` | `SYR` | `760` |
|
|
236
|
+
| `TH` | `THA` | `764` |
|
|
237
|
+
| `TJ` | `TJK` | `762` |
|
|
238
|
+
| `TL` | `TLS` | `626` |
|
|
239
|
+
| `TM` | `TKM` | `795` |
|
|
240
|
+
| `TR` | `TUR` | `792` |
|
|
241
|
+
| `TW` | `TWN` | — |
|
|
242
|
+
| `UZ` | `UZB` | `860` |
|
|
243
|
+
| `VN` | `VNM` | `704` |
|
|
244
|
+
| `YE` | `YEM` | `887` |
|
|
245
|
+
|
|
246
|
+
### Europe — `EU`
|
|
247
|
+
|
|
248
|
+
| alpha-2 | alpha-3 | numeric |
|
|
249
|
+
|---|---|---|
|
|
250
|
+
| `AD` | `AND` | `20` |
|
|
251
|
+
| `AL` | `ALB` | `8` |
|
|
252
|
+
| `AT` | `AUT` | `40` |
|
|
253
|
+
| `AX` | — | — |
|
|
254
|
+
| `BA` | `BIH` | `70` |
|
|
255
|
+
| `BE` | `BEL` | `56` |
|
|
256
|
+
| `BG` | `BGR` | `100` |
|
|
257
|
+
| `BY` | `BLR` | `112` |
|
|
258
|
+
| `CH` | `CHE` | `756` |
|
|
259
|
+
| `CZ` | `CZE` | `203` |
|
|
260
|
+
| `DE` | `DEU` | `276` |
|
|
261
|
+
| `DK` | `DNK` | `208` |
|
|
262
|
+
| `EE` | `EST` | `233` |
|
|
263
|
+
| `ES` | `ESP` | `724` |
|
|
264
|
+
| `FI` | `FIN` | `246` |
|
|
265
|
+
| `FO` | — | — |
|
|
266
|
+
| `FR` | `FRA` | `250` |
|
|
267
|
+
| `GB` | `GBR` | `826` |
|
|
268
|
+
| `GG` | — | — |
|
|
269
|
+
| `GI` | — | — |
|
|
270
|
+
| `GR` | `GRC` | `300` |
|
|
271
|
+
| `HR` | `HRV` | `191` |
|
|
272
|
+
| `HU` | `HUN` | `348` |
|
|
273
|
+
| `IE` | `IRL` | `372` |
|
|
274
|
+
| `IM` | — | — |
|
|
275
|
+
| `IS` | `ISL` | `352` |
|
|
276
|
+
| `IT` | `ITA` | `380` |
|
|
277
|
+
| `JE` | — | — |
|
|
278
|
+
| `LI` | `LIE` | `438` |
|
|
279
|
+
| `LT` | `LTU` | `440` |
|
|
280
|
+
| `LU` | `LUX` | `442` |
|
|
281
|
+
| `LV` | `LVA` | `428` |
|
|
282
|
+
| `MC` | `MCO` | — |
|
|
283
|
+
| `MD` | `MDA` | `498` |
|
|
284
|
+
| `ME` | `MNE` | `499` |
|
|
285
|
+
| `MK` | `MKD` | `807` |
|
|
286
|
+
| `MT` | `MLT` | `470` |
|
|
287
|
+
| `NL` | `NLD` | `528` |
|
|
288
|
+
| `NO` | `NOR` | `578` |
|
|
289
|
+
| `PL` | `POL` | `616` |
|
|
290
|
+
| `PT` | `PRT` | `620` |
|
|
291
|
+
| `RO` | `ROU` | `642` |
|
|
292
|
+
| `RS` | `SRB` | `688` |
|
|
293
|
+
| `RU` | `RUS` | `643` |
|
|
294
|
+
| `SE` | `SWE` | `752` |
|
|
295
|
+
| `SI` | `SVN` | `705` |
|
|
296
|
+
| `SK` | `SVK` | `703` |
|
|
297
|
+
| `SM` | `SMR` | — |
|
|
298
|
+
| `UA` | `UKR` | `804` |
|
|
299
|
+
| `VA` | — | — |
|
|
300
|
+
|
|
301
|
+
### North America — `NA`
|
|
302
|
+
|
|
303
|
+
| alpha-2 | alpha-3 | numeric |
|
|
304
|
+
|---|---|---|
|
|
305
|
+
| `AG` | — | — |
|
|
306
|
+
| `AI` | — | — |
|
|
307
|
+
| `AW` | — | — |
|
|
308
|
+
| `BB` | `BRB` | `52` |
|
|
309
|
+
| `BM` | — | — |
|
|
310
|
+
| `BS` | `BHS` | `44` |
|
|
311
|
+
| `BZ` | `BLZ` | `84` |
|
|
312
|
+
| `CA` | `CAN` | `124` |
|
|
313
|
+
| `CR` | `CRI` | `188` |
|
|
314
|
+
| `CU` | `CUB` | `192` |
|
|
315
|
+
| `DM` | `DMA` | `212` |
|
|
316
|
+
| `DO` | `DOM` | `214` |
|
|
317
|
+
| `GD` | — | — |
|
|
318
|
+
| `GL` | `GRL` | `304` |
|
|
319
|
+
| `GP` | — | — |
|
|
320
|
+
| `GT` | `GTM` | `320` |
|
|
321
|
+
| `HN` | `HND` | `340` |
|
|
322
|
+
| `HT` | `HTI` | `332` |
|
|
323
|
+
| `JM` | `JAM` | `388` |
|
|
324
|
+
| `KN` | `KNA` | — |
|
|
325
|
+
| `KY` | — | — |
|
|
326
|
+
| `LC` | `LCA` | — |
|
|
327
|
+
| `MQ` | — | — |
|
|
328
|
+
| `MX` | `MEX` | `484` |
|
|
329
|
+
| `NI` | `NIC` | `558` |
|
|
330
|
+
| `PA` | `PAN` | `591` |
|
|
331
|
+
| `PM` | — | — |
|
|
332
|
+
| `PR` | `PRI` | `630` |
|
|
333
|
+
| `SV` | `SLV` | `222` |
|
|
334
|
+
| `TC` | — | — |
|
|
335
|
+
| `TT` | `TTO` | `780` |
|
|
336
|
+
| `US` | `USA` | `840` |
|
|
337
|
+
| `VC` | `VCT` | — |
|
|
338
|
+
| `VG` | — | — |
|
|
339
|
+
| `VI` | — | — |
|
|
340
|
+
|
|
341
|
+
### Oceania — `OC`
|
|
342
|
+
|
|
343
|
+
| alpha-2 | alpha-3 | numeric |
|
|
344
|
+
|---|---|---|
|
|
345
|
+
| `AS` | — | — |
|
|
346
|
+
| `AU` | `AUS` | `36` |
|
|
347
|
+
| `FJ` | `FJI` | — |
|
|
348
|
+
| `FM` | `FSM` | — |
|
|
349
|
+
| `GU` | — | — |
|
|
350
|
+
| `KI` | `KIR` | — |
|
|
351
|
+
| `MH` | `MHL` | — |
|
|
352
|
+
| `NC` | — | — |
|
|
353
|
+
| `NR` | `NRU` | `520` |
|
|
354
|
+
| `NZ` | `NZL` | `554` |
|
|
355
|
+
| `PF` | — | — |
|
|
356
|
+
| `PG` | `PNG` | `598` |
|
|
357
|
+
| `PW` | `PLW` | `585` |
|
|
358
|
+
| `SB` | `SLB` | `90` |
|
|
359
|
+
| `TO` | `TON` | `776` |
|
|
360
|
+
| `TV` | `TUV` | `798` |
|
|
361
|
+
| `VU` | `VUT` | `548` |
|
|
362
|
+
| `WS` | `WSM` | `882` |
|
|
363
|
+
|
|
364
|
+
### South America — `SA`
|
|
365
|
+
|
|
366
|
+
| alpha-2 | alpha-3 | numeric |
|
|
367
|
+
|---|---|---|
|
|
368
|
+
| `AR` | `ARG` | `32` |
|
|
369
|
+
| `BO` | `BOL` | `68` |
|
|
370
|
+
| `BR` | `BRA` | `76` |
|
|
371
|
+
| `CL` | `CHL` | `152` |
|
|
372
|
+
| `CO` | `COL` | `170` |
|
|
373
|
+
| `EC` | `ECU` | `218` |
|
|
374
|
+
| `FK` | — | — |
|
|
375
|
+
| `GF` | — | — |
|
|
376
|
+
| `GY` | `GUY` | `328` |
|
|
377
|
+
| `PE` | `PER` | `604` |
|
|
378
|
+
| `PY` | `PRY` | `600` |
|
|
379
|
+
| `SR` | `SUR` | `740` |
|
|
380
|
+
| `UY` | `URY` | `858` |
|
|
381
|
+
| `VE` | `VEN` | `862` |
|