Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document select #1353

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/transforms/select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,50 @@ export interface SelectOptions {
z?: ChannelValue;
}

/**
* Selects points from each series (usually defined by *stroke*, *fill* or *z*)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “usually defined by stroke, fill or z” feels unnecessarily imprecise. How would the user know when or not the “usual” definition applies? We should list these channels in order of precedence: z, fill, stroke. The README is more definite:

The data are grouped into series using the z, fill, or stroke channel in the same fashion as the area and line marks.

And similarly for the area mark:

By default, the data is assumed to represent a single series (i.e., a single value that varies over time). If the z channel is specified, data is grouped by z to form separate series. Typically z is a categorical value such as a series name. If z is not specified, it defaults to fill if a channel, or stroke if a channel.

* based on a selector. The selector can be specified either as a function which
* receives as input the index of the series, the shorthand “first” or “last”,
* or as a {*key*: *value*} object with exactly one *key* being the name of a
* channel and the *value* being a function which receives as input the index of
* the series and the channel values. The *value* may alternatively be specified
* as the shorthand “min” and “max” which respectively select the minimum and
* maximum points for the specified channel.
*/
export function select<T>(selector: Selector<T>, options?: T & SelectOptions): Transformed<T>;

/**
* Selects the first point of each series (usually defined by *stroke*, *fill*
* or *z*) in input order.
*/
export function selectFirst<T>(options?: T & SelectOptions): Transformed<T>;

/**
* Selects the last point of each series (usually defined by *stroke*, *fill*
* or *z*) in input order.
*/
export function selectLast<T>(options?: T & SelectOptions): Transformed<T>;

/**
* Selects the first point of each series (usually defined by *stroke*, *fill*
* or *z*) in ascending *x* order.
*/
export function selectMinX<T>(options?: T & SelectOptions): Transformed<T>;

/**
* Selects the first point of each series (usually defined by *stroke*, *fill*
* or *z*) in ascending *y* order.
*/
export function selectMinY<T>(options?: T & SelectOptions): Transformed<T>;

/**
* Selects the first point of each series (usually defined by *stroke*, *fill*
* or *z*) in descending *x* order.
*/
export function selectMaxX<T>(options?: T & SelectOptions): Transformed<T>;

/**
* Selects the first point of each series (usually defined by *stroke*, *fill*
* or *z*) in descending *y* order.
*/
export function selectMaxY<T>(options?: T & SelectOptions): Transformed<T>;