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
Copy file name to clipboardExpand all lines: docs/transforms/hexbin.md
+13-4Lines changed: 13 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -174,9 +174,9 @@ Plot.plot({
174
174
175
175
The *options* must specify the **x** and **y** channels. The **binWidth** option (default 20) defines the distance between centers of neighboring hexagons in pixels. If any of **z**, **fill**, or **stroke** is a channel, the first of these channels will be used to subdivide bins.
176
176
177
-
The *outputs* options are similar to the [bin transform](./bin.md); 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.
177
+
The *outputs* options are similar to the [bin transform](./bin.md); for each hexagon, an output channel value is derived by reducing the corresponding binned input channel values. The *outputs* object specifies the reducer for each output channel.
178
178
179
-
The following aggregation methods are supported:
179
+
The following named reducers are supported:
180
180
181
181
**first* - the first value, in input order
182
182
**last* - the last value, in input order
@@ -195,13 +195,22 @@ The following aggregation methods are supported:
195
195
**variance* - the variance per [Welford’s algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm)
196
196
**mode* - the value with the most occurrences
197
197
**identity* - the array of values
198
-
* a function to be passed the array of values for each bin and the extent of the bin
198
+
**x* - the hexagon’s *x* center
199
+
**y* - the hexagon’s *y* center
200
+
201
+
In addition, a reducer may be specified as:
202
+
203
+
* a function to be passed the array of values for each bin and the center of the bin
199
204
* an object with a *reduceIndex* method
200
205
206
+
In the last case, the **reduceIndex** method is repeatedly passed three arguments: the index for each bin (an array of integers), the input channel’s array of values, and the center of the bin (an object {data, x, y}); it must then return the corresponding aggregate value for the bin.
207
+
208
+
Most reducers require binding the output channel to an input channel; for example, if you want the **y** output channel to be a *sum* (not merely a count), there should be a corresponding **y** input channel specifying which values to sum. If there is not, *sum* will be equivalent to *count*.
0 commit comments