@uwdata/mosaic-spec 0.11.0 → 0.12.1
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/README.md +2 -0
- package/dist/mosaic-schema.json +9664 -2691
- package/dist/mosaic-spec.js +4174 -2653
- package/dist/mosaic-spec.min.js +24 -24
- package/dist/types/ast/ColumnParamRefNode.d.ts +8 -0
- package/dist/types/ast/ExpressionNode.d.ts +2 -4
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/spec/Input.d.ts +1 -1
- package/dist/types/spec/PlotAttribute.d.ts +11 -5
- package/dist/types/spec/PlotFrom.d.ts +1 -1
- package/dist/types/spec/PlotInteractor.d.ts +2 -1
- package/dist/types/spec/PlotMark.d.ts +2 -1
- package/dist/types/spec/Transform.d.ts +8 -2
- package/dist/types/spec/interactors/BrushStyles.d.ts +27 -0
- package/dist/types/spec/interactors/Interval1D.d.ts +6 -27
- package/dist/types/spec/interactors/Interval2D.d.ts +6 -5
- package/dist/types/spec/interactors/Region.d.ts +32 -0
- package/dist/types/spec/interactors/Toggle.d.ts +3 -3
- package/dist/types/spec/marks/Marks.d.ts +5 -0
- package/dist/types/spec/marks/Waffle.d.ts +58 -0
- package/package.json +6 -6
- package/src/ast/ColumnParamRefNode.js +21 -0
- package/src/ast/DataNode.js +3 -3
- package/src/ast/ExpressionNode.js +17 -22
- package/src/ast/PlotFromNode.js +6 -6
- package/src/ast/PlotMarkNode.js +2 -2
- package/src/ast/TransformNode.js +14 -12
- package/src/config/transforms.js +1 -0
- package/src/constants.js +1 -1
- package/src/spec/Input.ts +1 -1
- package/src/spec/PlotAttribute.ts +13 -5
- package/src/spec/PlotFrom.ts +1 -1
- package/src/spec/PlotInteractor.ts +7 -5
- package/src/spec/PlotMark.ts +3 -1
- package/src/spec/Transform.ts +10 -1
- package/src/spec/interactors/BrushStyles.ts +27 -0
- package/src/spec/interactors/Interval1D.ts +6 -28
- package/src/spec/interactors/Interval2D.ts +6 -5
- package/src/spec/interactors/Region.ts +34 -0
- package/src/spec/interactors/Toggle.ts +3 -3
- package/src/spec/marks/Marks.ts +6 -0
- package/src/spec/marks/Waffle.ts +61 -0
package/src/config/transforms.js
CHANGED
package/src/constants.js
CHANGED
|
@@ -13,6 +13,7 @@ export const OPTIONS = 'options';
|
|
|
13
13
|
// params and selections
|
|
14
14
|
export const SELECTION = 'selection';
|
|
15
15
|
export const PARAMREF = 'paramref';
|
|
16
|
+
export const COLUMPARAMREF = 'columnparamref';
|
|
16
17
|
export const PARAM = 'param';
|
|
17
18
|
export const INCLUDE = 'include';
|
|
18
19
|
|
|
@@ -30,7 +31,6 @@ export const DATA = 'data';
|
|
|
30
31
|
// sql expressions
|
|
31
32
|
export const EXPRESSION = 'expression';
|
|
32
33
|
export const SQL = 'sql';
|
|
33
|
-
export const AGG = 'agg';
|
|
34
34
|
|
|
35
35
|
// inputs
|
|
36
36
|
export const INPUT = 'input';
|
package/src/spec/Input.ts
CHANGED
|
@@ -171,7 +171,7 @@ export interface Table {
|
|
|
171
171
|
/**
|
|
172
172
|
* The name of a database table to use as a data source for this widget.
|
|
173
173
|
*/
|
|
174
|
-
from: string;
|
|
174
|
+
from: string | ParamRef;
|
|
175
175
|
/**
|
|
176
176
|
* A list of column names to include in the table grid.
|
|
177
177
|
* If unspecified, all table columns are included.
|
|
@@ -178,13 +178,21 @@ export interface PlotAttributes {
|
|
|
178
178
|
grid?: boolean | string | ParamRef;
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
|
-
*
|
|
182
|
-
* default the scale label is inferred from channel definitions, possibly with
|
|
183
|
-
* an arrow (↑, →, ↓, or ←) to indicate the direction of increasing value.
|
|
181
|
+
* The [aria-label attribute][1] on the SVG root.
|
|
184
182
|
*
|
|
185
|
-
*
|
|
183
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label
|
|
186
184
|
*/
|
|
187
|
-
|
|
185
|
+
ariaLabel?: string | null;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The [aria-description attribute][1] on the SVG root.
|
|
189
|
+
*
|
|
190
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-description
|
|
191
|
+
*/
|
|
192
|
+
ariaDescription?: string | null;
|
|
193
|
+
|
|
194
|
+
/** The default clip for all marks. */
|
|
195
|
+
clip?: 'frame' | 'sphere' | boolean | null | ParamRef;
|
|
188
196
|
|
|
189
197
|
|
|
190
198
|
// x scale attributes
|
package/src/spec/PlotFrom.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type PlotDataInline = any[];
|
|
|
9
9
|
/** Input data specification for a plot mark. */
|
|
10
10
|
export interface PlotFrom {
|
|
11
11
|
/** The name of the backing data table. */
|
|
12
|
-
from: string;
|
|
12
|
+
from: string | ParamRef;
|
|
13
13
|
/** A selection that filters the mark data. */
|
|
14
14
|
filterBy?: ParamRef;
|
|
15
15
|
/**
|
|
@@ -3,6 +3,7 @@ import { IntervalX, IntervalY } from './interactors/Interval1D.js';
|
|
|
3
3
|
import { IntervalXY } from './interactors/Interval2D.js';
|
|
4
4
|
import { NearestX, NearestY } from './interactors/Nearest.js';
|
|
5
5
|
import { Pan, PanX, PanY, PanZoom, PanZoomX, PanZoomY } from './interactors/PanZoom.js';
|
|
6
|
+
import { Region } from './interactors/Region.js';
|
|
6
7
|
import { Toggle, ToggleColor, ToggleX, ToggleY } from './interactors/Toggle.js';
|
|
7
8
|
|
|
8
9
|
/** A plot interactor entry. */
|
|
@@ -13,13 +14,14 @@ export type PlotInteractor =
|
|
|
13
14
|
| IntervalXY
|
|
14
15
|
| NearestX
|
|
15
16
|
| NearestY
|
|
16
|
-
| Toggle
|
|
17
|
-
| ToggleX
|
|
18
|
-
| ToggleY
|
|
19
|
-
| ToggleColor
|
|
20
17
|
| Pan
|
|
21
18
|
| PanX
|
|
22
19
|
| PanY
|
|
23
20
|
| PanZoom
|
|
24
21
|
| PanZoomX
|
|
25
|
-
| PanZoomY
|
|
22
|
+
| PanZoomY
|
|
23
|
+
| Region
|
|
24
|
+
| Toggle
|
|
25
|
+
| ToggleX
|
|
26
|
+
| ToggleY
|
|
27
|
+
| ToggleColor;
|
package/src/spec/PlotMark.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { RuleX, RuleY } from './marks/Rule.js';
|
|
|
23
23
|
import { Text,TextX, TextY } from './marks/Text.js';
|
|
24
24
|
import { TickX, TickY } from './marks/Tick.js';
|
|
25
25
|
import { Spike, Vector, VectorX, VectorY } from './marks/Vector.js';
|
|
26
|
+
import { WaffleX, WaffleY } from './marks/Waffle.js';
|
|
26
27
|
|
|
27
28
|
/** A plot mark entry. */
|
|
28
29
|
export type PlotMark =
|
|
@@ -50,4 +51,5 @@ export type PlotMark =
|
|
|
50
51
|
| RuleX | RuleY
|
|
51
52
|
| Text | TextX | TextY
|
|
52
53
|
| TickX | TickY
|
|
53
|
-
| Vector | VectorX | VectorY | Spike
|
|
54
|
+
| Vector | VectorX | VectorY | Spike
|
|
55
|
+
| WaffleX | WaffleY;
|
package/src/spec/Transform.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface AggregateOptions {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/** A transform argument. */
|
|
20
|
-
type Arg = string | number | boolean;
|
|
20
|
+
type Arg = string | number | boolean | ParamRef;
|
|
21
21
|
|
|
22
22
|
/** A zero argument transform signature. */
|
|
23
23
|
type Arg0 = null | [];
|
|
@@ -102,6 +102,14 @@ export interface Bin {
|
|
|
102
102
|
offset?: number;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
/* A column transform. */
|
|
106
|
+
export interface Column {
|
|
107
|
+
/**
|
|
108
|
+
* Intpret a string or param-value as a column reference.
|
|
109
|
+
*/
|
|
110
|
+
column: Arg1;
|
|
111
|
+
}
|
|
112
|
+
|
|
105
113
|
/* A dateMonth transform. */
|
|
106
114
|
export interface DateMonth {
|
|
107
115
|
/**
|
|
@@ -423,6 +431,7 @@ export interface NthValue extends WindowOptions {
|
|
|
423
431
|
/** A data transform that maps one column value to another. */
|
|
424
432
|
export type ColumnTransform =
|
|
425
433
|
| Bin
|
|
434
|
+
| Column
|
|
426
435
|
| DateMonth
|
|
427
436
|
| DateMonthDay
|
|
428
437
|
| DateDay
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Styles for rectangular selection brushes. */
|
|
2
|
+
export interface BrushStyles {
|
|
3
|
+
/**
|
|
4
|
+
* The overall opacity of the brush rectangle.
|
|
5
|
+
*/
|
|
6
|
+
opacity?: number;
|
|
7
|
+
/**
|
|
8
|
+
* The fill opacity of the brush rectangle.
|
|
9
|
+
*/
|
|
10
|
+
fillOpacity?: number;
|
|
11
|
+
/**
|
|
12
|
+
* The stroke opacity of the brush rectangle.
|
|
13
|
+
*/
|
|
14
|
+
strokeOpacity?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The fill color of the brush rectangle.
|
|
17
|
+
*/
|
|
18
|
+
fill?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The stroke color of the brush rectangle.
|
|
21
|
+
*/
|
|
22
|
+
stroke?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The stroke dash array of the brush rectangle.
|
|
25
|
+
*/
|
|
26
|
+
strokeDasharray?: string;
|
|
27
|
+
}
|
|
@@ -1,28 +1,5 @@
|
|
|
1
1
|
import { ParamRef } from '../Param.js';
|
|
2
|
-
|
|
3
|
-
/** Styles for rectangular selection brushes. */
|
|
4
|
-
export interface BrushStyles {
|
|
5
|
-
/**
|
|
6
|
-
* The overall opacity of the brush rectangle.
|
|
7
|
-
*/
|
|
8
|
-
opacity?: number;
|
|
9
|
-
/**
|
|
10
|
-
* The fill opacity of the brush rectangle.
|
|
11
|
-
*/
|
|
12
|
-
fillOpacity?: number;
|
|
13
|
-
/**
|
|
14
|
-
* The stroke opacity of the brush rectangle.
|
|
15
|
-
*/
|
|
16
|
-
strokeOpacity?: number;
|
|
17
|
-
/**
|
|
18
|
-
* The fill color of the brush rectangle.
|
|
19
|
-
*/
|
|
20
|
-
fill?: string;
|
|
21
|
-
/**
|
|
22
|
-
* The stroke color of the brush rectangle.
|
|
23
|
-
*/
|
|
24
|
-
stroke?: string;
|
|
25
|
-
}
|
|
2
|
+
import { BrushStyles } from './BrushStyles.js';
|
|
26
3
|
|
|
27
4
|
/** Options for 1D interval interactors. */
|
|
28
5
|
export interface Interval1DOptions {
|
|
@@ -39,13 +16,14 @@ export interface Interval1DOptions {
|
|
|
39
16
|
field?: string;
|
|
40
17
|
/**
|
|
41
18
|
* The size of an interative pixel (default `1`). Larger pixel sizes reduce
|
|
42
|
-
* the brush resolution, which can reduce the size of
|
|
19
|
+
* the brush resolution, which can reduce the size of pre-aggregated
|
|
20
|
+
* materialized views.
|
|
43
21
|
*/
|
|
44
22
|
pixelSize?: number;
|
|
45
23
|
/**
|
|
46
|
-
* A flag indicating if peer (sibling) marks are when
|
|
47
|
-
* (default `true`). If set, peer marks will not be
|
|
48
|
-
* interactor's selection in cross-filtering setups.
|
|
24
|
+
* A flag indicating if peer (sibling) marks are excluded when
|
|
25
|
+
* cross-filtering (default `true`). If set, peer marks will not be
|
|
26
|
+
* filtered by this interactor's selection in cross-filtering setups.
|
|
49
27
|
*/
|
|
50
28
|
peers?: boolean;
|
|
51
29
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParamRef } from '../Param.js';
|
|
2
|
-
import { BrushStyles } from './
|
|
2
|
+
import { BrushStyles } from './BrushStyles.js';
|
|
3
3
|
|
|
4
4
|
/** Options for 2D interval interactors. */
|
|
5
5
|
export interface Interval2DOptions {
|
|
@@ -23,13 +23,14 @@ export interface Interval2DOptions {
|
|
|
23
23
|
yfield?: string;
|
|
24
24
|
/**
|
|
25
25
|
* The size of an interative pixel (default `1`). Larger pixel sizes reduce
|
|
26
|
-
* the brush resolution, which can reduce the size of
|
|
26
|
+
* the brush resolution, which can reduce the size of pre-aggregated
|
|
27
|
+
* materialized views.
|
|
27
28
|
*/
|
|
28
29
|
pixelSize?: number;
|
|
29
30
|
/**
|
|
30
|
-
* A flag indicating if peer (sibling) marks are when
|
|
31
|
-
* (default `true`). If set, peer marks will not be
|
|
32
|
-
* interactor's selection in cross-filtering setups.
|
|
31
|
+
* A flag indicating if peer (sibling) marks are excluded when
|
|
32
|
+
* cross-filtering (default `true`). If set, peer marks will not be
|
|
33
|
+
* filtered by this interactor's selection in cross-filtering setups.
|
|
33
34
|
*/
|
|
34
35
|
peers?: boolean;
|
|
35
36
|
/**
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ParamRef } from '../Param.js';
|
|
2
|
+
import { BrushStyles } from './BrushStyles.js';
|
|
3
|
+
|
|
4
|
+
/** Options for region interactors. */
|
|
5
|
+
export interface RegionOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The output selection. A clause of the form
|
|
8
|
+
* `(field = value1) OR (field = value2) ...`
|
|
9
|
+
* is added for the currently selected values.
|
|
10
|
+
*/
|
|
11
|
+
as: ParamRef;
|
|
12
|
+
/**
|
|
13
|
+
* The encoding channels over which to select values.
|
|
14
|
+
* For a selected mark, selection clauses will cover
|
|
15
|
+
* the backing data fields for each channel.
|
|
16
|
+
*/
|
|
17
|
+
channels: string[];
|
|
18
|
+
/**
|
|
19
|
+
* A flag indicating if peer (sibling) marks are excluded when
|
|
20
|
+
* cross-filtering (default `true`). If set, peer marks will not be
|
|
21
|
+
* filtered by this interactor's selection in cross-filtering setups.
|
|
22
|
+
*/
|
|
23
|
+
peers?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* CSS styles for the brush (SVG `rect`) element.
|
|
26
|
+
*/
|
|
27
|
+
brush?: BrushStyles;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A rectangular region interactor. */
|
|
31
|
+
export interface Region extends RegionOptions {
|
|
32
|
+
/** Select aspects of individual marks within a 2D range. */
|
|
33
|
+
select: 'region';
|
|
34
|
+
}
|
|
@@ -9,9 +9,9 @@ export interface ToggleOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
as: ParamRef;
|
|
11
11
|
/**
|
|
12
|
-
* A flag indicating if peer (sibling) marks are when
|
|
13
|
-
* (default `true`). If set, peer marks will not be
|
|
14
|
-
* interactor's selection in cross-filtering setups.
|
|
12
|
+
* A flag indicating if peer (sibling) marks are excluded when
|
|
13
|
+
* cross-filtering (default `true`). If set, peer marks will not be
|
|
14
|
+
* filtered by this interactor's selection in cross-filtering setups.
|
|
15
15
|
*/
|
|
16
16
|
peers?: boolean;
|
|
17
17
|
}
|
package/src/spec/marks/Marks.ts
CHANGED
|
@@ -432,6 +432,12 @@ export interface MarkOptions {
|
|
|
432
432
|
| (TipOptions & { pointer?: TipPointer })
|
|
433
433
|
| ParamRef;
|
|
434
434
|
|
|
435
|
+
/**
|
|
436
|
+
* Additional named channels, for example to include in a tooltip.
|
|
437
|
+
* Consists of (channel name, data field name) key-value pairs.
|
|
438
|
+
*/
|
|
439
|
+
channels?: Record<string, string>;
|
|
440
|
+
|
|
435
441
|
/**
|
|
436
442
|
* How to clip the mark; one of:
|
|
437
443
|
*
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ParamRef } from '../Param.js';
|
|
2
|
+
import { BarXOptions, BarYOptions } from './Bar.js';
|
|
3
|
+
import { MarkData } from './Marks.js';
|
|
4
|
+
|
|
5
|
+
/** Options for the waffleX and waffleY mark. */
|
|
6
|
+
export interface WaffleOptions {
|
|
7
|
+
/** The number of cells per row or column; defaults to undefined for automatic. */
|
|
8
|
+
multiple?: number | ParamRef;
|
|
9
|
+
/** The quantity each cell represents; defaults to 1. */
|
|
10
|
+
unit?: number | ParamRef;
|
|
11
|
+
/** The gap in pixels between cells; defaults to 1. */
|
|
12
|
+
gap?: number | ParamRef;
|
|
13
|
+
/** If true, round to integers to avoid partial cells. */
|
|
14
|
+
round?: boolean | ParamRef;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The waffleX mark. */
|
|
18
|
+
export interface WaffleX extends MarkData, BarXOptions, WaffleOptions {
|
|
19
|
+
/**
|
|
20
|
+
* A horizontal waffle mark. The required *x* values should be quantitative,
|
|
21
|
+
* and the optional *y* values should be ordinal.
|
|
22
|
+
*
|
|
23
|
+
* If neither **x1** nor **x2** nor **interval** is specified, an implicit
|
|
24
|
+
* stackX transform is applied and **x** defaults to the identity function,
|
|
25
|
+
* assuming that *data* = [*x₀*, *x₁*, *x₂*, …]. Otherwise if an **interval**
|
|
26
|
+
* is specified, then **x1** and **x2** are derived from **x**, representing
|
|
27
|
+
* the lower and upper bound of the containing interval, respectively.
|
|
28
|
+
* Otherwise, if only one of **x1** or **x2** is specified, the other
|
|
29
|
+
* defaults to **x**, which defaults to zero.
|
|
30
|
+
*
|
|
31
|
+
* The optional **y** ordinal channel specifies the vertical position; it is
|
|
32
|
+
* typically bound to the *y* scale, which must be a *band* scale. If the
|
|
33
|
+
* **y** channel is not specified, the bar will span the vertical extent of
|
|
34
|
+
* the plot’s frame. Because a waffle represents a discrete number of square
|
|
35
|
+
* cells, it may not use all of the available bandwidth.
|
|
36
|
+
*/
|
|
37
|
+
mark: 'waffleX';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The waffleY mark. */
|
|
41
|
+
export interface WaffleY extends MarkData, BarYOptions, WaffleOptions {
|
|
42
|
+
/**
|
|
43
|
+
* A vertical waffle mark. The required *y* values should be quantitative,
|
|
44
|
+
* and the optional *x* values should be ordinal.
|
|
45
|
+
*
|
|
46
|
+
* If neither **y1** nor **y2** nor **interval** is specified, an implicit
|
|
47
|
+
* stackY transform is applied and **y** defaults to the identity function,
|
|
48
|
+
* assuming that *data* = [*y₀*, *y₁*, *y₂*, …]. Otherwise if an **interval**
|
|
49
|
+
* is specified, then **y1** and **y2** are derived from **y**, representing
|
|
50
|
+
* the lower and upper bound of the containing interval, respectively.
|
|
51
|
+
* Otherwise, if only one of **y1** or **y2** is specified, the other
|
|
52
|
+
* defaults to **y**, which defaults to zero.
|
|
53
|
+
*
|
|
54
|
+
* The optional **x** ordinal channel specifies the horizontal position; it
|
|
55
|
+
* is typically bound to the *x* scale, which must be a *band* scale. If the
|
|
56
|
+
* **x** channel is not specified, the bar will span the horizontal extent of
|
|
57
|
+
* the plot’s frame. Because a waffle represents a discrete number of square
|
|
58
|
+
* cells, it may not use all of the available bandwidth.
|
|
59
|
+
*/
|
|
60
|
+
mark: 'waffleY';
|
|
61
|
+
}
|