@uwdata/mosaic-spec 0.9.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/LICENSE +47 -0
- package/dist/mosaic-schema.json +103 -33
- package/dist/mosaic-spec.js +2815 -2464
- 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 +5 -0
- package/dist/types/spec/Param.d.ts +6 -0
- package/dist/types/spec/PlotAttribute.d.ts +6 -0
- package/dist/types/spec/Transform.d.ts +33 -13
- package/dist/types/util.d.ts +3 -3
- package/package.json +7 -7
- package/src/ast/ParamNode.js +2 -2
- package/src/ast/SelectionNode.js +11 -7
- package/src/ast/TransformNode.js +44 -10
- package/src/spec/Input.ts +5 -0
- package/src/spec/Param.ts +7 -0
- package/src/spec/PlotAttribute.ts +7 -0
- package/src/spec/Transform.ts +44 -15
|
@@ -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>;
|
|
@@ -162,6 +162,11 @@ export interface Table {
|
|
|
162
162
|
* A table grid widget.
|
|
163
163
|
*/
|
|
164
164
|
input: 'table';
|
|
165
|
+
/**
|
|
166
|
+
* The output selection. A selection clause is added for each
|
|
167
|
+
* currently selected table row.
|
|
168
|
+
*/
|
|
169
|
+
as?: ParamRef;
|
|
165
170
|
/**
|
|
166
171
|
* The name of a database table to use as a data source for this widget.
|
|
167
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].
|
|
@@ -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.
|
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",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"prepublishOnly": "npm run test && npm run lint && npm run build"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@uwdata/mosaic-core": "^0.
|
|
37
|
-
"@uwdata/mosaic-sql": "^0.
|
|
38
|
-
"@uwdata/vgplot": "^0.
|
|
39
|
-
"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"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "94fc4f0d4efc622001f6afd6714d1e9dda745be2"
|
|
42
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 {
|
package/src/ast/SelectionNode.js
CHANGED
|
@@ -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
|
|
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
|
}
|
package/src/ast/TransformNode.js
CHANGED
|
@@ -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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
}
|
package/src/spec/Input.ts
CHANGED
|
@@ -163,6 +163,11 @@ export interface Table {
|
|
|
163
163
|
* A table grid widget.
|
|
164
164
|
*/
|
|
165
165
|
input: 'table';
|
|
166
|
+
/**
|
|
167
|
+
* The output selection. A selection clause is added for each
|
|
168
|
+
* currently selected table row.
|
|
169
|
+
*/
|
|
170
|
+
as?: ParamRef;
|
|
166
171
|
/**
|
|
167
172
|
* The name of a database table to use as a data source for this widget.
|
|
168
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].
|
package/src/spec/Transform.ts
CHANGED
|
@@ -41,20 +41,58 @@ type Arg2Opt = Arg | [Arg, Arg?];
|
|
|
41
41
|
*/
|
|
42
42
|
type Arg3Opt = Arg | [Arg, Arg?, Arg?];
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
export
|
|
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
|
|
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`
|
|
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
|
|
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
|
/**
|