@uwdata/vgplot 0.4.0 → 0.6.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 +6677 -6503
  3. package/dist/vgplot.min.js +12 -33
  4. package/package.json +8 -10
  5. package/src/api.js +347 -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 +32 -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 +18 -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
@@ -1,56 +0,0 @@
1
- import { scaleLinear } from 'd3';
2
- import { Fixed, Transient } from '../../symbols.js';
3
-
4
- export const xext = { x: ['min', 'max'] };
5
- export const yext = { y: ['min', 'max'] };
6
- export const xyext = { ...xext, ...yext };
7
-
8
- export function plotExtent(mark, filter, channel, domainAttr, niceAttr) {
9
- const { plot, stats } = mark;
10
- const domain = plot.getAttribute(domainAttr);
11
- const nice = plot.getAttribute(niceAttr);
12
-
13
- if (Array.isArray(domain) && !domain[Transient]) {
14
- return domain;
15
- } else {
16
- const { field } = mark.channelField(channel);
17
- const { column } = field;
18
- const { min, max } = stats[column];
19
- const dom = filteredExtent(filter, column) || (nice
20
- ? scaleLinear().domain([min, max]).nice().domain()
21
- : [min, max]);
22
- if (domain !== Fixed) dom[Transient] = true;
23
- plot.setAttribute(domainAttr, dom, { silent: true });
24
- return dom;
25
- }
26
- }
27
-
28
- export function extentX(mark, filter) {
29
- return plotExtent(mark, filter, 'x', 'xDomain', 'xNice');
30
- }
31
-
32
- export function extentY(mark, filter) {
33
- return plotExtent(mark, filter, 'y', 'yDomain', 'yNice');
34
- }
35
-
36
- export function filteredExtent(filter, column) {
37
- if (!filter) return;
38
-
39
- let lo;
40
- let hi;
41
- const visitor = (type, clause) => {
42
- if (type === 'BETWEEN' && clause.field.column === column) {
43
- const { range } = clause;
44
- if (range && (lo == null || range[0] < lo)) lo = range[0];
45
- if (range && (hi == null || range[1] > hi)) hi = range[1];
46
- }
47
- };
48
-
49
- if (Array.isArray(filter)) {
50
- filter.forEach(p => p.visit?.(visitor));
51
- } else if (filter.visit) {
52
- filter.visit(visitor);
53
- }
54
-
55
- return lo != null && hi != null && lo !== hi ? [lo, hi] : undefined;
56
- }
@@ -1,57 +0,0 @@
1
- import { isArrowTable } from './is-arrow-table.js';
2
-
3
- export function grid1d(n, values) {
4
- return valuesToGrid(new Float64Array(n), values);
5
- }
6
-
7
- export function grid2d(m, n, values, groupby = []) {
8
- return groupby.length
9
- ? Object.values(groupedValuesToGrids(m * n, values, groupby))
10
- : [{ grid: valuesToGrid(new Float64Array(m * n), values) }];
11
- }
12
-
13
- function valuesToGrid(grid, values) {
14
- if (isArrowTable(values)) {
15
- // optimize access for Arrow tables
16
- const numRows = values.numRows;
17
- if (numRows === 0) return grid;
18
- const index = values.getChild('index').toArray();
19
- const value = values.getChild('value').toArray();
20
- for (let row = 0; row < numRows; ++row) {
21
- grid[index[row]] = value[row];
22
- }
23
- } else {
24
- // fallback to iterable data
25
- for (const row of values) {
26
- grid[row.index] = row.value;
27
- }
28
- }
29
- return grid;
30
- }
31
-
32
- function groupedValuesToGrids(size, values, groupby) {
33
- const grids = {};
34
- const getGrid = key => {
35
- const cell = grids[key] || (grids[key] = { key, grid: new Float64Array(size) });
36
- return cell.grid;
37
- };
38
- if (isArrowTable(values)) {
39
- // optimize access for Arrow tables
40
- const numRows = values.numRows;
41
- if (numRows === 0) return grids;
42
- const index = values.getChild('index').toArray();
43
- const value = values.getChild('value').toArray();
44
- const groups = groupby.map(name => values.getChild(name));
45
- for (let row = 0; row < numRows; ++row) {
46
- const key = groups.map(vec => vec.get(row));
47
- getGrid(key)[index[row]] = value[row];
48
- }
49
- } else {
50
- // fallback to iterable data
51
- for (const row of values) {
52
- const key = groupby.map(col => row[col]);
53
- getGrid(key)[row.index] = row.value;
54
- }
55
- }
56
- return grids;
57
- }
@@ -1,14 +0,0 @@
1
- import { isParam } from '@uwdata/mosaic-core';
2
-
3
- export function handleParam(client, key, param, update) {
4
- if (isParam(param)) {
5
- update = update || (() => client.requestUpdate());
6
- param.addEventListener('value', value => {
7
- client[key] = value;
8
- return update();
9
- });
10
- client[key] = param.value;
11
- } else {
12
- client[key] = param;
13
- }
14
- }
@@ -1,3 +0,0 @@
1
- export function isArrowTable(values) {
2
- return typeof values?.getChild === 'function';
3
- }
@@ -1,18 +0,0 @@
1
- import { color } from 'd3';
2
-
3
- // Mostly relies on d3-color, with a few extra color keywords. Currently this
4
- // strictly requires that the value be a string; we might want to apply string
5
- // coercion here, though note that d3-color instances would need to support
6
- // valueOf to work correctly with InternMap.
7
- // https://www.w3.org/TR/SVG11/painting.html#SpecifyingPaint
8
- export function isColor(value) {
9
- if (typeof value !== "string") return false;
10
- value = value.toLowerCase().trim();
11
- return (
12
- value === "none" ||
13
- value === "currentcolor" ||
14
- (value.startsWith("url(") && value.endsWith(")")) || // <funciri>, e.g. pattern or gradient
15
- (value.startsWith("var(") && value.endsWith(")")) || // CSS variable
16
- color(value) !== null
17
- );
18
- }
@@ -1,40 +0,0 @@
1
- const constantOptions = new Set([
2
- 'order',
3
- 'sort',
4
- 'label',
5
- 'anchor',
6
- 'curve',
7
- 'tension',
8
- 'marker',
9
- 'markerStart',
10
- 'markerMid',
11
- 'markerEnd',
12
- 'textAnchor',
13
- 'lineAnchor',
14
- 'lineHeight',
15
- 'textOverflow',
16
- 'monospace',
17
- 'fontFamily',
18
- 'fontSize',
19
- 'fontStyle',
20
- 'fontVariant',
21
- 'fontWeight',
22
- 'frameAnchor',
23
- 'strokeLinejoin',
24
- 'strokeLinecap',
25
- 'strokeMiterlimit',
26
- 'strokeDasharray',
27
- 'strokeDashoffset',
28
- 'mixBlendMode',
29
- 'shapeRendering',
30
- 'imageRendering',
31
- 'preserveAspectRatio',
32
- 'interpolate',
33
- 'crossOrigin',
34
- 'paintOrder',
35
- 'pointerEvents'
36
- ]);
37
-
38
- export function isConstantOption(value) {
39
- return constantOptions.has(value);
40
- }
@@ -1,20 +0,0 @@
1
- const symbols = new Set([
2
- 'asterisk',
3
- 'circle',
4
- 'cross',
5
- 'diamond',
6
- 'diamond2',
7
- 'hexagon',
8
- 'plus',
9
- 'square',
10
- 'square2',
11
- 'star',
12
- 'times',
13
- 'triangle',
14
- 'triangle2',
15
- 'wye'
16
- ]);
17
-
18
- export function isSymbol(value) {
19
- return symbols.has(`${value}`.toLowerCase());
20
- }
@@ -1,44 +0,0 @@
1
- import { rgb } from 'd3';
2
-
3
- export function raster(grid, data, w, h, scale, scheme) {
4
- const n = (scheme.length >> 2) - 1;
5
- for (let j = 0, k = 0; j < h; ++j) {
6
- for (let i = 0, row = (h - j - 1) * w; i < w; ++i, k += 4) {
7
- const c = (n * scale(grid[i + row])) << 2;
8
- data[k + 0] = scheme[c + 0];
9
- data[k + 1] = scheme[c + 1];
10
- data[k + 2] = scheme[c + 2];
11
- data[k + 3] = scheme[c + 3];
12
- }
13
- }
14
- }
15
-
16
- export function palette(size, interp) {
17
- const p = new Uint8ClampedArray(4 * size);
18
- const n = size - 1;
19
- for (let i = 0; i <= n; ++i) {
20
- const v = interp(i / n);
21
- const { r, g, b, opacity = 1 } = typeof v === 'string' ? rgb(v) : v;
22
- const k = i << 2;
23
- p[k + 0] = r;
24
- p[k + 1] = g;
25
- p[k + 2] = b;
26
- p[k + 3] = (255 * opacity) | 0;
27
- }
28
- return p;
29
- }
30
-
31
- export function createCanvas(w, h) {
32
- if (typeof document !== 'undefined') {
33
- const c = document.createElement('canvas');
34
- c.setAttribute('width', w);
35
- c.setAttribute('height', h);
36
- return c;
37
- }
38
- throw new Error('Can not create a canvas instance.');
39
- }
40
-
41
- export function opacityMap(color = 'black') {
42
- const { r, g, b } = rgb(color);
43
- return opacity => ({ r, g, b, opacity });
44
- }
@@ -1,133 +0,0 @@
1
- // https://github.com/jstat/jstat
2
- //
3
- // Copyright (c) 2013 jStat
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // of this software and associated documentation files (the "Software"), to deal
7
- // in the Software without restriction, including without limitation the rights
8
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // copies of the Software, and to permit persons to whom the Software is
10
- // furnished to do so, subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in
13
- // all copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- // SOFTWARE.
22
-
23
- export function ibetainv(p, a, b) {
24
- var EPS = 1e-8;
25
- var a1 = a - 1;
26
- var b1 = b - 1;
27
- var j = 0;
28
- var lna, lnb, pp, t, u, err, x, al, h, w, afac;
29
- if (p <= 0) return 0;
30
- if (p >= 1) return 1;
31
- if (a >= 1 && b >= 1) {
32
- pp = p < 0.5 ? p : 1 - p;
33
- t = Math.sqrt(-2 * Math.log(pp));
34
- x = (2.30753 + t * 0.27061) / (1 + t * (0.99229 + t * 0.04481)) - t;
35
- if (p < 0.5) x = -x;
36
- al = (x * x - 3) / 6;
37
- h = 2 / (1 / (2 * a - 1) + 1 / (2 * b - 1));
38
- w = (x * Math.sqrt(al + h)) / h - (1 / (2 * b - 1) - 1 / (2 * a - 1)) * (al + 5 / 6 - 2 / (3 * h));
39
- x = a / (a + b * Math.exp(2 * w));
40
- } else {
41
- lna = Math.log(a / (a + b));
42
- lnb = Math.log(b / (a + b));
43
- t = Math.exp(a * lna) / a;
44
- u = Math.exp(b * lnb) / b;
45
- w = t + u;
46
- if (p < t / w) x = Math.pow(a * w * p, 1 / a);
47
- else x = 1 - Math.pow(b * w * (1 - p), 1 / b);
48
- }
49
- afac = -gammaln(a) - gammaln(b) + gammaln(a + b);
50
- for (; j < 10; j++) {
51
- if (x === 0 || x === 1) return x;
52
- err = ibeta(x, a, b) - p;
53
- t = Math.exp(a1 * Math.log(x) + b1 * Math.log(1 - x) + afac);
54
- u = err / t;
55
- x -= t = u / (1 - 0.5 * Math.min(1, u * (a1 / x - b1 / (1 - x))));
56
- if (x <= 0) x = 0.5 * (x + t);
57
- if (x >= 1) x = 0.5 * (x + t + 1);
58
- if (Math.abs(t) < EPS * x && j > 0) break;
59
- }
60
- return x;
61
- }
62
-
63
- export function ibeta(x, a, b) {
64
- // Factors in front of the continued fraction.
65
- var bt =
66
- x === 0 || x === 1 ? 0 : Math.exp(gammaln(a + b) - gammaln(a) - gammaln(b) + a * Math.log(x) + b * Math.log(1 - x));
67
- if (x < 0 || x > 1) return false;
68
- if (x < (a + 1) / (a + b + 2))
69
- // Use continued fraction directly.
70
- return (bt * betacf(x, a, b)) / a;
71
- // else use continued fraction after making the symmetry transformation.
72
- return 1 - (bt * betacf(1 - x, b, a)) / b;
73
- }
74
-
75
- export function betacf(x, a, b) {
76
- var fpmin = 1e-30;
77
- var m = 1;
78
- var qab = a + b;
79
- var qap = a + 1;
80
- var qam = a - 1;
81
- var c = 1;
82
- var d = 1 - (qab * x) / qap;
83
- var m2, aa, del, h;
84
-
85
- // These q's will be used in factors that occur in the coefficients
86
- if (Math.abs(d) < fpmin) d = fpmin;
87
- d = 1 / d;
88
- h = d;
89
-
90
- for (; m <= 100; m++) {
91
- m2 = 2 * m;
92
- aa = (m * (b - m) * x) / ((qam + m2) * (a + m2));
93
- // One step (the even one) of the recurrence
94
- d = 1 + aa * d;
95
- if (Math.abs(d) < fpmin) d = fpmin;
96
- c = 1 + aa / c;
97
- if (Math.abs(c) < fpmin) c = fpmin;
98
- d = 1 / d;
99
- h *= d * c;
100
- aa = (-(a + m) * (qab + m) * x) / ((a + m2) * (qap + m2));
101
- // Next step of the recurrence (the odd one)
102
- d = 1 + aa * d;
103
- if (Math.abs(d) < fpmin) d = fpmin;
104
- c = 1 + aa / c;
105
- if (Math.abs(c) < fpmin) c = fpmin;
106
- d = 1 / d;
107
- del = d * c;
108
- h *= del;
109
- if (Math.abs(del - 1.0) < 3e-7) break;
110
- }
111
-
112
- return h;
113
- }
114
-
115
- export function gammaln(x) {
116
- var j = 0;
117
- var cof = [
118
- 76.18009172947146, -86.5053203294167, 24.01409824083091, -1.231739572450155, 0.1208650973866179e-2,
119
- -0.5395239384953e-5
120
- ];
121
- var ser = 1.000000000190015;
122
- var xx, y, tmp;
123
- tmp = (y = xx = x) + 5.5;
124
- tmp -= (xx + 0.5) * Math.log(tmp);
125
- for (; j < 6; j++) ser += cof[j] / ++y;
126
- return Math.log((2.506628274631 * ser) / xx) - tmp;
127
- }
128
-
129
- export function qt(p, dof) {
130
- var x = ibetainv(2 * Math.min(p, 1 - p), 0.5 * dof, 0.5);
131
- x = Math.sqrt((dof * (1 - x)) / x);
132
- return p > 0.5 ? x : -x;
133
- }
@@ -1,58 +0,0 @@
1
- import { isArrowTable } from './is-arrow-table.js';
2
-
3
- const INTEGER = 2;
4
- const TIMESTAMP = 10;
5
-
6
- export function toDataArray(data) {
7
- return isArrowTable(data) ? arrowToObjects(data) : data;
8
- }
9
-
10
- export function arrowToObjects(data) {
11
- const { batches, numRows: length } = data;
12
-
13
- // return an empty array for empty tables
14
- if (!length) return [];
15
-
16
- // pre-allocate output objects
17
- const objects = Array.from({ length }, () => ({}));
18
-
19
- // for each row batch...
20
- for (let k = 0, b = 0; b < batches.length; ++b) {
21
- const batch = batches[b];
22
- const { schema, numRows, numCols } = batch;
23
-
24
- // for each column...
25
- for (let j = 0; j < numCols; ++j) {
26
- const child = batch.getChildAt(j);
27
- const { name, type } = schema.fields[j];
28
- const valueOf = convert(type);
29
-
30
- // for each row in the current batch...
31
- for (let o = k, i = 0; i < numRows; ++i, ++o) {
32
- // extract/convert value from arrow, copy to output object
33
- objects[o][name] = valueOf(child.get(i));
34
- }
35
- }
36
-
37
- k += numRows;
38
- }
39
-
40
- return objects;
41
- }
42
-
43
- function convert(type) {
44
- const { typeId } = type;
45
-
46
- // map timestamp numbers to date objects
47
- if (typeId === TIMESTAMP) {
48
- return v => v == null ? v : new Date(v);
49
- }
50
-
51
- // map bignum to number
52
- if (typeId === INTEGER && type.bitWidth >= 64) {
53
- return v => v == null ? v : Number(v);
54
- }
55
-
56
- // otherwise use Arrow JS defaults
57
- return v => v;
58
- }
@@ -1,211 +0,0 @@
1
- export const attributeMap = new Map([
2
- ['style', 'style'],
3
- ['width', 'width'],
4
- ['height', 'height'],
5
- ['margin', 'margin'],
6
- ['marginLeft', 'marginLeft'],
7
- ['marginRight', 'marginRight'],
8
- ['marginTop', 'marginTop'],
9
- ['marginBottom', 'marginBottom'],
10
- ['align', 'align'],
11
- ['aspectRatio', 'aspectRatio'],
12
- ['axis', 'axis'],
13
- ['inset', 'inset'],
14
- ['grid', 'grid'],
15
- ['label', 'label'],
16
- ['padding', 'padding'],
17
- ['round', 'round'],
18
- ['xScale', 'x.type'],
19
- ['xDomain', 'x.domain'],
20
- ['xRange', 'x.range'],
21
- ['xNice', 'x.nice'],
22
- ['xInset', 'x.inset'],
23
- ['xInsetLeft', 'x.insetLeft'],
24
- ['xInsetRight', 'x.insetRight'],
25
- ['xClamp', 'x.clamp'],
26
- ['xRound', 'x.round'],
27
- ['xAlign', 'x.align'],
28
- ['xPadding', 'x.padding'],
29
- ['xPaddingInner', 'x.paddingInner'],
30
- ['xPaddingOuter', 'x.paddingOuter'],
31
- ['xAxis', 'x.axis'],
32
- ['xTicks', 'x.ticks'],
33
- ['xTickSize', 'x.tickSize'],
34
- ['xTickSpacing', 'x.tickSpacing'],
35
- ['xTickPadding', 'x.tickPadding'],
36
- ['xTickFormat', 'x.tickFormat'],
37
- ['xTickRotate', 'x.tickRotate'],
38
- ['xGrid', 'x.grid'],
39
- ['xLine', 'x.line'],
40
- ['xLabel', 'x.label'],
41
- ['xLabelAnchor', 'x.labelAnchor'],
42
- ['xLabelOffset', 'x.labelOffset'],
43
- ['xFontVariant', 'x.fontVariant'],
44
- ['xAriaLabel', 'x.ariaLabel'],
45
- ['xAriaDescription', 'x.ariaDescription'],
46
- ['xReverse', 'x.reverse'],
47
- ['xZero', 'x.zero'],
48
- ['yScale', 'y.type'],
49
- ['yDomain', 'y.domain'],
50
- ['yRange', 'y.range'],
51
- ['yNice', 'y.nice'],
52
- ['yInset', 'y.inset'],
53
- ['yInsetTop', 'y.insetTop'],
54
- ['yInsetBottom', 'y.insetBottom'],
55
- ['yClamp', 'y.clamp'],
56
- ['yRound', 'y.round'],
57
- ['yAlign', 'y.align'],
58
- ['yPadding', 'y.padding'],
59
- ['yPaddingInner', 'y.paddingInner'],
60
- ['yPaddingOuter', 'y.paddingOuter'],
61
- ['yAxis', 'y.axis'],
62
- ['yTicks', 'y.ticks'],
63
- ['yTickSize', 'y.tickSize'],
64
- ['yTickSpacing', 'y.tickSpacing'],
65
- ['yTickPadding', 'y.tickPadding'],
66
- ['yTickFormat', 'y.tickFormat'],
67
- ['yTickRotate', 'y.tickRotate'],
68
- ['yGrid', 'y.grid'],
69
- ['yLine', 'y.line'],
70
- ['yLabel', 'y.label'],
71
- ['yLabelAnchor', 'y.labelAnchor'],
72
- ['yLabelOffset', 'y.labelOffset'],
73
- ['yFontVariant', 'y.fontVariant'],
74
- ['yAriaLabel', 'y.ariaLabel'],
75
- ['yAriaDescription', 'y.ariaDescription'],
76
- ['yReverse', 'y.reverse'],
77
- ['yZero', 'y.zero'],
78
- ['facetMargin', 'facet.margin'],
79
- ['facetMarginTop', 'facet.marginTop'],
80
- ['facetMarginBottom', 'facet.marginBottom'],
81
- ['facetMarginLeft', 'facet.marginLeft'],
82
- ['facetMarginRight', 'facet.marginRight'],
83
- ['facetGrid', 'facet.grid'],
84
- ['facetLabel', 'facet.label'],
85
- ['fxDomain', 'fx.domain'],
86
- ['fxRange', 'fx.range'],
87
- ['fxNice', 'fx.nice'],
88
- ['fxInset', 'fx.inset'],
89
- ['fxInsetLeft', 'fx.insetLeft'],
90
- ['fxInsetRight', 'fx.insetRight'],
91
- ['fxRound', 'fx.round'],
92
- ['fxAlign', 'fx.align'],
93
- ['fxPadding', 'fx.padding'],
94
- ['fxPaddingInner', 'fx.paddingInner'],
95
- ['fxPaddingOuter', 'fx.paddingOuter'],
96
- ['fxAxis', 'fx.axis'],
97
- ['fxTicks', 'fx.ticks'],
98
- ['fxTickSize', 'fx.tickSize'],
99
- ['fxTickSpacing', 'fx.tickSpacing'],
100
- ['fxTickPadding', 'fx.tickPadding'],
101
- ['fxTickFormat', 'fx.tickFormat'],
102
- ['fxTickRotate', 'fx.tickRotate'],
103
- ['fxGrid', 'fx.grid'],
104
- ['fxLine', 'fx.line'],
105
- ['fxLabel', 'fx.label'],
106
- ['fxLabelAnchor', 'fx.labelAnchor'],
107
- ['fxLabelOffset', 'fx.labelOffset'],
108
- ['fxFontVariant', 'fx.fontVariant'],
109
- ['fxAriaLabel', 'fx.ariaLabel'],
110
- ['fxAriaDescription', 'fx.ariaDescription'],
111
- ['fxReverse', 'fx.reverse'],
112
- ['fyDomain', 'fy.domain'],
113
- ['fyRange', 'fy.range'],
114
- ['fyNice', 'fy.mice'],
115
- ['fyInset', 'fy,inset'],
116
- ['fyInsetTop', 'fy.insetTop'],
117
- ['fyInsetBottom', 'fy.insetBottom'],
118
- ['fyRound', 'fy.round'],
119
- ['fyAlign', 'fy.align'],
120
- ['fyPadding', 'fy.padding'],
121
- ['fyPaddingInner', 'fy.paddingInner'],
122
- ['fyPaddingOuter', 'fy.paddingOuter'],
123
- ['fyAxis', 'fy.axis'],
124
- ['fyTicks', 'fy.ticks'],
125
- ['fyTickSize', 'fy.tickSize'],
126
- ['fyTickSpacing', 'fy.tickSpacing'],
127
- ['fyTickPadding', 'fy.tickPadding'],
128
- ['fyTickFormat', 'fy.tickFormat'],
129
- ['fyTickRotate', 'fy.tickRotate'],
130
- ['fyGrid', 'fy.grid'],
131
- ['fyLine', 'fy.line'],
132
- ['fyLabel', 'fy.label'],
133
- ['fyLabelAnchor', 'fy.labelAnchor'],
134
- ['fyLabelOffset', 'fy.labelOffset'],
135
- ['fyFontVariant', 'fy.fontVariant'],
136
- ['fyAriaLabel', 'fy.ariaLabel'],
137
- ['fyAriaDescription', 'fy.ariaDescription'],
138
- ['fyReverse', 'fy.reverse'],
139
- ['colorScale', 'color.type'],
140
- ['colorDomain', 'color.domain'],
141
- ['colorRange', 'color.range'],
142
- ['colorClamp', 'color.clamp'],
143
- ['colorNice', 'color.nice'],
144
- ['colorScheme', 'color.scheme'],
145
- ['colorInterpolate', 'color.interpolate'],
146
- ['colorPivot', 'color.pivot'],
147
- ['colorSymmetric', 'color.symmetric'],
148
- ['colorLabel', 'color.label'],
149
- ['colorReverse', 'color.reverse'],
150
- ['colorZero', 'color.zero'],
151
- ['colorTickFormat', 'color.tickFormat'],
152
- ['opacityScale', 'opacity.type'],
153
- ['opacityDomain', 'opacity.domain'],
154
- ['opacityRange', 'opacity.range'],
155
- ['opacityClamp', 'opacity.clamp'],
156
- ['opacityNice', 'opacity.nice'],
157
- ['opacityLabel', 'opacity.label'],
158
- ['opacityReverse', 'opacity.reverse'],
159
- ['opacityZero', 'opacity.zero'],
160
- ['opacityTickFormat', 'opacity.tickFormat'],
161
- ['rScale', 'r.type'],
162
- ['rDomain', 'r.domain'],
163
- ['rRange', 'r.range'],
164
- ['rClamp', 'r.clamp'],
165
- ['rNice', 'r.nice'],
166
- ['rZero', 'r.zero'],
167
- ['lengthScale', 'length.type'],
168
- ['lengthDomain', 'length.domain'],
169
- ['lengthRange', 'length.range'],
170
- ['lengthClamp', 'length.clamp'],
171
- ['lengthNice', 'length.nice'],
172
- ['lengthZero', 'length.zero'],
173
- ['projectionType', 'projection.type'],
174
- ['projectionParallels', 'projection.parallels'],
175
- ['projectionPrecision', 'projection.precision'],
176
- ['projectionRotate', 'projection.rotate'],
177
- ['projectionDomain', 'projection.domain'],
178
- ['projectionInset', 'projection.inset'],
179
- ['projectionInsetLeft', 'projection.insetLeft'],
180
- ['projectionInsetRight', 'projection.insetRight'],
181
- ['projectionInsetTop', 'projection.insetTop'],
182
- ['projectionInsetBottom', 'projection.insetBottom'],
183
- ['projectionClip', 'projection.clip']
184
- ]);
185
-
186
- function setProperty(object, path, value) {
187
- for (let i = 0; i < path.length; ++i) {
188
- const key = path[i];
189
- if (i === path.length - 1) {
190
- object[key] = value;
191
- } else {
192
- object = (object[key] || (object[key] = {}));
193
- }
194
- }
195
- }
196
-
197
- export function setAttributes(attributes, spec, symbols) {
198
- // populate top-level and scale properties
199
- for (const key in attributes) {
200
- const specKey = attributeMap.get(key);
201
- if (specKey == null) {
202
- throw new Error(`Unrecognized plot attribute: ${key}`);
203
- }
204
- const value = attributes[key];
205
- if (typeof value === 'symbol') {
206
- symbols.push(key);
207
- } else if (value !== undefined) {
208
- setProperty(spec, specKey.split('.'), value);
209
- }
210
- }
211
- }