Skip to content

Commit 383d3a2

Browse files
authored
document arrow (#1398)
* document arrow * shorter arrow * no space
1 parent 0542835 commit 383d3a2

File tree

4 files changed

+88
-7
lines changed

4 files changed

+88
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,8 @@ For vertical or horizontal arrows, the **x** option can be specified as shorthan
942942
943943
The arrow mark supports the [standard mark options](#marks). The **stroke** defaults to currentColor. The **fill** defaults to none. The **strokeWidth** defaults to 1.5, and the **strokeMiterlimit** defaults to one. The following additional options are supported:
944944
945-
* **bend** - the bend angle, in degrees; defaults to zero
946-
* **headAngle** - the arrowhead angle, in degrees; defaults to 22.5°
945+
* **bend** - the bend angle, in degrees; defaults to zero; true for 22.5°
946+
* **headAngle** - the arrowhead angle, in degrees; defaults to 60°
947947
* **headLength** - the arrowhead scale; defaults to 8
948948
* **insetEnd** - inset at the end of the arrow (useful if the arrow points to a dot)
949949
* **insetStart** - inset at the start of the arrow

src/inset.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/** Options for insetting rectangular shapes. */
22
export interface InsetOptions {
33
/**
4-
* Shorthand to set the same default for all four insets: insetTop,
5-
* insetRight, insetBottom, and insetLeft. All insets typically default to
6-
* zero, though not always (say, a rect mark and a ban transform). A positive
7-
* inset reduces effective area, while a negative inset increases it.
4+
* Shorthand to set the same default for all four insets: **insetTop**,
5+
* **insetRight**, **insetBottom**, and **insetLeft**. All insets typically
6+
* default to zero, though not always (say when using bin transform). A
7+
* positive inset reduces effective area, while a negative inset increases it.
88
*/
99
inset?: number;
1010

src/marks/arrow.d.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,102 @@
11
import type {ChannelValueSpec} from "../channel.js";
22
import type {Data, MarkOptions, RenderableMark} from "../mark.js";
33

4+
/** Options for the arrow mark. */
45
export interface ArrowOptions extends MarkOptions {
6+
/**
7+
* The horizontal position, for vertical arrows; typically bound to the *x*
8+
* scale; shorthand for setting defaults for both **x1** and **x2**.
9+
*/
510
x?: ChannelValueSpec;
11+
12+
/**
13+
* The vertical position, for horizontal arrows; typically bound to the *y*
14+
* scale; shorthand for setting defaults for both **y1** and **y2**.
15+
*/
616
y?: ChannelValueSpec;
17+
18+
/**
19+
* The starting horizontal position; typically bound to the *x* scale; also
20+
* sets a default for **x2**.
21+
*/
722
x1?: ChannelValueSpec;
23+
24+
/**
25+
* The starting vertical position; typically bound to the *y* scale; also sets
26+
* a default for **y2**.
27+
*/
828
y1?: ChannelValueSpec;
29+
30+
/**
31+
* The ending horizontal position; typically bound to the *x* scale; also sets
32+
* a default for **x1**.
33+
*/
934
x2?: ChannelValueSpec;
35+
36+
/**
37+
* The ending vertical position; typically bound to the *y* scale; also sets a
38+
* default for **y1**.
39+
*/
1040
y2?: ChannelValueSpec;
41+
42+
/**
43+
* The angle, a constant in degrees, between the straight line intersecting
44+
* the arrow’s two control points and the outgoing tangent direction of the
45+
* arrow from the start point. The angle must be within ±90°; a positive angle
46+
* will produce a clockwise curve, while a negative angle will produce a
47+
* counterclockwise curve; zero (the default) will produce a straight line.
48+
* Use true for 22.5°.
49+
*/
1150
bend?: number | boolean;
51+
52+
/**
53+
* How pointy the arrowhead is, in degrees; a constant typically between 0°
54+
* and 180°, and defaults to 60°.
55+
*/
1256
headAngle?: number;
57+
58+
/**
59+
* The size of the arrowhead relative to the **strokeWidth**; a constant.
60+
* Assuming the default of stroke width 1.5px, this is the length of the
61+
* arrowhead’s side in pixels.
62+
*/
1363
headLength?: number;
64+
65+
/**
66+
* Shorthand to set the same default for **insetStart** and **insetEnd**.
67+
*/
1468
inset?: number;
69+
70+
/**
71+
* The starting inset, a constant in pixels; defaults to 0. A positive inset
72+
* shortens the arrow by moving the starting point towards the endpoint point,
73+
* while a negative inset extends it by moving the starting point in the
74+
* opposite direction. A positive starting inset may be useful if the arrow
75+
* emerges from a dot.
76+
*/
1577
insetStart?: number;
78+
79+
/**
80+
* The ending inset, a constant in pixels; defaults to 0. A positive inset
81+
* shortens the arrow by moving the ending point towards the starting point,
82+
* while a negative inset extends it by moving the ending point in the
83+
* opposite direction. A positive ending inset may be useful if the arrow
84+
* points to a dot.
85+
*/
1686
insetEnd?: number;
1787
}
1888

89+
/**
90+
* Returns a new arrow mark for the given *data* and *options*, drawing
91+
* (possibly swoopy) arrows connecting pairs of points. For example, to draw an
92+
* arrow connecting an observation from 1980 with an observation from 2015 in a
93+
* scatterplot of population and revenue inequality of U.S. cities:
94+
*
95+
* ```js
96+
* Plot.arrow(inequality, {x1: "POP_1980", y1: "R90_10_1980", x2: "POP_2015", y2: "R90_10_2015", bend: true})
97+
* ```
98+
*/
1999
export function arrow(data?: Data, options?: ArrowOptions): Arrow;
20100

101+
/** The arrow mark. */
21102
export class Arrow extends RenderableMark {}

src/marks/link.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface LinkOptions extends MarkOptions, MarkerOptions, CurveAutoOption
5959

6060
/**
6161
* Returns a new link mark for the given *data* and *options*, drawing line
62-
* segments (curves) to connect pairs of points. For example, to draw a link
62+
* segments (curves) connecting pairs of points. For example, to draw a link
6363
* connecting an observation from 1980 with an observation from 2015 in a
6464
* scatterplot of population and revenue inequality of U.S. cities:
6565
*

0 commit comments

Comments
 (0)