@urban-toolkit/autk-grammar 4.0.0 → 4.1.1
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 +22 -1
- package/build/autk-grammar-schema.json +56 -0
- package/dist/autk-grammar.js +322 -310
- package/dist/autk-grammar.js.map +1 -1
- package/dist/autk-grammar.umd.cjs +2 -2
- package/dist/autk-grammar.umd.cjs.map +1 -1
- package/dist/index.d.ts +24 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ A declarative grammar for urban visual analytics, running on [Autark](https://au
|
|
|
12
12
|
npm install @urban-toolkit/autk-grammar
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
It runs on Autark 4: `@urban-toolkit/autk-core`, `autk-db`, `autk-map`, `autk-plot` and `autk-compute` 4.x, installed with it.
|
|
15
|
+
It runs on Autark 4.1: `@urban-toolkit/autk-core`, `autk-db`, `autk-map`, `autk-plot` and `autk-compute` 4.1 or a later 4.x, installed with it.
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
@@ -29,6 +29,27 @@ const grammar = new AutkGrammar({ map: 'map', plot: 'plot' }); // ids of the map
|
|
|
29
29
|
await grammar.run(spec);
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
## Maps
|
|
33
|
+
|
|
34
|
+
Each map draws on demand: one frame once its layers are loaded, then one each time it changes. `grammar.maps` holds the `AutkMap` of each `map` entry of the last run, in order. Between frames a map canvas can read back empty, so to read a map's pixels (for example with `canvas.toDataURL()`), call its `requestRender()` and read in a `requestAnimationFrame` callback registered after that call:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const map = grammar.maps[0];
|
|
38
|
+
map.requestRender();
|
|
39
|
+
requestAnimationFrame(() => {
|
|
40
|
+
const png = map.canvas.toDataURL('image/png');
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Interactions
|
|
45
|
+
|
|
46
|
+
A layer with `isPick` and a plot with `events` report what the user selects on `grammar.interactions`: `map:picking` and `plot:selection` give feature ids, the positions of the selected features among those the layer or the plot draws (a map layer leaves out features without a geometry). To link a selection to other tables, name the columns whose values identify those rows with `selectFields` on the layer or the plot, for example `selectFields: ['nta2020']`. The grammar does not read it; the events still report feature ids, and the app reads the key values from those rows.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
grammar.interactions.on('map:picking', ({ layerId, selection }) => { /* feature ids */ });
|
|
50
|
+
grammar.interactions.on('plot:selection', ({ plotId, event, selection }) => { /* feature ids */ });
|
|
51
|
+
```
|
|
52
|
+
|
|
32
53
|
## JSON Schema
|
|
33
54
|
|
|
34
55
|
The package ships the grammar's JSON Schema (draft-07) as `@urban-toolkit/autk-grammar/build/autk-grammar-schema.json`, with `$id` `https://autarkjs.org/schema/autk-grammar/v1.json`. Validate a spec with any draft-07 validator:
|
|
@@ -96,6 +96,14 @@
|
|
|
96
96
|
"const": "bar",
|
|
97
97
|
"type": "string"
|
|
98
98
|
},
|
|
99
|
+
"selectFields": {
|
|
100
|
+
"description": "Columns whose values name the rows a selection in this plot selects, so an app can link the selection to other tables that hold those columns. Neither adapter reads it: the Autark adapter's `plot:selection` events still report feature ids.",
|
|
101
|
+
"items": {
|
|
102
|
+
"type": "string"
|
|
103
|
+
},
|
|
104
|
+
"minItems": 1,
|
|
105
|
+
"type": "array"
|
|
106
|
+
},
|
|
99
107
|
"title": {
|
|
100
108
|
"type": "string"
|
|
101
109
|
},
|
|
@@ -925,6 +933,14 @@
|
|
|
925
933
|
"const": "heatmatrix",
|
|
926
934
|
"type": "string"
|
|
927
935
|
},
|
|
936
|
+
"selectFields": {
|
|
937
|
+
"description": "Columns whose values name the rows a selection in this plot selects, so an app can link the selection to other tables that hold those columns. Neither adapter reads it: the Autark adapter's `plot:selection` events still report feature ids.",
|
|
938
|
+
"items": {
|
|
939
|
+
"type": "string"
|
|
940
|
+
},
|
|
941
|
+
"minItems": 1,
|
|
942
|
+
"type": "array"
|
|
943
|
+
},
|
|
928
944
|
"title": {
|
|
929
945
|
"type": "string"
|
|
930
946
|
},
|
|
@@ -1204,6 +1220,14 @@
|
|
|
1204
1220
|
],
|
|
1205
1221
|
"type": "string"
|
|
1206
1222
|
},
|
|
1223
|
+
"selectFields": {
|
|
1224
|
+
"description": "Columns whose values name the rows a selection in this plot selects, so an app can link the selection to other tables that hold those columns. Neither adapter reads it: the Autark adapter's `plot:selection` events still report feature ids.",
|
|
1225
|
+
"items": {
|
|
1226
|
+
"type": "string"
|
|
1227
|
+
},
|
|
1228
|
+
"minItems": 1,
|
|
1229
|
+
"type": "array"
|
|
1230
|
+
},
|
|
1207
1231
|
"title": {
|
|
1208
1232
|
"type": "string"
|
|
1209
1233
|
},
|
|
@@ -1334,6 +1358,14 @@
|
|
|
1334
1358
|
"type": "number"
|
|
1335
1359
|
},
|
|
1336
1360
|
"type": "array"
|
|
1361
|
+
},
|
|
1362
|
+
"selectFields": {
|
|
1363
|
+
"description": "Columns whose values name the rows a pick on this layer selects, so an app can link the selection to other tables that hold those columns. Neither adapter reads it: the Autark adapter's `map:picking` events still report feature ids.",
|
|
1364
|
+
"items": {
|
|
1365
|
+
"type": "string"
|
|
1366
|
+
},
|
|
1367
|
+
"minItems": 1,
|
|
1368
|
+
"type": "array"
|
|
1337
1369
|
}
|
|
1338
1370
|
},
|
|
1339
1371
|
"required": [
|
|
@@ -1575,6 +1607,14 @@
|
|
|
1575
1607
|
"const": "parallel-coordinates",
|
|
1576
1608
|
"type": "string"
|
|
1577
1609
|
},
|
|
1610
|
+
"selectFields": {
|
|
1611
|
+
"description": "Columns whose values name the rows a selection in this plot selects, so an app can link the selection to other tables that hold those columns. Neither adapter reads it: the Autark adapter's `plot:selection` events still report feature ids.",
|
|
1612
|
+
"items": {
|
|
1613
|
+
"type": "string"
|
|
1614
|
+
},
|
|
1615
|
+
"minItems": 1,
|
|
1616
|
+
"type": "array"
|
|
1617
|
+
},
|
|
1578
1618
|
"title": {
|
|
1579
1619
|
"type": "string"
|
|
1580
1620
|
},
|
|
@@ -1919,6 +1959,14 @@
|
|
|
1919
1959
|
"const": "scatter",
|
|
1920
1960
|
"type": "string"
|
|
1921
1961
|
},
|
|
1962
|
+
"selectFields": {
|
|
1963
|
+
"description": "Columns whose values name the rows a selection in this plot selects, so an app can link the selection to other tables that hold those columns. Neither adapter reads it: the Autark adapter's `plot:selection` events still report feature ids.",
|
|
1964
|
+
"items": {
|
|
1965
|
+
"type": "string"
|
|
1966
|
+
},
|
|
1967
|
+
"minItems": 1,
|
|
1968
|
+
"type": "array"
|
|
1969
|
+
},
|
|
1922
1970
|
"title": {
|
|
1923
1971
|
"type": "string"
|
|
1924
1972
|
},
|
|
@@ -1995,6 +2043,14 @@
|
|
|
1995
2043
|
"const": "table",
|
|
1996
2044
|
"type": "string"
|
|
1997
2045
|
},
|
|
2046
|
+
"selectFields": {
|
|
2047
|
+
"description": "Columns whose values name the rows a selection in this plot selects, so an app can link the selection to other tables that hold those columns. Neither adapter reads it: the Autark adapter's `plot:selection` events still report feature ids.",
|
|
2048
|
+
"items": {
|
|
2049
|
+
"type": "string"
|
|
2050
|
+
},
|
|
2051
|
+
"minItems": 1,
|
|
2052
|
+
"type": "array"
|
|
2053
|
+
},
|
|
1998
2054
|
"title": {
|
|
1999
2055
|
"type": "string"
|
|
2000
2056
|
},
|