-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathtip.d.ts
More file actions
114 lines (98 loc) · 3.77 KB
/
tip.d.ts
File metadata and controls
114 lines (98 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import {PointerOptions} from "../interactions/pointer.js";
import type {ChannelName, ChannelValueSpec} from "../channel.js";
import type {Data, FrameAnchor, MarkOptions, RenderableMark} from "../mark.js";
import type {TextStyles} from "./text.js";
/** Options for the tip mark. */
export interface TipOptions extends MarkOptions, TextStyles, PointerOptions {
/**
* The horizontal position channel specifying the tip’s anchor, typically
* bound to the *x* scale.
*/
x?: ChannelValueSpec;
/**
* The starting horizontal position channel specifying the tip’s anchor,
* typically bound to the *x* scale.
*/
x1?: ChannelValueSpec;
/**
* The ending horizontal position channel specifying the tip’s anchor,
* typically bound to the *x* scale.
*/
x2?: ChannelValueSpec;
/**
* The vertical position channel specifying the tip’s anchor, typically
* bound to the *y* scale.
*/
y?: ChannelValueSpec;
/**
* The starting vertical position channel specifying the tip’s anchor,
* typically bound to the *y* scale.
*/
y1?: ChannelValueSpec;
/**
* The ending vertical position channel specifying the tip’s anchor, typically
* bound to the *y* scale.
*/
y2?: ChannelValueSpec;
/**
* The frame anchor specifies defaults for **x** and **y** based on the plot’s
* frame; it may be one of the four sides (*top*, *right*, *bottom*, *left*),
* one of the four corners (*top-left*, *top-right*, *bottom-right*,
* *bottom-left*), or the *middle* of the frame. For example, for tips
* distributed horizontally at the top of the frame:
*
* ```js
* Plot.tip(data, {x: "date", frameAnchor: "top"})
* ```
*/
frameAnchor?: FrameAnchor;
/**
* The tip anchor specifies how to orient the tip box relative to its anchor
* position; it refers to the part of the tip box that is attached to the
* anchor point. For example, the *top-left* anchor places the top-left corner
* of tip box near the anchor position, hence placing the tip box below and to
* the right of the anchor position.
*/
anchor?: FrameAnchor;
/**
* If an explicit tip anchor is not specified, an anchor is chosen
* automatically such that the tip fits within the plot’s frame; if the
* preferred anchor fits, it is chosen.
*/
preferredAnchor?: FrameAnchor | null;
/**
* How channel values are formatted for display. If a format is a string, it
* is interpreted as a (UTC) time format for temporal channels, and otherwise
* a number format.
*/
format?: {[name in ChannelName]?: null | boolean | TipFormat} | TipFormat;
/** The image filter for the tip’s box; defaults to a drop shadow. */
pathFilter?: string;
/** The size of the tip’s pointer in pixels; defaults to 12. */
pointerSize?: number;
/** The padding around the text in pixels; defaults to 8. */
textPadding?: number;
}
/**
* How to format channel values; one of:
*
* - a [d3-format][1] string for numeric scales
* - a [d3-time-format][2] string for temporal scales
* - a function passed a channel *value* and *index*, returning a string
*
* [1]: https://d3js.org/d3-time
* [2]: https://d3js.org/d3-time-format
*/
export type TipFormat = string | ((d: any, i: number) => string);
/**
* Returns a new tip mark for the given *data* and *options*.
*
* If either **x** or **y** is not specified, the default is determined by the
* **frameAnchor** option. If none of **x**, **y**, and **frameAnchor** are
* specified, *data* is assumed to be an array of pairs [[*x₀*, *y₀*], [*x₁*,
* *y₁*], [*x₂*, *y₂*], …] such that **x** = [*x₀*, *x₁*, *x₂*, …] and **y** =
* [*y₀*, *y₁*, *y₂*, …].
*/
export function tip(data?: Data, options?: TipOptions): Tip;
/** The tip mark. */
export class Tip extends RenderableMark {}