-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathaxis.d.ts
More file actions
209 lines (191 loc) · 9.78 KB
/
axis.d.ts
File metadata and controls
209 lines (191 loc) · 9.78 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
import type {CompoundMark, Data, MarkOptions} from "../mark.js";
import type {ScaleOptions} from "../scales.js";
import type {RuleX, RuleXOptions, RuleY, RuleYOptions} from "./rule.js";
import type {TextOptions} from "./text.js";
import type {TickXOptions, TickYOptions} from "./tick.js";
/** The subset of scale options for grids. */
type GridScaleOptions = Pick<ScaleOptions, "interval" | "ticks" | "tickSpacing">;
/** The subset of scale options for axes. */
type AxisScaleOptions = Pick<ScaleOptions, "tickSize" | "tickPadding" | "tickFormat" | "tickRotate" | "label" | "labelOffset" | "labelAnchor" | "labelArrow">; // prettier-ignore
/** Options for the grid marks. */
export interface GridOptions extends GridScaleOptions {
/**
* The side of the frame on which to place the axis: *top* or *bottom* for
* horizontal axes (axisX and axisFx) and their associated vertical grids
* (gridX and gridFx), or *left* or *right* for vertical axes (axisY and
* axisFY) and their associated horizontal grids (gridY and gridFy).
*
* The default **anchor** depends on the associated scale:
*
* - *x* - *bottom*
* - *y* - *left*
* - *fx* - *top* if there is a *bottom* *x* axis, and otherwise *bottom*
* - *fy* - *right* if there is a *left* *y* axis, and otherwise *right*
*
* For grids, the **anchor** also affects the extent of grid lines when the
* opposite dimension is specified (**x** for gridY and **y** for gridX). For
* example, to draw a horizontal gridY between the *right* edge of the frame
* and the specified **x** value:
*
* ```js
* Plot.gridY({x: (y) => aapl.find((d) => d.Close >= y)?.Date, anchor: "right"})
* ```
*/
anchor?: "top" | "right" | "bottom" | "left";
/**
* A shorthand for setting both **fill** and **stroke**; affects the stroke of
* tick vectors and grid rules, and the fill of tick texts and axis label
* texts; defaults to *currentColor*.
*/
color?: MarkOptions["stroke"];
/**
* A shorthand for setting both **fillOpacity** and **strokeOpacity**; affects
* the stroke opacity of tick vectors and grid rules, and the fill opacity of
* tick texts and axis label texts; defaults to 1 for axes and 0.1 for grids.
*/
opacity?: MarkOptions["opacity"];
}
/** Options for the axis marks. */
export interface AxisOptions extends GridOptions, MarkOptions, TextOptions, AxisScaleOptions {
/** The tick text **stroke**, say for a *white* outline to improve legibility; defaults to null. */
textStroke?: MarkOptions["stroke"];
/** The tick text **strokeOpacity**; defaults to 1; has no effect unless **textStroke** is set. */
textStrokeOpacity?: MarkOptions["strokeOpacity"];
/** The tick text **strokeWidth**; defaults to 4; has no effect unless **textStroke** is set. */
textStrokeWidth?: MarkOptions["strokeWidth"];
}
/** Options for the axisX and axisFx marks. */
export interface AxisXOptions extends AxisOptions, TickXOptions {}
/** Options for the axisY and axisFy marks. */
export interface AxisYOptions extends AxisOptions, TickYOptions {}
/** Options for the gridX and gridFx marks. */
export interface GridXOptions extends GridOptions, Omit<RuleXOptions, "interval"> {}
/** Options for the gridY and gridFy marks. */
export interface GridYOptions extends GridOptions, Omit<RuleYOptions, "interval"> {}
/**
* Returns a new compound axis mark to document the visual encoding of the
* vertical position *y* scale, comprised of (up to) three marks: a vector for
* ticks, a text for tick labels, and another text for an axis label. The *data*
* defaults to tick values sampled from the *y* scale’s domain; if desired,
* specify the axis mark’s *data* explicitly, or use one of the **ticks**,
* **tickSpacing**, or **interval** options.
*
* The **facetAnchor** option defaults to *right-empty* if **anchor** is
* *right*, and *left-empty* if **anchor** is *left*. The default margins
* likewise depend on **anchor** as follows; in order of **marginTop**,
* **marginRight**, **marginBottom**, and **marginLeft**, in pixels:
*
* - *right* - 20, 40, 20, 0
* - *left* - 20, 0, 20, 40
*
* For simplicity, and for consistent layout across plots, default axis margins
* are not affected by tick labels. If tick labels are too long, either increase
* the margin or shorten the labels: use the *k* SI-prefix tick format; use the
* **transform** *y*-scale option to show thousands or millions; or use the
* **textOverflow** and **lineWidth** options to clip.
*/
export function axisY(data?: Data, options?: AxisYOptions): CompoundMark;
export function axisY(options?: AxisYOptions): CompoundMark;
/**
* Returns a new compound axis mark to document the visual encoding of the
* vertical facet position *fy* scale, comprised of (up to) three marks: a
* vector for ticks, a text for tick labels, and another text for an axis label.
* The *data* defaults to the *fy* scale’s domain; if desired, specify the axis
* mark’s *data* explicitly, or use one of the **ticks**, **tickSpacing**, or
* **interval** options.
*
* The **facetAnchor** option defaults to *right-empty* if **anchor** is
* *right*, and *left-empty* if **anchor** is *left*. The default margins
* likewise depend on **anchor** as follows; in order of **marginTop**,
* **marginRight**, **marginBottom**, and **marginLeft**, in pixels:
*
* - *right* - 20, 40, 20, 0
* - *left* - 20, 0, 20, 40
*
* For simplicity, and for consistent layout across plots, default axis margins
* are not affected by tick labels. If tick labels are too long, either increase
* the margin or shorten the labels, say by using the **textOverflow** and
* **lineWidth** options to clip.
*/
export function axisFy(data?: Data, options?: AxisYOptions): CompoundMark;
export function axisFy(options?: AxisYOptions): CompoundMark;
/**
* Returns a new compound axis mark to document the visual encoding of the
* horizontal position *x* scale, comprised of (up to) three marks: a vector for
* ticks, a text for tick labels, and another text for an axis label. The *data*
* defaults to tick values sampled from the *x* scale’s domain; if desired,
* specify the axis mark’s *data* explicitly, or use one of the **ticks**,
* **tickSpacing**, or **interval** options.
*
* The **facetAnchor** option defaults to *bottom-empty* if **anchor** is
* *bottom*, and *top-empty* if **anchor** is *top*. The default margins
* likewise depend on **anchor** as follows; in order of **marginTop**,
* **marginRight**, **marginBottom**, and **marginLeft**, in pixels:
*
* - *top* - 30, 20, 0, 20
* - *bottom* - 0, 20, 30, 20
*
* For simplicity, and for consistent layout across plots, default axis margins
* are not affected by tick labels. If tick labels are too long, either increase
* the margin or shorten the labels: use the *k* SI-prefix tick format; use the
* **transform** *x*-scale option to show thousands or millions; or use the
* **textOverflow** and **lineWidth** options to clip; or use the **tickRotate**
* option to rotate.
*/
export function axisX(data?: Data, options?: AxisXOptions): CompoundMark;
export function axisX(options?: AxisXOptions): CompoundMark;
/**
* Returns a new compound axis mark to document the visual encoding of the
* horizontal facet position *fx* scale, comprised of (up to) three marks: a
* vector for ticks, a text for tick labels, and another text for an axis label.
* The *data* defaults to the *fx* scale’s domain; if desired, specify the axis
* mark’s *data* explicitly, or use one of the **ticks**, **tickSpacing**, or
* **interval** options.
*
* The **facetAnchor** and **frameAnchor** options defaults to **anchor**. The
* default margins likewise depend on **anchor** as follows; in order of
* **marginTop**, **marginRight**, **marginBottom**, and **marginLeft**, in
* pixels:
*
* - *top* - 30, 20, 0, 20
* - *bottom* - 0, 20, 30, 20
*
* For simplicity, and for consistent layout across plots, default axis margins
* are not affected by tick labels. If tick labels are too long, either increase
* the margin or shorten the labels, say by using the **textOverflow** and
* **lineWidth** options to clip, or using the **tickRotate** option to rotate.
*/
export function axisFx(data?: Data, options?: AxisXOptions): CompoundMark;
export function axisFx(options?: AxisXOptions): CompoundMark;
/**
* Returns a new horizontally-positioned ruleX mark (a vertical line, |) that
* renders a grid for the *x* scale. The *data* defaults to tick values sampled
* from the *x* scale’s domain; if desired, specify the *data* explicitly, or
* use one of the **ticks**, **tickSpacing**, or **interval** options.
*/
export function gridX(data?: Data, options?: GridXOptions): RuleX;
export function gridX(options?: GridXOptions): RuleX;
/**
* Returns a new horizontally-positioned ruleX mark (a vertical line, |) that
* renders a grid for the *fx* scale. The *data* defaults to the *fx* scale’s
* domain; if desired, specify the *data* explicitly, or use the **ticks**
* option.
*/
export function gridFx(data?: Data, options?: GridXOptions): RuleX;
export function gridFx(options?: GridXOptions): RuleX;
/**
* Returns a new vertically-positioned ruleY mark (a horizontal line, —) that
* renders a grid for the *y* scale. The *data* defaults to tick values sampled
* from the *y* scale’s domain; if desired, specify the *data* explicitly, or
* use one of the **ticks**, **tickSpacing**, or **interval** options.
*/
export function gridY(data?: Data, options?: GridYOptions): RuleY;
export function gridY(options?: GridYOptions): RuleY;
/**
* Returns a new vertically-positioned ruleY mark (a horizontal line, —) that
* renders a grid for the *fy* scale. The *data* defaults to the *fy* scale’s
* domain; if desired, specify the *data* explicitly, or use the **ticks**
* option.
*/
export function gridFy(data?: Data, options?: GridYOptions): RuleY;
export function gridFy(options?: GridYOptions): RuleY;