-
Notifications
You must be signed in to change notification settings - Fork 186
document hexbin #1359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
document hexbin #1359
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,56 @@ | ||
import type {ChannelReducers} from "../channel.js"; | ||
import type {Transformed} from "./basic.js"; | ||
import type {ChannelReducers, ChannelValue} from "../channel.js"; | ||
import type {Initialized} from "./basic.js"; | ||
|
||
/** Options for the hexbin transform. */ | ||
export interface HexbinOptions { | ||
/** | ||
* The horizontal distance between centers of neighboring (pointy-topped) | ||
* hexagons, in pixels; defaults to 20. | ||
*/ | ||
binWidth?: number; | ||
|
||
/** | ||
* How to group data prior to binning. If not specified, defaults to the | ||
* *fill* channel, if any, or the *stroke* channel, if any. If null, bins will | ||
* not be subdivided. | ||
*/ | ||
z?: ChannelValue; | ||
} | ||
|
||
export function hexbin<T>(outputs?: ChannelReducers, options?: T & HexbinOptions): Transformed<T>; | ||
/** | ||
* Groups points specified by the *x* and *y* channels into hexagonal bins in | ||
* scaled coordinates (pixels), computing new *x* and *y* channels as the | ||
* centers of each bin, and deriving new output channels by applying the | ||
* specified reducers (such as *count*) to each bin’s values. The first of the | ||
* *z*, *fill*, or *stroke* channels, if any, will be used to subdivide bins. | ||
* | ||
* The hexbin transform can be applied to any mark that consumes *x* and *y*, | ||
* such as the dot, image, text, and vector marks. For the dot mark, the | ||
* **symbol** option defaults to *hexagon*, and the *r* option defaults to half | ||
* the **binWidth**. If a **fill** output channel is declared, the **stroke** | ||
* option defaults to *none*. | ||
* | ||
* The reducer for each channel in *outputs* may be specified as: | ||
* | ||
* * *first* - the first value, in input order | ||
* * *last* - the last value, in input order | ||
* * *count* - the number of elements (frequency) | ||
* * *distinct* - the number of distinct values | ||
* * *sum* - the sum of values | ||
* * *proportion* - the sum proportional to the overall total (weighted frequency) | ||
* * *proportion-facet* - the sum proportional to the facet total | ||
* * *min* - the minimum value | ||
* * *min-index* - the zero-based index of the minimum value | ||
* * *max* - the maximum value | ||
* * *max-index* - the zero-based index of the maximum value | ||
* * *mean* - the mean value (average) | ||
* * *median* - the median value | ||
* * *deviation* - the standard deviation | ||
* * *variance* - the variance per [Welford’s algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm) | ||
* * *mode* - the value with the most occurrences | ||
* * a function to be passed the array of values for each bin | ||
* * an object with a *reduceIndex* method | ||
* | ||
* See also the hexgrid mark. | ||
*/ | ||
export function hexbin<T>(outputs?: ChannelReducers, options?: T & HexbinOptions): Initialized<T>; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The distance between centers of neighboring hexagons is complete and correct :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course! Oops. Thanks for the correction.