Skip to content

Commit 2508468

Browse files
Filmbostock
authored andcommitted
document pixel
1 parent 425f1d3 commit 2508468

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,7 @@ In addition to the [standard mark options](#marks), the following optional chann
13311331
* **y** - the vertical position; bound to the *y* scale
13321332
* **width** - the image width (in pixels)
13331333
* **height** - the image height (in pixels)
1334+
* **imageRendering** - the [image-rendering](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/image-rendering) attribute
13341335
13351336
If either of the **x** or **y** channels are not specified, the corresponding position is controlled by the **frameAnchor** option.
13361337
@@ -1523,6 +1524,40 @@ If an **interval** is specified, such as d3.utcDay, **x1** and **x2** can be der
15231524
15241525
The rect mark supports the [standard mark options](#marks), including insets and rounded corners. The **stroke** defaults to none. The **fill** defaults to currentColor if the stroke is none, and to none otherwise.
15251526
1527+
### Pixel
1528+
1529+
#### Plot.pixel(*data*, *options*)
1530+
1531+
<!-- jsdoc pixel -->
1532+
1533+
```js
1534+
Plot.pixel(triplets, {x: "0", y: "1", fill: "2"})
1535+
```
1536+
1537+
Returns a new raster image with samples at coordinates *x* and *y* optionally set to the given *fill* color and *opacity*. The image is created as a canvas and inserted into the chart as an image with a [data-url](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs) href.
1538+
1539+
The **x** and **y** options are both required, as a constant or as a channel, and mapped to the quantitative scales *x* and *y*. Each sample is represented by a rectangular fill from position ﹤x − ½, y − ½﹥ to position ﹤x + ½, y + ½﹥, minus any insets, and possibly rounded to the closest pixel on the underlying canvas to avoid anti-aliasing artifacts.
1540+
1541+
The pixel mark supports the following options:
1542+
1543+
* **fill** - the sample’s color, as a constant or a channel
1544+
* **fillOpacity** - the sample’s opacity, as a constant or a channel
1545+
* **opacity** - alias for fillOpacity
1546+
* **mixBlendMode** - controls both the [mix-blend-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode) attribute of the image, and the [globalCompositeOperation](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation) for composing overlapping samples
1547+
* **imageRendering** - the [image-rendering](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/image-rendering) attribute, defaults to pixelated
1548+
* **pixelRatio** - the canvas pixel ratio, defaults to [devicePixelRatio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio)
1549+
* **round** - whether the scaled coordinates are rounded, defaults to true
1550+
* **inset** - inset of the mark in screen pixels, defaults to zero; note: this length is measured independently of the mark’s pixelRatio
1551+
* **insetTop** - inset the top edge
1552+
* **insetRight** - inset the right edge
1553+
* **insetBottom** - inset the bottom edge
1554+
* **insetLeft** - inset the left edge
1555+
1556+
Only a few common mark options are supported: **dx**, **dy**, **ariaDescription**, **clip**, and **pointerEvents**. All the options related to the **stroke** (**strokeOpacity**, **paintOrder**…) are ignored, as are **shapeRendering** (but, see imageRendering), **href** and **target**.
1557+
1558+
1559+
<!-- jsdocEnd pixel -->
1560+
15261561
#### Plot.rect(*data*, *options*)
15271562
15281563
<!-- jsdoc rect -->

0 commit comments

Comments
 (0)