You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* document layouts (as "scale-aware transforms")
* document binWidth
* document the initialize option after 42ac4f0
* sort hex bins by radius (descending)
group by z
inline hexbin
binWidth is the distance between two centers
(rebased on mbostock/reinitialize)
* dodge
rebased on mbostock/reinitialize
* compose intializers
* use composeInitialize to make dodge composable
* add new channels as you compose initializers
* darker transform, to demonstrate composition with dodgeY
(added as an example, but we could promote it to a transform)
* a more generic "remap"
* jiggle layout
(using the same remap intializer as in the darkerDodge plot)
Equivalent to [Plot.dot](#plotdotdata-options) except that if the **y** option is not specified, it defaults to the identity function and assumes that *data* = [*y₀*, *y₁*, *y₂*, …].
1039
1039
1040
+
### Hexgrid
1041
+
1042
+
The hexgrid mark can be used to support marks using the [hexbin](#hexbin) layout.
1043
+
1044
+
#### Plot.hexgrid([*options*])
1045
+
1046
+
The *binWidth* option specifies the distance between the centers of neighboring hexagons, in pixels (defaults to 20). The *clip* option defaults to true, clipping the mark to the frame’s dimensions.
1047
+
1040
1048
### Image
1041
1049
1042
1050
[<img src="./img/image.png" width="320" height="198" alt="a scatterplot of Presidential portraits">](https://observablehq.com/@observablehq/plot-image)
@@ -1524,10 +1532,10 @@ The following aggregation methods are supported:
1524
1532
* *pXX* - the percentile value, where XX is a number in [00,99]
1525
1533
* *deviation* - the standard deviation
1526
1534
* *variance* - the variance per [Welford’s algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm)
1527
-
* *x* - the middle the bin’s *x*-extent (when binning on *x*)
1535
+
* *x* - the middle of the bin’s *x*-extent (when binning on *x*)
1528
1536
* *x1* - the lower bound of the bin’s *x*-extent (when binning on *x*)
1529
1537
* *x2* - the upper bound of the bin’s *x*-extent (when binning on *x*)
1530
-
* *y* - the middle the bin’s *y*-extent (when binning on *y*)
1538
+
* *y* - the middle of the bin’s *y*-extent (when binning on *y*)
1531
1539
* *y1* - the lower bound of the bin’s *y*-extent (when binning on *y*)
1532
1540
* *y2* - the upper bound of the bin’s *y*-extent (when binning on *y*)
1533
1541
* a function to be passed the array of values for each bin and the extent of the bin
@@ -2145,6 +2153,69 @@ This helper for constructing derived columns returns a [*column*, *setColumn*] a
2145
2153
2146
2154
Plot.column is typically used by options transforms to define new channels; the associated columns are populated (derived) when the **transform** option function is invoked.
2147
2155
2156
+
## Scale-aware transforms
2157
+
2158
+
Some transforms need to operate in representation space (such as pixels and colors, *i.e.* after scales have been applied) rather than data space. Such a transform might, for example, modify the marks’ positions in screen space to avoid occlusion. These scale-aware transforms are applied *after* the initial setting of the scales, and can modify the channels or derive new channels—which can in turn be passed to scales.
2159
+
2160
+
### Dodge
2161
+
2162
+
The dodge transform can be applied to any mark that consumes *x* or *y*, such as the Dot, Image, Text and Vector marks.
2163
+
#### Plot.dodgeY([*layoutOptions*, ]*options*)
2164
+
2165
+
```js
2166
+
Plot.dodgeY({x:"date"})
2167
+
```
2168
+
2169
+
If the marks are arranged along the *x* axis, the dodgeY transform piles them vertically, keeping their *x* position unchanged, and creating a *y* position that avoids overlapping.
2170
+
2171
+
#### Plot.dodgeX([*layoutOptions*, ]*options*)
2172
+
2173
+
```js
2174
+
Plot.dodgeX({y:"value"})
2175
+
```
2176
+
2177
+
Equivalent to Plot.dodgeY, but the piling is horizontal, keeping the marks’ *y* position unchanged, and creating an *x* position that avoids overlapping.
2178
+
The dodge transforms accept the following options:
2179
+
* **padding** — a number of pixels added to the radius of the mark to estimate its size
2180
+
* **anchor** - the frame anchor: one of *middle*, *right*, and *left* (default) for dodgeX, and one of *middle*, *top*, and *bottom* (default) for dodgeY. With the *middle* anchor the piles will grow from the center in both directions; with the other anchors, the piles will grow from the specified anchor towards the opposite direction.
2181
+
2182
+
### Hexbin
2183
+
2184
+
The hexbin transform can be applied to any mark that consumes *x* and *y*, such as the Dot, Image, Text and Vector marks. It aggregates the values into hexagonal bins of the given *radius* (in pixel space), and computes new values *x* and *y* as the centers of each bin. It can also return new channels by applying a reducer to each bin, such as the number of elements in the bin.
2185
+
2186
+
#### Plot.hexbin(*outputs*, *options*)
2187
+
2188
+
[Source](./src/transforms/hexbin.js) · [Examples](https://observablehq.com/@observablehq/plot-hexbin) · Aggregates the given inputs into hexagonal bins, and creates output channels with the reduced data. The options must specify the *x* and *y* channels, and can optionally indicate the *binWidth* in pixels (defaults to 20), defined as the distance between the centers of two neighboring hexagons. If any of **z**, **fill**, or **stroke** is a channel, the first of these channels will be used to subdivide bins. The *outputs* options are similar to Plot.bin’s outputs; each output channel receives as input, for each hexagon, the subset of the data which has been matched to its center. The outputs object specifies the aggregation method for each output channel.
2189
+
2190
+
The following aggregation methods are supported:
2191
+
2192
+
* *first* - the first value, in input order
2193
+
* *last* - the last value, in input order
2194
+
* *count* - the number of elements (frequency)
2195
+
* *distinct* - the number of distinct values
2196
+
* *sum* - the sum of values
2197
+
* *proportion* - the sum proportional to the overall total (weighted frequency)
2198
+
* *proportion-facet* - the sum proportional to the facet total
2199
+
* *min* - the minimum value
2200
+
* *min-index* - the zero-based index of the minimum value
2201
+
* *max* - the maximum value
2202
+
* *max-index* - the zero-based index of the maximum value
2203
+
* *mean* - the mean value (average)
2204
+
* *median* - the median value
2205
+
* *deviation* - the standard deviation
2206
+
* *variance* - the variance per [Welford’s algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm)
2207
+
* *mode* - the value with the most occurrences
2208
+
* a function to be passed the array of values for each bin and the extent of the bin
2209
+
* an object with a *reduce* method
2210
+
2211
+
When the hexbin transform has an *r* output, the bins are returned in decreasing size order.
2212
+
2213
+
See also the [hexgrid](#hexgrid) mark.
2214
+
2215
+
### Custom scale-aware transforms
2216
+
2217
+
When its *options* have an *initialize* property, the initialize function is called after the scales have been computed. It receives as inputs the (possibly transformed) data array, the index of elements of this array that belong to each facet, the input channels (as a key: array object), the scales, and the dimensions, with the mark as this. It must return the data, index, and the channels that need to be scaled in a second pass.
2218
+
2148
2219
## Curves
2149
2220
2150
2221
A curve defines how to turn a discrete representation of a line as a sequence of points [[*x₀*, *y₀*], [*x₁*, *y₁*], [*x₂*, *y₂*], …] into a continuous path; *i.e.*, how to interpolate between points. Curves are used by the [line](#line), [area](#area), and [link](#link) mark, and are implemented by [d3-shape](https://github.com/d3/d3-shape/blob/master/README.md#curves).
0 commit comments