Skip to content

Commit c04f3ad

Browse files
committed
edits
1 parent 035cead commit c04f3ad

File tree

1 file changed

+51
-101
lines changed

1 file changed

+51
-101
lines changed

src/marks/dot.d.ts

Lines changed: 51 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,57 @@ import type {SymbolType} from "../symbol.js";
66
/** Options for the dot mark. */
77
export interface DotOptions extends MarkOptions {
88
/**
9-
* The horizontal position of the dot’s center, typically bound to the *x*
10-
* scale.
9+
* The horizontal position channel specifying the dot’s center, typically
10+
* bound to the *x* scale.
1111
*/
1212
x?: ChannelValueSpec;
1313

1414
/**
15-
* The vertical position of the dot’s center, typically bound to the *y*
16-
* scale.
15+
* The vertical position channel specifying the dot’s center, typically bound
16+
* to the *y* scale.
1717
*/
1818
y?: ChannelValueSpec;
1919

2020
/**
21-
* The **r** option can be specified as either a channel or constant. When the
22-
* radius is specified as a number, it is interpreted as a constant, in
23-
* pixels; otherwise it is interpreted as a channel, typically bound to the
24-
* *r* channel, which defaults to the *sqrt* type for proportional symbols.
25-
* The radius defaults to 4.5 pixels when using the **symbol** channel, and
26-
* otherwise 3 pixels. Dots with a nonpositive radius are not drawn.
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.
2727
*/
2828
r?: ChannelValueSpec | number;
2929

3030
/**
31-
* An angle to rotate the **symbol** around its center, in degrees clockwise.
32-
* Defaults to 0°, pointing up. Obviously inoperant with the *circle* symbol.
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.
3334
*/
3435
rotate?: ChannelValue | number;
3536

3637
/**
37-
* The categorical symbol; if a channel, bound to the *symbol* scale. A
38-
* constant symbol can be specified by a name such as *star*, or by its
39-
* implementation as a function of the *context* and *size*. Defaults to
40-
* *circle* for the **dot** mark, and *hexagon* for the **hexagon** mark.
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.
4147
*/
4248
symbol?: ChannelValueSpec | SymbolType;
4349

4450
/**
4551
* The frame anchor may be specified as one of the four sides (*top*, *right*,
4652
* *bottom*, *left*), one of the four corners (*top-left*, *top-right*,
4753
* *bottom-right*, *bottom-left*), or the *middle* of the frame. It controls
48-
* any component of the dot’s position not specified by **x** or **y**.
49-
*
50-
* For example, for a dot marking each bin and positioned at the top of the
51-
* frame:
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:
5257
*
5358
* ```js
54-
* Plot.dot(*data*, Plot.binX({x: "date", frameAnchor: "top"}))
59+
* Plot.dot(data, {x: "date", frameAnchor: "top"})
5560
* ```
5661
*/
5762
frameAnchor?: FrameAnchor;
@@ -61,15 +66,13 @@ export interface DotOptions extends MarkOptions {
6166
export interface DotXOptions extends Omit<DotOptions, "y"> {
6267
/**
6368
* The vertical position of the dot’s center, typically bound to the *y*
64-
* scale. If an **interval** is specified, such as *day*, **y** is transformed
65-
* to the middle of the day. If the interval is specified as a number *n*,
66-
* **y** will be the midpoint of two consecutive multiples of *n* that bracket
67-
* **y**.
69+
* scale.
6870
*/
6971
y?: ChannelValueIntervalSpec;
7072

7173
/**
72-
* An interval (such as *day* or a number), to bin *y* values.
74+
* An interval (such as *day* or a number), to transform **y** values to the
75+
* middle of the interval.
7376
*/
7477
interval?: Interval;
7578
}
@@ -78,119 +81,66 @@ export interface DotXOptions extends Omit<DotOptions, "y"> {
7881
export interface DotYOptions extends Omit<DotOptions, "x"> {
7982
/**
8083
* The horizontal position of the dot’s center, typically bound to the *x*
81-
* scale. If an **interval** is specified, such as *day*, **x** is transformed
82-
* to the middle of the day. If the interval is specified as a number *n*,
83-
* **x** will be the midpoint of two consecutive multiples of *n* that bracket
84-
* **x**.
84+
* scale.
8585
*/
8686
x?: ChannelValueIntervalSpec;
8787

8888
/**
89-
* An interval (such as *day* or a number), to bin *x* values.
89+
* An interval (such as *day* or a number), to transform **x** values to the
90+
* middle of the interval.
9091
*/
9192
interval?: Interval;
9293
}
9394

9495
/**
95-
* Draws circles, or other symbols, as in a scatterplot.
96-
*
97-
* In addition to the standard mark options, the following optional channels are
98-
* supported:
99-
*
100-
* - **x** - the horizontal position; bound to the *x* scale
101-
* - **y** - the vertical position; bound to the *y* scale
102-
* - **r** - the radius (area); bound to the *radius* scale, which defaults to
103-
* *sqrt*
104-
* - **rotate** - the rotation angle in degrees clockwise
105-
* - **symbol** - the categorical symbol; bound to the *symbol* scale
106-
*
107-
* For example, a scatterplot of sales by fruit type (category) and units sold
108-
* (quantitative):
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):
10998
*
11099
* ```js
111100
* Plot.dot(sales, {x: "units", y: "fruit"})
112101
* ```
113102
*
114-
* If either of the **x** or **y** channels are not specified, the corresponding
115-
* position is controlled by the **frameAnchor** option.
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₂*, …].
116108
*
117-
* The following options are also supported:
118-
*
119-
* - **r** - the effective radius
120-
* - **rotate** - the rotation angle in degrees clockwise; defaults to 0
121-
* - **symbol** - the categorical symbol; defaults to circle
122-
* - **frameAnchor** - the frame anchor; defaults to *middle*
123-
*
124-
*
125-
* The **stroke** defaults to none. The **fill** defaults to currentColor if the
126-
* stroke is none, and to none otherwise. The **strokeWidth** defaults to 1.5.
127-
* The **rotate** and **symbol** options can be specified as either channels or
128-
* constants. When rotate is specified as a number, it is interpreted as a
129-
* constant; otherwise it is interpreted as a channel. When symbol is a valid
130-
* symbol name or symbol object (implementing the draw method), it is
131-
* interpreted as a constant; otherwise it is interpreted as a channel. If the
132-
* **symbol** channel’s values are all symbols, symbol names, or nullish, the
133-
* channel is unscaled (values are interpreted literally); otherwise, the
134-
* channel is bound to the *symbol* scale.
135-
*
136-
* The built-in **symbol** types are: *circle*, *cross*, *diamond*, *square*,
137-
* *star*, *triangle*, and *wye* (for fill) and *circle*, *plus*, *times*,
138-
* *triangle2*, *asterisk*, *square2*, and *diamond2* (for stroke, based on
139-
* [Heman Robinson’s
140-
* research](https://www.tandfonline.com/doi/abs/10.1080/10618600.2019.1637746)).
141-
* The *hexagon* symbol is also supported. You can also specify a D3 or custom
142-
* symbol type as an object that implements the [*symbol*.draw(*context*,
143-
* *size*)](https://github.com/d3/d3-shape/blob/main/README.md#custom-symbol-types)
144-
* method.
145-
*
146-
* Dots are sorted by descending radius by default to mitigate overplotting; set
147-
* the **sort** option to null to draw them in input order.
148-
*
149-
* If neither the **x** nor **y** nor **frameAnchor** options are specified,
150-
* *data* is assumed to be an array of pairs [[*x₀*, *y₀*], [*x₁*, *y₁*], [*x₂*,
151-
* *y₂*], …] such that **x** = [*x₀*, *x₁*, *x₂*, …] and **y** = [*y₀*, *y₁*,
152-
* *y₂*, …].
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.
153111
*/
154112
export function dot(data?: Data, options?: DotOptions): Dot;
155113

156114
/**
157-
* Equivalent to **dot** except that if the **x** option is not specified, it
158-
* defaults to the identity function and assumes that *data* = [*x₀*, *x₁*,
159-
* *x₂*, …].
115+
* Like dot, except that **x** defaults to the identity function, assuming that
116+
* *data* = [*x₀*, *x₁*, *x₂*, …].
160117
*
161118
* ```js
162119
* Plot.dotX(cars.map(d => d["economy (mpg)"]))
163120
* ```
164121
*
165-
* If an **interval** is specified, such as "day", **y** is transformed to the
166-
* middle of the day. If the interval is specified as a number *n*, **y** will
167-
* be the midpoint of two consecutive multiples of *n* that bracket **y**.
122+
* If an **interval** is specified, such as *day*, **y** is transformed to the
123+
* middle of the interval.
168124
*/
169125
export function dotX(data?: Data, options?: DotXOptions): Dot;
170126

171127
/**
172-
* Equivalent to **dot** except that if the **y** option is not specified, it
173-
* defaults to the identity function and assumes that *data* = [*y₀*, *y₁*,
174-
* *y₂*, …].
128+
* Like dot, except that **y** defaults to the identity function, assuming that
129+
* *data* = [*y₀*, *y₁*, *y₂*, …].
175130
*
176131
* ```js
177132
* Plot.dotY(cars.map(d => d["economy (mpg)"]))
178133
* ```
179134
*
180-
* If an **interval** is specified, such as "day", **x** is transformed to the
181-
* middle of the day. If the interval is specified as a number *n*, **x** will
182-
* be the midpoint of two consecutive multiples of *n* that bracket **x**.
135+
* If an **interval** is specified, such as *day*, **x** is transformed to the
136+
* middle of the interval.
183137
*/
184138
export function dotY(data?: Data, options?: DotYOptions): Dot;
185139

186-
/**
187-
* Equivalent to **dot** except that the **symbol** option is set to *circle*.
188-
*/
140+
/** Like dot, except that the **symbol** option is set to *circle*. */
189141
export function circle(data?: Data, options?: Exclude<DotOptions, "symbol">): Dot;
190142

191-
/**
192-
* Equivalent to **dot**, except that the **symbol** option is set to *hexagon*.
193-
*/
143+
/** Like dot, except that the **symbol** option is set to *hexagon*. */
194144
export function hexagon(data?: Data, options?: Exclude<DotOptions, "symbol">): Dot;
195145

196146
/** The dot mark. */

0 commit comments

Comments
 (0)