@uwdata/mosaic-spec 0.7.1 → 0.9.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 +192673 -0
- package/dist/mosaic-spec.js +5077 -5774
- package/dist/mosaic-spec.min.js +23 -23
- package/dist/types/ast/ASTNode.d.ts +26 -0
- package/dist/types/ast/DataNode.d.ts +60 -0
- package/dist/types/ast/ExpressionNode.d.ts +15 -0
- package/dist/types/ast/HConcatNode.d.ts +10 -0
- package/dist/types/ast/HSpaceNode.d.ts +11 -0
- package/dist/types/ast/InputNode.d.ts +8 -0
- package/dist/types/ast/LiteralNode.d.ts +7 -0
- package/dist/types/ast/OptionsNode.d.ts +10 -0
- package/dist/types/ast/ParamNode.d.ts +9 -0
- package/dist/types/ast/ParamRefNode.d.ts +8 -0
- package/dist/types/ast/PlotAttributeNode.d.ts +18 -0
- package/dist/types/ast/PlotFromNode.d.ts +9 -0
- package/dist/types/ast/PlotInteractorNode.d.ts +8 -0
- package/dist/types/ast/PlotLegendNode.d.ts +10 -0
- package/dist/types/ast/PlotMarkNode.d.ts +10 -0
- package/dist/types/ast/PlotNode.d.ts +11 -0
- package/dist/types/ast/SelectionNode.d.ts +12 -0
- package/dist/types/ast/SpecNode.d.ts +10 -0
- package/dist/types/ast/TransformNode.d.ts +13 -0
- package/dist/types/ast/VConcatNode.d.ts +10 -0
- package/dist/types/ast/VSpaceNode.d.ts +11 -0
- package/dist/types/ast-to-dom.d.ts +38 -0
- package/dist/types/ast-to-esm.d.ts +64 -0
- package/dist/types/config/components.d.ts +4 -0
- package/dist/types/config/extensions.d.ts +9 -0
- package/dist/types/config/inputs.d.ts +5 -0
- package/dist/types/config/plots.d.ts +34 -0
- package/dist/types/config/transforms.d.ts +4 -0
- package/dist/types/constants.d.ts +30 -0
- package/dist/types/index.d.ts +29 -0
- package/dist/types/parse-spec.d.ts +86 -0
- package/dist/types/spec/CSSStyles.d.ts +3 -0
- package/dist/types/spec/Data.d.ts +165 -0
- package/dist/types/spec/Expression.d.ts +27 -0
- package/dist/types/spec/HConcat.d.ts +8 -0
- package/dist/types/spec/HSpace.d.ts +9 -0
- package/dist/types/spec/Input.d.ts +207 -0
- package/dist/types/spec/Param.d.ts +51 -0
- package/dist/types/spec/Plot.d.ts +14 -0
- package/dist/types/spec/PlotAttribute.d.ts +1522 -0
- package/dist/types/spec/PlotFrom.d.ts +20 -0
- package/dist/types/spec/PlotInteractor.d.ts +8 -0
- package/dist/types/spec/PlotLegend.d.ts +68 -0
- package/dist/types/spec/PlotMark.d.ts +27 -0
- package/dist/types/spec/PlotTypes.d.ts +293 -0
- package/dist/types/spec/Spec.d.ts +52 -0
- package/dist/types/spec/Transform.d.ts +314 -0
- package/dist/types/spec/VConcat.d.ts +8 -0
- package/dist/types/spec/VSpace.d.ts +9 -0
- package/dist/types/spec/interactors/Highlight.d.ts +37 -0
- package/dist/types/spec/interactors/Interval1D.d.ts +63 -0
- package/dist/types/spec/interactors/Interval2D.d.ts +46 -0
- package/dist/types/spec/interactors/Nearest.d.ts +44 -0
- package/dist/types/spec/interactors/PanZoom.d.ts +58 -0
- package/dist/types/spec/interactors/Toggle.d.ts +59 -0
- package/dist/types/spec/marks/Area.d.ts +139 -0
- package/dist/types/spec/marks/Arrow.d.ts +94 -0
- package/dist/types/spec/marks/Axis.d.ts +281 -0
- package/dist/types/spec/marks/Bar.d.ts +150 -0
- package/dist/types/spec/marks/Cell.d.ts +57 -0
- package/dist/types/spec/marks/Contour.d.ts +23 -0
- package/dist/types/spec/marks/Delaunay.d.ts +86 -0
- package/dist/types/spec/marks/DenseLine.d.ts +27 -0
- package/dist/types/spec/marks/Density.d.ts +121 -0
- package/dist/types/spec/marks/Dot.d.ts +133 -0
- package/dist/types/spec/marks/ErrorBar.d.ts +82 -0
- package/dist/types/spec/marks/Frame.d.ts +21 -0
- package/dist/types/spec/marks/Geo.d.ts +53 -0
- package/dist/types/spec/marks/Hexbin.d.ts +30 -0
- package/dist/types/spec/marks/Hexgrid.d.ts +25 -0
- package/dist/types/spec/marks/Image.d.ts +89 -0
- package/dist/types/spec/marks/Line.d.ts +82 -0
- package/dist/types/spec/marks/Link.d.ts +60 -0
- package/dist/types/spec/marks/Marks.d.ts +905 -0
- package/dist/types/spec/marks/Raster.d.ts +124 -0
- package/dist/types/spec/marks/Rect.d.ts +166 -0
- package/dist/types/spec/marks/Regression.d.ts +58 -0
- package/dist/types/spec/marks/Rule.d.ts +100 -0
- package/dist/types/spec/marks/Text.d.ts +110 -0
- package/dist/types/spec/marks/Tick.d.ts +61 -0
- package/dist/types/spec/marks/Vector.d.ts +99 -0
- package/dist/types/util.d.ts +12 -0
- package/jsconfig.json +10 -0
- package/package.json +14 -9
- package/src/ast/ASTNode.js +23 -2
- package/src/ast/DataNode.js +79 -21
- package/src/ast/HSpaceNode.js +1 -1
- package/src/ast/InputNode.js +1 -2
- package/src/ast/ParamNode.js +1 -2
- package/src/ast/PlotAttributeNode.js +1 -2
- package/src/ast/PlotInteractorNode.js +1 -2
- package/src/ast/PlotLegendNode.js +1 -2
- package/src/ast/PlotMarkNode.js +3 -2
- package/src/ast/TransformNode.js +1 -2
- package/src/ast/VSpaceNode.js +1 -1
- package/src/ast-to-dom.js +9 -3
- package/src/ast-to-esm.js +41 -12
- package/src/config/inputs.js +1 -0
- package/src/config/plots.js +4 -0
- package/src/config/transforms.js +6 -0
- package/src/index.js +4 -0
- package/src/parse-spec.js +38 -5
- package/src/spec/CSSStyles.ts +9 -0
- package/src/spec/Data.ts +184 -0
- package/src/spec/Expression.ts +31 -0
- package/src/spec/HConcat.ts +9 -0
- package/src/spec/HSpace.ts +9 -0
- package/src/spec/Input.ts +204 -0
- package/src/spec/Param.ts +68 -0
- package/src/spec/Plot.ts +15 -0
- package/src/spec/PlotAttribute.ts +1783 -0
- package/src/spec/PlotFrom.ts +23 -0
- package/src/spec/PlotInteractor.ts +25 -0
- package/src/spec/PlotLegend.ts +70 -0
- package/src/spec/PlotMark.ts +53 -0
- package/src/spec/PlotTypes.ts +519 -0
- package/src/spec/Spec.ts +70 -0
- package/src/spec/Transform.ts +446 -0
- package/src/spec/VConcat.ts +9 -0
- package/src/spec/VSpace.ts +9 -0
- package/src/spec/interactors/Highlight.ts +38 -0
- package/src/spec/interactors/Interval1D.ts +67 -0
- package/src/spec/interactors/Interval2D.ts +48 -0
- package/src/spec/interactors/Nearest.ts +48 -0
- package/src/spec/interactors/PanZoom.ts +65 -0
- package/src/spec/interactors/Toggle.ts +65 -0
- package/src/spec/marks/Area.ts +154 -0
- package/src/spec/marks/Arrow.ts +108 -0
- package/src/spec/marks/Axis.ts +305 -0
- package/src/spec/marks/Bar.ts +160 -0
- package/src/spec/marks/Cell.ts +62 -0
- package/src/spec/marks/Contour.ts +25 -0
- package/src/spec/marks/Delaunay.ts +95 -0
- package/src/spec/marks/DenseLine.ts +30 -0
- package/src/spec/marks/Density.ts +145 -0
- package/src/spec/marks/Dot.ts +152 -0
- package/src/spec/marks/ErrorBar.ts +91 -0
- package/src/spec/marks/Frame.ts +23 -0
- package/src/spec/marks/Geo.ts +58 -0
- package/src/spec/marks/Hexbin.ts +34 -0
- package/src/spec/marks/Hexgrid.ts +27 -0
- package/src/spec/marks/Image.ts +101 -0
- package/src/spec/marks/Line.ts +93 -0
- package/src/spec/marks/Link.ts +70 -0
- package/src/spec/marks/Marks.ts +1088 -0
- package/src/spec/marks/Raster.ts +145 -0
- package/src/spec/marks/Rect.ts +183 -0
- package/src/spec/marks/Regression.ts +63 -0
- package/src/spec/marks/Rule.ts +113 -0
- package/src/spec/marks/Text.ts +127 -0
- package/src/spec/marks/Tick.ts +69 -0
- package/src/spec/marks/Vector.ts +113 -0
- package/src/util.js +8 -0
- package/tsconfig.json +11 -0
- package/LICENSE +0 -47
|
@@ -0,0 +1,1088 @@
|
|
|
1
|
+
import { AggregateExpression, SQLExpression } from '../Expression.js';
|
|
2
|
+
import { ParamRef } from '../Param.js';
|
|
3
|
+
import { PlotMarkData } from '../PlotFrom.js';
|
|
4
|
+
import { CurveName, FrameAnchor, Interval, Reducer, ScaleName } from '../PlotTypes.js';
|
|
5
|
+
import { Transform } from '../Transform.js';
|
|
6
|
+
|
|
7
|
+
/** The set of known channel names. */
|
|
8
|
+
export type ChannelName =
|
|
9
|
+
| 'ariaLabel'
|
|
10
|
+
| 'fill'
|
|
11
|
+
| 'fillOpacity'
|
|
12
|
+
| 'fontSize'
|
|
13
|
+
| 'fx'
|
|
14
|
+
| 'fy'
|
|
15
|
+
| 'geometry'
|
|
16
|
+
| 'height'
|
|
17
|
+
| 'href'
|
|
18
|
+
| 'length'
|
|
19
|
+
| 'opacity'
|
|
20
|
+
| 'path'
|
|
21
|
+
| 'r'
|
|
22
|
+
| 'rotate'
|
|
23
|
+
| 'src'
|
|
24
|
+
| 'stroke'
|
|
25
|
+
| 'strokeOpacity'
|
|
26
|
+
| 'strokeWidth'
|
|
27
|
+
| 'symbol'
|
|
28
|
+
| 'text'
|
|
29
|
+
| 'title'
|
|
30
|
+
| 'weight'
|
|
31
|
+
| 'width'
|
|
32
|
+
| 'x'
|
|
33
|
+
| 'x1'
|
|
34
|
+
| 'x2'
|
|
35
|
+
| 'y'
|
|
36
|
+
| 'y1'
|
|
37
|
+
| 'y2'
|
|
38
|
+
| 'z';
|
|
39
|
+
|
|
40
|
+
type ChannelScale = ScaleName | 'auto' | boolean | null;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A channel’s values may be expressed as:
|
|
44
|
+
*
|
|
45
|
+
* - a field name, to extract the corresponding value for each datum
|
|
46
|
+
* - an iterable of values, typically of the same length as the data
|
|
47
|
+
* - a channel transform or SQL expression
|
|
48
|
+
* - a constant number or boolean
|
|
49
|
+
* - null to represent no value
|
|
50
|
+
*/
|
|
51
|
+
export type ChannelValue =
|
|
52
|
+
| any[] // column of values
|
|
53
|
+
| (string & Record<never, never>) // field or literal color; see also https://github.com/microsoft/TypeScript/issues/29729
|
|
54
|
+
| number // constant
|
|
55
|
+
| boolean // constant
|
|
56
|
+
| null // constant
|
|
57
|
+
| Transform
|
|
58
|
+
| SQLExpression
|
|
59
|
+
| AggregateExpression;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* When specifying a mark channel’s value, you can provide a {value, scale}
|
|
63
|
+
* object to override the scale that would normally be associated with the
|
|
64
|
+
* channel.
|
|
65
|
+
*/
|
|
66
|
+
export type ChannelValueSpec =
|
|
67
|
+
| ChannelValue
|
|
68
|
+
| {
|
|
69
|
+
value: ChannelValue;
|
|
70
|
+
label?: string;
|
|
71
|
+
scale?: ScaleName | 'auto' | boolean | null;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* In some contexts, when specifying a mark channel’s value, you can provide a
|
|
76
|
+
* {value, interval} object to specify an associated interval.
|
|
77
|
+
*/
|
|
78
|
+
export type ChannelValueIntervalSpec =
|
|
79
|
+
| ChannelValueSpec
|
|
80
|
+
| { value: ChannelValue; interval: Interval };
|
|
81
|
+
|
|
82
|
+
/** A channel name, or an implied one for domain sorting. */
|
|
83
|
+
type ChannelDomainName = ChannelName | 'data' | 'width' | 'height';
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The available inputs for imputing scale domains. In addition to a named
|
|
87
|
+
* channel, an input may be specified as:
|
|
88
|
+
*
|
|
89
|
+
* - *data* - impute from mark data
|
|
90
|
+
* - *width* - impute from |*x2* - *x1*|
|
|
91
|
+
* - *height* - impute from |*y2* - *y1*|
|
|
92
|
+
* - null - impute from input order
|
|
93
|
+
*
|
|
94
|
+
* If the *x* channel is not defined, the *x2* channel will be used instead if
|
|
95
|
+
* available, and similarly for *y* and *y2*; this is useful for marks that
|
|
96
|
+
* implicitly stack. The *data* input is typically used in conjunction with a
|
|
97
|
+
* custom **reduce** function, as when the built-in single-channel reducers are
|
|
98
|
+
* insufficient.
|
|
99
|
+
*/
|
|
100
|
+
export type ChannelDomainValue = ChannelDomainName | `-${ChannelDomainName}` | null;
|
|
101
|
+
|
|
102
|
+
/** Options for imputing scale domains from channel values. */
|
|
103
|
+
export interface ChannelDomainOptions {
|
|
104
|
+
/**
|
|
105
|
+
* How to produce a singular value (for subsequent sorting) from aggregated
|
|
106
|
+
* channel values; one of:
|
|
107
|
+
*
|
|
108
|
+
* - true (default) - alias for *max*
|
|
109
|
+
* - false or null - disabled; don’t impute the scale domain
|
|
110
|
+
* - a named reducer implementation such as *count* or *sum*
|
|
111
|
+
* - a function that takes an array of values and returns the reduced value
|
|
112
|
+
* - an object that implements the *reduceIndex* method
|
|
113
|
+
*/
|
|
114
|
+
reduce?: Reducer | boolean | null;
|
|
115
|
+
|
|
116
|
+
/** How to order reduced values. */
|
|
117
|
+
order?: 'ascending' | 'descending' | null;
|
|
118
|
+
|
|
119
|
+
/** If true, reverse the order after sorting. */
|
|
120
|
+
reverse?: boolean;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* If a positive number, limit the domain to the first *n* sorted values. If a
|
|
124
|
+
* negative number, limit the domain to the last *-n* sorted values. Hence, a
|
|
125
|
+
* positive **limit** with **reverse** true will return the top *n* values in
|
|
126
|
+
* descending order.
|
|
127
|
+
*
|
|
128
|
+
* If an array [*lo*, *hi*], slices the sorted domain from *lo* (inclusive) to
|
|
129
|
+
* *hi* (exclusive). As with [*array*.slice][1], if either *lo* or *hi* are
|
|
130
|
+
* negative, it indicates an offset from the end of the array; if *lo* is
|
|
131
|
+
* undefined it defaults to 0, and if *hi* is undefined it defaults to
|
|
132
|
+
* Infinity.
|
|
133
|
+
*
|
|
134
|
+
* Note: limiting the imputed domain of one scale, say *x*, does not affect
|
|
135
|
+
* the imputed domain of another scale, say *y*; each scale domain is imputed
|
|
136
|
+
* independently.
|
|
137
|
+
*
|
|
138
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
|
|
139
|
+
*/
|
|
140
|
+
limit?: number | [lo?: number, hi?: number];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** How to derive a scale’s domain from a channel’s values. */
|
|
144
|
+
export type ChannelDomainValueSpec =
|
|
145
|
+
| ChannelDomainValue
|
|
146
|
+
| ({ value: ChannelDomainValue } & ChannelDomainOptions);
|
|
147
|
+
|
|
148
|
+
/** How to impute scale domains from channel values. */
|
|
149
|
+
export type ChannelDomainSort = {
|
|
150
|
+
[key in ScaleName]?: ChannelDomainValueSpec
|
|
151
|
+
} & ChannelDomainOptions;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Output channels for aggregating transforms, such as bin and group. Each
|
|
155
|
+
* declared output channel has an associated reducer, and typically a
|
|
156
|
+
* corresponding input channel in *options*. Non-grouping channels declared in
|
|
157
|
+
* *options* but not *outputs* are computed on reduced data after grouping,
|
|
158
|
+
* which defaults to the array of data for the current group.
|
|
159
|
+
*
|
|
160
|
+
* If **title** is in *options* but not *outputs*, the reducer defaults to
|
|
161
|
+
* summarizing the most common values. If **href** is in *options* but not
|
|
162
|
+
* *outputs*, the reducer defaults to *first*. When **x1** or **x2** is in
|
|
163
|
+
* *outputs*, reads the input channel **x** if **x1** or **x2** is not in
|
|
164
|
+
* *options*; likewise for **y1** or **y2**, reads the input channel **y** if
|
|
165
|
+
* **y1** or **y2** is not in *options*.
|
|
166
|
+
*/
|
|
167
|
+
export type ChannelReducers<T = Reducer> = {
|
|
168
|
+
[key in ChannelName]?: T | { reduce: T; scale?: ChannelScale } | null
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/** Abstract (unscaled) values, and associated scale, per channel. */
|
|
172
|
+
export type ChannelStates = {
|
|
173
|
+
[key in ChannelName]?: { value: any[]; scale: ScaleName | null }
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/** Possibly-scaled values for each channel. */
|
|
177
|
+
export type ChannelValues = {
|
|
178
|
+
[key in ChannelName]?: any[]
|
|
179
|
+
} & { channels: ChannelStates };
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* How to order values; one of:
|
|
183
|
+
*
|
|
184
|
+
* - a function for comparing data, returning a signed number
|
|
185
|
+
* - a channel value definition for sorting given values in ascending order
|
|
186
|
+
* - a {value, order} object for sorting given values
|
|
187
|
+
* - a {channel, order} object for sorting the named channel’s values
|
|
188
|
+
*/
|
|
189
|
+
export type SortOrder =
|
|
190
|
+
| ChannelValue
|
|
191
|
+
| { value?: ChannelValue; order?: 'ascending' | 'descending' }
|
|
192
|
+
| { channel?: ChannelName | `-${ChannelName}`; order?: 'ascending' | 'descending' };
|
|
193
|
+
|
|
194
|
+
/** The pointer mode for the tip; corresponds to pointerX, pointerY, and pointer. */
|
|
195
|
+
export type TipPointer = 'x' | 'y' | 'xy';
|
|
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
|
+
|
|
209
|
+
export interface MarkData {
|
|
210
|
+
/**
|
|
211
|
+
* The data source for the mark.
|
|
212
|
+
*/
|
|
213
|
+
data: PlotMarkData;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export interface MarkDataOptional {
|
|
217
|
+
/**
|
|
218
|
+
* The data source for the mark.
|
|
219
|
+
*/
|
|
220
|
+
data?: PlotMarkData;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Shared options for all marks. */
|
|
224
|
+
export interface MarkOptions {
|
|
225
|
+
/**
|
|
226
|
+
* Applies a transform to filter the mark’s index according to the given
|
|
227
|
+
* channel values; only truthy values are retained.
|
|
228
|
+
*
|
|
229
|
+
* Note that filtering only affects the rendered mark index, not the
|
|
230
|
+
* associated channel values, and has no effect on imputed scale domains.
|
|
231
|
+
*/
|
|
232
|
+
filter?: ChannelValue;
|
|
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
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Applies a transform to reverse the order of the mark’s index, say for
|
|
250
|
+
* reverse input order.
|
|
251
|
+
*/
|
|
252
|
+
reverse?: boolean | ParamRef;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Either applies a transform to sort the mark’s index by the specified
|
|
256
|
+
* channel values, or imputes ordinal scale domains from this mark’s channels.
|
|
257
|
+
*
|
|
258
|
+
* When imputing ordinal scale domains from channel values, the **sort**
|
|
259
|
+
* option is an object whose keys are ordinal scale names such as *x* or *fx*,
|
|
260
|
+
* and whose values are channel names such as *y*, *y1*, or *y2*. For example,
|
|
261
|
+
* to impute the *y* scale’s domain from the associated *x* channel values in
|
|
262
|
+
* ascending order:
|
|
263
|
+
*
|
|
264
|
+
* ```js
|
|
265
|
+
* sort: {y: "x"}
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* For different sort options for different scales, replace the channel name
|
|
269
|
+
* with a *value* object and per-scale options:
|
|
270
|
+
*
|
|
271
|
+
* ```js
|
|
272
|
+
* sort: {y: {value: "-x"}}
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* When sorting the mark’s index, the **sort** option is instead one of:
|
|
276
|
+
*
|
|
277
|
+
* - a channel value definition for sorting given values in ascending order
|
|
278
|
+
* - a {value, order} object for sorting given values
|
|
279
|
+
* - a {channel, order} object for sorting the named channel’s values
|
|
280
|
+
*/
|
|
281
|
+
sort?: SortOrder | ChannelDomainSort;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* The horizontal facet position channel, for mark-level faceting, bound to
|
|
285
|
+
* the *fx* scale.
|
|
286
|
+
*/
|
|
287
|
+
fx?: ChannelValue;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* The vertical facet position channel, for mark-level faceting, bound to the
|
|
291
|
+
* *fy* scale.
|
|
292
|
+
*/
|
|
293
|
+
fy?: ChannelValue;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Whether to enable or disable faceting; one of:
|
|
297
|
+
*
|
|
298
|
+
* - *auto* (default) - automatically determine if this mark should be faceted
|
|
299
|
+
* - *include* (or true) - draw the subset of the mark’s data in the current facet
|
|
300
|
+
* - *exclude* - draw the subset of the mark’s data *not* in the current facet
|
|
301
|
+
* - *super* - draw this mark in a single frame that covers all facets
|
|
302
|
+
* - null (or false) - repeat this mark’s data across all facets (*i.e.*, no faceting)
|
|
303
|
+
*
|
|
304
|
+
* When a mark uses *super* faceting, it is not allowed to use position scales
|
|
305
|
+
* (*x*, *y*, *fx*, or *fy*); *super* faceting is intended for decorations,
|
|
306
|
+
* such as labels and legends.
|
|
307
|
+
*
|
|
308
|
+
* When top-level faceting is used, the default *auto* setting is equivalent
|
|
309
|
+
* to *include* when the mark data is strictly equal to the top-level facet
|
|
310
|
+
* data; otherwise it is equivalent to null. When the *include* or *exclude*
|
|
311
|
+
* facet mode is chosen, the mark data must be parallel to the top-level facet
|
|
312
|
+
* data: the data must have the same length and order. If the data are not
|
|
313
|
+
* parallel, then the wrong data may be shown in each facet. The default
|
|
314
|
+
* *auto* therefore requires strict equality (`===`) for safety, and using the
|
|
315
|
+
* facet data as mark data is recommended when using the *exclude* facet mode.
|
|
316
|
+
* (To construct parallel data safely, consider using [*array*.map][1] on the
|
|
317
|
+
* facet data.)
|
|
318
|
+
*
|
|
319
|
+
* When mark-level faceting is used, the default *auto* setting is equivalent
|
|
320
|
+
* to *include*: the mark will be faceted if either the **fx** or **fy**
|
|
321
|
+
* channel option (or both) is specified. The null or false option will
|
|
322
|
+
* disable faceting, while *exclude* draws the subset of the mark’s data *not*
|
|
323
|
+
* in the current facet.
|
|
324
|
+
*
|
|
325
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
|
|
326
|
+
*/
|
|
327
|
+
facet?: 'auto' | 'include' | 'exclude' | 'super' | boolean | null | ParamRef;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* How to place the mark with respect to facets; one of:
|
|
331
|
+
*
|
|
332
|
+
* - null (default for most marks) - display the mark in each non-empty facet
|
|
333
|
+
* - *top*, *right*, *bottom*, or *left* - display the mark only in facets on
|
|
334
|
+
* the given side
|
|
335
|
+
* - *top-empty*, *right-empty*, *bottom-empty*, or *left-empty* (default for
|
|
336
|
+
* axis marks) - display the mark only in facets that have empty space on
|
|
337
|
+
* the given side: either the margin, or an empty facet
|
|
338
|
+
* - *empty* - display the mark in empty facets only
|
|
339
|
+
*/
|
|
340
|
+
facetAnchor?:
|
|
341
|
+
| 'top'
|
|
342
|
+
| 'right'
|
|
343
|
+
| 'bottom'
|
|
344
|
+
| 'left'
|
|
345
|
+
| 'top-left'
|
|
346
|
+
| 'top-right'
|
|
347
|
+
| 'bottom-left'
|
|
348
|
+
| 'bottom-right'
|
|
349
|
+
| 'top-empty'
|
|
350
|
+
| 'right-empty'
|
|
351
|
+
| 'bottom-empty'
|
|
352
|
+
| 'left-empty'
|
|
353
|
+
| 'empty'
|
|
354
|
+
| null
|
|
355
|
+
| ParamRef;
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Shorthand to set the same default for all four mark margins: **marginTop**,
|
|
359
|
+
* **marginRight**, **marginBottom**, and **marginLeft**; typically defaults
|
|
360
|
+
* to 0, except for axis marks.
|
|
361
|
+
*/
|
|
362
|
+
margin?: number | ParamRef;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* The mark’s top margin; the minimum distance in pixels between the top edges
|
|
366
|
+
* of the inner and outer plot area.
|
|
367
|
+
*/
|
|
368
|
+
marginTop?: number | ParamRef;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* The mark’s right margin; the minimum distance in pixels between the right
|
|
372
|
+
* edges of the mark’s inner and outer plot area.
|
|
373
|
+
*/
|
|
374
|
+
marginRight?: number | ParamRef;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* The mark’s bottom margin; the minimum distance in pixels between the bottom
|
|
378
|
+
* edges of the inner and outer plot area.
|
|
379
|
+
*/
|
|
380
|
+
marginBottom?: number | ParamRef;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* The mark’s left margin; the minimum distance in pixels between the left
|
|
384
|
+
* edges of the inner and outer plot area.
|
|
385
|
+
*/
|
|
386
|
+
marginLeft?: number | ParamRef;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* The [aria-description][1]; a constant textual description.
|
|
390
|
+
*
|
|
391
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-description
|
|
392
|
+
*/
|
|
393
|
+
ariaDescription?: string | ParamRef;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* The [aria-hidden][1] state; a constant indicating whether the element is
|
|
397
|
+
* exposed to an accessibility API.
|
|
398
|
+
*
|
|
399
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden
|
|
400
|
+
*/
|
|
401
|
+
ariaHidden?: string | ParamRef;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* The [aria-label][1]; a channel specifying short textual labels representing
|
|
405
|
+
* the value in the accessibility tree.
|
|
406
|
+
*
|
|
407
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label
|
|
408
|
+
*/
|
|
409
|
+
ariaLabel?: ChannelValue;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* The [pointer-events][1] property; a constant string such as *none*.
|
|
413
|
+
*
|
|
414
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
415
|
+
*/
|
|
416
|
+
pointerEvents?: string | ParamRef;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* The title; a channel specifying accessible, short textual descriptions as
|
|
420
|
+
* strings (possibly with newlines). If the tip option is specified, the title
|
|
421
|
+
* will be displayed with an interactive tooltip instead of using the SVG
|
|
422
|
+
* [title element][1].
|
|
423
|
+
*
|
|
424
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title
|
|
425
|
+
*/
|
|
426
|
+
title?: ChannelValue;
|
|
427
|
+
|
|
428
|
+
/** Whether to generate a tooltip for this mark, and any tip options. */
|
|
429
|
+
tip?:
|
|
430
|
+
| boolean
|
|
431
|
+
| TipPointer
|
|
432
|
+
| (TipOptions & { pointer?: TipPointer })
|
|
433
|
+
| ParamRef;
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* How to clip the mark; one of:
|
|
437
|
+
*
|
|
438
|
+
* - *frame* or true - clip to the plot’s frame (inner area)
|
|
439
|
+
* - *sphere* - clip to the projected sphere (*e.g.*, front hemisphere)
|
|
440
|
+
* - null or false - do not clip
|
|
441
|
+
*
|
|
442
|
+
* The *sphere* clip option requires a geographic projection.
|
|
443
|
+
*/
|
|
444
|
+
clip?: 'frame' | 'sphere' | boolean | null | ParamRef;
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The horizontal offset in pixels; a constant option. On low-density screens,
|
|
448
|
+
* an additional 0.5px offset may be applied for crisp edges.
|
|
449
|
+
*/
|
|
450
|
+
dx?: number | ParamRef;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* The vertical offset in pixels; a constant option. On low-density screens,
|
|
454
|
+
* an additional 0.5px offset may be applied for crisp edges.
|
|
455
|
+
*/
|
|
456
|
+
dy?: number | ParamRef;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* The [fill][1]; a constant CSS color string, or a channel typically bound to
|
|
460
|
+
* the *color* scale. If all channel values are valid CSS colors, by default
|
|
461
|
+
* the channel will not be bound to the *color* scale, interpreting the colors
|
|
462
|
+
* literally.
|
|
463
|
+
*
|
|
464
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill
|
|
465
|
+
*/
|
|
466
|
+
fill?: ChannelValueSpec | ParamRef;
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* The [fill-opacity][1]; a constant number between 0 and 1, or a channel
|
|
470
|
+
* typically bound to the *opacity* scale. If all channel values are numbers
|
|
471
|
+
* in [0, 1], by default the channel will not be bound to the *opacity* scale,
|
|
472
|
+
* interpreting the opacities literally.
|
|
473
|
+
*
|
|
474
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-opacity
|
|
475
|
+
*/
|
|
476
|
+
fillOpacity?: ChannelValueSpec | ParamRef;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* The [stroke][1]; a constant CSS color string, or a channel typically bound
|
|
480
|
+
* to the *color* scale. If all channel values are valid CSS colors, by
|
|
481
|
+
* default the channel will not be bound to the *color* scale, interpreting
|
|
482
|
+
* the colors literally.
|
|
483
|
+
*
|
|
484
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke
|
|
485
|
+
*/
|
|
486
|
+
stroke?: ChannelValueSpec | ParamRef;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* The [stroke-dasharray][1]; a constant number indicating the length in
|
|
490
|
+
* pixels of alternating dashes and gaps, or a constant string of numbers
|
|
491
|
+
* separated by spaces or commas (_e.g._, *10 2* for dashes of 10 pixels
|
|
492
|
+
* separated by gaps of 2 pixels), or *none* (the default) for no dashing
|
|
493
|
+
*
|
|
494
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
|
|
495
|
+
*/
|
|
496
|
+
strokeDasharray?: string | number | ParamRef;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* The [stroke-dashoffset][1]; a constant indicating the offset in pixels of
|
|
500
|
+
* the first dash along the stroke; defaults to zero.
|
|
501
|
+
*
|
|
502
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dashoffset
|
|
503
|
+
*/
|
|
504
|
+
strokeDashoffset?: string | number | ParamRef;
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* The [stroke-linecap][1]; a constant specifying how to cap stroked paths,
|
|
508
|
+
* such as *butt*, *round*, or *square*.
|
|
509
|
+
*
|
|
510
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap
|
|
511
|
+
*/
|
|
512
|
+
strokeLinecap?: string | ParamRef;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* The [stroke-linejoin][1]; a constant specifying how to join stroked paths,
|
|
516
|
+
* such as *bevel*, *miter*, *miter-clip*, or *round*.
|
|
517
|
+
*
|
|
518
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin
|
|
519
|
+
*/
|
|
520
|
+
strokeLinejoin?: string | ParamRef;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* The [stroke-miterlimit][1]; a constant number specifying how to limit the
|
|
524
|
+
* length of *miter* joins on stroked paths.
|
|
525
|
+
*
|
|
526
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit
|
|
527
|
+
*/
|
|
528
|
+
strokeMiterlimit?: number | ParamRef;
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* The [stroke-opacity][1]; a constant between 0 and 1, or a channel typically
|
|
532
|
+
* bound to the *opacity* scale. If all channel values are numbers in [0, 1],
|
|
533
|
+
* by default the channel will not be bound to the *opacity* scale,
|
|
534
|
+
* interpreting the opacities literally.
|
|
535
|
+
*
|
|
536
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-opacity
|
|
537
|
+
*/
|
|
538
|
+
strokeOpacity?: ChannelValueSpec;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* The [stroke-width][1]; a constant number in pixels, or a channel.
|
|
542
|
+
*
|
|
543
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width
|
|
544
|
+
*/
|
|
545
|
+
strokeWidth?: ChannelValueSpec;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* The [opacity][1]; a constant between 0 and 1, or a channel typically bound
|
|
549
|
+
* to the *opacity* scale. If all channel values are numbers in [0, 1], by
|
|
550
|
+
* default the channel will not be bound to the *opacity* scale, interpreting
|
|
551
|
+
* the opacities literally. For faster rendering, prefer the **strokeOpacity**
|
|
552
|
+
* or **fillOpacity** option.
|
|
553
|
+
*
|
|
554
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/opacity
|
|
555
|
+
*/
|
|
556
|
+
opacity?: ChannelValueSpec;
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* The [mix-blend-mode][1]; a constant string specifying how to blend content
|
|
560
|
+
* such as *multiply*.
|
|
561
|
+
*
|
|
562
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode
|
|
563
|
+
*/
|
|
564
|
+
mixBlendMode?: string | ParamRef;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* A CSS [filter][1]; a constant string used to adjust the rendering of
|
|
568
|
+
* images, such as *blur(5px)*.
|
|
569
|
+
*
|
|
570
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/filter
|
|
571
|
+
*/
|
|
572
|
+
imageFilter?: string | ParamRef;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* The [paint-order][1]; a constant string specifying the order in which the
|
|
576
|
+
* **fill**, **stroke**, and any markers are drawn; defaults to *normal*,
|
|
577
|
+
* which draws the fill, then stroke, then markers; defaults to *stroke* for
|
|
578
|
+
* the text mark to create a “halo” around text to improve legibility.
|
|
579
|
+
*
|
|
580
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/paint-order
|
|
581
|
+
*/
|
|
582
|
+
paintOrder?: string | ParamRef;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* The [shape-rendering][1]; a constant string such as *crispEdges*.
|
|
586
|
+
*
|
|
587
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering
|
|
588
|
+
*/
|
|
589
|
+
shapeRendering?: string | ParamRef;
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* The [href][1]; a channel specifying URLs for clickable links. May be used
|
|
593
|
+
* in conjunction with the **target** option to open links in another window.
|
|
594
|
+
*
|
|
595
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/href
|
|
596
|
+
*/
|
|
597
|
+
href?: ChannelValue;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* The [target][1]; a constant string specifying the target window (_e.g._,
|
|
601
|
+
* *_blank*) for clickable links; used in conjunction with the **href**
|
|
602
|
+
* option.
|
|
603
|
+
*
|
|
604
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/target
|
|
605
|
+
*/
|
|
606
|
+
target?: string | ParamRef;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/** Options for insetting rectangular shapes. */
|
|
610
|
+
export interface InsetOptions {
|
|
611
|
+
/**
|
|
612
|
+
* Shorthand to set the same default for all four insets: **insetTop**,
|
|
613
|
+
* **insetRight**, **insetBottom**, and **insetLeft**. All insets typically
|
|
614
|
+
* default to zero, though not always (say when using bin transform). A
|
|
615
|
+
* positive inset reduces effective area, while a negative inset increases it.
|
|
616
|
+
*/
|
|
617
|
+
inset?: number | ParamRef;
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Insets the top edge by the specified number of pixels. A positive value
|
|
621
|
+
* insets towards the bottom edge (reducing effective area), while a negative
|
|
622
|
+
* value insets away from the bottom edge (increasing it).
|
|
623
|
+
*/
|
|
624
|
+
insetTop?: number | ParamRef;
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* Insets the right edge by the specified number of pixels. A positive value
|
|
628
|
+
* insets towards the left edge (reducing effective area), while a negative
|
|
629
|
+
* value insets away from the left edge (increasing it).
|
|
630
|
+
*/
|
|
631
|
+
insetRight?: number | ParamRef;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Insets the bottom edge by the specified number of pixels. A positive value
|
|
635
|
+
* insets towards the top edge (reducing effective area), while a negative
|
|
636
|
+
* value insets away from the top edge (increasing it).
|
|
637
|
+
*/
|
|
638
|
+
insetBottom?: number | ParamRef;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Insets the left edge by the specified number of pixels. A positive value
|
|
642
|
+
* insets towards the right edge (reducing effective area), while a negative
|
|
643
|
+
* value insets away from the right edge (increasing it).
|
|
644
|
+
*/
|
|
645
|
+
insetLeft?: number | ParamRef;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** Options for styling text (independent of anchor position). */
|
|
649
|
+
export interface TextStyles {
|
|
650
|
+
/**
|
|
651
|
+
* The [text anchor][1] controls how text is aligned (typically horizontally)
|
|
652
|
+
* relative to its anchor point; it is one of *start*, *end*, or *middle*. If
|
|
653
|
+
* the frame anchor is *left*, *top-left*, or *bottom-left*, the default text
|
|
654
|
+
* anchor is *start*; if the frame anchor is *right*, *top-right*, or
|
|
655
|
+
* *bottom-right*, the default is *end*; otherwise it is *middle*.
|
|
656
|
+
*
|
|
657
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-anchor
|
|
658
|
+
*/
|
|
659
|
+
textAnchor?: 'start' | 'middle' | 'end' | ParamRef;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* The line height in ems; defaults to 1. The line height affects the
|
|
663
|
+
* (typically vertical) separation between adjacent baselines of text, as well
|
|
664
|
+
* as the separation between the text and its anchor point.
|
|
665
|
+
*/
|
|
666
|
+
lineHeight?: number | ParamRef;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* The line width in ems (e.g., 10 for about 20 characters); defaults to
|
|
670
|
+
* infinity, disabling wrapping and clipping.
|
|
671
|
+
*
|
|
672
|
+
* If **textOverflow** is null, lines will be wrapped at the specified length.
|
|
673
|
+
* If a line is split at a soft hyphen (\xad), a hyphen (-) will be displayed
|
|
674
|
+
* at the end of the line. If **textOverflow** is not null, lines will be
|
|
675
|
+
* clipped according to the given strategy.
|
|
676
|
+
*/
|
|
677
|
+
lineWidth?: number | ParamRef;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* How truncate (or wrap) lines of text longer than the given **lineWidth**;
|
|
681
|
+
* one of:
|
|
682
|
+
*
|
|
683
|
+
* - null (default) - preserve overflowing characters (and wrap if needed)
|
|
684
|
+
* - *clip* or *clip-end* - remove characters from the end
|
|
685
|
+
* - *clip-start* - remove characters from the start
|
|
686
|
+
* - *ellipsis* or *ellipsis-end* - replace characters from the end with an ellipsis (…)
|
|
687
|
+
* - *ellipsis-start* - replace characters from the start with an ellipsis (…)
|
|
688
|
+
* - *ellipsis-middle* - replace characters from the middle with an ellipsis (…)
|
|
689
|
+
*
|
|
690
|
+
* If no **title** was specified, if text requires truncation, a title
|
|
691
|
+
* containing the non-truncated text will be implicitly added.
|
|
692
|
+
*/
|
|
693
|
+
textOverflow?:
|
|
694
|
+
| null
|
|
695
|
+
| 'clip'
|
|
696
|
+
| 'ellipsis'
|
|
697
|
+
| 'clip-start'
|
|
698
|
+
| 'clip-end'
|
|
699
|
+
| 'ellipsis-start'
|
|
700
|
+
| 'ellipsis-middle'
|
|
701
|
+
| 'ellipsis-end'
|
|
702
|
+
| ParamRef;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* If true, changes the default **fontFamily** to *monospace*, and uses
|
|
706
|
+
* simplified monospaced text metrics calculations.
|
|
707
|
+
*/
|
|
708
|
+
monospace?: boolean | ParamRef;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* The [font-family][1]; a constant; defaults to the plot’s font family, which
|
|
712
|
+
* is typically [*system-ui*][2].
|
|
713
|
+
*
|
|
714
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/font-family
|
|
715
|
+
* [2]: https://drafts.csswg.org/css-fonts-4/#valdef-font-family-system-ui
|
|
716
|
+
*/
|
|
717
|
+
fontFamily?: string | ParamRef;
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* The [font size][1] in pixels; either a constant or a channel; defaults to
|
|
721
|
+
* the plot’s font size, which is typically 10. When a number, it is
|
|
722
|
+
* interpreted as a constant; otherwise it is interpreted as a channel.
|
|
723
|
+
*
|
|
724
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/font-size
|
|
725
|
+
*/
|
|
726
|
+
fontSize?: ChannelValue | ParamRef;
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* The [font style][1]; a constant; defaults to the plot’s font style, which
|
|
730
|
+
* is typically *normal*.
|
|
731
|
+
*
|
|
732
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/font-style
|
|
733
|
+
*/
|
|
734
|
+
fontStyle?: string | ParamRef;
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* The [font variant][1]; a constant; if the **text** channel contains numbers
|
|
738
|
+
* or dates, defaults to *tabular-nums* to facilitate comparing numbers;
|
|
739
|
+
* otherwise defaults to the plot’s font style, which is typically *normal*.
|
|
740
|
+
*
|
|
741
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant
|
|
742
|
+
*/
|
|
743
|
+
fontVariant?: string | ParamRef;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* The [font weight][1]; a constant; defaults to the plot’s font weight, which
|
|
747
|
+
* is typically *normal*.
|
|
748
|
+
*
|
|
749
|
+
* [1]: https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
|
|
750
|
+
*/
|
|
751
|
+
fontWeight?: string | number | ParamRef;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/** Options for the tip mark. */
|
|
755
|
+
export interface TipOptions extends MarkOptions, TextStyles {
|
|
756
|
+
/**
|
|
757
|
+
* The horizontal position channel specifying the tip’s anchor, typically
|
|
758
|
+
* bound to the *x* scale.
|
|
759
|
+
*/
|
|
760
|
+
x?: ChannelValueSpec;
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* The starting horizontal position channel specifying the tip’s anchor,
|
|
764
|
+
* typically bound to the *x* scale.
|
|
765
|
+
*/
|
|
766
|
+
x1?: ChannelValueSpec;
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* The ending horizontal position channel specifying the tip’s anchor,
|
|
770
|
+
* typically bound to the *x* scale.
|
|
771
|
+
*/
|
|
772
|
+
x2?: ChannelValueSpec;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* The vertical position channel specifying the tip’s anchor, typically
|
|
776
|
+
* bound to the *y* scale.
|
|
777
|
+
*/
|
|
778
|
+
y?: ChannelValueSpec;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* The starting vertical position channel specifying the tip’s anchor,
|
|
782
|
+
* typically bound to the *y* scale.
|
|
783
|
+
*/
|
|
784
|
+
y1?: ChannelValueSpec;
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* The ending vertical position channel specifying the tip’s anchor, typically
|
|
788
|
+
* bound to the *y* scale.
|
|
789
|
+
*/
|
|
790
|
+
y2?: ChannelValueSpec;
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* The frame anchor specifies defaults for **x** and **y** based on the plot’s
|
|
794
|
+
* frame; it may be one of the four sides (*top*, *right*, *bottom*, *left*),
|
|
795
|
+
* one of the four corners (*top-left*, *top-right*, *bottom-right*,
|
|
796
|
+
* *bottom-left*), or the *middle* of the frame. For example, for tips
|
|
797
|
+
* distributed horizontally at the top of the frame:
|
|
798
|
+
*
|
|
799
|
+
* ```js
|
|
800
|
+
* Plot.tip(data, {x: "date", frameAnchor: "top"})
|
|
801
|
+
* ```
|
|
802
|
+
*/
|
|
803
|
+
frameAnchor?: FrameAnchor | ParamRef;
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* The tip anchor specifies how to orient the tip box relative to its anchor
|
|
807
|
+
* position; it refers to the part of the tip box that is attached to the
|
|
808
|
+
* anchor point. For example, the *top-left* anchor places the top-left corner
|
|
809
|
+
* of tip box near the anchor position, hence placing the tip box below and to
|
|
810
|
+
* the right of the anchor position.
|
|
811
|
+
*/
|
|
812
|
+
anchor?: FrameAnchor | ParamRef;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* If an explicit tip anchor is not specified, an anchor is chosen
|
|
816
|
+
* automatically such that the tip fits within the plot’s frame; if the
|
|
817
|
+
* preferred anchor fits, it is chosen.
|
|
818
|
+
*/
|
|
819
|
+
preferredAnchor?: FrameAnchor | null | ParamRef;
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* How channel values are formatted for display. If a format is a string, it
|
|
823
|
+
* is interpreted as a (UTC) time format for temporal channels, and otherwise
|
|
824
|
+
* a number format.
|
|
825
|
+
*/
|
|
826
|
+
format?: {
|
|
827
|
+
[name in ChannelName]?: boolean | string | ParamRef
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
/** The image filter for the tip’s box; defaults to a drop shadow. */
|
|
831
|
+
pathFilter?: string | ParamRef;
|
|
832
|
+
|
|
833
|
+
/** The size of the tip’s pointer in pixels; defaults to 12. */
|
|
834
|
+
pointerSize?: number | ParamRef;
|
|
835
|
+
|
|
836
|
+
/** The padding around the text in pixels; defaults to 8. */
|
|
837
|
+
textPadding?: number | ParamRef;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/** How to interpolate between control points. */
|
|
841
|
+
export type Curve = CurveName;
|
|
842
|
+
|
|
843
|
+
/** Options for marks that support curves, such as lines and areas. */
|
|
844
|
+
export interface CurveOptions extends CurveAutoOptions {
|
|
845
|
+
/**
|
|
846
|
+
* The curve (interpolation) method for connecting adjacent points. One of:
|
|
847
|
+
*
|
|
848
|
+
* - *basis* - a cubic basis spline (repeating the end points)
|
|
849
|
+
* - *basis-open* - an open cubic basis spline
|
|
850
|
+
* - *basis-closed* - a closed cubic basis spline
|
|
851
|
+
* - *bump-x* - a Bézier curve with horizontal tangents
|
|
852
|
+
* - *bump-y* - a Bézier curve with vertical tangents
|
|
853
|
+
* - *bundle* - a straightened cubic basis spline (suitable for lines only, not areas)
|
|
854
|
+
* - *cardinal* - a cubic cardinal spline (with one-sided differences at the ends)
|
|
855
|
+
* - *cardinal-open* - an open cubic cardinal spline
|
|
856
|
+
* - *cardinal-closed* - an closed cubic cardinal spline
|
|
857
|
+
* - *catmull-rom* - a cubic Catmull–Rom spline (with one-sided differences at the ends)
|
|
858
|
+
* - *catmull-rom-open* - an open cubic Catmull–Rom spline
|
|
859
|
+
* - *catmull-rom-closed* - a closed cubic Catmull–Rom spline
|
|
860
|
+
* - *linear* - a piecewise linear curve (*i.e.*, straight line segments)
|
|
861
|
+
* - *linear-closed* - a closed piecewise linear curve (*i.e.*, straight line segments)
|
|
862
|
+
* - *monotone-x* - a cubic spline that preserves monotonicity in *x*
|
|
863
|
+
* - *monotone-y* - a cubic spline that preserves monotonicity in *y*
|
|
864
|
+
* - *natural* - a natural cubic spline
|
|
865
|
+
* - *step* - a piecewise constant function where *y* changes at the midpoint of *x*
|
|
866
|
+
* - *step-after* - a piecewise constant function where *y* changes after *x*
|
|
867
|
+
* - *step-before* - a piecewise constant function where *x* changes after *y*
|
|
868
|
+
*/
|
|
869
|
+
curve?: Curve | ParamRef;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/** Options for marks that support possibly-projected curves. */
|
|
873
|
+
export interface CurveAutoOptions {
|
|
874
|
+
/**
|
|
875
|
+
* The curve (interpolation) method for connecting adjacent points. One of:
|
|
876
|
+
*
|
|
877
|
+
* - *basis* - a cubic basis spline (repeating the end points)
|
|
878
|
+
* - *basis-open* - an open cubic basis spline
|
|
879
|
+
* - *basis-closed* - a closed cubic basis spline
|
|
880
|
+
* - *bump-x* - a Bézier curve with horizontal tangents
|
|
881
|
+
* - *bump-y* - a Bézier curve with vertical tangents
|
|
882
|
+
* - *bundle* - a straightened cubic basis spline (suitable for lines only, not areas)
|
|
883
|
+
* - *cardinal* - a cubic cardinal spline (with one-sided differences at the ends)
|
|
884
|
+
* - *cardinal-open* - an open cubic cardinal spline
|
|
885
|
+
* - *cardinal-closed* - an closed cubic cardinal spline
|
|
886
|
+
* - *catmull-rom* - a cubic Catmull–Rom spline (with one-sided differences at the ends)
|
|
887
|
+
* - *catmull-rom-open* - an open cubic Catmull–Rom spline
|
|
888
|
+
* - *catmull-rom-closed* - a closed cubic Catmull–Rom spline
|
|
889
|
+
* - *linear* - a piecewise linear curve (*i.e.*, straight line segments)
|
|
890
|
+
* - *linear-closed* - a closed piecewise linear curve (*i.e.*, straight line segments)
|
|
891
|
+
* - *monotone-x* - a cubic spline that preserves monotonicity in *x*
|
|
892
|
+
* - *monotone-y* - a cubic spline that preserves monotonicity in *y*
|
|
893
|
+
* - *natural* - a natural cubic spline
|
|
894
|
+
* - *step* - a piecewise constant function where *y* changes at the midpoint of *x*
|
|
895
|
+
* - *step-after* - a piecewise constant function where *y* changes after *x*
|
|
896
|
+
* - *step-before* - a piecewise constant function where *x* changes after *y*
|
|
897
|
+
* - *auto* (default) - like *linear*, but use the (possibly spherical) projection, if any
|
|
898
|
+
*
|
|
899
|
+
* The *auto* curve is typically used in conjunction with a spherical
|
|
900
|
+
* projection to interpolate along geodesics.
|
|
901
|
+
*/
|
|
902
|
+
curve?: Curve | 'auto' | ParamRef;
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* The tension option only has an effect on bundle, cardinal and Catmull–Rom
|
|
906
|
+
* splines (*bundle*, *cardinal*, *cardinal-open*, *cardinal-closed*,
|
|
907
|
+
* *catmull-rom*, *catmull-rom-open*, and *catmull-rom-closed*). For bundle
|
|
908
|
+
* splines, it corresponds to [beta][1]; for cardinal splines, [tension][2];
|
|
909
|
+
* for Catmull–Rom splines, [alpha][3].
|
|
910
|
+
*
|
|
911
|
+
* [1]: https://d3js.org/d3-shape/curve#curveBundle_beta
|
|
912
|
+
* [2]: https://d3js.org/d3-shape/curve#curveCardinal_tension
|
|
913
|
+
* [3]: https://d3js.org/d3-shape/curve#curveCatmullRom_alpha
|
|
914
|
+
*/
|
|
915
|
+
tension?: number | ParamRef;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* A built-in stack offset method; one of:
|
|
920
|
+
*
|
|
921
|
+
* - *normalize* - rescale each stack to fill [0, 1]
|
|
922
|
+
* - *center* - align the centers of all stacks
|
|
923
|
+
* - *wiggle* - translate stacks to minimize apparent movement
|
|
924
|
+
*
|
|
925
|
+
* If a given stack has zero total value, the *normalize* offset will not adjust
|
|
926
|
+
* the stack’s position. Both the *center* and *wiggle* offsets ensure that the
|
|
927
|
+
* lowest element across stacks starts at zero for better default axes. The
|
|
928
|
+
* *wiggle* offset is recommended for streamgraphs in conjunction with the
|
|
929
|
+
* *inside-out* order. For more, see [Byron & Wattenberg][1].
|
|
930
|
+
*
|
|
931
|
+
* [1]: https://leebyron.com/streamgraph/
|
|
932
|
+
*/
|
|
933
|
+
export type StackOffsetName =
|
|
934
|
+
| 'center'
|
|
935
|
+
| 'normalize'
|
|
936
|
+
| 'wiggle';
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* A stack offset method; one of:
|
|
940
|
+
*
|
|
941
|
+
* - *normalize* - rescale each stack to fill [0, 1]
|
|
942
|
+
* - *center* - align the centers of all stacks
|
|
943
|
+
* - *wiggle* - translate stacks to minimize apparent movement
|
|
944
|
+
*
|
|
945
|
+
* If a given stack has zero total value, the *normalize* offset will not adjust
|
|
946
|
+
* the stack’s position. Both the *center* and *wiggle* offsets ensure that the
|
|
947
|
+
* lowest element across stacks starts at zero for better default axes. The
|
|
948
|
+
* *wiggle* offset is recommended for streamgraphs in conjunction with the
|
|
949
|
+
* *inside-out* order. For more, see [Byron & Wattenberg][1].
|
|
950
|
+
*
|
|
951
|
+
* [1]: https://leebyron.com/streamgraph/
|
|
952
|
+
*/
|
|
953
|
+
export type StackOffset = StackOffsetName;
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* The built-in stack order methods; one of:
|
|
957
|
+
*
|
|
958
|
+
* - *x* - alias of *value*; for stackX only
|
|
959
|
+
* - *y* - alias of *value*; for stackY only
|
|
960
|
+
* - *value* - ascending value (or descending with **reverse**)
|
|
961
|
+
* - *sum* - total value per series
|
|
962
|
+
* - *appearance* - position of maximum value per series
|
|
963
|
+
* - *inside-out* (default with *wiggle*) - order the earliest-appearing series on the inside
|
|
964
|
+
*
|
|
965
|
+
* The *inside-out* order is recommended for streamgraphs in conjunction with
|
|
966
|
+
* the *wiggle* offset. For more, see [Byron & Wattenberg][1].
|
|
967
|
+
*
|
|
968
|
+
* [1]: https://leebyron.com/streamgraph/
|
|
969
|
+
*/
|
|
970
|
+
export type StackOrderName = 'value' | 'x' | 'y' | 'z' | 'sum' | 'appearance' | 'inside-out';
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* How to order layers prior to stacking; one of:
|
|
974
|
+
*
|
|
975
|
+
* - a named stack order method such as *inside-out* or *sum*
|
|
976
|
+
* - a field name, for natural order of the corresponding values
|
|
977
|
+
* - an array of explicit **z** values in the desired order
|
|
978
|
+
*/
|
|
979
|
+
export type StackOrder =
|
|
980
|
+
| StackOrderName
|
|
981
|
+
| `-${StackOrderName}`
|
|
982
|
+
| (string & Record<never, never>)
|
|
983
|
+
| any[];
|
|
984
|
+
|
|
985
|
+
/** Options for the stack transform. */
|
|
986
|
+
export interface StackOptions {
|
|
987
|
+
/**
|
|
988
|
+
* After stacking, an optional **offset** can be applied to translate and
|
|
989
|
+
* scale stacks, say to produce a streamgraph; defaults to null for a zero
|
|
990
|
+
* baseline (**y** = 0 for stackY, and **x** = 0 for stackX). If the *wiggle*
|
|
991
|
+
* offset is used, the default **order** changes to *inside-out*.
|
|
992
|
+
*/
|
|
993
|
+
offset?: StackOffset | null | ParamRef;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* The order in which stacks are layered; one of:
|
|
997
|
+
*
|
|
998
|
+
* - null (default) for input order
|
|
999
|
+
* - a named stack order method such as *inside-out* or *sum*
|
|
1000
|
+
* - a field name, for natural order of the corresponding values
|
|
1001
|
+
* - a function of data, for natural order of the corresponding values
|
|
1002
|
+
* - an array of explicit **z** values in the desired order
|
|
1003
|
+
*
|
|
1004
|
+
* If the *wiggle* **offset** is used, as for a streamgraph, the default
|
|
1005
|
+
* changes to *inside-out*.
|
|
1006
|
+
*/
|
|
1007
|
+
order?: StackOrder | null | ParamRef;
|
|
1008
|
+
|
|
1009
|
+
/** If true, reverse the effective order of the stacks. */
|
|
1010
|
+
reverse?: boolean | ParamRef;
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* The **z** channel defines the series of each value in the stack. Used when
|
|
1014
|
+
* the **order** is *sum*, *appearance*, *inside-out*, or an explicit array of
|
|
1015
|
+
* **z** values.
|
|
1016
|
+
*/
|
|
1017
|
+
z?: ChannelValue;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* The built-in marker implementations; one of:
|
|
1022
|
+
*
|
|
1023
|
+
* - *arrow* - an arrowhead with *auto* orientation
|
|
1024
|
+
* - *arrow-reverse* - an arrowhead with *auto-start-reverse* orientation
|
|
1025
|
+
* - *dot* - a filled *circle* with no stroke and 2.5px radius
|
|
1026
|
+
* - *circle-fill* - a filled circle with a white stroke and 3px radius
|
|
1027
|
+
* - *circle-stroke* - a stroked circle with a white fill and 3px radius
|
|
1028
|
+
* - *circle* - alias for *circle-fill*
|
|
1029
|
+
* - *tick* - a small opposing line
|
|
1030
|
+
* - *tick-x* - a small horizontal line
|
|
1031
|
+
* - *tick-y* - a small vertical line
|
|
1032
|
+
*/
|
|
1033
|
+
export type MarkerName =
|
|
1034
|
+
| 'arrow'
|
|
1035
|
+
| 'arrow-reverse'
|
|
1036
|
+
| 'dot'
|
|
1037
|
+
| 'circle'
|
|
1038
|
+
| 'circle-fill'
|
|
1039
|
+
| 'circle-stroke'
|
|
1040
|
+
| 'tick'
|
|
1041
|
+
| 'tick-x'
|
|
1042
|
+
| 'tick-y';
|
|
1043
|
+
|
|
1044
|
+
/** Options for marks that support markers, such as lines and links. */
|
|
1045
|
+
export interface MarkerOptions {
|
|
1046
|
+
/**
|
|
1047
|
+
* Shorthand to set the same default for markerStart, markerMid, and
|
|
1048
|
+
* markerEnd; one of:
|
|
1049
|
+
*
|
|
1050
|
+
* - a marker name such as *arrow* or *circle*
|
|
1051
|
+
* - *none* (default) - no marker
|
|
1052
|
+
* * true - alias for *circle-fill*
|
|
1053
|
+
* * false or null - alias for *none*
|
|
1054
|
+
*/
|
|
1055
|
+
marker?: MarkerName | 'none' | boolean | null | ParamRef;
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* The marker for the starting point of a line segment; one of:
|
|
1059
|
+
*
|
|
1060
|
+
* - a marker name such as *arrow* or *circle*
|
|
1061
|
+
* * *none* (default) - no marker
|
|
1062
|
+
* * true - alias for *circle-fill*
|
|
1063
|
+
* * false or null - alias for *none*
|
|
1064
|
+
*/
|
|
1065
|
+
markerStart?: MarkerName | 'none' | boolean | null | ParamRef;
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* The marker for any middle (interior) points of a line segment. If the line
|
|
1069
|
+
* segment only has a start and end point, this option has no effect. One of:
|
|
1070
|
+
*
|
|
1071
|
+
* - a marker name such as *arrow* or *circle*
|
|
1072
|
+
* * *none* (default) - no marker
|
|
1073
|
+
* * true - alias for *circle-fill*
|
|
1074
|
+
* * false or null - alias for *none*
|
|
1075
|
+
* * a function - a custom marker function; see below
|
|
1076
|
+
*/
|
|
1077
|
+
markerMid?: MarkerName | 'none' | boolean | null | ParamRef;
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* The marker for the ending point of a line segment; one of:
|
|
1081
|
+
*
|
|
1082
|
+
* - a marker name such as *arrow* or *circle*
|
|
1083
|
+
* * *none* (default) - no marker
|
|
1084
|
+
* * true - alias for *circle-fill*
|
|
1085
|
+
* * false or null - alias for *none*
|
|
1086
|
+
*/
|
|
1087
|
+
markerEnd?: MarkerName | 'none' | boolean | null | ParamRef;
|
|
1088
|
+
}
|