Skip to content

Commit e829ede

Browse files
Filmbostock
andauthored
document dot and symbol (#1370)
* document symbol * dot, save point * more dot * edits --------- Co-authored-by: Mike Bostock <[email protected]>
1 parent b846615 commit e829ede

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

src/marks/dot.d.ts

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,145 @@ import type {Interval} from "../interval.js";
33
import type {Data, FrameAnchor, MarkOptions, RenderableMark} from "../mark.js";
44
import type {SymbolType} from "../symbol.js";
55

6+
/** Options for the dot mark. */
67
export interface DotOptions extends MarkOptions {
8+
/**
9+
* The horizontal position channel specifying the dot’s center, typically
10+
* bound to the *x* scale.
11+
*/
712
x?: ChannelValueSpec;
13+
14+
/**
15+
* The vertical position channel specifying the dot’s center, typically bound
16+
* to the *y* scale.
17+
*/
818
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+
*/
928
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+
*/
1035
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+
*/
1148
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+
*/
1262
frameAnchor?: FrameAnchor;
1363
}
1464

65+
/** Options for the dotX mark. */
1566
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+
*/
1671
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+
*/
1777
interval?: Interval;
1878
}
1979

80+
/** Options for the dotY mark. */
2081
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+
*/
2186
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+
*/
2292
interval?: Interval;
2393
}
2494

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+
*/
25112
export function dot(data?: Data, options?: DotOptions): Dot;
26113

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+
*/
27125
export function dotX(data?: Data, options?: DotXOptions): Dot;
28126

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+
*/
29138
export function dotY(data?: Data, options?: DotYOptions): Dot;
30139

140+
/** Like dot, except that the **symbol** option is set to *circle*. */
31141
export function circle(data?: Data, options?: Exclude<DotOptions, "symbol">): Dot;
32142

143+
/** Like dot, except that the **symbol** option is set to *hexagon*. */
33144
export function hexagon(data?: Data, options?: Exclude<DotOptions, "symbol">): Dot;
34145

146+
/** The dot mark. */
35147
export class Dot extends RenderableMark {}

0 commit comments

Comments
 (0)