forked from observablehq/plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselect.d.ts
More file actions
78 lines (69 loc) · 2.95 KB
/
select.d.ts
File metadata and controls
78 lines (69 loc) · 2.95 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
import type {ChannelValue} from "../channel.js";
import type {Transformed} from "./basic.js";
/**
* How to select points within each series; one of:
*
* - *first* - the first point by input order
* - *last* - the last point by input order
* - a {*channel*: *min*} object - the minimum point by channel value
* - a {*channel*: *max*} object - the maximum point by channel value
* - a {*channel*: function} object to filter by series index and channel values
* - a function to filter by series index
*
* A selector function is given an *index* representing the contents of the
* current series, the input channel’s array of *source* values (if a channel is
* specified), and returns the corresponding subset of *index* to be selected.
*/
export type Selector<T> =
| "first"
| "last"
| ((index: number[]) => number[])
| {[key in keyof T]?: "min" | "max" | ((index: number[], values: any[]) => number[])};
/** Options for the select transform. */
export interface SelectOptions {
/**
* How to group data into series. If not specified, series will be determined
* by the **fill** channel, if any, or the **stroke** channel, if any.
*/
z?: ChannelValue;
}
/**
* Groups on the first channel of **z**, **fill**, or **stroke**, if any, and
* then selects points from each series based on the given *selector*. For
* example to select the maximum point of the **y** channel, as selectMaxY:
*
* ```js
* Plot.text(data, Plot.select({y: "max"}, options))
* ```
*/
export function select<T>(selector: Selector<T>, options?: T & SelectOptions): Transformed<T>;
/**
* Groups on the first channel of **z**, **fill**, or **stroke**, if any, and
* then selects the first point from each series in input order.
*/
export function selectFirst<T>(options?: T & SelectOptions): Transformed<T>;
/**
* Groups on the first channel of **z**, **fill**, or **stroke**, if any, and
* then selects the last point from each series in input order.
*/
export function selectLast<T>(options?: T & SelectOptions): Transformed<T>;
/**
* Groups on the first channel of **z**, **fill**, or **stroke**, if any, and
* then selects the minimum point from each series based on **x** channel value.
*/
export function selectMinX<T>(options?: T & SelectOptions): Transformed<T>;
/**
* Groups on the first channel of **z**, **fill**, or **stroke**, if any, and
* then selects the minimum point from each series based on **y** channel value.
*/
export function selectMinY<T>(options?: T & SelectOptions): Transformed<T>;
/**
* Groups on the first channel of **z**, **fill**, or **stroke**, if any, and
* then selects the maximum point from each series based on **x** channel value.
*/
export function selectMaxX<T>(options?: T & SelectOptions): Transformed<T>;
/**
* Groups on the first channel of **z**, **fill**, or **stroke**, if any, and
* then selects the maximum point from each series based on **y** channel value.
*/
export function selectMaxY<T>(options?: T & SelectOptions): Transformed<T>;