@mosaicajs/deck 0.1.0-rc.4 → 0.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/dist/basemap.d.ts +26 -29
- package/dist/basemap.js +12 -13
- package/dist/camera.d.ts +9 -9
- package/dist/camera.js +9 -9
- package/dist/colour.d.ts +20 -21
- package/dist/colour.js +5 -5
- package/dist/density-counter.d.ts +44 -49
- package/dist/density-counter.js +36 -39
- package/dist/density.d.ts +17 -16
- package/dist/density.js +5 -5
- package/dist/frame.d.ts +21 -9
- package/dist/frame.js +21 -9
- package/dist/index.d.ts +51 -8
- package/dist/index.js +51 -8
- package/dist/layer.d.ts +91 -111
- package/dist/layer.js +15 -21
- package/dist/pick.d.ts +23 -12
- package/dist/pick.js +14 -3
- package/dist/size.d.ts +11 -8
- package/dist/size.js +1 -1
- package/package.json +4 -4
package/dist/layer.d.ts
CHANGED
|
@@ -11,160 +11,146 @@ import { type Sizing } from './size.js';
|
|
|
11
11
|
import { MarkSlab } from './slab.js';
|
|
12
12
|
/**
|
|
13
13
|
* The props of a {@link MosaicaLayer}: deck.gl's `CompositeLayerProps` and the props below, all
|
|
14
|
-
* optional. `pickable` defaults to true.
|
|
15
|
-
*
|
|
16
|
-
* `store`
|
|
14
|
+
* optional. `pickable` defaults to true.
|
|
15
|
+
*
|
|
16
|
+
* Usually you set `store` and the layer reads `marks`, `depth`, `artifacts`, `meta`, `legend` and
|
|
17
|
+
* `status` from the store's projections. You can set any of those six yourself, and your value is
|
|
18
|
+
* drawn in place of the store's. Without a `store`, set the ones you need; the rest draw nothing.
|
|
17
19
|
*/
|
|
18
20
|
export type MosaicaLayerProps = CompositeLayerProps & {
|
|
19
|
-
/** The store to
|
|
21
|
+
/** The store to draw. The layer redraws whenever its projections change. Defaults to `null`. */
|
|
20
22
|
store?: Store | null;
|
|
21
|
-
/** The marks to draw
|
|
23
|
+
/** The marks to draw. Defaults to the store's `marks`. */
|
|
22
24
|
marks?: MarksProjection | null;
|
|
23
|
-
/**
|
|
24
|
-
* The depth of the frame's bands, which chooses the mark buffers drawn. Defaults to 0, which with
|
|
25
|
-
* `store` reads the store's `view.depth`.
|
|
26
|
-
*/
|
|
25
|
+
/** The tile depth of the frame drawn. Defaults to 0. With a store, 0 reads the store's `view.depth`. */
|
|
27
26
|
depth?: number;
|
|
28
|
-
/** The
|
|
27
|
+
/** The artifacts to name, outline and colour by. Defaults to the store's `artifacts`. */
|
|
29
28
|
artifacts?: ArtifactsProjection | null;
|
|
30
29
|
/**
|
|
31
|
-
* The `/v1/meta`
|
|
32
|
-
*
|
|
33
|
-
* `null`.
|
|
30
|
+
* The server's `/v1/meta` response, which describes the columns and artifact layers. Defaults to
|
|
31
|
+
* the store's `meta`. Without it every mark is drawn in one colour.
|
|
34
32
|
*/
|
|
35
33
|
meta?: Meta | null;
|
|
36
34
|
/**
|
|
37
|
-
* The
|
|
38
|
-
* `cluster:<layer>` to colour each mark by the artifact it belongs to
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* `setColourBy`, `setSizeBy` or `setPointColumns`.
|
|
35
|
+
* The column the marks are coloured and sized by. Defaults to the store's `legend`. Its
|
|
36
|
+
* `colourBy` is a column, or `cluster:<layer>` to colour each mark by the artifact it belongs to.
|
|
37
|
+
* Its `sizeBy` is a number column. The store fetches a column with the points only after you call
|
|
38
|
+
* its `setColourBy`, `setSizeBy` or `setPointColumns`.
|
|
42
39
|
*/
|
|
43
40
|
legend?: LegendProjection | null;
|
|
44
41
|
/**
|
|
45
|
-
* The
|
|
46
|
-
*
|
|
42
|
+
* The map's status. Defaults to `idle`. With a store, `idle` reads the store's `status`. No marks
|
|
43
|
+
* are drawn while it is `refused`.
|
|
47
44
|
*/
|
|
48
45
|
status?: PresentedStatus;
|
|
49
46
|
/**
|
|
50
|
-
* The level of a `stacked` or `tiered` layer to colour, name and outline artifacts at.
|
|
51
|
-
*
|
|
47
|
+
* The level of a `stacked` or `tiered` artifact layer to colour, name and outline artifacts at.
|
|
48
|
+
* Defaults to the coarsest level served. On a `nested` or `dag` layer it has no default, and each
|
|
49
|
+
* mark takes the nearest artifact served.
|
|
52
50
|
*/
|
|
53
51
|
clusterLevel?: number;
|
|
54
|
-
/** Whether the artifacts' names
|
|
52
|
+
/** Whether to draw the artifacts' names, with the count of the one under the pointer. Defaults to `true`. */
|
|
55
53
|
labels?: boolean;
|
|
56
54
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* `dark`.
|
|
55
|
+
* Whether the map's background is `light` or `dark`. The colours of names, outlines, the
|
|
56
|
+
* picked mark's ring and the selected region are chosen to suit it. Defaults to `dark`.
|
|
60
57
|
*/
|
|
61
58
|
scheme?: 'light' | 'dark';
|
|
62
59
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
60
|
+
* Where to draw a ring round the picked mark, in world units. {@link resolvePick} returns it as
|
|
61
|
+
* `worldXY`. Defaults to `null`, no ring.
|
|
65
62
|
*/
|
|
66
63
|
selectedWorldXY?: [number, number] | null;
|
|
67
64
|
/**
|
|
68
|
-
* The `mosaicaId` of the opened artifact,
|
|
69
|
-
*
|
|
65
|
+
* The `mosaicaId` of the opened artifact, which is outlined. While marks are coloured by
|
|
66
|
+
* artifact, every mark outside it is dimmed. Defaults to `null`.
|
|
70
67
|
*/
|
|
71
68
|
openedArtifact?: bigint | null;
|
|
72
|
-
/** The `mosaicaId` of the artifact under the pointer,
|
|
69
|
+
/** The `mosaicaId` of the artifact under the pointer, which is outlined. Defaults to `null`. */
|
|
73
70
|
hoveredArtifact?: bigint | null;
|
|
74
|
-
/** The selected region as a box `[x0, y0, x1, y1]` in world units. Defaults to `null`. */
|
|
71
|
+
/** The selected region as a box, `[x0, y0, x1, y1]` in world units. Defaults to `null`. */
|
|
75
72
|
region?: [number, number, number, number] | null;
|
|
76
73
|
/**
|
|
77
|
-
* The selected region as a polygon of world points.
|
|
78
|
-
* of `region` and
|
|
74
|
+
* The selected region as a polygon of world points. If it has two or more points it is drawn in
|
|
75
|
+
* place of `region` and `drag`. Defaults to `null`.
|
|
79
76
|
*/
|
|
80
77
|
regionPolygon?: [number, number][] | null;
|
|
81
78
|
/**
|
|
82
|
-
* The box
|
|
83
|
-
*
|
|
79
|
+
* The box the user is dragging, `[x0, y0, x1, y1]` in world units. It is drawn in place of
|
|
80
|
+
* `region`, with a fainter fill. Defaults to `null`.
|
|
84
81
|
*/
|
|
85
82
|
drag?: [number, number, number, number] | null;
|
|
86
83
|
/**
|
|
87
|
-
* The lasso
|
|
88
|
-
*
|
|
84
|
+
* The lasso the user is drawing, as world points. It is drawn in place of `regionPolygon` and
|
|
85
|
+
* `drag`, with a fainter fill. Defaults to `null`.
|
|
89
86
|
*/
|
|
90
87
|
dragPolygon?: [number, number][] | null;
|
|
91
88
|
/**
|
|
92
|
-
* Whether
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* Defaults to false.
|
|
89
|
+
* Whether a highlight is set. If it is, the marks it matches keep their colour and are drawn
|
|
90
|
+
* larger with a glow, and the rest are drawn faint grey. The layer does not read this from the
|
|
91
|
+
* store, so pass the store's `view.highlighting`. Defaults to `false`.
|
|
96
92
|
*/
|
|
97
93
|
highlighting?: boolean;
|
|
98
|
-
/** Whether the marks
|
|
94
|
+
/** Whether to draw the marks. Density, outlines, names and the selection are drawn either way. Defaults to `true`. */
|
|
99
95
|
points?: boolean;
|
|
100
96
|
/**
|
|
101
|
-
* A fixed mark radius in pixels. Defaults to `null`, which
|
|
102
|
-
*
|
|
103
|
-
* zoom level up to zoom 10.
|
|
97
|
+
* A fixed mark radius in pixels. Defaults to `null`, which chooses a radius from the number of
|
|
98
|
+
* marks and the zoom: 2 px for ten thousand marks or fewer, down to 1.1 px for a million, plus
|
|
99
|
+
* 0.05 px per zoom level up to zoom 10. While the legend has a `sizeBy`, `sizing` is used instead.
|
|
104
100
|
*/
|
|
105
101
|
radius?: number | null;
|
|
106
102
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* with `setSizeBy(column, {rank: true})`. Defaults to {@link DEFAULT_SIZING}.
|
|
103
|
+
* How marks are sized while the legend has a `sizeBy`. A radius that is not a positive finite
|
|
104
|
+
* number is replaced by the default's. For the `rank` scale, call the store's
|
|
105
|
+
* `setSizeBy(column, {rank: true})`, or every mark is drawn at the smallest size. Defaults to
|
|
106
|
+
* {@link DEFAULT_SIZING}.
|
|
112
107
|
*/
|
|
113
108
|
sizing?: Sizing;
|
|
114
109
|
/**
|
|
115
|
-
* A fixed mark
|
|
116
|
-
* which
|
|
117
|
-
* million, plus
|
|
110
|
+
* A fixed mark opacity from 0 to 1, multiplied by the colour's own alpha. Defaults to `null`,
|
|
111
|
+
* which chooses it from the number of marks: 0.8 for ten thousand or fewer, down to 0.34 for a
|
|
112
|
+
* million, plus 0.015 per zoom level up to zoom 10, and at most 0.9.
|
|
118
113
|
*/
|
|
119
114
|
pointOpacity?: number | null;
|
|
120
115
|
/**
|
|
121
|
-
* How density is drawn under the marks
|
|
122
|
-
*
|
|
123
|
-
* Defaults to `none`, as on `<mosaica-map>`.
|
|
116
|
+
* How density is drawn under the marks: `none`, `smooth` (a soft wash), `hex` (hexagons), `grid`
|
|
117
|
+
* (square cells) or `contours` (lines of equal density). Defaults to `none`.
|
|
124
118
|
*/
|
|
125
119
|
density?: DensityMode;
|
|
126
120
|
/**
|
|
127
|
-
* The counts by cell density is drawn from
|
|
128
|
-
*
|
|
129
|
-
* Defaults to `null`.
|
|
121
|
+
* The counts by cell that density is drawn from. Set it to draw counts you fetched yourself.
|
|
122
|
+
* Defaults to `null`, which draws the counts from `densityCounter` or the layer's own counter.
|
|
130
123
|
*/
|
|
131
124
|
densityCounts?: DensityCounts | null;
|
|
132
125
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* `densityResolution`.
|
|
126
|
+
* A {@link DensityCounter} to draw density from, if you keep one yourself. Defaults to `null`, in
|
|
127
|
+
* which case a layer with a `store` keeps its own counter, which follows the layer's camera,
|
|
128
|
+
* `density` and `densityResolution`.
|
|
137
129
|
*/
|
|
138
130
|
densityCounter?: DensityCounter | null;
|
|
139
|
-
/**
|
|
140
|
-
* The cell size on screen, in CSS pixels, the layer's own counter asks for; see
|
|
141
|
-
* {@link DensityCounter}. Defaults to 12.
|
|
142
|
-
*/
|
|
131
|
+
/** The size on screen of a density cell, in CSS pixels, for the layer's own counter. Defaults to 12. */
|
|
143
132
|
densityResolution?: number;
|
|
144
133
|
/**
|
|
145
134
|
* The colours density is drawn in. Defaults to `null`, which draws the smooth wash in warm grey
|
|
146
|
-
* while
|
|
135
|
+
* while marks are drawn, and Viridis otherwise.
|
|
147
136
|
*/
|
|
148
137
|
densityColours?: DensityColours | null;
|
|
149
138
|
/** How strongly density is drawn, from 0 (not at all) to 1 (fully). Defaults to 1. */
|
|
150
139
|
densityStrength?: number;
|
|
151
140
|
/**
|
|
152
|
-
* How a cell's count
|
|
153
|
-
*
|
|
141
|
+
* How a cell's count maps to its colour, its opacity in the wash and the contour levels: `linear`
|
|
142
|
+
* or `log`. Defaults to `log`.
|
|
154
143
|
*/
|
|
155
144
|
densityScale?: DensityScale;
|
|
156
|
-
/**
|
|
157
|
-
* The palette, ramp and chosen value colours column colour uses. Defaults to
|
|
158
|
-
* {@link DEFAULT_COLOURING}.
|
|
159
|
-
*/
|
|
145
|
+
/** The palette, ramp and per-value colours used when colouring by a column. Defaults to {@link DEFAULT_COLOURING}. */
|
|
160
146
|
colouring?: Colouring;
|
|
161
147
|
/**
|
|
162
|
-
* Called each
|
|
163
|
-
*
|
|
164
|
-
*
|
|
148
|
+
* Called after each render with the number of marks drawn: `drawn` marks of the current frame,
|
|
149
|
+
* and `provisional` stand-ins from another depth, shown until the frame's own marks arrive.
|
|
150
|
+
* Defaults to `null`.
|
|
165
151
|
*/
|
|
166
152
|
onDrawn?: ((drawn: number, provisional: number) => void) | null;
|
|
167
|
-
/** Called each
|
|
153
|
+
/** Called after each render with what it cost and drew. Defaults to `null`. */
|
|
168
154
|
onTimings?: ((t: LayerTimings) => void) | null;
|
|
169
155
|
};
|
|
170
156
|
/**
|
|
@@ -172,34 +158,34 @@ export type MosaicaLayerProps = CompositeLayerProps & {
|
|
|
172
158
|
* milliseconds. On a render that draws no marks, `slabMs`, `densityMs` and the mark figures are 0.
|
|
173
159
|
*/
|
|
174
160
|
export type LayerTimings = {
|
|
175
|
-
/** Time spent writing
|
|
161
|
+
/** Time spent writing newly arrived marks into the GPU buffers. */
|
|
176
162
|
slabMs: number;
|
|
177
163
|
/**
|
|
178
|
-
* Time spent
|
|
179
|
-
*
|
|
164
|
+
* Time spent building the density layers. It excludes the smooth wash's image, which is built
|
|
165
|
+
* after the render, and the aggregation deck.gl does for the other modes.
|
|
180
166
|
*/
|
|
181
167
|
densityMs: number;
|
|
182
|
-
/** Time spent updating the
|
|
168
|
+
/** Time spent updating the texture that colours marks by artifact. */
|
|
183
169
|
lutMs: number;
|
|
184
170
|
/** Time spent building the outlines. */
|
|
185
171
|
outlinesMs: number;
|
|
186
|
-
/** Time spent placing
|
|
172
|
+
/** Time spent placing names. */
|
|
187
173
|
labelsMs: number;
|
|
188
|
-
/** Time for the whole render
|
|
174
|
+
/** Time for the whole render. */
|
|
189
175
|
layersMs: number;
|
|
190
|
-
/**
|
|
176
|
+
/** How many times the texture that colours marks by artifact has been written since the layer was created. */
|
|
191
177
|
lutWrites: number;
|
|
192
178
|
/** Outline parts drawn. An artifact in several pieces has several parts. */
|
|
193
179
|
outlines: number;
|
|
194
180
|
/** Artifacts outlined: 0, 1 or 2 (the hovered and the opened). */
|
|
195
181
|
outlinesDrawn: number;
|
|
196
|
-
/**
|
|
182
|
+
/** Names placed. */
|
|
197
183
|
labels: number;
|
|
198
|
-
/** The mark radius drawn, in pixels
|
|
184
|
+
/** The mark radius drawn, in pixels. While marks are sized by a column, the largest. */
|
|
199
185
|
markRadius: number;
|
|
200
|
-
/** The
|
|
186
|
+
/** The opacity the marks are drawn at, from 0 to 1, multiplied by their colour's own alpha. */
|
|
201
187
|
markAlpha: number;
|
|
202
|
-
/** The number of marks the radius and
|
|
188
|
+
/** The number of marks the radius and opacity were chosen for, stand-ins included. */
|
|
203
189
|
markCount: number;
|
|
204
190
|
};
|
|
205
191
|
/** A layer's colouring, as the store's `colourBy` names it: `cluster:<layer>` or a column. */
|
|
@@ -378,29 +364,23 @@ export type MosaicaLayerInternalProps = MosaicaLayerProps & {
|
|
|
378
364
|
slab?: MarkSlab | null;
|
|
379
365
|
};
|
|
380
366
|
/**
|
|
381
|
-
* A deck.gl
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
386
|
-
* The layer draws in the 512-unit world square (`WORLD_SIZE`) for an `OrthographicView` with
|
|
387
|
-
* `flipY: true`, and {@link viewInputOf} turns that view's camera into what `store.setView` takes.
|
|
388
|
-
* It has no adapter for a geographic `MapView` or a MapLibre host.
|
|
389
|
-
*
|
|
390
|
-
* With `store` set, the layer subscribes to it and redraws on each change. The layer does not
|
|
391
|
-
* fetch. Every served mark is drawn, with no budget, cap or filter applied in the layer, and a
|
|
392
|
-
* value the colouring cannot resolve draws grey.
|
|
393
|
-
*
|
|
394
|
-
* Only an artifact at the level drawn (`clusterLevel`) is outlined. On a layer that declares a
|
|
395
|
-
* shape, the outline appears once `store.needShape` has fetched the shape. On a layer that declares
|
|
396
|
-
* none, the outline is the artifact's box, drawn as a thin unfilled rectangle.
|
|
367
|
+
* A deck.gl layer that draws a Mosaica map. Give it a `store` and it draws the store's projections
|
|
368
|
+
* and redraws whenever they change. From bottom to top it draws the outlines of the hovered and
|
|
369
|
+
* opened artifacts, density, the points as marks, the artifacts' names, the selected region and a
|
|
370
|
+
* ring round the picked mark. The props are {@link MosaicaLayerProps}.
|
|
397
371
|
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
372
|
+
* The layer fetches nothing itself. The store decides what to fetch from the camera you give it,
|
|
373
|
+
* and the layer draws every mark the store holds. Use it in an `OrthographicView` with
|
|
374
|
+
* `flipY: true`. It draws in a world square 512 units across, and {@link viewInputOf} converts
|
|
375
|
+
* that view's camera for the store's `setView`. It cannot be used in a geographic `MapView` or
|
|
376
|
+
* with MapLibre.
|
|
401
377
|
*
|
|
402
|
-
* The layer
|
|
403
|
-
*
|
|
378
|
+
* The layer does not handle hover or clicks. Pass the pick info from deck's `onHover` or `onClick`
|
|
379
|
+
* to {@link resolvePick} to find the item or artifact under the pointer, then set the props that
|
|
380
|
+
* show it, such as `selectedWorldXY` and `hoveredArtifact`. If the artifact's layer declares
|
|
381
|
+
* shapes, call the store's `needShape` with its id: the outline appears once the shape arrives.
|
|
382
|
+
* Otherwise the outline is the artifact's bounding box. Only an artifact drawn at `clusterLevel`
|
|
383
|
+
* is outlined.
|
|
404
384
|
*/
|
|
405
385
|
export declare class MosaicaLayer extends CompositeLayer<MosaicaLayerInternalProps> {
|
|
406
386
|
/** @internal */
|
package/dist/layer.js
CHANGED
|
@@ -440,29 +440,23 @@ export function outlineOf(a, fetched) {
|
|
|
440
440
|
return null;
|
|
441
441
|
}
|
|
442
442
|
/**
|
|
443
|
-
* A deck.gl
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
*
|
|
443
|
+
* A deck.gl layer that draws a Mosaica map. Give it a `store` and it draws the store's projections
|
|
444
|
+
* and redraws whenever they change. From bottom to top it draws the outlines of the hovered and
|
|
445
|
+
* opened artifacts, density, the points as marks, the artifacts' names, the selected region and a
|
|
446
|
+
* ring round the picked mark. The props are {@link MosaicaLayerProps}.
|
|
447
447
|
*
|
|
448
|
-
* The layer
|
|
449
|
-
*
|
|
450
|
-
*
|
|
448
|
+
* The layer fetches nothing itself. The store decides what to fetch from the camera you give it,
|
|
449
|
+
* and the layer draws every mark the store holds. Use it in an `OrthographicView` with
|
|
450
|
+
* `flipY: true`. It draws in a world square 512 units across, and {@link viewInputOf} converts
|
|
451
|
+
* that view's camera for the store's `setView`. It cannot be used in a geographic `MapView` or
|
|
452
|
+
* with MapLibre.
|
|
451
453
|
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* none, the outline is the artifact's box, drawn as a thin unfilled rectangle.
|
|
459
|
-
*
|
|
460
|
-
* Hover and pick are the host's: pass deck's pick info to {@link resolvePick}, which returns the
|
|
461
|
-
* mark or the artifact name under the pointer. Outlines, the wash and the selected region are not
|
|
462
|
-
* pickable.
|
|
463
|
-
*
|
|
464
|
-
* The layer makes its mark buffers and colour lookup texture on its deck's device, and releases
|
|
465
|
-
* them when deck finalises it.
|
|
454
|
+
* The layer does not handle hover or clicks. Pass the pick info from deck's `onHover` or `onClick`
|
|
455
|
+
* to {@link resolvePick} to find the item or artifact under the pointer, then set the props that
|
|
456
|
+
* show it, such as `selectedWorldXY` and `hoveredArtifact`. If the artifact's layer declares
|
|
457
|
+
* shapes, call the store's `needShape` with its id: the outline appears once the shape arrives.
|
|
458
|
+
* Otherwise the outline is the artifact's bounding box. Only an artifact drawn at `clusterLevel`
|
|
459
|
+
* is outlined.
|
|
466
460
|
*/
|
|
467
461
|
export class MosaicaLayer extends CompositeLayer {
|
|
468
462
|
/** @internal */
|
package/dist/pick.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { type ArtifactsProjection, type Band } from '@mosaicajs/client';
|
|
|
2
2
|
/**
|
|
3
3
|
* What {@link resolvePick} found under the pointer, by `kind`:
|
|
4
4
|
*
|
|
5
|
-
* - `mark`: an item
|
|
6
|
-
*
|
|
7
|
-
* - `artifact`: an artifact's name
|
|
8
|
-
* - `miss`: nothing
|
|
9
|
-
* - `broken`: a hit
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* - `mark`: an item. `id` is its `mosaicaId`, and `worldXY` the mark's position in world units, or
|
|
6
|
+
* the pointer's if the mark's position is not known, or `null` if neither is known.
|
|
7
|
+
* - `artifact`: an artifact's name. `id` is the artifact's `mosaicaId`.
|
|
8
|
+
* - `miss`: nothing.
|
|
9
|
+
* - `broken`: a hit the layer cannot resolve to an id, which is a bug in the layer. It is kept
|
|
10
|
+
* apart from a miss so that you can report it. `layer` is the sublayer's id, `hasIds` whether it
|
|
11
|
+
* has ids and `idCount` how many.
|
|
12
12
|
*/
|
|
13
13
|
export type Picked = {
|
|
14
14
|
kind: 'mark';
|
|
@@ -26,7 +26,7 @@ export type Picked = {
|
|
|
26
26
|
hasIds: boolean;
|
|
27
27
|
idCount: number;
|
|
28
28
|
};
|
|
29
|
-
/** The fields of deck.gl's `PickingInfo` that {@link resolvePick} reads.
|
|
29
|
+
/** The fields of deck.gl's `PickingInfo` that {@link resolvePick} reads. Pass deck's `PickingInfo` as it is. */
|
|
30
30
|
export type PickInfo = {
|
|
31
31
|
/** The index of the hit within the sublayer's data, or -1 for no hit. */
|
|
32
32
|
index: number;
|
|
@@ -40,13 +40,24 @@ export type PickInfo = {
|
|
|
40
40
|
id: string;
|
|
41
41
|
props: object;
|
|
42
42
|
} | null;
|
|
43
|
-
/** The pointer's position in world units, used as a mark's `worldXY`
|
|
43
|
+
/** The pointer's position in world units, used as a mark's `worldXY` if the mark's own position is not known. */
|
|
44
44
|
coordinate?: number[] | null;
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* Finds the item or artifact under the pointer from a deck.gl pick on a {@link MosaicaLayer}. Pass
|
|
48
|
+
* it the pick info that deck gives `onHover` or `onClick`. Only marks and artifact names can be
|
|
49
|
+
* picked, so anything else, such as an outline or the density wash, is a `miss`.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* new Deck({
|
|
54
|
+
* // ...
|
|
55
|
+
* onClick: (info) => {
|
|
56
|
+
* const picked = resolvePick(info);
|
|
57
|
+
* if (picked.kind === 'mark') store.pick(picked.id);
|
|
58
|
+
* }
|
|
59
|
+
* });
|
|
60
|
+
* ```
|
|
50
61
|
*/
|
|
51
62
|
export declare function resolvePick(info: PickInfo): Picked;
|
|
52
63
|
/**
|
package/dist/pick.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { NO_ORDINAL } from '@mosaicajs/client';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Finds the item or artifact under the pointer from a deck.gl pick on a {@link MosaicaLayer}. Pass
|
|
4
|
+
* it the pick info that deck gives `onHover` or `onClick`. Only marks and artifact names can be
|
|
5
|
+
* picked, so anything else, such as an outline or the density wash, is a `miss`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* new Deck({
|
|
10
|
+
* // ...
|
|
11
|
+
* onClick: (info) => {
|
|
12
|
+
* const picked = resolvePick(info);
|
|
13
|
+
* if (picked.kind === 'mark') store.pick(picked.id);
|
|
14
|
+
* }
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
6
17
|
*/
|
|
7
18
|
export function resolvePick(info) {
|
|
8
19
|
if (info.index < 0)
|
package/dist/size.d.ts
CHANGED
|
@@ -8,30 +8,33 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { LegendProjection, Meta, ScalarColumn } from '@mosaicajs/client';
|
|
10
10
|
/**
|
|
11
|
-
* How a number is placed between the smallest and largest size: `linear
|
|
12
|
-
*
|
|
13
|
-
* size; or `rank`, the value's rank
|
|
14
|
-
* evenly.
|
|
11
|
+
* How a number is placed between the smallest and largest size: `linear`, in proportion to the
|
|
12
|
+
* value; `log`, in proportion to `log(1 + (v − min))`, so a long tail does not leave most marks at
|
|
13
|
+
* the smallest size; or `rank`, by the value's rank in a sample of the values drawn, which spreads
|
|
14
|
+
* skewed values evenly. The rank is an estimate, because the marks drawn are themselves a sample.
|
|
15
15
|
*
|
|
16
16
|
* @category Size
|
|
17
17
|
*/
|
|
18
18
|
export type SizeScale = 'linear' | 'log' | 'rank';
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* How to size marks by a number column: the radius in pixels of the smallest and largest values,
|
|
21
21
|
* and the scale between them.
|
|
22
22
|
*
|
|
23
23
|
* @category Size
|
|
24
24
|
*/
|
|
25
25
|
export type Sizing = {
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* The radius in pixels of the smallest value. A mark with no value, or a value that is not
|
|
28
|
+
* finite, is drawn as a ring, at this radius or 3 px, whichever is larger.
|
|
29
|
+
*/
|
|
27
30
|
min: number;
|
|
28
31
|
/** The radius in pixels of the largest value. */
|
|
29
32
|
max: number;
|
|
30
|
-
/** How a value is placed between
|
|
33
|
+
/** How a value is placed between `min` and `max`. */
|
|
31
34
|
scale: SizeScale;
|
|
32
35
|
};
|
|
33
36
|
/**
|
|
34
|
-
* The sizing
|
|
37
|
+
* The default sizing: 2 to 9 pixels on a linear scale.
|
|
35
38
|
*
|
|
36
39
|
* @category Size
|
|
37
40
|
*/
|
package/dist/size.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { numericValues, sizesPoints } from '@mosaicajs/client/internal';
|
|
2
2
|
import { fractionOf } from './colour.js';
|
|
3
3
|
/**
|
|
4
|
-
* The sizing
|
|
4
|
+
* The default sizing: 2 to 9 pixels on a linear scale.
|
|
5
5
|
*
|
|
6
6
|
* @category Size
|
|
7
7
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mosaicajs/deck",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A deck.gl layer that draws a Mosaica store, for a host with its own Deck.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mosaica",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"directory": "clients/ts/deck"
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
|
-
"author": "
|
|
22
|
+
"author": "mosaicadb",
|
|
23
23
|
"type": "module",
|
|
24
24
|
"main": "./dist/index.js",
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@mosaicajs/client": "0.1.0
|
|
48
|
+
"@mosaicajs/client": "0.1.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@deck.gl/aggregation-layers": "^9.3.7",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@deck.gl/layers": "^9.3.7",
|
|
60
60
|
"@luma.gl/core": "^9.3.6",
|
|
61
61
|
"typescript": "^5.9.0",
|
|
62
|
-
"vitest": "^
|
|
62
|
+
"vitest": "^4.1.12"
|
|
63
63
|
},
|
|
64
64
|
"publishConfig": {
|
|
65
65
|
"access": "public"
|