Skip to content

Commit

Permalink
symbol edits
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 25, 2023
1 parent 5b576f6 commit 61ae5f3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/marks/dot.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type {ChannelValue, ChannelValueIntervalSpec, ChannelValueSpec} from "../channel.js";
import type {Interval} from "../interval.js";
import type {Data, FrameAnchor, MarkOptions, RenderableMark} from "../mark.js";
import type {SymbolImplementation, SymbolName} from "../symbol.js";
import type {SymbolType} from "../symbol.js";

export interface DotOptions extends MarkOptions {
x?: ChannelValueSpec;
y?: ChannelValueSpec;
r?: ChannelValueSpec | number;
rotate?: ChannelValue | number;
symbol?: ChannelValueSpec | SymbolName | SymbolImplementation;
symbol?: ChannelValueSpec | SymbolType;
frameAnchor?: FrameAnchor;
}

Expand Down
9 changes: 7 additions & 2 deletions src/marks/vector.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type {ChannelValue, ChannelValueSpec} from "../channel.js";
import type {Data, FrameAnchor, MarkOptions, RenderableMark} from "../mark.js";

/** The built-in vector shape implementations. */
/**
* The built-in vector shape implementations; one of:
*
* - *arrow* - a straight line with an open arrowhead at the end (↑)
* - *spike* - an isosceles triangle with a flat base (▲)
*/
export type VectorShapeName = "arrow" | "spike";

/** A vector shape implementation. */
Expand All @@ -10,7 +15,7 @@ export interface VectorShapeImplementation {
draw(context: CanvasPath, length: number, radius: number): void;
}

/** How to draw a vector. */
/** How to draw a vector: either a named shape or a custom implementation. */
export type VectorShape = VectorShapeName | VectorShapeImplementation;

/** Options for the vector mark. */
Expand Down
31 changes: 29 additions & 2 deletions src/symbol.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
import type {SymbolType} from "d3";
import type {SymbolType as SymbolImplementation} from "d3";
export type {SymbolType as SymbolImplementation} from "d3";

/**
* The built-in symbol implementations. For fill, one of:
*
* - *circle* - a circle
* - *cross* - a Greek cross with arms of equal length
* - *diamond* - a rhombus
* - *square* - a square
* - *star* - a pentagonal star (pentagram)
* - *triangle* - an up-pointing triangle
* - *wye* - a Y with arms of equal length
*
* For stroke (based on [Heman Robinson’s research][1]), one of:
*
* - *circle* - a circle
* - *plus* - a plus sign
* - *times* - an X with arms of equal length
* - *triangle2* - an (alternate) up-pointing triangle
* - *asterisk* - an asterisk
* - *square2* - a (alternate) square
* - *diamond2* - a rotated square
*
* The *hexagon* symbol is also supported.
*
* [1]: https://www.tandfonline.com/doi/abs/10.1080/10618600.2019.1637746
*/
export type SymbolName =
| "asterisk"
| "circle"
Expand All @@ -16,4 +42,5 @@ export type SymbolName =
| "triangle2"
| "wye";

export type SymbolImplementation = SymbolType;
/** How to draw a symbol: either a named symbol or a custom implementation. */
export type SymbolType = SymbolName | SymbolImplementation;

0 comments on commit 61ae5f3

Please sign in to comment.