-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathbar.d.ts
More file actions
213 lines (200 loc) · 8.27 KB
/
bar.d.ts
File metadata and controls
213 lines (200 loc) · 8.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import type {ChannelValueIntervalSpec, ChannelValueSpec} from "../channel.js";
import type {InsetOptions} from "../inset.js";
import type {Interval} from "../interval.js";
import type {Data, MarkOptions, RenderableMark} from "../mark.js";
import type {StackOptions} from "../transforms/stack.js";
import type {RectCornerOptions} from "./rect.js";
/** Options for the barX and barY marks. */
interface BarOptions extends MarkOptions, InsetOptions, RectCornerOptions, StackOptions {
/**
* How to convert a continuous value (**x** for barX, or **y** for barY) into
* an interval (**x1** and **x2** for barX, or **y1** and **y2** for barY);
* one of:
*
* - an object that implements *floor*, *offset*, and *range* methods
* - a named time interval such as *day* (for date intervals)
* - a number (for number intervals), defining intervals at integer multiples of *n*
*
* For example, for a scatterplot showing the frequency distribution of
* English letters, where the vertical extent of each bar covers a unit
* percentage:
*
* ```js
* Plot.barY(alphabet, {x: "letter", y: "frequency", interval: 0.01})
* ```
*
* Setting this option disables the implicit stack transform (stackX for barX,
* or stackY for barY).
*/
interval?: Interval;
}
/** Options for the barX mark. */
export interface BarXOptions extends BarOptions {
/**
* The horizontal position (or length/width) channel, typically bound to the
* *x* scale.
*
* If neither **x1** nor **x2** nor **interval** is specified, an implicit
* stackX transform is applied and **x** defaults to the identity function,
* assuming that *data* = [*x₀*, *x₁*, *x₂*, …]. Otherwise, if an **interval**
* is specified, then **x1** and **x2** are derived from **x**, representing
* the lower and upper bound of the containing interval, respectively.
* Otherwise, if only one of **x1** or **x2** is specified, the other defaults
* to **x**, which defaults to zero.
*/
x?: ChannelValueIntervalSpec;
/**
* The required primary (starting, often left) horizontal position channel,
* typically bound to the *x* scale. Setting this option disables the implicit
* stackX transform.
*
* If *x* represents ordinal values, use a cell mark instead.
*/
x1?: ChannelValueSpec;
/**
* The required secondary (ending, often right) horizontal position channel,
* typically bound to the *x* scale. Setting this option disables the implicit
* stackX transform.
*
* If *x* represents ordinal values, use a cell mark instead.
*/
x2?: ChannelValueSpec;
/**
* The optional vertical position of the bar; an ordinal channel typically
* bound to the *y* scale. If not specified, the bar spans the vertical extent
* of the frame; otherwise the *y* scale must be a *band* scale.
*
* If *y* represents quantitative or temporal values, use a rectX mark
* instead.
*/
y?: ChannelValueSpec;
}
/** Options for the barY mark. */
export interface BarYOptions extends BarOptions {
/**
* The vertical position (or length/height) channel, typically bound to the
* *y* scale.
*
* If neither **y1** nor **y2** nor **interval** is specified, an implicit
* stackY transform is applied and **y** defaults to the identity function,
* assuming that *data* = [*y₀*, *y₁*, *y₂*, …]. Otherwise, if an **interval**
* is specified, then **y1** and **y2** are derived from **y**, representing
* the lower and upper bound of the containing interval, respectively.
* Otherwise, if only one of **y1** or **y2** is specified, the other defaults
* to **y**, which defaults to zero.
*/
y?: ChannelValueIntervalSpec;
/**
* The required primary (starting, often bottom) vertical position channel,
* typically bound to the *y* scale. Setting this option disables the implicit
* stackY transform.
*
* If *y* represents ordinal values, use a cell mark instead.
*/
y1?: ChannelValueSpec;
/**
* The required secondary (ending, often top) horizontal position channel,
* typically bound to the *y* scale. Setting this option disables the implicit
* stackY transform.
*
* If *y* represents ordinal values, use a cell mark instead.
*/
y2?: ChannelValueSpec;
/**
* The optional horizontal position of the bar; an ordinal channel typically
* bound to the *x* scale. If not specified, the bar spans the horizontal
* extent of the frame; otherwise the *x* scale must be a *band* scale.
*
* If *x* represents quantitative or temporal values, use a rectY mark
* instead.
*/
x?: ChannelValueSpec;
}
/**
* Returns a new horizontal bar mark for the given *data* and *options*; the
* required *x* values should be quantitative or temporal, and the optional *y*
* values should be ordinal. For example, for a horizontal bar chart of English
* letter frequency:
*
* ```js
* Plot.barX(alphabet, {x: "frequency", y: "letter"})
* ```
*
* If neither **x1** nor **x2** nor **interval** is specified, an implicit
* stackX transform is applied and **x** defaults to the identity function,
* assuming that *data* = [*x₀*, *x₁*, *x₂*, …]. Otherwise, if an **interval** is
* specified, then **x1** and **x2** are derived from **x**, representing the
* lower and upper bound of the containing interval, respectively. Otherwise, if
* only one of **x1** or **x2** is specified, the other defaults to **x**, which
* defaults to zero.
*
* The optional **y** ordinal channel specifies the vertical position; it is
* typically bound to the *y* scale, which must be a *band* scale. If the **y**
* channel is not specified, the bar will span the vertical extent of the plot’s
* frame. The barX mark is often used in conjunction with the groupY transform.
* For a stacked histogram of penguins by species, colored by sex:
*
* ```js
* Plot.barX(penguins, Plot.groupY({x: "count"}, {y: "species", fill: "sex"}))
* ```
*
* If *y* is quantitative, use the rectX mark instead, possibly with a binY
* transform. If *x* is ordinal, use the cell mark instead, possibly with a
* group transform.
*
* If *options* is undefined, then **y** defaults to the zero-based index of
* *data* [0, 1, 2, …], allowing a quick bar chart from an array of numbers:
*
* ```js
* Plot.barX([4, 9, 24, 46, 66, 7])
* ```
*/
export function barX(data?: Data, options?: BarXOptions): BarX;
/**
* Returns a new vertical bar mark for the given *data* and *options*; the
* required *y* values should be quantitative or temporal, and the optional *x*
* values should be ordinal. For example, for a vertical bar chart of English
* letter frequency:
*
* ```js
* Plot.barY(alphabet, {y: "frequency", x: "letter"})
* ```
*
* If neither **y1** nor **y2** nor **interval** is specified, an implicit
* stackY transform is applied and **y** defaults to the identity function,
* assuming that *data* = [*y₀*, *y₁*, *y₂*, …]. Otherwise, if an **interval** is
* specified, then **y1** and **y2** are derived from **y**, representing the
* lower and upper bound of the containing interval, respectively. Otherwise, if
* only one of **y1** or **y2** is specified, the other defaults to **y**, which
* defaults to zero.
*
* The optional **x** ordinal channel specifies the horizontal position; it is
* typically bound to the *x* scale, which must be a *band* scale. If the **x**
* channel is not specified, the bar will span the horizontal extent of the
* plot’s frame. The barY mark is often used in conjunction with the groupX
* transform. For a stacked histogram of penguins by species, colored by sex:
*
* ```js
* Plot.barY(penguins, Plot.groupX({y: "count"}, {x: "species", fill: "sex"}))
* ```
*
* If *x* is quantitative, use the rectY mark instead, possibly with a binX
* transform. If *y* is ordinal, use the cell mark instead, possibly with a
* group transform.
*
* If *options* is undefined, then **x** defaults to the zero-based index of
* *data* [0, 1, 2, …], allowing a quick bar chart from an array of numbers:
*
* ```js
* Plot.barY([4, 9, 24, 46, 66, 7])
* ```
*/
export function barY(data?: Data, options?: BarYOptions): BarY;
/** The barX mark. */
export class BarX extends RenderableMark {
constructor(data?: Data, options?: BarXOptions);
}
/** The barY mark. */
export class BarY extends RenderableMark {
constructor(data?: Data, options?: BarYOptions);
}