@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.
- package/dist/mosaic-schema.json +12651 -6061
- package/dist/mosaic-spec.js +2409 -1495
- package/dist/mosaic-spec.min.js +20 -20
- package/dist/types/ast/ASTNode.d.ts +2 -2
- package/dist/types/ast/DataNode.d.ts +3 -3
- package/dist/types/ast/SelectionNode.d.ts +3 -1
- package/dist/types/ast/TransformNode.d.ts +9 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/parse-spec.d.ts +1 -1
- package/dist/types/spec/Input.d.ts +33 -3
- package/dist/types/spec/Param.d.ts +6 -0
- package/dist/types/spec/PlotAttribute.d.ts +6 -0
- package/dist/types/spec/PlotMark.d.ts +2 -1
- package/dist/types/spec/Spec.d.ts +7 -0
- package/dist/types/spec/Transform.d.ts +70 -14
- package/dist/types/spec/interactors/Nearest.d.ts +25 -6
- package/dist/types/spec/interactors/Toggle.d.ts +8 -0
- package/dist/types/spec/marks/Dot.d.ts +4 -0
- package/dist/types/spec/marks/ErrorBar.d.ts +82 -0
- package/dist/types/spec/marks/Marks.d.ts +16 -1
- package/dist/types/spec/marks/Text.d.ts +4 -0
- package/dist/types/util.d.ts +3 -3
- package/package.json +8 -10
- package/src/ast/ParamNode.js +2 -2
- package/src/ast/SelectionNode.js +11 -7
- package/src/ast/TransformNode.js +44 -10
- package/src/config/transforms.js +6 -0
- package/src/spec/Input.ts +30 -3
- package/src/spec/Param.ts +7 -0
- package/src/spec/PlotAttribute.ts +7 -0
- package/src/spec/PlotMark.ts +2 -0
- package/src/spec/Spec.ts +7 -0
- package/src/spec/Transform.ts +97 -16
- package/src/spec/interactors/Nearest.ts +26 -6
- package/src/spec/interactors/Toggle.ts +9 -0
- package/src/spec/marks/Dot.ts +5 -0
- package/src/spec/marks/ErrorBar.ts +91 -0
- package/src/spec/marks/Marks.ts +27 -1
- package/src/spec/marks/Text.ts +5 -0
|
@@ -12,13 +12,13 @@ export class ASTNode {
|
|
|
12
12
|
* @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
|
|
13
13
|
* @returns {*} The instantiated value of this node.
|
|
14
14
|
*/
|
|
15
|
-
instantiate(ctx: import(
|
|
15
|
+
instantiate(ctx: import("../ast-to-dom.js").InstantiateContext): any;
|
|
16
16
|
/**
|
|
17
17
|
* Generate ESM code for this AST node.
|
|
18
18
|
* @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
|
|
19
19
|
* @returns {string|void} The generated ESM code for the node.
|
|
20
20
|
*/
|
|
21
|
-
codegen(ctx: import(
|
|
21
|
+
codegen(ctx: import("../ast-to-esm.js").CodegenContext): string | void;
|
|
22
22
|
/**
|
|
23
23
|
* @returns {*} This AST node in JSON specification format.
|
|
24
24
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {import('../parse-spec.js').ParseContext} ctx The parser context.
|
|
6
6
|
* @returns {DataNode} a parsed data definition AST node
|
|
7
7
|
*/
|
|
8
|
-
export function parseData(name: string, spec: import(
|
|
8
|
+
export function parseData(name: string, spec: import("../spec/Data.js").DataDefinition, ctx: import("../parse-spec.js").ParseContext): DataNode;
|
|
9
9
|
export const TABLE_DATA: "table";
|
|
10
10
|
export const PARQUET_DATA: "parquet";
|
|
11
11
|
export const CSV_DATA: "csv";
|
|
@@ -21,13 +21,13 @@ export class QueryDataNode extends DataNode {
|
|
|
21
21
|
* @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
|
|
22
22
|
* @returns {string|void} The instantiated query.
|
|
23
23
|
*/
|
|
24
|
-
instantiateQuery(ctx: import(
|
|
24
|
+
instantiateQuery(ctx: import("../ast-to-dom.js").InstantiateContext): string | void;
|
|
25
25
|
/**
|
|
26
26
|
* Code generate a table creation query.
|
|
27
27
|
* @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
|
|
28
28
|
* @returns {string|void} The generated query code.
|
|
29
29
|
*/
|
|
30
|
-
codegenQuery(ctx: import(
|
|
30
|
+
codegenQuery(ctx: import("../ast-to-esm.js").CodegenContext): string | void;
|
|
31
31
|
}
|
|
32
32
|
export class TableDataNode extends QueryDataNode {
|
|
33
33
|
constructor(name: any, query: any, options: any);
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export class SelectionNode extends ASTNode {
|
|
2
|
-
constructor(select: string, cross: any);
|
|
2
|
+
constructor(select: string, cross: any, empty: any);
|
|
3
3
|
select: string;
|
|
4
4
|
cross: any;
|
|
5
|
+
empty: any;
|
|
5
6
|
instantiate(ctx: any): any;
|
|
6
7
|
codegen(ctx: any): string;
|
|
7
8
|
toJSON(): {
|
|
8
9
|
select: string;
|
|
9
10
|
cross: any;
|
|
11
|
+
empty: any;
|
|
10
12
|
};
|
|
11
13
|
}
|
|
12
14
|
import { ASTNode } from './ASTNode.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function parseTransform(spec: any, ctx: any): TransformNode;
|
|
1
|
+
export function parseTransform(spec: any, ctx: any): BinTransformNode | TransformNode;
|
|
2
2
|
export class TransformNode extends ASTNode {
|
|
3
3
|
constructor(name: any, args: any, options: any);
|
|
4
4
|
name: any;
|
|
@@ -10,4 +10,12 @@ export class TransformNode extends ASTNode {
|
|
|
10
10
|
[x: number]: any;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
+
export class BinTransformNode extends ASTNode {
|
|
14
|
+
constructor(name: any, arg: any, options: any);
|
|
15
|
+
name: any;
|
|
16
|
+
arg: any;
|
|
17
|
+
options: any;
|
|
18
|
+
instantiate(ctx: any): any;
|
|
19
|
+
codegen(ctx: any): string;
|
|
20
|
+
}
|
|
13
21
|
import { ASTNode } from './ASTNode.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export { VSpaceNode } from "./ast/VSpaceNode.js";
|
|
|
22
22
|
/**
|
|
23
23
|
* A Mosaic declarative specification.
|
|
24
24
|
*/
|
|
25
|
-
export type Spec = import(
|
|
25
|
+
export type Spec = import("./spec/Spec.js").Spec;
|
|
26
26
|
export { astToDOM, InstantiateContext } from "./ast-to-dom.js";
|
|
27
27
|
export { astToESM, CodegenContext } from "./ast-to-esm.js";
|
|
28
28
|
export { DataNode, QueryDataNode, TableDataNode, FileDataNode, CSVDataNode, JSONDataNode, ParquetDataNode, SpatialDataNode, LiteralJSONDataNode } from "./ast/DataNode.js";
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* dataset definition AST nodes.
|
|
21
21
|
* @returns {SpecNode} The top-level AST spec node.
|
|
22
22
|
*/
|
|
23
|
-
export function parseSpec(spec: import(
|
|
23
|
+
export function parseSpec(spec: import("./spec/Spec.js").Spec, options?: {
|
|
24
24
|
components?: Map<string, Function>;
|
|
25
25
|
transforms?: Set<string>;
|
|
26
26
|
inputs?: Set<string>;
|
|
@@ -10,6 +10,11 @@ export interface Menu {
|
|
|
10
10
|
* currently selected menu option.
|
|
11
11
|
*/
|
|
12
12
|
as?: ParamRef;
|
|
13
|
+
/**
|
|
14
|
+
* The database column name to use within generated selection clause
|
|
15
|
+
* predicates. Defaults to the `column` property.
|
|
16
|
+
*/
|
|
17
|
+
field?: string;
|
|
13
18
|
/**
|
|
14
19
|
* The name of a database table to use as a data source for this widget.
|
|
15
20
|
* Used in conjunction with the `column` property.
|
|
@@ -32,11 +37,14 @@ export interface Menu {
|
|
|
32
37
|
/**
|
|
33
38
|
* An array of menu options, as literal values or option objects.
|
|
34
39
|
* Option objects have a `value` property and an optional `label` property.
|
|
35
|
-
* If no label is provided, the
|
|
40
|
+
* If no label is provided, the string-coerced value is used.
|
|
36
41
|
*/
|
|
37
|
-
options?: Array<any
|
|
42
|
+
options?: Array<any | {
|
|
43
|
+
value: any;
|
|
44
|
+
label?: string;
|
|
45
|
+
}>;
|
|
38
46
|
/**
|
|
39
|
-
* The initial selected menu
|
|
47
|
+
* The initial selected menu value.
|
|
40
48
|
*/
|
|
41
49
|
value?: any;
|
|
42
50
|
}
|
|
@@ -51,6 +59,11 @@ export interface Search {
|
|
|
51
59
|
* current text search query.
|
|
52
60
|
*/
|
|
53
61
|
as?: ParamRef;
|
|
62
|
+
/**
|
|
63
|
+
* The database column name to use within generated selection clause
|
|
64
|
+
* predicates. Defaults to the `column` property.
|
|
65
|
+
*/
|
|
66
|
+
field?: string;
|
|
54
67
|
/**
|
|
55
68
|
* The type of text search query to perform. One of:
|
|
56
69
|
* - `"contains"` (default): the query string may appear anywhere in the text
|
|
@@ -90,6 +103,18 @@ export interface Slider {
|
|
|
90
103
|
* currently selected slider option.
|
|
91
104
|
*/
|
|
92
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';
|
|
93
118
|
/**
|
|
94
119
|
* The name of a database table to use as a data source for this widget.
|
|
95
120
|
* Used in conjunction with the `column` property.
|
|
@@ -137,6 +162,11 @@ export interface Table {
|
|
|
137
162
|
* A table grid widget.
|
|
138
163
|
*/
|
|
139
164
|
input: 'table';
|
|
165
|
+
/**
|
|
166
|
+
* The output selection. A selection clause is added for each
|
|
167
|
+
* currently selected table row.
|
|
168
|
+
*/
|
|
169
|
+
as?: ParamRef;
|
|
140
170
|
/**
|
|
141
171
|
* The name of a database table to use as a data source for this widget.
|
|
142
172
|
*/
|
|
@@ -46,6 +46,12 @@ export interface Selection {
|
|
|
46
46
|
* but not oneself (default `false`, except for `crossfilter` selections).
|
|
47
47
|
*/
|
|
48
48
|
cross?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* A flag for setting an initial empty selection state. If true, a selection
|
|
51
|
+
* with no clauses corresponds to an empty selection with no records. If
|
|
52
|
+
* false, a selection with no clauses selects all values.
|
|
53
|
+
*/
|
|
54
|
+
empty?: boolean;
|
|
49
55
|
}
|
|
50
56
|
/** A Param or Selection definition. */
|
|
51
57
|
export type ParamDefinition = ParamValue | Param | ParamDate | Selection;
|
|
@@ -1328,6 +1328,12 @@ export interface PlotAttributes {
|
|
|
1328
1328
|
* For continuous scales only.
|
|
1329
1329
|
*/
|
|
1330
1330
|
rNice?: boolean | number | Interval | ParamRef;
|
|
1331
|
+
/**
|
|
1332
|
+
* A textual label to show on the axis or legend; if null, show no label. By
|
|
1333
|
+
* default the scale label is inferred from channel definitions, possibly with
|
|
1334
|
+
* an arrow (↑, →, ↓, or ←) to indicate the direction of increasing value.
|
|
1335
|
+
*/
|
|
1336
|
+
rLabel?: string | null | ParamRef;
|
|
1331
1337
|
/**
|
|
1332
1338
|
* If true, shorthand for a transform suitable for percentages, mapping
|
|
1333
1339
|
* 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';
|
|
@@ -23,4 +24,4 @@ import { Text, TextX, TextY } from './marks/Text.js';
|
|
|
23
24
|
import { TickX, TickY } from './marks/Tick.js';
|
|
24
25
|
import { Spike, Vector, VectorX, VectorY } from './marks/Vector.js';
|
|
25
26
|
/** A plot mark entry. */
|
|
26
|
-
export type PlotMark = Area | AreaX | AreaY | Arrow | AxisX | AxisY | AxisFx | AxisFy | GridX | GridY | GridFx | GridFy | BarX | BarY | Cell | CellX | CellY | Contour | DelaunayLink | DelaunayMesh | Hull | Voronoi | VoronoiMesh | DenseLine | Density | DensityX | DensityY | Dot | DotX | DotY | Circle | Hexagon | Frame | Geo | Graticule | Sphere | Hexbin | Hexgrid | Image | Line | LineX | LineY | Link | Raster | Heatmap | RasterTile | Rect | RectX | RectY | RegressionY | RuleX | RuleY | Text | TextX | TextY | TickX | TickY | Vector | VectorX | VectorY | Spike;
|
|
27
|
+
export type PlotMark = Area | AreaX | AreaY | Arrow | AxisX | AxisY | AxisFx | AxisFy | GridX | GridY | GridFx | GridFy | BarX | BarY | Cell | CellX | CellY | Contour | DelaunayLink | DelaunayMesh | Hull | Voronoi | VoronoiMesh | DenseLine | Density | DensityX | DensityY | Dot | DotX | DotY | Circle | Hexagon | ErrorBarX | ErrorBarY | Frame | Geo | Graticule | Sphere | Hexbin | Hexgrid | Image | Line | LineX | LineY | Link | Raster | Heatmap | RasterTile | Rect | RectX | RectY | RegressionY | RuleX | RuleY | Text | TextX | TextY | TickX | TickY | Vector | VectorX | VectorY | Spike;
|
|
@@ -28,6 +28,13 @@ export type Data = Record<string, DataDefinition>;
|
|
|
28
28
|
export type Params = Record<string, ParamDefinition>;
|
|
29
29
|
/** Top-level specification properties. */
|
|
30
30
|
export interface SpecHead {
|
|
31
|
+
/**
|
|
32
|
+
* A [JSON schema](http://json-schema.org/) URL for this specification,
|
|
33
|
+
* such as https://uwdata.github.io/mosaic/schema/latest.json. This property
|
|
34
|
+
* enables validation and autocomplete in editors with JSON schema support.
|
|
35
|
+
* @format uri
|
|
36
|
+
*/
|
|
37
|
+
$schema?: string;
|
|
31
38
|
/** Specification metadata. */
|
|
32
39
|
meta?: Meta;
|
|
33
40
|
/** Configuration options. */
|
|
@@ -31,20 +31,47 @@ type Arg2Opt = Arg | [Arg, Arg?];
|
|
|
31
31
|
* second and third arguments are optional.
|
|
32
32
|
*/
|
|
33
33
|
type Arg3Opt = Arg | [Arg, Arg?, Arg?];
|
|
34
|
-
/**
|
|
35
|
-
export
|
|
34
|
+
/** Binning interval names. */
|
|
35
|
+
export type BinInterval = 'date' | 'number' | 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year';
|
|
36
|
+
export interface Bin {
|
|
37
|
+
/**
|
|
38
|
+
* Bin a continuous variable into discrete intervals. The bin argument
|
|
39
|
+
* specifies a data column or expression to bin. Both numerical and
|
|
40
|
+
* temporal (date/time) values are supported.
|
|
41
|
+
*/
|
|
42
|
+
bin: Arg | [Arg];
|
|
43
|
+
/**
|
|
44
|
+
* The interval bin unit to use, typically used to indicate a date/time
|
|
45
|
+
* unit for binning temporal values, such as `hour`, `day`, or `month`.
|
|
46
|
+
* If `date`, the extent of data values is used to automatically select
|
|
47
|
+
* an interval for temporal data. The value `number` enforces normal
|
|
48
|
+
* numerical binning, even over temporal data. If unspecified, defaults
|
|
49
|
+
* to `number` for numerical data and `date` for temporal data.
|
|
50
|
+
*/
|
|
51
|
+
interval?: BinInterval;
|
|
52
|
+
/**
|
|
53
|
+
* The step size to use between bins. When binning numerical values (or
|
|
54
|
+
* interval type `number`), this setting specifies the numerical step size.
|
|
55
|
+
* For data/time intervals, this indicates the number of steps of that unit,
|
|
56
|
+
* such as hours, days, or years.
|
|
57
|
+
*/
|
|
58
|
+
step?: number;
|
|
36
59
|
/**
|
|
37
60
|
* The target number of binning steps to use. To accommodate human-friendly
|
|
38
|
-
* bin boundaries, the actual number of bins may diverge from this
|
|
61
|
+
* ("nice") bin boundaries, the actual number of bins may diverge from this
|
|
62
|
+
* exact value. This option is ignored when **step** is specified.
|
|
39
63
|
*/
|
|
40
64
|
steps?: number;
|
|
41
65
|
/**
|
|
42
|
-
* The minimum allowed bin step size (default `0`)
|
|
43
|
-
* For example, a setting of `1`
|
|
66
|
+
* The minimum allowed bin step size (default `0`) when performing numerical
|
|
67
|
+
* binning. For example, a setting of `1` prevents step sizes less than 1.
|
|
68
|
+
* This option is ignored when **step** is specified.
|
|
44
69
|
*/
|
|
45
70
|
minstep?: number;
|
|
46
71
|
/**
|
|
47
|
-
* A flag requesting "nice" human-friendly
|
|
72
|
+
* A flag (default `true`) requesting "nice" human-friendly end points and
|
|
73
|
+
* step sizes when performing numerical binning. When **step** is specified,
|
|
74
|
+
* this option affects the binning end points (e.g., origin) only.
|
|
48
75
|
*/
|
|
49
76
|
nice?: true;
|
|
50
77
|
/**
|
|
@@ -53,13 +80,6 @@ export interface BinOptions {
|
|
|
53
80
|
*/
|
|
54
81
|
offset?: number;
|
|
55
82
|
}
|
|
56
|
-
export interface Bin {
|
|
57
|
-
/**
|
|
58
|
-
* Bin a continuous variable into discrete intervals. This transform accepts
|
|
59
|
-
* a data column to bin over as well as an optional bin options object.
|
|
60
|
-
*/
|
|
61
|
-
bin: Arg | [Arg] | [Arg, BinOptions];
|
|
62
|
-
}
|
|
63
83
|
export interface DateMonth {
|
|
64
84
|
/**
|
|
65
85
|
* Transform a Date value to a month boundary for cyclic comparison.
|
|
@@ -133,6 +153,18 @@ export interface Count extends AggregateOptions, WindowOptions {
|
|
|
133
153
|
*/
|
|
134
154
|
count: Arg0 | Arg1;
|
|
135
155
|
}
|
|
156
|
+
export interface Covariance extends AggregateOptions, WindowOptions {
|
|
157
|
+
/**
|
|
158
|
+
* Compute the sample covariance of between the given columns.
|
|
159
|
+
*/
|
|
160
|
+
covariance: Arg2;
|
|
161
|
+
}
|
|
162
|
+
export interface CovarPop extends AggregateOptions, WindowOptions {
|
|
163
|
+
/**
|
|
164
|
+
* Compute the population covariance of between the given columns.
|
|
165
|
+
*/
|
|
166
|
+
covarPop: Arg2;
|
|
167
|
+
}
|
|
136
168
|
export interface First extends AggregateOptions, WindowOptions {
|
|
137
169
|
/**
|
|
138
170
|
* Return the first column value found in an aggregation group.
|
|
@@ -182,12 +214,36 @@ export interface Quantile extends AggregateOptions, WindowOptions {
|
|
|
182
214
|
*/
|
|
183
215
|
quantile: Arg2;
|
|
184
216
|
}
|
|
217
|
+
export interface Stddev extends AggregateOptions, WindowOptions {
|
|
218
|
+
/**
|
|
219
|
+
* Compute the sum of the given column.
|
|
220
|
+
*/
|
|
221
|
+
stddev: Arg1;
|
|
222
|
+
}
|
|
223
|
+
export interface StddevPop extends AggregateOptions, WindowOptions {
|
|
224
|
+
/**
|
|
225
|
+
* Compute the sum of the given column.
|
|
226
|
+
*/
|
|
227
|
+
stddevPop: Arg1;
|
|
228
|
+
}
|
|
185
229
|
export interface Sum extends AggregateOptions, WindowOptions {
|
|
186
230
|
/**
|
|
187
231
|
* Compute the sum of the given column.
|
|
188
232
|
*/
|
|
189
233
|
sum: Arg1;
|
|
190
234
|
}
|
|
235
|
+
export interface Variance extends AggregateOptions, WindowOptions {
|
|
236
|
+
/**
|
|
237
|
+
* Compute the sample variance of the given column.
|
|
238
|
+
*/
|
|
239
|
+
variance: Arg1;
|
|
240
|
+
}
|
|
241
|
+
export interface VarPop extends AggregateOptions, WindowOptions {
|
|
242
|
+
/**
|
|
243
|
+
* Compute the population variance of the given column.
|
|
244
|
+
*/
|
|
245
|
+
varPop: Arg1;
|
|
246
|
+
}
|
|
191
247
|
export interface RowNumber extends WindowOptions {
|
|
192
248
|
/**
|
|
193
249
|
* Compute the 1-based row number over an ordered window partition.
|
|
@@ -271,7 +327,7 @@ export interface NthValue extends WindowOptions {
|
|
|
271
327
|
/** A data transform that maps one column value to another. */
|
|
272
328
|
export type ColumnTransform = Bin | DateMonth | DateMonthDay | DateDay | Centroid | CentroidX | CentroidY | GeoJSON;
|
|
273
329
|
/** An aggregate transform that combines multiple values. */
|
|
274
|
-
export type AggregateTransform = Argmax | Argmin | Avg | Count | Max | Min | First | Last | Max | Min | Median | Mode | Product | Quantile | Sum;
|
|
330
|
+
export type AggregateTransform = Argmax | Argmin | Avg | Count | Max | Min | First | Last | Max | Min | Median | Mode | Product | Quantile | Stddev | StddevPop | Sum | Variance | VarPop;
|
|
275
331
|
export type WindowTransform = RowNumber | Rank | DenseRank | PercentRank | CumeDist | NTile | Rank | Lag | Lead | FirstValue | LastValue | NthValue;
|
|
276
332
|
/** A data transform. */
|
|
277
333
|
export type Transform = ColumnTransform | AggregateTransform | WindowTransform;
|
|
@@ -7,19 +7,38 @@ export interface NearestOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
as: ParamRef;
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* The encoding channels whose domain values should be selected. For example,
|
|
11
|
+
* a setting of `['color']` selects the data value backing the color channel,
|
|
12
|
+
* whereas `['x', 'z']` selects both x and z channel domain values. If
|
|
13
|
+
* unspecified, the selected channels default to match the current pointer
|
|
14
|
+
* settings: a `nearestX` interactor selects the `['x']` channels, while
|
|
15
|
+
* a `nearest` interactor selects the `['x', 'y']` channels.
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
channels?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* The fields (database column names) to use in generated selection clause
|
|
20
|
+
* predicates. If unspecified, the fields backing the selected *channels*
|
|
21
|
+
* in the first valid prior mark definition are used by default.
|
|
22
|
+
*/
|
|
23
|
+
fields?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* The maximum radius of a nearest selection (default 40). Marks with (x, y)
|
|
26
|
+
* coordinates outside this radius will not be selected as nearest points.
|
|
27
|
+
*/
|
|
28
|
+
maxRadius?: number;
|
|
29
|
+
}
|
|
30
|
+
/** A nearest interactor. */
|
|
31
|
+
export interface Nearest extends NearestOptions {
|
|
32
|
+
/** Select values from the mark closest to the pointer. */
|
|
33
|
+
select: 'nearest';
|
|
15
34
|
}
|
|
16
35
|
/** A nearestX interactor. */
|
|
17
36
|
export interface NearestX extends NearestOptions {
|
|
18
|
-
/** Select
|
|
37
|
+
/** Select values from the mark closest to the pointer *x* location. */
|
|
19
38
|
select: 'nearestX';
|
|
20
39
|
}
|
|
21
40
|
/** A nearestY interactor. */
|
|
22
41
|
export interface NearestY extends NearestOptions {
|
|
23
|
-
/** Select
|
|
42
|
+
/** Select values from the mark closest to the pointer *y* location. */
|
|
24
43
|
select: 'nearestY';
|
|
25
44
|
}
|
|
@@ -41,6 +41,14 @@ export interface ToggleY extends ToggleOptions {
|
|
|
41
41
|
*/
|
|
42
42
|
select: 'toggleY';
|
|
43
43
|
}
|
|
44
|
+
/** A toggleZ interactor. */
|
|
45
|
+
export interface ToggleZ extends ToggleOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Select individal values in the `z` scale domain.
|
|
48
|
+
* Clicking or touching a mark toggles its selection status.
|
|
49
|
+
*/
|
|
50
|
+
select: 'toggleZ';
|
|
51
|
+
}
|
|
44
52
|
/** A toggleColor interactor. */
|
|
45
53
|
export interface ToggleColor extends ToggleOptions {
|
|
46
54
|
/**
|
|
@@ -13,6 +13,10 @@ export interface DotOptions extends MarkOptions {
|
|
|
13
13
|
* to the *y* scale.
|
|
14
14
|
*/
|
|
15
15
|
y?: ChannelValueSpec;
|
|
16
|
+
/**
|
|
17
|
+
* An optional ordinal channel for grouping data into series.
|
|
18
|
+
*/
|
|
19
|
+
z?: ChannelValue;
|
|
16
20
|
/**
|
|
17
21
|
* The radius of dots; either a channel or constant. When a number, it is
|
|
18
22
|
* interpreted as a constant radius in pixels. Otherwise it is interpreted as
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ParamRef } from '../Param.js';
|
|
2
|
+
import { ChannelValue, ChannelValueSpec, MarkData, MarkOptions, MarkerOptions } from './Marks.js';
|
|
3
|
+
/** Options for errorbar marks. */
|
|
4
|
+
interface ErrorBarOptions extends MarkOptions, MarkerOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The confidence interval in (0, 1); defaults to 0.95.
|
|
7
|
+
*/
|
|
8
|
+
ci?: number | ParamRef;
|
|
9
|
+
/**
|
|
10
|
+
* An optional ordinal channel for grouping data, producing an independent
|
|
11
|
+
* error bar for each group. If not specified, it defaults to **stroke** if
|
|
12
|
+
* a channel.
|
|
13
|
+
*/
|
|
14
|
+
z?: ChannelValue;
|
|
15
|
+
}
|
|
16
|
+
/** Options for the errorbarX mark. */
|
|
17
|
+
export interface ErrorBarXOptions extends ErrorBarOptions {
|
|
18
|
+
/**
|
|
19
|
+
* The dependent variable horizontal position channel, typically bound to the
|
|
20
|
+
* *x* scale.
|
|
21
|
+
*/
|
|
22
|
+
x: ChannelValueSpec;
|
|
23
|
+
/**
|
|
24
|
+
* The independent variable vertical position channel, typically bound to
|
|
25
|
+
* the *y* scale; defaults to the zero-based index of the data [0, 1, 2, …].
|
|
26
|
+
*/
|
|
27
|
+
y?: ChannelValueSpec;
|
|
28
|
+
}
|
|
29
|
+
/** The errorbarX mark. */
|
|
30
|
+
export interface ErrorBarX extends MarkData, ErrorBarXOptions {
|
|
31
|
+
/**
|
|
32
|
+
* A mark that draws error bars for a calculated parametric confidence
|
|
33
|
+
* interval for a dependent variable (*x*), potentially grouped by an
|
|
34
|
+
* independent variable (*y*).
|
|
35
|
+
*
|
|
36
|
+
* This mark aggregates raw values to produce a [parametric confidence
|
|
37
|
+
* interval][1] of the mean, assuming a normal distribution. To instead
|
|
38
|
+
* visualize pre-computeted interval values or custom aggregations, use
|
|
39
|
+
* a **ruleY** mark with specified **x1** and **x2** channels.
|
|
40
|
+
*
|
|
41
|
+
* Multiple error bars can be produced by specifying a **z** or **stroke**
|
|
42
|
+
* channel. Set the **marker** option to `'tick'` to add small perpendicular
|
|
43
|
+
* lines at the start and end of the error interval.
|
|
44
|
+
*
|
|
45
|
+
* [1]: https://en.wikipedia.org/wiki/Normal_distribution#Confidence_intervals
|
|
46
|
+
*/
|
|
47
|
+
mark: 'errorbarX';
|
|
48
|
+
}
|
|
49
|
+
/** Options for the errorbarY mark. */
|
|
50
|
+
export interface ErrorBarYOptions extends ErrorBarOptions {
|
|
51
|
+
/**
|
|
52
|
+
* The independent variable horizontal position channel, typically bound to
|
|
53
|
+
* the *x* scale; defaults to the zero-based index of the data [0, 1, 2, …].
|
|
54
|
+
*/
|
|
55
|
+
x?: ChannelValueSpec;
|
|
56
|
+
/**
|
|
57
|
+
* The dependent variable vertical position channel, typically bound to the
|
|
58
|
+
* *y* scale.
|
|
59
|
+
*/
|
|
60
|
+
y: ChannelValueSpec;
|
|
61
|
+
}
|
|
62
|
+
/** The errorbarY mark. */
|
|
63
|
+
export interface ErrorBarY extends MarkData, ErrorBarYOptions {
|
|
64
|
+
/**
|
|
65
|
+
* A mark that draws error bars for a calculated parametric confidence
|
|
66
|
+
* interval for a dependent variable (*y*), potentially grouped by an
|
|
67
|
+
* independent variable (*x*).
|
|
68
|
+
*
|
|
69
|
+
* This mark aggregates raw values to produce a [parametric confidence
|
|
70
|
+
* interval][1] of the mean, assuming a normal distribution. To instead
|
|
71
|
+
* visualize pre-computeted interval values or custom aggregations, use
|
|
72
|
+
* a **ruleX** mark with specified **y1** and **y2** channels.
|
|
73
|
+
*
|
|
74
|
+
* Multiple error bars can be produced by specifying a **z** or **stroke**
|
|
75
|
+
* channel. Set the **marker** option to `'tick'` to add small perpendicular
|
|
76
|
+
* lines at the start and end of the error interval.
|
|
77
|
+
*
|
|
78
|
+
* [1]: https://en.wikipedia.org/wiki/Normal_distribution#Confidence_intervals
|
|
79
|
+
*/
|
|
80
|
+
mark: 'errorbarY';
|
|
81
|
+
}
|
|
82
|
+
export {};
|
|
@@ -147,6 +147,8 @@ export type SortOrder = ChannelValue | {
|
|
|
147
147
|
};
|
|
148
148
|
/** The pointer mode for the tip; corresponds to pointerX, pointerY, and pointer. */
|
|
149
149
|
export type TipPointer = 'x' | 'y' | 'xy';
|
|
150
|
+
/** Selection filters to apply internally to mark data. */
|
|
151
|
+
export type SelectFilter = 'first' | 'last' | 'maxX' | 'maxY' | 'minX' | 'minY' | 'nearest' | 'nearestX' | 'nearestY';
|
|
150
152
|
export interface MarkData {
|
|
151
153
|
/**
|
|
152
154
|
* The data source for the mark.
|
|
@@ -166,9 +168,22 @@ export interface MarkOptions {
|
|
|
166
168
|
* channel values; only truthy values are retained.
|
|
167
169
|
*
|
|
168
170
|
* Note that filtering only affects the rendered mark index, not the
|
|
169
|
-
* associated channel values, and
|
|
171
|
+
* associated channel values, and has no effect on imputed scale domains.
|
|
170
172
|
*/
|
|
171
173
|
filter?: ChannelValue;
|
|
174
|
+
/**
|
|
175
|
+
* Applies a filter transform after data is loaded to highlight selected
|
|
176
|
+
* values only. For example, `first` and `last` select the first or last
|
|
177
|
+
* values of series only (using the *z* channel to separate series).
|
|
178
|
+
* Meanwhile, `nearestX` and `nearestY` select the point nearest to the
|
|
179
|
+
* pointer along the *x* or *y* channel dimension. Unlike Mosaic selections,
|
|
180
|
+
* a mark level *select* is internal to the mark only, and does not populate
|
|
181
|
+
* a param or selection value to be shared across clients.
|
|
182
|
+
*
|
|
183
|
+
* Note that filtering only affects the rendered mark index, not the
|
|
184
|
+
* associated channel values, and has no effect on imputed scale domains.
|
|
185
|
+
*/
|
|
186
|
+
select?: SelectFilter;
|
|
172
187
|
/**
|
|
173
188
|
* Applies a transform to reverse the order of the mark’s index, say for
|
|
174
189
|
* reverse input order.
|
|
@@ -13,6 +13,10 @@ export interface TextOptions extends MarkOptions, TextStyles {
|
|
|
13
13
|
* bound to the *y* scale.
|
|
14
14
|
*/
|
|
15
15
|
y?: ChannelValueSpec;
|
|
16
|
+
/**
|
|
17
|
+
* An optional ordinal channel for grouping data into series.
|
|
18
|
+
*/
|
|
19
|
+
z?: ChannelValue;
|
|
16
20
|
/**
|
|
17
21
|
* The text contents channel, possibly with line breaks (\n, \r\n, or \r). If
|
|
18
22
|
* not specified, defaults to the zero-based index [0, 1, 2, …].
|
package/dist/types/util.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ export function paramRef(value: any): any;
|
|
|
2
2
|
export function paramStr(value: any): any;
|
|
3
3
|
export function toParamRef(name: any): string;
|
|
4
4
|
export function toArray(value: any): any[];
|
|
5
|
-
export function isArray(value: any):
|
|
5
|
+
export function isArray(value: any): value is any[];
|
|
6
6
|
export function isObject(value: any): boolean;
|
|
7
|
-
export function isNumber(value: any):
|
|
7
|
+
export function isNumber(value: any): value is number;
|
|
8
8
|
export function isNumberOrString(value: any): boolean;
|
|
9
|
-
export function isString(value: any):
|
|
9
|
+
export function isString(value: any): value is string;
|
|
10
10
|
export function isFunction(value: any): boolean;
|
|
11
11
|
export function error(message: any, data: any): void;
|
|
12
12
|
export function isoparse(string: any, fallback: any): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uwdata/mosaic-spec",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Declarative specification of Mosaic-powered applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mosaic",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"specification"
|
|
11
11
|
],
|
|
12
12
|
"license": "BSD-3-Clause",
|
|
13
|
-
"author": "Jeffrey Heer (
|
|
13
|
+
"author": "Jeffrey Heer (https://idl.uw.edu)",
|
|
14
14
|
"type": "module",
|
|
15
15
|
"main": "src/index.js",
|
|
16
16
|
"module": "src/index.js",
|
|
@@ -29,16 +29,14 @@
|
|
|
29
29
|
"schema": "ts-json-schema-generator -f tsconfig.json -p src/spec/Spec.ts -t Spec --no-type-check --no-ref-encode --functions hide > dist/mosaic-schema.json",
|
|
30
30
|
"pretest": "npm run prebuild && npm run types",
|
|
31
31
|
"test": "mocha 'test/**/*-test.js' && tsc -p jsconfig.json",
|
|
32
|
+
"version": "cd ../.. && npm run docs:schema",
|
|
32
33
|
"prepublishOnly": "npm run test && npm run lint && npm run build"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@uwdata/mosaic-core": "^0.
|
|
36
|
-
"@uwdata/mosaic-sql": "^0.
|
|
37
|
-
"@uwdata/vgplot": "^0.
|
|
38
|
-
"ts-json-schema-generator": "^2.
|
|
36
|
+
"@uwdata/mosaic-core": "^0.10.0",
|
|
37
|
+
"@uwdata/mosaic-sql": "^0.10.0",
|
|
38
|
+
"@uwdata/vgplot": "^0.10.0",
|
|
39
|
+
"ts-json-schema-generator": "^2.3.0"
|
|
39
40
|
},
|
|
40
|
-
"
|
|
41
|
-
"ajv": "^8.13.0"
|
|
42
|
-
},
|
|
43
|
-
"gitHead": "a24b4c9f7dfa1c38c6af96ec17e075326c1af9b0"
|
|
41
|
+
"gitHead": "94fc4f0d4efc622001f6afd6714d1e9dda745be2"
|
|
44
42
|
}
|
package/src/ast/ParamNode.js
CHANGED
|
@@ -7,13 +7,13 @@ const paramTypes = new Set([VALUE, SINGLE, CROSSFILTER, INTERSECT, UNION]);
|
|
|
7
7
|
|
|
8
8
|
export function parseParam(spec, ctx) {
|
|
9
9
|
const param = isObject(spec) ? spec : { value: spec };
|
|
10
|
-
const { select = VALUE, cross, date, value } = param;
|
|
10
|
+
const { select = VALUE, cross, empty, date, value } = param;
|
|
11
11
|
if (!paramTypes.has(select)) {
|
|
12
12
|
ctx.error(`Unrecognized param type: ${select}`, param);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
if (select !== VALUE) {
|
|
16
|
-
return new SelectionNode(select, cross);
|
|
16
|
+
return new SelectionNode(select, cross, empty);
|
|
17
17
|
} else if (isArray(value)) {
|
|
18
18
|
return new ParamNode(value.map(v => ctx.maybeParam(v)));
|
|
19
19
|
} else {
|