@@ -3,33 +3,145 @@ import type {Interval} from "../interval.js";
3
3
import type { Data , FrameAnchor , MarkOptions , RenderableMark } from "../mark.js" ;
4
4
import type { SymbolType } from "../symbol.js" ;
5
5
6
+ /** Options for the dot mark. */
6
7
export interface DotOptions extends MarkOptions {
8
+ /**
9
+ * The horizontal position channel specifying the dot’s center, typically
10
+ * bound to the *x* scale.
11
+ */
7
12
x ?: ChannelValueSpec ;
13
+
14
+ /**
15
+ * The vertical position channel specifying the dot’s center, typically bound
16
+ * to the *y* scale.
17
+ */
8
18
y ?: ChannelValueSpec ;
19
+
20
+ /**
21
+ * The radius of dots; either a channel or constant. When a number, it is
22
+ * interpreted as a constant radius in pixels. Otherwise it is interpreted as
23
+ * a channel, typically bound to the *r* channel, which defaults to the *sqrt*
24
+ * type for proportional symbols. The radius defaults to 4.5 pixels when using
25
+ * the **symbol** channel, and otherwise 3 pixels. Dots with a nonpositive
26
+ * radius are not drawn.
27
+ */
9
28
r ?: ChannelValueSpec | number ;
29
+
30
+ /**
31
+ * The rotation angle of dots in degrees clockwise; either a channel or a
32
+ * constant. When a number, it is interpreted as a constant; otherwise it is
33
+ * interpreted as a channel. Defaults to 0°, pointing up.
34
+ */
10
35
rotate ?: ChannelValue | number ;
36
+
37
+ /**
38
+ * The categorical symbol; either a channel or a constant. A constant symbol
39
+ * can be specified by a valid symbol name such as *star*, or a symbol object
40
+ * (implementing the draw method); otherwise it is interpreted as a channel.
41
+ * Defaults to *circle* for the **dot** mark, and *hexagon* for the
42
+ * **hexagon** mark.
43
+ *
44
+ * If the **symbol** channel’s values are all symbols, symbol names, or
45
+ * nullish, the channel is unscaled (values are interpreted literally);
46
+ * otherwise, the channel is bound to the *symbol* scale.
47
+ */
11
48
symbol ?: ChannelValueSpec | SymbolType ;
49
+
50
+ /**
51
+ * The frame anchor may be specified as one of the four sides (*top*, *right*,
52
+ * *bottom*, *left*), one of the four corners (*top-left*, *top-right*,
53
+ * *bottom-right*, *bottom-left*), or the *middle* of the frame. It controls
54
+ * any component of the dot’s position not specified by **x** or **y**. For
55
+ * example, for a dots distributed in a horizontal line positioned at the top
56
+ * of the frame:
57
+ *
58
+ * ```js
59
+ * Plot.dot(data, {x: "date", frameAnchor: "top"})
60
+ * ```
61
+ */
12
62
frameAnchor ?: FrameAnchor ;
13
63
}
14
64
65
+ /** Options for the dotX mark. */
15
66
export interface DotXOptions extends Omit < DotOptions , "y" > {
67
+ /**
68
+ * The vertical position of the dot’s center, typically bound to the *y*
69
+ * scale.
70
+ */
16
71
y ?: ChannelValueIntervalSpec ;
72
+
73
+ /**
74
+ * An interval (such as *day* or a number), to transform **y** values to the
75
+ * middle of the interval.
76
+ */
17
77
interval ?: Interval ;
18
78
}
19
79
80
+ /** Options for the dotY mark. */
20
81
export interface DotYOptions extends Omit < DotOptions , "x" > {
82
+ /**
83
+ * The horizontal position of the dot’s center, typically bound to the *x*
84
+ * scale.
85
+ */
21
86
x ?: ChannelValueIntervalSpec ;
87
+
88
+ /**
89
+ * An interval (such as *day* or a number), to transform **x** values to the
90
+ * middle of the interval.
91
+ */
22
92
interval ?: Interval ;
23
93
}
24
94
95
+ /**
96
+ * Draws circles, or other symbols, as in a scatterplot. For example, a
97
+ * scatterplot of sales by fruit type (category) and units sold (quantitative):
98
+ *
99
+ * ```js
100
+ * Plot.dot(sales, {x: "units", y: "fruit"})
101
+ * ```
102
+ *
103
+ * If either **x** or **y** is not specified, the default is determined by the
104
+ * **frameAnchor** option. If none of **x**, **y**, and **frameAnchor** are
105
+ * specified, *data* is assumed to be an array of pairs [[*x₀*, *y₀*], [*x₁*,
106
+ * *y₁*], [*x₂*, *y₂*], …] such that **x** = [*x₀*, *x₁*, *x₂*, …] and **y** =
107
+ * [*y₀*, *y₁*, *y₂*, …].
108
+ *
109
+ * Dots are sorted by descending radius **r** by default to mitigate
110
+ * overplotting; set the **sort** option to null to draw them in input order.
111
+ */
25
112
export function dot ( data ?: Data , options ?: DotOptions ) : Dot ;
26
113
114
+ /**
115
+ * Like dot, except that **x** defaults to the identity function, assuming that
116
+ * *data* = [*x₀*, *x₁*, *x₂*, …].
117
+ *
118
+ * ```js
119
+ * Plot.dotX(cars.map(d => d["economy (mpg)"]))
120
+ * ```
121
+ *
122
+ * If an **interval** is specified, such as *day*, **y** is transformed to the
123
+ * middle of the interval.
124
+ */
27
125
export function dotX ( data ?: Data , options ?: DotXOptions ) : Dot ;
28
126
127
+ /**
128
+ * Like dot, except that **y** defaults to the identity function, assuming that
129
+ * *data* = [*y₀*, *y₁*, *y₂*, …].
130
+ *
131
+ * ```js
132
+ * Plot.dotY(cars.map(d => d["economy (mpg)"]))
133
+ * ```
134
+ *
135
+ * If an **interval** is specified, such as *day*, **x** is transformed to the
136
+ * middle of the interval.
137
+ */
29
138
export function dotY ( data ?: Data , options ?: DotYOptions ) : Dot ;
30
139
140
+ /** Like dot, except that the **symbol** option is set to *circle*. */
31
141
export function circle ( data ?: Data , options ?: Exclude < DotOptions , "symbol" > ) : Dot ;
32
142
143
+ /** Like dot, except that the **symbol** option is set to *hexagon*. */
33
144
export function hexagon ( data ?: Data , options ?: Exclude < DotOptions , "symbol" > ) : Dot ;
34
145
146
+ /** The dot mark. */
35
147
export class Dot extends RenderableMark { }
0 commit comments