Skip to content

Commit bb27526

Browse files
Filmbostock
andauthored
document image (#1395)
* document image * edits * edits --------- Co-authored-by: Mike Bostock <[email protected]>
1 parent 6cece38 commit bb27526

File tree

2 files changed

+83
-8
lines changed

2 files changed

+83
-8
lines changed

src/marks/dot.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ export interface DotOptions extends MarkOptions {
4848
symbol?: ChannelValueSpec | SymbolType;
4949

5050
/**
51-
* The frame anchor may be specified as one of the four sides (*top*, *right*,
52-
* *bottom*, *left*), one of the four corners (*top-left*, *top-right*,
53-
* *bottom-right*, *bottom-left*), or the *middle* of the frame. It controls
54-
* any component of the dot’s position not specified by **x** or **y**. For
55-
* example, for a dots distributed in a horizontal line positioned at the top
56-
* of the frame:
51+
* The frame anchor specifies defaults for **x** and **y** based on the plot’s
52+
* frame; it may be one of the four sides (*top*, *right*, *bottom*, *left*),
53+
* one of the four corners (*top-left*, *top-right*, *bottom-right*,
54+
* *bottom-left*), or the *middle* of the frame. For example, for dots
55+
* distributed horizontally at the top of the frame:
5756
*
5857
* ```js
5958
* Plot.dot(data, {x: "date", frameAnchor: "top"})
@@ -93,8 +92,9 @@ export interface DotYOptions extends Omit<DotOptions, "x"> {
9392
}
9493

9594
/**
96-
* Draws circles, or other symbols, as in a scatterplot. For example, a
97-
* scatterplot of sales by fruit type (category) and units sold (quantitative):
95+
* Returns a new dot mark for the given *data* and *options* that draws circles,
96+
* or other symbols, as in a scatterplot. For example, a scatterplot of sales by
97+
* fruit type (category) and units sold (quantitative):
9898
*
9999
* ```js
100100
* Plot.dot(sales, {x: "units", y: "fruit"})

src/marks/image.d.ts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,93 @@
11
import type {ChannelValue, ChannelValueSpec} from "../channel.js";
22
import type {Data, FrameAnchor, MarkOptions, RenderableMark} from "../mark.js";
33

4+
/** Options for the image mark. */
45
export interface ImageOptions extends MarkOptions {
6+
/**
7+
* The horizontal position channel specifying the image’s center; typically
8+
* bound to the *x* scale.
9+
*/
510
x?: ChannelValueSpec;
11+
12+
/**
13+
* The vertical position channel specifying the image’s center; typically
14+
* bound to the *y* scale.
15+
*/
616
y?: ChannelValueSpec;
17+
18+
/**
19+
* The image width in pixels. When a number, it is interpreted as a constant
20+
* radius in pixels; otherwise it is interpreted as a channel. Also sets the
21+
* default **height**; if neither are set, defaults to 16. Images with a
22+
* nonpositive width are not drawn.
23+
*/
724
width?: ChannelValue;
25+
26+
/**
27+
* The image height in pixels. When a number, it is interpreted as a constant
28+
* radius in pixels; otherwise it is interpreted as a channel. Also sets the
29+
* default **height**; if neither are set, defaults to 16. Images with a
30+
* nonpositive height are not drawn.
31+
*/
832
height?: ChannelValue;
33+
34+
/**
35+
* The required image URL (or relative path). If a string that starts with a
36+
* dot, slash, or URL protocol (*e.g.*, “https:”) it is assumed to be a
37+
* constant; otherwise it is interpreted as a channel.
38+
*/
939
src?: ChannelValue;
40+
41+
/**
42+
* The image [aspect ratio][1]; defaults to *xMidYMid meet*. To crop the image
43+
* instead of scaling it to fit, use *xMidYMid slice*.
44+
*
45+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio
46+
*/
1047
preserveAspectRatio?: string;
48+
49+
/**
50+
* The [cross-origin][1] behavior. See the [Plot.image notebook][2] for details.
51+
*
52+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/crossorigin
53+
* [2]: https://observablehq.com/@observablehq/plot-image
54+
*/
1155
crossOrigin?: string;
56+
57+
/**
58+
* The frame anchor specifies defaults for **x** and **y** based on the plot’s
59+
* frame; it may be one of the four sides (*top*, *right*, *bottom*, *left*),
60+
* one of the four corners (*top-left*, *top-right*, *bottom-right*,
61+
* *bottom-left*), or the *middle* of the frame.
62+
*/
1263
frameAnchor?: FrameAnchor;
64+
65+
/**
66+
* The [image-rendering attribute][1]; defaults to *auto* (bilinear). The
67+
* option may be set to *pixelated* to disable bilinear interpolation for a
68+
* sharper image; however, note that this is not supported in WebKit.
69+
*
70+
* [1]: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/image-rendering
71+
*/
1372
imageRendering?: string;
1473
}
1574

75+
/**
76+
* Returns a new image mark for the given *data* and *options* that draws images
77+
* as in a scatterplot. For example, portraits of U.S. presidents by date of
78+
* inauguration and favorability:
79+
*
80+
* ```js
81+
* Plot.image(presidents, {x: "inauguration", y: "favorability", src: "portrait"})
82+
* ```
83+
*
84+
* If either **x** or **y** is not specified, the default is determined by the
85+
* **frameAnchor** option. If none of **x**, **y**, and **frameAnchor** are
86+
* specified, *data* is assumed to be an array of pairs [[*x₀*, *y₀*], [*x₁*,
87+
* *y₁*], [*x₂*, *y₂*], …] such that **x** = [*x₀*, *x₁*, *x₂*, …] and **y** =
88+
* [*y₀*, *y₁*, *y₂*, …].
89+
*/
1690
export function image(data?: Data, options?: ImageOptions): Image;
1791

92+
/** The image mark. */
1893
export class Image extends RenderableMark {}

0 commit comments

Comments
 (0)