@uwdata/mosaic-spec 0.8.0 → 0.10.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 (39) hide show
  1. package/dist/mosaic-schema.json +12651 -6061
  2. package/dist/mosaic-spec.js +2409 -1495
  3. package/dist/mosaic-spec.min.js +20 -20
  4. package/dist/types/ast/ASTNode.d.ts +2 -2
  5. package/dist/types/ast/DataNode.d.ts +3 -3
  6. package/dist/types/ast/SelectionNode.d.ts +3 -1
  7. package/dist/types/ast/TransformNode.d.ts +9 -1
  8. package/dist/types/index.d.ts +1 -1
  9. package/dist/types/parse-spec.d.ts +1 -1
  10. package/dist/types/spec/Input.d.ts +33 -3
  11. package/dist/types/spec/Param.d.ts +6 -0
  12. package/dist/types/spec/PlotAttribute.d.ts +6 -0
  13. package/dist/types/spec/PlotMark.d.ts +2 -1
  14. package/dist/types/spec/Spec.d.ts +7 -0
  15. package/dist/types/spec/Transform.d.ts +70 -14
  16. package/dist/types/spec/interactors/Nearest.d.ts +25 -6
  17. package/dist/types/spec/interactors/Toggle.d.ts +8 -0
  18. package/dist/types/spec/marks/Dot.d.ts +4 -0
  19. package/dist/types/spec/marks/ErrorBar.d.ts +82 -0
  20. package/dist/types/spec/marks/Marks.d.ts +16 -1
  21. package/dist/types/spec/marks/Text.d.ts +4 -0
  22. package/dist/types/util.d.ts +3 -3
  23. package/package.json +8 -10
  24. package/src/ast/ParamNode.js +2 -2
  25. package/src/ast/SelectionNode.js +11 -7
  26. package/src/ast/TransformNode.js +44 -10
  27. package/src/config/transforms.js +6 -0
  28. package/src/spec/Input.ts +30 -3
  29. package/src/spec/Param.ts +7 -0
  30. package/src/spec/PlotAttribute.ts +7 -0
  31. package/src/spec/PlotMark.ts +2 -0
  32. package/src/spec/Spec.ts +7 -0
  33. package/src/spec/Transform.ts +97 -16
  34. package/src/spec/interactors/Nearest.ts +26 -6
  35. package/src/spec/interactors/Toggle.ts +9 -0
  36. package/src/spec/marks/Dot.ts +5 -0
  37. package/src/spec/marks/ErrorBar.ts +91 -0
  38. package/src/spec/marks/Marks.ts +27 -1
  39. package/src/spec/marks/Text.ts +5 -0
@@ -2,25 +2,29 @@ import { ASTNode } from './ASTNode.js';
2
2
  import { INTERSECT, SELECTION } from '../constants.js';
3
3
 
4
4
  export class SelectionNode extends ASTNode {
5
- constructor(select = INTERSECT, cross) {
5
+ constructor(select = INTERSECT, cross, empty) {
6
6
  super(SELECTION);
7
7
  this.select = select;
8
8
  this.cross = cross;
9
+ this.empty = empty;
9
10
  }
10
11
 
11
12
  instantiate(ctx) {
12
- const { select, cross } = this;
13
- return ctx.api.Selection[select]({ cross });
13
+ const { select, cross, empty } = this;
14
+ return ctx.api.Selection[select]({ cross, empty });
14
15
  }
15
16
 
16
17
  codegen(ctx) {
17
- const { select, cross } = this;
18
- const arg = cross != null ? `{ cross: ${cross} }` : '';
18
+ const { select, cross, empty } = this;
19
+ const args = [['cross', cross], ['empty', empty]]
20
+ .filter(a => a[1] != null)
21
+ .map(a => `${a[0]}: ${a[1]}`);
22
+ const arg = args.length ? `{ ${args.join(', ')} }` : '';
19
23
  return `${ctx.ns()}Selection.${select}(${arg})`;
20
24
  }
21
25
 
22
26
  toJSON() {
23
- const { select, cross } = this;
24
- return { select, cross };
27
+ const { select, cross, empty } = this;
28
+ return { select, cross, empty };
25
29
  }
26
30
  }
@@ -1,5 +1,6 @@
1
1
  import { ASTNode } from './ASTNode.js';
2
2
  import { TRANSFORM } from '../constants.js';
3
+ import { parseOptions } from './OptionsNode.js';
3
4
 
4
5
  function toArray(value) {
5
6
  return value == null ? [] : [value].flat();
@@ -17,16 +18,21 @@ export function parseTransform(spec, ctx) {
17
18
  return; // return undefined to signal no transform!
18
19
  }
19
20
 
20
- const args = name === 'count' || name == null ? [] : toArray(spec[name]);
21
- const options = {
22
- distinct: spec.distinct,
23
- orderby: toArray(spec.orderby).map(v => ctx.maybeParam(v)),
24
- partitionby: toArray(spec.partitionby).map(v => ctx.maybeParam(v)),
25
- rows: spec.rows ? ctx.maybeParam(spec.rows) : null,
26
- range: spec.range ? ctx.maybeParam(spec.range) : null
27
- };
28
-
29
- return new TransformNode(name, args, options);
21
+ if (name === 'bin') {
22
+ const { bin, ...options } = spec;
23
+ const [arg] = toArray(bin);
24
+ return new BinTransformNode(name, arg, parseOptions(options, ctx));
25
+ } else {
26
+ const args = name === 'count' && !spec[name] ? [] : toArray(spec[name]);
27
+ const options = {
28
+ distinct: spec.distinct,
29
+ orderby: toArray(spec.orderby).map(v => ctx.maybeParam(v)),
30
+ partitionby: toArray(spec.partitionby).map(v => ctx.maybeParam(v)),
31
+ rows: spec.rows ? ctx.maybeParam(spec.rows) : null,
32
+ range: spec.range ? ctx.maybeParam(spec.range) : null
33
+ };
34
+ return new TransformNode(name, args, options);
35
+ }
30
36
  }
31
37
 
32
38
  export class TransformNode extends ASTNode {
@@ -112,6 +118,34 @@ export class TransformNode extends ASTNode {
112
118
  }
113
119
  }
114
120
 
121
+ export class BinTransformNode extends ASTNode {
122
+ constructor(name, arg, options) {
123
+ super(TRANSFORM);
124
+ this.name = name;
125
+ this.arg = arg;
126
+ this.options = options;
127
+ }
128
+
129
+ instantiate(ctx) {
130
+ const { name, arg, options } = this;
131
+ return ctx.api[name](arg, options.instantiate(ctx));
132
+ }
133
+
134
+ codegen(ctx) {
135
+ const { name, arg, options } = this;
136
+ const opt = options.codegen(ctx);
137
+ return `${ctx.ns()}${name}(`
138
+ + JSON.stringify(arg)
139
+ + (opt ? `, ${opt}` : '')
140
+ + ')';
141
+ }
142
+
143
+ toJSON() {
144
+ const { name, arg, options } = this;
145
+ return { [name]: arg, ...options.toJSON() };
146
+ }
147
+ }
148
+
115
149
  function simplify(array) {
116
150
  return array.length === 0 ? '' : array.length === 1 ? array[0] : array;
117
151
  }
@@ -11,6 +11,8 @@ export function transformNames(overrides = []) {
11
11
  'centroidX',
12
12
  'centroidY',
13
13
  'count',
14
+ 'covariance',
15
+ 'covarPop',
14
16
  'dateMonth',
15
17
  'dateMonthDay',
16
18
  'dateDay',
@@ -23,7 +25,11 @@ export function transformNames(overrides = []) {
23
25
  'mode',
24
26
  'product',
25
27
  'quantile',
28
+ 'stddev',
29
+ 'stddevPop',
26
30
  'sum',
31
+ 'variance',
32
+ 'varPop',
27
33
  'row_number',
28
34
  'rank',
29
35
  'dense_rank',
package/src/spec/Input.ts CHANGED
@@ -11,6 +11,11 @@ export interface Menu {
11
11
  * currently selected menu option.
12
12
  */
13
13
  as?: ParamRef;
14
+ /**
15
+ * The database column name to use within generated selection clause
16
+ * predicates. Defaults to the `column` property.
17
+ */
18
+ field?: string;
14
19
  /**
15
20
  * The name of a database table to use as a data source for this widget.
16
21
  * Used in conjunction with the `column` property.
@@ -33,11 +38,11 @@ export interface Menu {
33
38
  /**
34
39
  * An array of menu options, as literal values or option objects.
35
40
  * Option objects have a `value` property and an optional `label` property.
36
- * If no label is provided, the (string-coerced) value is used.
41
+ * If no label is provided, the string-coerced value is used.
37
42
  */
38
- options?: Array<any>;
43
+ options?: Array<any | { value: any, label?: string }>;
39
44
  /**
40
- * The initial selected menu option.
45
+ * The initial selected menu value.
41
46
  */
42
47
  value?: any;
43
48
  }
@@ -53,6 +58,11 @@ export interface Search {
53
58
  * current text search query.
54
59
  */
55
60
  as?: ParamRef;
61
+ /**
62
+ * The database column name to use within generated selection clause
63
+ * predicates. Defaults to the `column` property.
64
+ */
65
+ field?: string;
56
66
  /**
57
67
  * The type of text search query to perform. One of:
58
68
  * - `"contains"` (default): the query string may appear anywhere in the text
@@ -93,6 +103,18 @@ export interface Slider {
93
103
  * currently selected slider option.
94
104
  */
95
105
  as?: ParamRef;
106
+ /**
107
+ * The database column name to use within generated selection clause
108
+ * predicates. Defaults to the `column` property.
109
+ */
110
+ field?: string;
111
+ /**
112
+ * The type of selection clause predicate to generate if the **as** option
113
+ * is a Selection. If `'point'` (the default), the selection predicate is an
114
+ * equality check for the slider value. If `'interval'`, the predicate checks
115
+ * an interval from the minimum to the current slider value.
116
+ */
117
+ select?: 'point' | 'interval';
96
118
  /**
97
119
  * The name of a database table to use as a data source for this widget.
98
120
  * Used in conjunction with the `column` property.
@@ -141,6 +163,11 @@ export interface Table {
141
163
  * A table grid widget.
142
164
  */
143
165
  input: 'table';
166
+ /**
167
+ * The output selection. A selection clause is added for each
168
+ * currently selected table row.
169
+ */
170
+ as?: ParamRef;
144
171
  /**
145
172
  * The name of a database table to use as a data source for this widget.
146
173
  */
package/src/spec/Param.ts CHANGED
@@ -58,6 +58,13 @@ export interface Selection {
58
58
  * but not oneself (default `false`, except for `crossfilter` selections).
59
59
  */
60
60
  cross?: boolean;
61
+
62
+ /**
63
+ * A flag for setting an initial empty selection state. If true, a selection
64
+ * with no clauses corresponds to an empty selection with no records. If
65
+ * false, a selection with no clauses selects all values.
66
+ */
67
+ empty?: boolean;
61
68
  }
62
69
 
63
70
  /** A Param or Selection definition. */
@@ -1556,6 +1556,13 @@ export interface PlotAttributes {
1556
1556
  */
1557
1557
  rNice?: boolean | number| Interval | ParamRef;
1558
1558
 
1559
+ /**
1560
+ * A textual label to show on the axis or legend; if null, show no label. By
1561
+ * default the scale label is inferred from channel definitions, possibly with
1562
+ * an arrow (↑, →, ↓, or ←) to indicate the direction of increasing value.
1563
+ */
1564
+ rLabel?: string | null | ParamRef;
1565
+
1559
1566
  /**
1560
1567
  * If true, shorthand for a transform suitable for percentages, mapping
1561
1568
  * proportions in [0, 1] to [0, 100].
@@ -8,6 +8,7 @@ import { DelaunayLink, DelaunayMesh, Hull, Voronoi, VoronoiMesh } from './marks/
8
8
  import { DenseLine } from './marks/DenseLine.js';
9
9
  import { Density, DensityX, DensityY } from './marks/Density.js';
10
10
  import { Circle, Dot, DotX, DotY, Hexagon } from './marks/Dot.js';
11
+ import { ErrorBarX, ErrorBarY } from './marks/ErrorBar.js';
11
12
  import { Frame } from './marks/Frame.js';
12
13
  import { Geo, Graticule, Sphere } from './marks/Geo.js';
13
14
  import { Hexbin } from './marks/Hexbin.js';
@@ -35,6 +36,7 @@ export type PlotMark =
35
36
  | DenseLine
36
37
  | Density | DensityX | DensityY
37
38
  | Dot | DotX | DotY | Circle | Hexagon
39
+ | ErrorBarX | ErrorBarY
38
40
  | Frame
39
41
  | Geo | Graticule | Sphere
40
42
  | Hexbin
package/src/spec/Spec.ts CHANGED
@@ -33,6 +33,13 @@ export type Params = Record<string, ParamDefinition>;
33
33
 
34
34
  /** Top-level specification properties. */
35
35
  export interface SpecHead {
36
+ /**
37
+ * A [JSON schema](http://json-schema.org/) URL for this specification,
38
+ * such as https://uwdata.github.io/mosaic/schema/latest.json. This property
39
+ * enables validation and autocomplete in editors with JSON schema support.
40
+ * @format uri
41
+ */
42
+ $schema?: string;
36
43
  /** Specification metadata. */
37
44
  meta?: Meta;
38
45
  /** Configuration options. */
@@ -41,20 +41,58 @@ type Arg2Opt = Arg | [Arg, Arg?];
41
41
  */
42
42
  type Arg3Opt = Arg | [Arg, Arg?, Arg?];
43
43
 
44
- /** Bin transform options. */
45
- export interface BinOptions {
44
+ /** Binning interval names. */
45
+ export type BinInterval =
46
+ | 'date'
47
+ | 'number'
48
+ | 'millisecond'
49
+ | 'second'
50
+ | 'minute'
51
+ | 'hour'
52
+ | 'day'
53
+ | 'month'
54
+ | 'year';
55
+
56
+ /* A bin transform. */
57
+ export interface Bin {
58
+ /**
59
+ * Bin a continuous variable into discrete intervals. The bin argument
60
+ * specifies a data column or expression to bin. Both numerical and
61
+ * temporal (date/time) values are supported.
62
+ */
63
+ bin: Arg | [Arg];
64
+ /**
65
+ * The interval bin unit to use, typically used to indicate a date/time
66
+ * unit for binning temporal values, such as `hour`, `day`, or `month`.
67
+ * If `date`, the extent of data values is used to automatically select
68
+ * an interval for temporal data. The value `number` enforces normal
69
+ * numerical binning, even over temporal data. If unspecified, defaults
70
+ * to `number` for numerical data and `date` for temporal data.
71
+ */
72
+ interval?: BinInterval;
73
+ /**
74
+ * The step size to use between bins. When binning numerical values (or
75
+ * interval type `number`), this setting specifies the numerical step size.
76
+ * For data/time intervals, this indicates the number of steps of that unit,
77
+ * such as hours, days, or years.
78
+ */
79
+ step?: number;
46
80
  /**
47
81
  * The target number of binning steps to use. To accommodate human-friendly
48
- * bin boundaries, the actual number of bins may diverge from this exact number.
82
+ * ("nice") bin boundaries, the actual number of bins may diverge from this
83
+ * exact value. This option is ignored when **step** is specified.
49
84
  */
50
85
  steps?: number;
51
86
  /**
52
- * The minimum allowed bin step size (default `0`).
53
- * For example, a setting of `1` will prevent step sizes less than 1.
87
+ * The minimum allowed bin step size (default `0`) when performing numerical
88
+ * binning. For example, a setting of `1` prevents step sizes less than 1.
89
+ * This option is ignored when **step** is specified.
54
90
  */
55
91
  minstep?: number;
56
92
  /**
57
- * A flag requesting "nice" human-friendly step sizes (default `true`).
93
+ * A flag (default `true`) requesting "nice" human-friendly end points and
94
+ * step sizes when performing numerical binning. When **step** is specified,
95
+ * this option affects the binning end points (e.g., origin) only.
58
96
  */
59
97
  nice?: true;
60
98
  /**
@@ -64,15 +102,6 @@ export interface BinOptions {
64
102
  offset?: number;
65
103
  }
66
104
 
67
- /* A bin transform. */
68
- export interface Bin {
69
- /**
70
- * Bin a continuous variable into discrete intervals. This transform accepts
71
- * a data column to bin over as well as an optional bin options object.
72
- */
73
- bin: Arg | [Arg] | [Arg, BinOptions];
74
- }
75
-
76
105
  /* A dateMonth transform. */
77
106
  export interface DateMonth {
78
107
  /**
@@ -168,6 +197,22 @@ export interface Count extends AggregateOptions, WindowOptions {
168
197
  count: Arg0 | Arg1;
169
198
  }
170
199
 
200
+ /* A sample covariance aggregate transform. */
201
+ export interface Covariance extends AggregateOptions, WindowOptions {
202
+ /**
203
+ * Compute the sample covariance of between the given columns.
204
+ */
205
+ covariance: Arg2;
206
+ }
207
+
208
+ /* A population covariance aggregate transform. */
209
+ export interface CovarPop extends AggregateOptions, WindowOptions {
210
+ /**
211
+ * Compute the population covariance of between the given columns.
212
+ */
213
+ covarPop: Arg2;
214
+ }
215
+
171
216
  /* A first aggregate transform. */
172
217
  export interface First extends AggregateOptions, WindowOptions {
173
218
  /**
@@ -233,6 +278,22 @@ export interface Quantile extends AggregateOptions, WindowOptions {
233
278
  quantile: Arg2;
234
279
  }
235
280
 
281
+ /* A sample standard deviation aggregate transform. */
282
+ export interface Stddev extends AggregateOptions, WindowOptions {
283
+ /**
284
+ * Compute the sum of the given column.
285
+ */
286
+ stddev: Arg1;
287
+ }
288
+
289
+ /* A population standard deviation aggregate transform. */
290
+ export interface StddevPop extends AggregateOptions, WindowOptions {
291
+ /**
292
+ * Compute the sum of the given column.
293
+ */
294
+ stddevPop: Arg1;
295
+ }
296
+
236
297
  /* A sum aggregate transform. */
237
298
  export interface Sum extends AggregateOptions, WindowOptions {
238
299
  /**
@@ -241,6 +302,22 @@ export interface Sum extends AggregateOptions, WindowOptions {
241
302
  sum: Arg1;
242
303
  }
243
304
 
305
+ /* A sample variance aggregate transform. */
306
+ export interface Variance extends AggregateOptions, WindowOptions {
307
+ /**
308
+ * Compute the sample variance of the given column.
309
+ */
310
+ variance: Arg1;
311
+ }
312
+
313
+ /* A population variance aggregate transform. */
314
+ export interface VarPop extends AggregateOptions, WindowOptions {
315
+ /**
316
+ * Compute the population variance of the given column.
317
+ */
318
+ varPop: Arg1;
319
+ }
320
+
244
321
  /* A row_number window transform. */
245
322
  export interface RowNumber extends WindowOptions {
246
323
  /**
@@ -370,7 +447,11 @@ export type AggregateTransform =
370
447
  | Mode
371
448
  | Product
372
449
  | Quantile
373
- | Sum;
450
+ | Stddev
451
+ | StddevPop
452
+ | Sum
453
+ | Variance
454
+ | VarPop;
374
455
 
375
456
  /* A window transform that operates over a sorted domain. */
376
457
  export type WindowTransform =
@@ -8,21 +8,41 @@ export interface NearestOptions {
8
8
  */
9
9
  as: ParamRef;
10
10
  /**
11
- * The name of the field (database column) over which the nearest
12
- * selection should be defined. If unspecified, the channel field of the
13
- * first valid prior mark definition is used.
11
+ * The encoding channels whose domain values should be selected. For example,
12
+ * a setting of `['color']` selects the data value backing the color channel,
13
+ * whereas `['x', 'z']` selects both x and z channel domain values. If
14
+ * unspecified, the selected channels default to match the current pointer
15
+ * settings: a `nearestX` interactor selects the `['x']` channels, while
16
+ * a `nearest` interactor selects the `['x', 'y']` channels.
14
17
  */
15
- field?: string;
18
+ channels?: string[];
19
+ /**
20
+ * The fields (database column names) to use in generated selection clause
21
+ * predicates. If unspecified, the fields backing the selected *channels*
22
+ * in the first valid prior mark definition are used by default.
23
+ */
24
+ fields?: string[];
25
+ /**
26
+ * The maximum radius of a nearest selection (default 40). Marks with (x, y)
27
+ * coordinates outside this radius will not be selected as nearest points.
28
+ */
29
+ maxRadius?: number;
30
+ }
31
+
32
+ /** A nearest interactor. */
33
+ export interface Nearest extends NearestOptions {
34
+ /** Select values from the mark closest to the pointer. */
35
+ select: 'nearest';
16
36
  }
17
37
 
18
38
  /** A nearestX interactor. */
19
39
  export interface NearestX extends NearestOptions {
20
- /** Select the **x** domain value of the mark closest to the pointer. */
40
+ /** Select values from the mark closest to the pointer *x* location. */
21
41
  select: 'nearestX';
22
42
  }
23
43
 
24
44
  /** A nearestY interactor. */
25
45
  export interface NearestY extends NearestOptions {
26
- /** Select the **y** domain value of the mark closest to the pointer. */
46
+ /** Select values from the mark closest to the pointer *y* location. */
27
47
  select: 'nearestY';
28
48
  }
@@ -46,6 +46,15 @@ export interface ToggleY extends ToggleOptions {
46
46
  select: 'toggleY';
47
47
  }
48
48
 
49
+ /** A toggleZ interactor. */
50
+ export interface ToggleZ extends ToggleOptions {
51
+ /**
52
+ * Select individal values in the `z` scale domain.
53
+ * Clicking or touching a mark toggles its selection status.
54
+ */
55
+ select: 'toggleZ';
56
+ }
57
+
49
58
  /** A toggleColor interactor. */
50
59
  export interface ToggleColor extends ToggleOptions {
51
60
  /**
@@ -19,6 +19,11 @@ export interface DotOptions extends MarkOptions {
19
19
  */
20
20
  y?: ChannelValueSpec;
21
21
 
22
+ /**
23
+ * An optional ordinal channel for grouping data into series.
24
+ */
25
+ z?: ChannelValue;
26
+
22
27
  /**
23
28
  * The radius of dots; either a channel or constant. When a number, it is
24
29
  * interpreted as a constant radius in pixels. Otherwise it is interpreted as
@@ -0,0 +1,91 @@
1
+ import { ParamRef } from '../Param.js';
2
+ import {
3
+ ChannelValue, ChannelValueSpec, MarkData, MarkOptions, MarkerOptions
4
+ } from './Marks.js';
5
+
6
+ /** Options for errorbar marks. */
7
+ interface ErrorBarOptions extends MarkOptions, MarkerOptions {
8
+ /**
9
+ * The confidence interval in (0, 1); defaults to 0.95.
10
+ */
11
+ ci?: number | ParamRef;
12
+
13
+ /**
14
+ * An optional ordinal channel for grouping data, producing an independent
15
+ * error bar for each group. If not specified, it defaults to **stroke** if
16
+ * a channel.
17
+ */
18
+ z?: ChannelValue;
19
+ }
20
+
21
+ /** Options for the errorbarX mark. */
22
+ export interface ErrorBarXOptions extends ErrorBarOptions {
23
+ /**
24
+ * The dependent variable horizontal position channel, typically bound to the
25
+ * *x* scale.
26
+ */
27
+ x: ChannelValueSpec;
28
+
29
+ /**
30
+ * The independent variable vertical position channel, typically bound to
31
+ * the *y* scale; defaults to the zero-based index of the data [0, 1, 2, …].
32
+ */
33
+ y?: ChannelValueSpec;
34
+ }
35
+
36
+ /** The errorbarX mark. */
37
+ export interface ErrorBarX extends MarkData, ErrorBarXOptions {
38
+ /**
39
+ * A mark that draws error bars for a calculated parametric confidence
40
+ * interval for a dependent variable (*x*), potentially grouped by an
41
+ * independent variable (*y*).
42
+ *
43
+ * This mark aggregates raw values to produce a [parametric confidence
44
+ * interval][1] of the mean, assuming a normal distribution. To instead
45
+ * visualize pre-computeted interval values or custom aggregations, use
46
+ * a **ruleY** mark with specified **x1** and **x2** channels.
47
+ *
48
+ * Multiple error bars can be produced by specifying a **z** or **stroke**
49
+ * channel. Set the **marker** option to `'tick'` to add small perpendicular
50
+ * lines at the start and end of the error interval.
51
+ *
52
+ * [1]: https://en.wikipedia.org/wiki/Normal_distribution#Confidence_intervals
53
+ */
54
+ mark: 'errorbarX';
55
+ }
56
+
57
+ /** Options for the errorbarY mark. */
58
+ export interface ErrorBarYOptions extends ErrorBarOptions {
59
+ /**
60
+ * The independent variable horizontal position channel, typically bound to
61
+ * the *x* scale; defaults to the zero-based index of the data [0, 1, 2, …].
62
+ */
63
+ x?: ChannelValueSpec;
64
+
65
+ /**
66
+ * The dependent variable vertical position channel, typically bound to the
67
+ * *y* scale.
68
+ */
69
+ y: ChannelValueSpec;
70
+ }
71
+
72
+ /** The errorbarY mark. */
73
+ export interface ErrorBarY extends MarkData, ErrorBarYOptions {
74
+ /**
75
+ * A mark that draws error bars for a calculated parametric confidence
76
+ * interval for a dependent variable (*y*), potentially grouped by an
77
+ * independent variable (*x*).
78
+ *
79
+ * This mark aggregates raw values to produce a [parametric confidence
80
+ * interval][1] of the mean, assuming a normal distribution. To instead
81
+ * visualize pre-computeted interval values or custom aggregations, use
82
+ * a **ruleX** mark with specified **y1** and **y2** channels.
83
+ *
84
+ * Multiple error bars can be produced by specifying a **z** or **stroke**
85
+ * channel. Set the **marker** option to `'tick'` to add small perpendicular
86
+ * lines at the start and end of the error interval.
87
+ *
88
+ * [1]: https://en.wikipedia.org/wiki/Normal_distribution#Confidence_intervals
89
+ */
90
+ mark: 'errorbarY';
91
+ }
@@ -194,6 +194,18 @@ export type SortOrder =
194
194
  /** The pointer mode for the tip; corresponds to pointerX, pointerY, and pointer. */
195
195
  export type TipPointer = 'x' | 'y' | 'xy';
196
196
 
197
+ /** Selection filters to apply internally to mark data. */
198
+ export type SelectFilter =
199
+ | 'first'
200
+ | 'last'
201
+ | 'maxX'
202
+ | 'maxY'
203
+ | 'minX'
204
+ | 'minY'
205
+ | 'nearest'
206
+ | 'nearestX'
207
+ | 'nearestY';
208
+
197
209
  export interface MarkData {
198
210
  /**
199
211
  * The data source for the mark.
@@ -215,10 +227,24 @@ export interface MarkOptions {
215
227
  * channel values; only truthy values are retained.
216
228
  *
217
229
  * Note that filtering only affects the rendered mark index, not the
218
- * associated channel values, and thus has no effect on imputed scale domains.
230
+ * associated channel values, and has no effect on imputed scale domains.
219
231
  */
220
232
  filter?: ChannelValue;
221
233
 
234
+ /**
235
+ * Applies a filter transform after data is loaded to highlight selected
236
+ * values only. For example, `first` and `last` select the first or last
237
+ * values of series only (using the *z* channel to separate series).
238
+ * Meanwhile, `nearestX` and `nearestY` select the point nearest to the
239
+ * pointer along the *x* or *y* channel dimension. Unlike Mosaic selections,
240
+ * a mark level *select* is internal to the mark only, and does not populate
241
+ * a param or selection value to be shared across clients.
242
+ *
243
+ * Note that filtering only affects the rendered mark index, not the
244
+ * associated channel values, and has no effect on imputed scale domains.
245
+ */
246
+ select?: SelectFilter;
247
+
222
248
  /**
223
249
  * Applies a transform to reverse the order of the mark’s index, say for
224
250
  * reverse input order.
@@ -19,6 +19,11 @@ export interface TextOptions extends MarkOptions, TextStyles {
19
19
  */
20
20
  y?: ChannelValueSpec;
21
21
 
22
+ /**
23
+ * An optional ordinal channel for grouping data into series.
24
+ */
25
+ z?: ChannelValue;
26
+
22
27
  /**
23
28
  * The text contents channel, possibly with line breaks (\n, \r\n, or \r). If
24
29
  * not specified, defaults to the zero-based index [0, 1, 2, …].