@@ -3,28 +3,125 @@ import type {InsetOptions} from "../inset.js";
3
3
import type { Interval } from "../interval.js" ;
4
4
import type { Data , MarkOptions , RenderableMark } from "../mark.js" ;
5
5
6
+ /** Options for the ruleX and ruleY marks. */
6
7
interface RuleOptions extends MarkOptions {
8
+ /**
9
+ * How to convert a continuous value (**y** for ruleX, or **x** for ruleY)
10
+ * into an interval; one of:
11
+ *
12
+ * - an object that implements *floor*, *offset*, and *range* methods
13
+ * - a named time interval such as *day* (for date intervals)
14
+ * - a number (for number intervals), defining intervals at integer multiples of *n*
15
+ *
16
+ * For example, to bin Apple’s daily stock price by month, plotting a sequence
17
+ * of barcodes showing monthly distributions:
18
+ *
19
+ * ```js
20
+ * Plot.ruleY(aapl, {x: "Date", y: "Close", interval: "month"})
21
+ * ```
22
+ */
7
23
interval ?: Interval ;
8
24
}
9
25
26
+ /** Options for the ruleX mark. */
10
27
export interface RuleXOptions extends RuleOptions , Omit < InsetOptions , "insetLeft" | "insetRight" > {
28
+ /**
29
+ * The horizontal position of the tick; an optional channel bound to the *x*
30
+ * scale. If not specified, the rule will be horizontally centered in the
31
+ * plot’s frame.
32
+ */
11
33
x ?: ChannelValueSpec ;
34
+
35
+ /**
36
+ * Shorthand for specifying both the primary and secondary vertical position
37
+ * of the tick as the bounds of the containing interval; can only be used in
38
+ * conjunction with the **interval** option.
39
+ */
12
40
y ?: ChannelValueIntervalSpec ;
41
+
42
+ /**
43
+ * The primary (starting) vertical position of the tick; a channel bound to
44
+ * the *y* scale.
45
+ *
46
+ * If *y* represents ordinal values, use a tickX mark instead.
47
+ */
13
48
y1 ?: ChannelValueSpec ;
49
+
50
+ /**
51
+ * The secondary (ending) vertical position of the tick; a channel bound to
52
+ * the *y* scale.
53
+ *
54
+ * If *y* represents ordinal values, use a tickX mark instead.
55
+ */
14
56
y2 ?: ChannelValueSpec ;
15
57
}
16
58
59
+ /** Options for the ruleY mark. */
17
60
export interface RuleYOptions extends RuleOptions , Omit < InsetOptions , "insetTop" | "insetBottom" > {
61
+ /**
62
+ * Shorthand for specifying both the primary and secondary horizontal position
63
+ * of the tick as the bounds of the containing interval; can only be used in
64
+ * conjunction with the **interval** option.
65
+ */
18
66
x ?: ChannelValueIntervalSpec ;
67
+
68
+ /**
69
+ * The primary (starting) horizontal position of the tick; a channel bound to
70
+ * the *x* scale.
71
+ *
72
+ * If *x* represents ordinal values, use a tickY mark instead.
73
+ */
19
74
x1 ?: ChannelValueSpec ;
75
+
76
+ /**
77
+ * The secondary (ending) horizontal position of the tick; a channel bound to
78
+ * the *x* scale.
79
+ *
80
+ * If *x* represents ordinal values, use a tickY mark instead.
81
+ */
20
82
x2 ?: ChannelValueSpec ;
83
+
84
+ /**
85
+ * The vertical position of the tick; an optional channel bound to the *y*
86
+ * scale. If not specified, the rule will be vertically centered in the plot’s
87
+ * frame.
88
+ */
21
89
y ?: ChannelValueSpec ;
22
90
}
23
91
92
+ /**
93
+ * Returns a new horizontally-positioned ruleX mark (a vertical line, |) for the
94
+ * given *data* and *options*. The **x** channel specifies the rule’s horizontal
95
+ * position and defaults to identity, assuming that *data* = [*x₀*, *x₁*, *x₂*,
96
+ * …]; the optional **y1** and **y2** channels specify its vertical extent. For
97
+ * example, for a candlestick chart of Apple’s daily stock price:
98
+ *
99
+ * ```js
100
+ * Plot.ruleX(aapl, {x: "Date", y1: "Open", y2: "Close"})
101
+ * ```
102
+ *
103
+ * If *y* represents ordinal values, use a tickX mark instead.
104
+ */
24
105
export function ruleX ( data ?: Data , options ?: RuleXOptions ) : RuleX ;
25
106
107
+ /**
108
+ * Returns a new vertically-positioned ruleY mark (a horizontal line, —) for the
109
+ * given *data* and *options*. The **y** channel specifies the vertical position
110
+ * of the rule and defaults to identity, assuming that *data* = [*y₀*, *y₁*,
111
+ * *y₂*, …]; the optional **x1** and **x2** channels specify its horizontal
112
+ * extent. For example, to bin Apple’s daily stock price by month, plotting a
113
+ * sequence of barcodes showing monthly distributions:
114
+ *
115
+ * ```js
116
+ * Plot.ruleY(aapl, {x: "Date", y: "Close", interval: "month"})
117
+ * ```
118
+ *
119
+ * If *x* represents ordinal values, use a tickY mark instead.
120
+ */
26
121
export function ruleY ( data ?: Data , options ?: RuleYOptions ) : RuleY ;
27
122
123
+ /** The ruleX mark. */
28
124
export class RuleX extends RenderableMark { }
29
125
126
+ /** The ruleY mark. */
30
127
export class RuleY extends RenderableMark { }
0 commit comments