-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathrule.d.ts
More file actions
147 lines (134 loc) · 4.87 KB
/
rule.d.ts
File metadata and controls
147 lines (134 loc) · 4.87 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
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 {MarkerOptions} from "../marker.js";
/** Options for the ruleX and ruleY marks. */
interface RuleOptions extends MarkOptions, MarkerOptions {
/**
* How to convert a continuous value (**y** for ruleX, or **x** for ruleY)
* into an interval (**y1** and **y2** for ruleX, or **x1** and **x2** for
* ruleY); 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, to bin Apple’s daily stock price by month, plotting a sequence
* of barcodes showing monthly distributions:
*
* ```js
* Plot.ruleY(aapl, {x: "Date", y: "Close", interval: "month"})
* ```
*/
interval?: Interval;
}
/** Options for the ruleX mark. */
export interface RuleXOptions extends RuleOptions, Omit<InsetOptions, "insetLeft" | "insetRight"> {
/**
* The horizontal position of the tick; an optional channel bound to the *x*
* scale. If not specified, the rule will be horizontally centered in the
* plot’s frame.
*/
x?: ChannelValueSpec;
/**
* Shorthand for specifying both the primary and secondary vertical position
* of the tick as the bounds of the containing interval; can only be used in
* conjunction with the **interval** option.
*/
y?: ChannelValueIntervalSpec;
/**
* The primary (starting, often bottom) vertical position of the tick; a
* channel bound to the *y* scale.
*
* If *y* represents ordinal values, use a tickX mark instead.
*/
y1?: ChannelValueSpec;
/**
* The secondary (ending, often top) vertical position of the tick; a channel
* bound to the *y* scale.
*
* If *y* represents ordinal values, use a tickX mark instead.
*/
y2?: ChannelValueSpec;
}
/** Options for the ruleY mark. */
export interface RuleYOptions extends RuleOptions, Omit<InsetOptions, "insetTop" | "insetBottom"> {
/**
* Shorthand for specifying both the primary and secondary horizontal position
* of the tick as the bounds of the containing interval; can only be used in
* conjunction with the **interval** option.
*/
x?: ChannelValueIntervalSpec;
/**
* The primary (starting, often left) horizontal position of the tick; a
* channel bound to the *x* scale.
*
* If *x* represents ordinal values, use a tickY mark instead.
*/
x1?: ChannelValueSpec;
/**
* The secondary (ending, often right) horizontal position of the tick; a
* channel bound to the *x* scale.
*
* If *x* represents ordinal values, use a tickY mark instead.
*/
x2?: ChannelValueSpec;
/**
* The vertical position of the tick; an optional channel bound to the *y*
* scale. If not specified, the rule will be vertically centered in the plot’s
* frame.
*/
y?: ChannelValueSpec;
}
/**
* Returns a new horizontally-positioned ruleX mark (a vertical line, |) for the
* given *data* and *options*. The **x** channel specifies the rule’s horizontal
* position and defaults to identity, assuming that *data* = [*x₀*, *x₁*, *x₂*,
* …]; the optional **y1** and **y2** channels specify its vertical extent. For
* example, for a candlestick chart of Apple’s daily stock price:
*
* ```js
* Plot.ruleX(aapl, {x: "Date", y1: "Open", y2: "Close"})
* ```
*
* The ruleX mark is often used to highlight specific *x* values. For example,
* to draw a rule at *x* = 0:
*
* ```js
* Plot.ruleX([0])
* ```
*
* If *y* represents ordinal values, use a tickX mark instead.
*/
export function ruleX(data?: Data, options?: RuleXOptions): RuleX;
/**
* Returns a new vertically-positioned ruleY mark (a horizontal line, —) for the
* given *data* and *options*. The **y** channel specifies the vertical position
* of the rule and defaults to identity, assuming that *data* = [*y₀*, *y₁*,
* *y₂*, …]; the optional **x1** and **x2** channels specify its horizontal
* extent. For example, to bin Apple’s daily stock price by month, plotting a
* sequence of barcodes showing monthly distributions:
*
* ```js
* Plot.ruleY(aapl, {x: "Date", y: "Close", interval: "month"})
* ```
*
* The ruleY mark is often used to highlight specific *y* values. For example,
* to draw a rule at *y* = 0:
*
* ```js
* Plot.ruleY([0])
* ```
*
* If *x* represents ordinal values, use a tickY mark instead.
*/
export function ruleY(data?: Data, options?: RuleYOptions): RuleY;
/** The ruleX mark. */
export class RuleX extends RenderableMark {
constructor(data?: Data, options?: RuleXOptions);
}
/** The ruleY mark. */
export class RuleY extends RenderableMark {
constructor(data?: Data, options?: RuleYOptions);
}