@@ -5,6 +5,13 @@ import type {plot} from "./plot.js";
5
5
import type { ScaleFunctions } from "./scales.js" ;
6
6
import type { InitializerFunction , SortOrder , TransformFunction } from "./transforms/basic.js" ;
7
7
8
+ /**
9
+ * How to anchor a mark relative to the plot’s frame; one of:
10
+ *
11
+ * - *middle* - centered in the middle
12
+ * - in the middle of one of the edges: *top*, *right*, *bottom*, *left*
13
+ * - in one of the corners: *top-left*, *top-right*, *bottom-right*, *bottom-left*
14
+ */
8
15
export type FrameAnchor =
9
16
| "middle"
10
17
| "top-left"
@@ -16,6 +23,12 @@ export type FrameAnchor =
16
23
| "bottom-left"
17
24
| "left" ;
18
25
26
+ /**
27
+ * A mark’s data; one of:
28
+ *
29
+ * - an array, typed array, or other iterable
30
+ * - an object with a length property and indexed values
31
+ */
19
32
export type Data = Iterable < any > | ArrayLike < any > ;
20
33
21
34
/**
@@ -49,11 +62,69 @@ export type Markish = RenderableMark | RenderFunction | Markish[] | null | undef
49
62
50
63
/** Shared options for all marks. */
51
64
export interface MarkOptions {
52
- // transforms
65
+ /**
66
+ * Applies a transform to filter the mark’s index according to the given
67
+ * channel values; only truthy values are retained. For example, to show only
68
+ * data whose body mass is greater than 3,000g:
69
+ *
70
+ * ```js
71
+ * filter: (d) => d.body_mass_g > 3000
72
+ * ```
73
+ *
74
+ * Note that filtering only affects the rendered mark index, not the
75
+ * associated channel values, and thus has no effect on imputed scale domains.
76
+ */
53
77
filter ?: ChannelValue ;
78
+
79
+ /**
80
+ * Applies a transform to reverse the order of the mark’s index, say for
81
+ * reverse input order.
82
+ */
54
83
reverse ?: boolean ;
84
+
85
+ /**
86
+ * Either applies a transform to sort the mark’s render index by the specified
87
+ * channel values, or imputes ordinal scale domains from this mark’s channels.
88
+ *
89
+ * When imputing ordinal scale domains from channel values, the **sort**
90
+ * option is an object whose keys are ordinal scale names such as *x* or *fx*,
91
+ * and whose values are channel names such as *y*, *y1*, or *y2*. For example,
92
+ * to impute the *y* scale’s domain from the associated *x* channel values in
93
+ * ascending order:
94
+ *
95
+ * ```js
96
+ * sort: {y: "x"}
97
+ * ```
98
+ *
99
+ * For different sort options for different scales, replace the channel name
100
+ * with a *value* object and per-scale options:
101
+ *
102
+ * ```js
103
+ * sort: {y: {value: "x", reverse: true}}
104
+ * ```
105
+ *
106
+ * When sorting the mark’s render index, the **sort** option is instead one
107
+ * of:
108
+ *
109
+ * - a function for comparing data, returning a signed number
110
+ * - a channel value definition for sorting given values in ascending order
111
+ * - a {value, order} object for sorting given values
112
+ * - a {channel, order} object for sorting the named channel’s values
113
+ *
114
+ * For example, to render in order of ascending body mass:
115
+ *
116
+ * ```js
117
+ * sort: "body_mass_g"
118
+ * ```
119
+ *
120
+ * See also the Plot.sort transform.
121
+ */
55
122
sort ?: SortOrder | ChannelDomainSort ;
123
+
124
+ /** A custom mark transform. */
56
125
transform ?: TransformFunction ;
126
+
127
+ /** A custom mark initializer. */
57
128
initializer ?: InitializerFunction ;
58
129
59
130
/**
0 commit comments