@uwdata/vgplot 0.4.0 → 0.5.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.
Files changed (65) hide show
  1. package/README.md +4 -2
  2. package/dist/vgplot.js +5643 -5842
  3. package/dist/vgplot.min.js +14 -35
  4. package/package.json +8 -10
  5. package/src/api.js +292 -0
  6. package/src/connect.js +14 -0
  7. package/src/context.js +20 -0
  8. package/src/index.js +14 -303
  9. package/src/inputs.js +24 -0
  10. package/src/{directives → plot}/attributes.js +14 -5
  11. package/src/{directives → plot}/interactors.js +8 -6
  12. package/src/{directives → plot}/legends.js +14 -6
  13. package/src/{directives → plot}/marks.js +16 -13
  14. package/src/plot/named-plots.js +49 -0
  15. package/src/plot/plot.js +9 -0
  16. package/src/directives/plot.js +0 -39
  17. package/src/interactors/Highlight.js +0 -101
  18. package/src/interactors/Interval1D.js +0 -90
  19. package/src/interactors/Interval2D.js +0 -102
  20. package/src/interactors/Nearest.js +0 -66
  21. package/src/interactors/PanZoom.js +0 -121
  22. package/src/interactors/Toggle.js +0 -111
  23. package/src/interactors/util/brush.js +0 -45
  24. package/src/interactors/util/close-to.js +0 -9
  25. package/src/interactors/util/get-field.js +0 -4
  26. package/src/interactors/util/invert.js +0 -3
  27. package/src/interactors/util/patchScreenCTM.js +0 -13
  28. package/src/interactors/util/sanitize-styles.js +0 -9
  29. package/src/interactors/util/to-kebab-case.js +0 -9
  30. package/src/layout/index.js +0 -2
  31. package/src/legend.js +0 -64
  32. package/src/marks/ConnectedMark.js +0 -63
  33. package/src/marks/ContourMark.js +0 -89
  34. package/src/marks/DenseLineMark.js +0 -146
  35. package/src/marks/Density1DMark.js +0 -104
  36. package/src/marks/Density2DMark.js +0 -69
  37. package/src/marks/Grid2DMark.js +0 -191
  38. package/src/marks/HexbinMark.js +0 -88
  39. package/src/marks/Mark.js +0 -195
  40. package/src/marks/RasterMark.js +0 -122
  41. package/src/marks/RasterTileMark.js +0 -332
  42. package/src/marks/RegressionMark.js +0 -117
  43. package/src/marks/util/bin-field.js +0 -17
  44. package/src/marks/util/density.js +0 -226
  45. package/src/marks/util/extent.js +0 -56
  46. package/src/marks/util/grid.js +0 -57
  47. package/src/marks/util/handle-param.js +0 -14
  48. package/src/marks/util/is-arrow-table.js +0 -3
  49. package/src/marks/util/is-color.js +0 -18
  50. package/src/marks/util/is-constant-option.js +0 -40
  51. package/src/marks/util/is-symbol.js +0 -20
  52. package/src/marks/util/raster.js +0 -44
  53. package/src/marks/util/stats.js +0 -133
  54. package/src/marks/util/to-data-array.js +0 -58
  55. package/src/plot-attributes.js +0 -211
  56. package/src/plot-renderer.js +0 -161
  57. package/src/plot.js +0 -136
  58. package/src/spec/parse-data.js +0 -69
  59. package/src/spec/parse-spec.js +0 -422
  60. package/src/spec/to-module.js +0 -465
  61. package/src/spec/util.js +0 -43
  62. package/src/symbols.js +0 -3
  63. package/src/transforms/bin.js +0 -81
  64. package/src/transforms/index.js +0 -3
  65. /package/src/{directives → plot}/data.js +0 -0
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@uwdata/vgplot",
3
- "version": "0.4.0",
4
- "description": "A Mosaic-based interactive grammar of graphics.",
3
+ "version": "0.5.0",
4
+ "description": "An API for interactive Mosaic-powered visualizations and dashboards.",
5
5
  "keywords": [
6
6
  "data",
7
7
  "visualization",
8
+ "interaction",
8
9
  "query",
9
10
  "database",
10
11
  "duckdb",
@@ -29,13 +30,10 @@
29
30
  "prepublishOnly": "npm run test && npm run lint && npm run build"
30
31
  },
31
32
  "dependencies": {
32
- "@observablehq/plot": "^0.6.13",
33
- "@uwdata/mosaic-core": "^0.4.0",
34
- "@uwdata/mosaic-inputs": "^0.4.0",
35
- "@uwdata/mosaic-sql": "^0.4.0",
36
- "d3": "^7.8.5",
37
- "isoformat": "^0.2.1",
38
- "topojson-client": "^3.1.0"
33
+ "@uwdata/mosaic-core": "^0.5.0",
34
+ "@uwdata/mosaic-inputs": "^0.5.0",
35
+ "@uwdata/mosaic-plot": "^0.5.0",
36
+ "@uwdata/mosaic-sql": "^0.5.0"
39
37
  },
40
- "gitHead": "4114465543a21b25d6d14647db7d95af875d2519"
38
+ "gitHead": "92886dddfb126c1439924c5a0189e4639c3519a7"
41
39
  }
package/src/api.js ADDED
@@ -0,0 +1,292 @@
1
+ export {
2
+ Param,
3
+ Selection,
4
+ coordinator
5
+ } from '@uwdata/mosaic-core';
6
+
7
+ export {
8
+ Fixed,
9
+ bin
10
+ } from '@uwdata/mosaic-plot';
11
+
12
+ export {
13
+ Query, agg, sql, column, literal,
14
+ cast, castDouble, castInteger,
15
+ argmax, argmin, arrayAgg, avg, count, corr, covarPop, entropy,
16
+ kurtosis, mad, max, median, min, mode, last, product, quantile,
17
+ skewness, stddev, stddevPop, stringAgg, sum, variance, varPop,
18
+ row_number, rank, dense_rank, percent_rank, cume_dist,
19
+ ntile, lag, lead, first_value, last_value, nth_value,
20
+ dateDay, dateMonth, dateMonthDay,
21
+ and, or, not, eq, neq, gt, gte, lt, lte,
22
+ isBetween, isNotBetween,
23
+ isDistinct, isNotDistinct,
24
+ isNull, isNotNull,
25
+ centroid, centroidX, centroidY, geojson,
26
+ create, loadExtension,
27
+ loadCSV, loadJSON, loadObjects, loadParquet, loadSpatial
28
+ } from '@uwdata/mosaic-sql';
29
+
30
+ export {
31
+ menu,
32
+ search,
33
+ slider,
34
+ table
35
+ } from './inputs.js';
36
+
37
+ export {
38
+ hconcat,
39
+ vconcat
40
+ } from './layout/concat.js';
41
+
42
+ export {
43
+ hspace,
44
+ vspace
45
+ } from './layout/space.js';
46
+
47
+ export {
48
+ name,
49
+ margins,
50
+ xyDomain,
51
+ style,
52
+ width,
53
+ height,
54
+ margin,
55
+ marginLeft,
56
+ marginRight,
57
+ marginTop,
58
+ marginBottom,
59
+ align,
60
+ aspectRatio,
61
+ axis,
62
+ inset,
63
+ grid,
64
+ label,
65
+ padding,
66
+ round,
67
+ xScale,
68
+ xDomain,
69
+ xRange,
70
+ xNice,
71
+ xInset,
72
+ xInsetLeft,
73
+ xInsetRight,
74
+ xClamp,
75
+ xRound,
76
+ xAlign,
77
+ xPadding,
78
+ xPaddingInner,
79
+ xPaddingOuter,
80
+ xAxis,
81
+ xTicks,
82
+ xTickSize,
83
+ xTickSpacing,
84
+ xTickPadding,
85
+ xTickFormat,
86
+ xTickRotate,
87
+ xGrid,
88
+ xLine,
89
+ xLabel,
90
+ xLabelAnchor,
91
+ xLabelOffset,
92
+ xFontVariant,
93
+ xAriaLabel,
94
+ xAriaDescription,
95
+ xReverse,
96
+ xZero,
97
+ yScale,
98
+ yDomain,
99
+ yRange,
100
+ yNice,
101
+ yInset,
102
+ yInsetTop,
103
+ yInsetBottom,
104
+ yClamp,
105
+ yRound,
106
+ yAlign,
107
+ yPadding,
108
+ yPaddingInner,
109
+ yPaddingOuter,
110
+ yAxis,
111
+ yTicks,
112
+ yTickSize,
113
+ yTickSpacing,
114
+ yTickPadding,
115
+ yTickFormat,
116
+ yTickRotate,
117
+ yGrid,
118
+ yLine,
119
+ yLabel,
120
+ yLabelAnchor,
121
+ yLabelOffset,
122
+ yFontVariant,
123
+ yAriaLabel,
124
+ yAriaDescription,
125
+ yReverse,
126
+ yZero,
127
+ facetMargin,
128
+ facetMarginTop,
129
+ facetMarginBottom,
130
+ facetMarginLeft,
131
+ facetMarginRight,
132
+ facetGrid,
133
+ facetLabel,
134
+ fxDomain,
135
+ fxRange,
136
+ fxNice,
137
+ fxInset,
138
+ fxInsetLeft,
139
+ fxInsetRight,
140
+ fxRound,
141
+ fxAlign,
142
+ fxPadding,
143
+ fxPaddingInner,
144
+ fxPaddingOuter,
145
+ fxAxis,
146
+ fxTicks,
147
+ fxTickSize,
148
+ fxTickSpacing,
149
+ fxTickPadding,
150
+ fxTickFormat,
151
+ fxTickRotate,
152
+ fxGrid,
153
+ fxLine,
154
+ fxLabel,
155
+ fxLabelAnchor,
156
+ fxLabelOffset,
157
+ fxFontVariant,
158
+ fxAriaLabel,
159
+ fxAriaDescription,
160
+ fxReverse,
161
+ fyDomain,
162
+ fyRange,
163
+ fyNice,
164
+ fyInset,
165
+ fyInsetTop,
166
+ fyInsetBottom,
167
+ fyRound,
168
+ fyAlign,
169
+ fyPadding,
170
+ fyPaddingInner,
171
+ fyPaddingOuter,
172
+ fyAxis,
173
+ fyTicks,
174
+ fyTickSize,
175
+ fyTickSpacing,
176
+ fyTickPadding,
177
+ fyTickFormat,
178
+ fyTickRotate,
179
+ fyGrid,
180
+ fyLine,
181
+ fyLabel,
182
+ fyLabelAnchor,
183
+ fyLabelOffset,
184
+ fyFontVariant,
185
+ fyAriaLabel,
186
+ fyAriaDescription,
187
+ fyReverse,
188
+ colorScale,
189
+ colorDomain,
190
+ colorRange,
191
+ colorClamp,
192
+ colorN,
193
+ colorNice,
194
+ colorScheme,
195
+ colorInterpolate,
196
+ colorPivot,
197
+ colorSymmetric,
198
+ colorLabel,
199
+ colorReverse,
200
+ colorZero,
201
+ colorTickFormat,
202
+ opacityScale,
203
+ opacityDomain,
204
+ opacityRange,
205
+ opacityClamp,
206
+ opacityNice,
207
+ opacityLabel,
208
+ opacityReverse,
209
+ opacityZero,
210
+ opacityTickFormat,
211
+ rScale,
212
+ rDomain,
213
+ rRange,
214
+ rClamp,
215
+ rNice,
216
+ rZero,
217
+ lengthScale,
218
+ lengthDomain,
219
+ lengthRange,
220
+ lengthClamp,
221
+ lengthNice,
222
+ lengthZero,
223
+ projectionType,
224
+ projectionParallels,
225
+ projectionPrecision,
226
+ projectionRotate,
227
+ projectionDomain,
228
+ projectionInset,
229
+ projectionInsetLeft,
230
+ projectionInsetRight,
231
+ projectionInsetTop,
232
+ projectionInsetBottom,
233
+ projectionClip,
234
+ } from './plot/attributes.js';
235
+
236
+ export {
237
+ from
238
+ } from './plot/data.js';
239
+
240
+ export {
241
+ area, areaX, areaY,
242
+ line, lineX, lineY,
243
+ barX, barY,
244
+ cell, cellX, cellY,
245
+ rect, rectX, rectY,
246
+ dot, dotX, dotY, circle, hexagon,
247
+ text, textX, textY,
248
+ image,
249
+ tickX, tickY,
250
+ ruleX, ruleY,
251
+ density, densityX, densityY, denseLine,
252
+ raster, rasterTile,
253
+ contour,
254
+ hexbin, hexgrid,
255
+ regressionY,
256
+ vector, vectorX, vectorY, spike,
257
+ voronoi, voronoiMesh, delaunayLink, delaunayMesh, hull,
258
+ arrow, link,
259
+ frame,
260
+ axisX, axisY, axisFx, axisFy,
261
+ gridX, gridY, gridFx, gridFy,
262
+ geo, sphere, graticule
263
+ } from './plot/marks.js';
264
+
265
+ export {
266
+ highlight,
267
+ intervalX,
268
+ intervalY,
269
+ intervalXY,
270
+ nearestX,
271
+ nearestY,
272
+ toggle,
273
+ toggleX,
274
+ toggleY,
275
+ toggleColor,
276
+ pan,
277
+ panX,
278
+ panY,
279
+ panZoom,
280
+ panZoomX,
281
+ panZoomY
282
+ } from './plot/interactors.js';
283
+
284
+ export {
285
+ colorLegend,
286
+ opacityLegend,
287
+ symbolLegend
288
+ } from './plot/legends.js';
289
+
290
+ export {
291
+ plot
292
+ } from './plot/plot.js';
package/src/connect.js ADDED
@@ -0,0 +1,14 @@
1
+ import { coordinator } from '@uwdata/mosaic-core';
2
+
3
+ /**
4
+ * Context-sensitive connector for coordinator and clients.
5
+ * This method proxies access to Coordinator.connect().
6
+ * If the provided context object has an explicit coordinator, that is used.
7
+ * Otherwise the default coordinator singleton is used.
8
+ */
9
+ export function connect(ctx, ...clients) {
10
+ const coord = ctx?.context?.coordinator ?? coordinator();
11
+ for (const client of clients) {
12
+ coord.connect(client);
13
+ }
14
+ }
package/src/context.js ADDED
@@ -0,0 +1,20 @@
1
+ import { coordinator as _coordinator } from '@uwdata/mosaic-core';
2
+ import { NamedPlots } from './plot/named-plots.js';
3
+ import * as vgplot from './api.js';
4
+
5
+ export function createAPIContext({
6
+ coordinator = _coordinator(),
7
+ namedPlots = new NamedPlots,
8
+ extensions = null,
9
+ ...options
10
+ } = {}) {
11
+ return {
12
+ ...vgplot,
13
+ ...extensions,
14
+ context: {
15
+ coordinator,
16
+ namedPlots,
17
+ ...options
18
+ }
19
+ };
20
+ }
package/src/index.js CHANGED
@@ -1,316 +1,27 @@
1
1
  export {
2
2
  Coordinator,
3
3
  MosaicClient,
4
- Param,
5
- Selection,
6
- coordinator,
7
- restConnector, socketConnector, wasmConnector
4
+ restConnector,
5
+ socketConnector,
6
+ wasmConnector
8
7
  } from '@uwdata/mosaic-core';
9
8
 
10
- export {
11
- menu,
12
- search,
13
- slider,
14
- table
15
- } from '@uwdata/mosaic-inputs';
16
-
17
- export {
18
- Query, agg, sql, column, literal,
19
- cast, castDouble, castInteger,
20
- argmax, argmin, arrayAgg, avg, count, corr, covarPop, entropy,
21
- kurtosis, mad, max, median, min, mode, last, product, quantile,
22
- skewness, stddev, stddevPop, stringAgg, sum, variance, varPop,
23
- row_number, rank, dense_rank, percent_rank, cume_dist,
24
- ntile, lag, lead, first_value, last_value, nth_value,
25
- dateDay, dateMonth, dateMonthDay,
26
- and, or, not, eq, neq, gt, gte, lt, lte,
27
- isBetween, isNotBetween,
28
- isDistinct, isNotDistinct,
29
- isNull, isNotNull,
30
- loadCSV, loadJSON, loadObjects, loadParquet
31
- } from '@uwdata/mosaic-sql';
32
-
33
- export {
34
- bin
35
- } from './transforms/index.js';
36
-
37
- export {
38
- name,
39
- attribute,
40
- attributes,
41
- margins,
42
- xyDomain,
43
- style,
44
- width,
45
- height,
46
- margin,
47
- marginLeft,
48
- marginRight,
49
- marginTop,
50
- marginBottom,
51
- align,
52
- aspectRatio,
53
- axis,
54
- inset,
55
- grid,
56
- label,
57
- padding,
58
- round,
59
- xScale,
60
- xDomain,
61
- xRange,
62
- xNice,
63
- xInset,
64
- xInsetLeft,
65
- xInsetRight,
66
- xClamp,
67
- xRound,
68
- xAlign,
69
- xPadding,
70
- xPaddingInner,
71
- xPaddingOuter,
72
- xAxis,
73
- xTicks,
74
- xTickSize,
75
- xTickSpacing,
76
- xTickPadding,
77
- xTickFormat,
78
- xTickRotate,
79
- xGrid,
80
- xLine,
81
- xLabel,
82
- xLabelAnchor,
83
- xLabelOffset,
84
- xFontVariant,
85
- xAriaLabel,
86
- xAriaDescription,
87
- xReverse,
88
- xZero,
89
- yScale,
90
- yDomain,
91
- yRange,
92
- yNice,
93
- yInset,
94
- yInsetTop,
95
- yInsetBottom,
96
- yClamp,
97
- yRound,
98
- yAlign,
99
- yPadding,
100
- yPaddingInner,
101
- yPaddingOuter,
102
- yAxis,
103
- yTicks,
104
- yTickSize,
105
- yTickSpacing,
106
- yTickPadding,
107
- yTickFormat,
108
- yTickRotate,
109
- yGrid,
110
- yLine,
111
- yLabel,
112
- yLabelAnchor,
113
- yLabelOffset,
114
- yFontVariant,
115
- yAriaLabel,
116
- yAriaDescription,
117
- yReverse,
118
- yZero,
119
- facetMargin,
120
- facetMarginTop,
121
- facetMarginBottom,
122
- facetMarginLeft,
123
- facetMarginRight,
124
- facetGrid,
125
- facetLabel,
126
- fxDomain,
127
- fxRange,
128
- fxNice,
129
- fxInset,
130
- fxInsetLeft,
131
- fxInsetRight,
132
- fxRound,
133
- fxAlign,
134
- fxPadding,
135
- fxPaddingInner,
136
- fxPaddingOuter,
137
- fxAxis,
138
- fxTicks,
139
- fxTickSize,
140
- fxTickSpacing,
141
- fxTickPadding,
142
- fxTickFormat,
143
- fxTickRotate,
144
- fxGrid,
145
- fxLine,
146
- fxLabel,
147
- fxLabelAnchor,
148
- fxLabelOffset,
149
- fxFontVariant,
150
- fxAriaLabel,
151
- fxAriaDescription,
152
- fxReverse,
153
- fyDomain,
154
- fyRange,
155
- fyNice,
156
- fyInset,
157
- fyInsetTop,
158
- fyInsetBottom,
159
- fyRound,
160
- fyAlign,
161
- fyPadding,
162
- fyPaddingInner,
163
- fyPaddingOuter,
164
- fyAxis,
165
- fyTicks,
166
- fyTickSize,
167
- fyTickSpacing,
168
- fyTickPadding,
169
- fyTickFormat,
170
- fyTickRotate,
171
- fyGrid,
172
- fyLine,
173
- fyLabel,
174
- fyLabelAnchor,
175
- fyLabelOffset,
176
- fyFontVariant,
177
- fyAriaLabel,
178
- fyAriaDescription,
179
- fyReverse,
180
- colorScale,
181
- colorDomain,
182
- colorRange,
183
- colorClamp,
184
- colorNice,
185
- colorScheme,
186
- colorInterpolate,
187
- colorPivot,
188
- colorSymmetric,
189
- colorLabel,
190
- colorReverse,
191
- colorZero,
192
- colorTickFormat,
193
- opacityScale,
194
- opacityDomain,
195
- opacityRange,
196
- opacityClamp,
197
- opacityNice,
198
- opacityLabel,
199
- opacityReverse,
200
- opacityZero,
201
- opacityTickFormat,
202
- rScale,
203
- rDomain,
204
- rRange,
205
- rClamp,
206
- rNice,
207
- rZero,
208
- lengthScale,
209
- lengthDomain,
210
- lengthRange,
211
- lengthClamp,
212
- lengthNice,
213
- lengthZero,
214
- projectionType,
215
- projectionParallels,
216
- projectionPrecision,
217
- projectionRotate,
218
- projectionDomain,
219
- projectionInset,
220
- projectionInsetLeft,
221
- projectionInsetRight,
222
- projectionInsetTop,
223
- projectionInsetBottom,
224
- projectionClip,
225
- } from './directives/attributes.js';
226
-
227
- export {
228
- from
229
- } from './directives/data.js';
230
-
231
- export {
232
- area, areaX, areaY,
233
- line, lineX, lineY,
234
- barX, barY,
235
- cell, cellX, cellY,
236
- rect, rectX, rectY,
237
- dot, dotX, dotY, circle, hexagon,
238
- text, textX, textY,
239
- image,
240
- tickX, tickY,
241
- ruleX, ruleY,
242
- density, densityX, densityY, denseLine,
243
- raster, rasterTile,
244
- contour,
245
- hexbin, hexgrid,
246
- regressionY,
247
- vector, vectorX, vectorY, spike,
248
- voronoi, voronoiMesh, delaunayLink, delaunayMesh, hull,
249
- arrow, link,
250
- frame,
251
- axisX, axisY, axisFx, axisFy,
252
- gridX, gridY, gridFx, gridFy,
253
- geo, sphere, graticule
254
- } from './directives/marks.js';
255
-
256
- export {
257
- highlight,
258
- intervalX,
259
- intervalY,
260
- intervalXY,
261
- nearestX,
262
- nearestY,
263
- toggle,
264
- toggleX,
265
- toggleY,
266
- toggleColor,
267
- pan,
268
- panX,
269
- panY,
270
- panZoom,
271
- panZoomX,
272
- panZoomY
273
- } from './directives/interactors.js';
274
-
275
- export {
276
- colorLegend,
277
- opacityLegend,
278
- symbolLegend
279
- } from './directives/legends.js';
9
+ export * from './api.js';
280
10
 
281
11
  export {
282
12
  namedPlots,
283
- plot,
284
- reset
285
- } from './directives/plot.js';
286
-
287
- export {
288
- hconcat,
289
- vconcat
290
- } from './layout/concat.js';
291
-
292
- export {
293
- hspace,
294
- vspace
295
- } from './layout/space.js';
296
-
297
- export {
298
- Fixed
299
- } from './symbols.js';
13
+ requestNamedPlot
14
+ } from './plot/named-plots.js';
300
15
 
301
16
  export {
302
- parseSpec,
303
- ParseContext
304
- } from './spec/parse-spec.js';
17
+ connect
18
+ } from './connect.js';
305
19
 
306
20
  export {
307
- specToModule
308
- } from './spec/to-module.js';
21
+ createAPIContext
22
+ } from './context.js';
309
23
 
310
- export {
311
- Plot
312
- } from './plot.js';
313
-
314
- export {
315
- Mark
316
- } from './marks/Mark.js';
24
+ export * as attributeDirectives from './plot/attributes.js';
25
+ export * as markDirectives from './plot/marks.js';
26
+ export * as interactorDirectives from './plot/interactors.js';
27
+ export * as legendDirectives from './plot/legends.js';
package/src/inputs.js ADDED
@@ -0,0 +1,24 @@
1
+ import { Menu, Search, Slider, Table } from '@uwdata/mosaic-inputs';
2
+ import { connect } from './connect.js';
3
+
4
+ function input(ctx, InputClass, options) {
5
+ const input = new InputClass(options);
6
+ connect(ctx, input); // ctx <- optional API context
7
+ return input.element;
8
+ }
9
+
10
+ export function menu(options) {
11
+ return input(this, Menu, options);
12
+ }
13
+
14
+ export function search(options) {
15
+ return input(this, Search, options);
16
+ }
17
+
18
+ export function slider(options) {
19
+ return input(this, Slider, options);
20
+ }
21
+
22
+ export function table(options) {
23
+ return input(this, Table, options);
24
+ }