@@ -4,30 +4,168 @@ import type {Data, MarkOptions, RenderableMark} from "../mark.js";
4
4
import type { BinOptions , BinReducer } from "../transforms/bin.js" ;
5
5
import type { StackOptions } from "../transforms/stack.js" ;
6
6
7
+ /** Options for the area, areaX, and areaY marks. */
7
8
export interface AreaOptions extends MarkOptions , StackOptions , CurveOptions {
9
+ /**
10
+ * The required primary horizontal position channel, representing the area’s
11
+ * baseline, typically bound to the *x* scale. For areaX, setting this option
12
+ * disables the implicit stackX transform.
13
+ */
8
14
x1 ?: ChannelValueSpec ;
15
+
16
+ /**
17
+ * The optional secondary horizontal position channel, representing the area’s
18
+ * topline, typically bound to the *x* scale; if not specified, **x1** is
19
+ * used. For areaX, setting this option disables the implicit stackX
20
+ * transform.
21
+ */
9
22
x2 ?: ChannelValueSpec ;
23
+
24
+ /**
25
+ * The required primary vertical position channel, representing the area’s
26
+ * baseline, typically bound to the *y* scale. For areaY, setting this option
27
+ * disables the implicit stackY transform.
28
+ */
10
29
y1 ?: ChannelValueSpec ;
30
+
31
+ /**
32
+ * The optional secondary vertical position channel, representing the area’s
33
+ * topline, typically bound to the *y* scale; if not specified, **y1** is
34
+ * used. For areaY, setting this option disables the implicit stackY
35
+ * transform.
36
+ */
11
37
y2 ?: ChannelValueSpec ;
38
+
39
+ /**
40
+ * The optional ordinal **z** channel, for grouping data into (possibly
41
+ * stacked) series to be drawn as separate areas. If not specified, it
42
+ * defaults to **fill** if a channel, or **stroke** if a channel.
43
+ */
12
44
z ?: ChannelValue ;
13
45
}
14
46
47
+ /** Options for the areaX mark. */
15
48
export interface AreaXOptions extends Omit < AreaOptions , "y1" | "y2" > , BinOptions {
49
+ /**
50
+ * The horizontal position (or length) channel, typically bound to the *x*
51
+ * scale.
52
+ *
53
+ * If neither **x1** nor **x2** is specified, an implicit stackX transform is
54
+ * applied and **x** defaults to the identity function, assuming that *data* =
55
+ * [*x₀*, *x₁*, *x₂*, …]. Otherwise, if only one of **x1** or **x2** is
56
+ * specified, the other defaults to **x**, which defaults to zero.
57
+ */
16
58
x ?: ChannelValueSpec ;
59
+
60
+ /**
61
+ * The vertical position channel, typically bound to the *y* scale; defaults
62
+ * to the zero-based index of the data.
63
+ *
64
+ * If an **interval** is specified, **x** values are binned accordingly,
65
+ * allowing zeroes for empty bins instead of interpolating across gaps. This
66
+ * is recommended to “regularize” sampled data; for example, if your data
67
+ * represents timestamped observations and you expect one observation per day,
68
+ * use *day* as the **interval**.
69
+ */
17
70
y ?: ChannelValueDenseBinSpec ;
71
+
72
+ /**
73
+ * How to reduce **x** values when the **y** channel is binned with an
74
+ * **interval**; defaults to *first*. For example, to create a vertical
75
+ * density plot (count of *y* values binned every 0.5):
76
+ *
77
+ * ```js
78
+ * Plot.areaX(data, {y: "value", interval: 0.5, reduce: "count"})
79
+ * ```
80
+ */
18
81
reduce ?: BinReducer ;
19
82
}
20
83
84
+ /** Options for the areaY mark. */
21
85
export interface AreaYOptions extends Omit < AreaOptions , "x1" | "x2" > , BinOptions {
86
+ /**
87
+ * The horizontal position channel, typically bound to the *x* scale; defaults
88
+ * to the zero-based index of the data.
89
+ *
90
+ * If an **interval** is specified, **x** values are binned accordingly,
91
+ * allowing zeroes for empty bins instead of interpolating across gaps. This
92
+ * is recommended to “regularize” sampled data; for example, if your data
93
+ * represents timestamped observations and you expect one observation per day,
94
+ * use *day* as the **interval**.
95
+ */
22
96
x ?: ChannelValueDenseBinSpec ;
97
+
98
+ /**
99
+ * The vertical position (or length) channel, typically bound to the *y*
100
+ * scale.
101
+ *
102
+ * If neither **y1** nor **y2** is specified, an implicit stackY transform is
103
+ * applied and **y** defaults to the identity function, assuming that *data* =
104
+ * [*y₀*, *y₁*, *y₂*, …]. Otherwise, if only one of **y1** or **y2** is
105
+ * specified, the other defaults to **y**, which defaults to zero.
106
+ */
23
107
y ?: ChannelValueSpec ;
108
+
109
+ /**
110
+ * How to reduce **y** values when the **x** channel is binned with an
111
+ * **interval**; defaults to *first*. For example, for an area chart of the
112
+ * count of records by month:
113
+ *
114
+ * ```js
115
+ * Plot.areaY(records, {x: "Date", interval: "month", reduce: "count"})
116
+ * ```
117
+ */
24
118
reduce ?: BinReducer ;
25
119
}
26
120
121
+ /**
122
+ * Returns a new area with the given *data* and *options*. The area mark is
123
+ * rarely used directly; it is only needed when the baseline and topline have
124
+ * neither *x* nor *y* values in common. Use areaY for a horizontal orientation
125
+ * where the baseline and topline share *x* values, or areaX for a vertical
126
+ * orientation where the baseline and topline share *y* values.
127
+ */
27
128
export function area ( data ?: Data , options ?: AreaOptions ) : Area ;
28
129
130
+ /**
131
+ * Returns a new vertically-oriented area for the given *data* and *options*,
132
+ * where the baseline and topline share **y** values, as in a time-series area
133
+ * chart where time goes up↑.
134
+ *
135
+ * ```js
136
+ * Plot.areaX(aapl, {y: "Date", x: "Close"})
137
+ * ```
138
+ *
139
+ * Variable aesthetic channels are supported: if the **fill** is defined as a
140
+ * channel, the area will be broken into contiguous overlapping sections when
141
+ * the fill color changes; the fill color will apply to the interval spanning
142
+ * the current data point and the following data point. This behavior also
143
+ * applies to the **fillOpacity**, **stroke**, **strokeOpacity**,
144
+ * **strokeWidth**, **opacity**, **href**, **title**, and **ariaLabel**
145
+ * channels. When any of these channels are used, setting an explicit **z**
146
+ * channel (possibly to null) is strongly recommended.
147
+ */
29
148
export function areaX ( data ?: Data , options ?: AreaXOptions ) : Area ;
30
149
150
+ /**
151
+ * Returns a new horizontall-oriented area for the given *data* and *options*,
152
+ * where the baseline and topline share **x** values, as in a time-series area
153
+ * chart where time goes right→.
154
+ *
155
+ * ```js
156
+ * Plot.areaY(aapl, {x: "Date", y: "Close"})
157
+ * ```
158
+ *
159
+ * Variable aesthetic channels are supported: if the **fill** is defined as a
160
+ * channel, the area will be broken into contiguous overlapping sections when
161
+ * the fill color changes; the fill color will apply to the interval spanning
162
+ * the current data point and the following data point. This behavior also
163
+ * applies to the **fillOpacity**, **stroke**, **strokeOpacity**,
164
+ * **strokeWidth**, **opacity**, **href**, **title**, and **ariaLabel**
165
+ * channels. When any of these channels are used, setting an explicit **z**
166
+ * channel (possibly to null) is strongly recommended.
167
+ */
31
168
export function areaY ( data ?: Data , options ?: AreaYOptions ) : Area ;
32
169
170
+ /** The area mark. */
33
171
export class Area extends RenderableMark { }
0 commit comments