|
1 | 1 | import type {ChannelValueSpec} from "../channel.js";
|
2 | 2 | import type {Data, MarkOptions, RenderableMark} from "../mark.js";
|
3 | 3 |
|
| 4 | +/** Options for the arrow mark. */ |
4 | 5 | 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 | + */ |
5 | 10 | 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 | + */ |
6 | 16 | y?: ChannelValueSpec;
|
| 17 | + |
| 18 | + /** |
| 19 | + * The starting horizontal position; typically bound to the *x* scale; also |
| 20 | + * sets a default for **x2**. |
| 21 | + */ |
7 | 22 | x1?: ChannelValueSpec;
|
| 23 | + |
| 24 | + /** |
| 25 | + * The starting vertical position; typically bound to the *y* scale; also sets |
| 26 | + * a default for **y2**. |
| 27 | + */ |
8 | 28 | y1?: ChannelValueSpec;
|
| 29 | + |
| 30 | + /** |
| 31 | + * The ending horizontal position; typically bound to the *x* scale; also sets |
| 32 | + * a default for **x1**. |
| 33 | + */ |
9 | 34 | x2?: ChannelValueSpec;
|
| 35 | + |
| 36 | + /** |
| 37 | + * The ending vertical position; typically bound to the *y* scale; also sets a |
| 38 | + * default for **y1**. |
| 39 | + */ |
10 | 40 | 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 | + */ |
11 | 50 | 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 | + */ |
12 | 56 | 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 | + */ |
13 | 63 | headLength?: number;
|
| 64 | + |
| 65 | + /** |
| 66 | + * Shorthand to set the same default for **insetStart** and **insetEnd**. |
| 67 | + */ |
14 | 68 | 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 | + */ |
15 | 77 | 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 | + */ |
16 | 86 | insetEnd?: number;
|
17 | 87 | }
|
18 | 88 |
|
| 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 | + */ |
19 | 99 | export function arrow(data?: Data, options?: ArrowOptions): Arrow;
|
20 | 100 |
|
| 101 | +/** The arrow mark. */ |
21 | 102 | export class Arrow extends RenderableMark {}
|
0 commit comments