Skip to content

document tickX/tickY #1378

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

Merged
merged 4 commits into from
Mar 30, 2023
Merged
Changes from all commits
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
59 changes: 59 additions & 0 deletions src/marks/tick.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,79 @@ import type {ChannelValueSpec} from "../channel.js";
import type {InsetOptions} from "../inset.js";
import type {Data, MarkOptions, RenderableMark} from "../mark.js";

/** Options for the tickX mark. */
export interface TickXOptions extends MarkOptions, Omit<InsetOptions, "insetLeft" | "insetRight"> {
/**
* The required horizontal position of the tick; a channel typically bound to
* the *x* scale.
*/
x?: ChannelValueSpec;

/**
* The optional vertical position of the tick; a categorical channel typically
* bound to the *y* scale. If not specified, the tick spans the vertical
* extent of the frame; otherwise the *y* scale must be a *band* scale.
*
* If **y** represents quantitative or temporal values, use a ruleX mark
* instead.
*/
y?: ChannelValueSpec;
}

/** Options for the tickY mark. */
export interface TickYOptions extends MarkOptions, Omit<InsetOptions, "insetTop" | "insetBottom"> {
/**
* The required vertical position of the tick; a channel typically bound to
* the *y* scale.
*/
y?: ChannelValueSpec;

/**
* The optional horizontal position of the tick; a categorical channel
* typically bound to the *x* scale. If not specified, the tick spans the
* horizontal extent of the frame; otherwise the *x* scale must be a *band*
* scale.
*
* If **x** represents quantitative or temporal values, use a ruleY mark
* instead.
*/
x?: ChannelValueSpec;
}

/**
* Returns a new horizontally-positioned tickX mark (a vertical line, |) for the
* given *data* and *options*. The **x** channel specifies the tick’s horizontal
* position and defaults to identity, assuming that *data* = [*x₀*, *x₁*, *x₂*,
* …]; the optional **y** categorical channel specifies its vertical position.
* For example, for a horizontal barcode plot of penguins’ weights:
*
* ```js
* Plot.tickX(penguins, {x: "body_mass_g", y: "sex", stroke: "species"})
* ```
*
* If **y** represents quantitative or temporal values, use a ruleX mark
* instead.
*/
export function tickX(data?: Data, options?: TickXOptions): TickX;

/**
* Returns a new vertically-positioned tickY mark (a horizontal line, —) for the
* given *data* and *options*. The **y** channel specifies the vertical position
* of the tick and defaults to identity, assuming that *data* = [*y₀*, *y₁*,
* *y₂*, …]; the optional **x** categorical channel specifies its horizontal
* position. For example, fpr a vertical barcode plot of penguins’ weights:
*
* ```js
* Plot.tickY(penguins, {y: "body_mass_g", x: "sex", stroke: "species"})
* ```
*
* If **x** represents quantitative or temporal values, use a ruleY mark
* instead.
*/
export function tickY(data?: Data, options?: TickYOptions): TickY;

/** The tickX mark. */
export class TickX extends RenderableMark {}

/** The tickY mark. */
export class TickY extends RenderableMark {}