d3 / d3-hexbin

Group two-dimensional points into hexagonal bins.
https://observablehq.com/collection/@d3/d3-hexbin
BSD 3-Clause "New" or "Revised" License
240 stars 34 forks source link

Support Canvas. #1

Open mbostock opened 8 years ago

mbostock commented 8 years ago

Should hexbin.hexagon implement the symbol type interface? But it has a specific radius, not an arbitrary size…

Should the hexagon method take a context? But then you have to construct a path buffer manually?

Should the hexbin take a context? And then render like a shape? (Rendering either a mesh of individual hexbins?) Maybe?

ghost commented 8 years ago

Sorry for the delay in replying to this pull request.

Here's what I think so far (subject to major revisions):

Would love to hear your thoughts. Also, I may be wrong on any/all of this, so please feel free to correct any errors.

syntagmatic commented 8 years ago

A v3 version of d3-hexbin that takes a Canvas context here: http://bl.ocks.org/syntagmatic/002ef2fb5c1dc2df5821

My opinion is d3-hexbin shouldn't deal directly with Canvas or SVG path strings. It should output arrays of coordinates. Turning that array into a path string or a Canvas subroutine should be a convenience method or a separate utility like d3-path.

But practically since the plugin already supported SVG, adding a convenient way to render to Canvas instead would be nice. In this case, the API should be similar to d3.geoPath. A method to access the raw coordinates would still be useful.