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

Cannot properly fill mesh hexagons #33

Closed MocanuMarius closed 2 years ago

MocanuMarius commented 2 years ago

All the hexagons generated by the associated hexbin.mesh function are basically half-hexagons, which makes filling via a svg "fill" quite impossible. The use-case is to have them look just like any other hexbin.hexagon in a lot of use-cases where they need a specific color.

I removed this .slice(0,4) from the library and it seems to work properly now ,even if i'm still missing one top left side of the hexagon.

It would be great to have some support to disable this half-hexagon optimization, not only it's useful for coloring the mesh but also hexes are not cut at the edges anymore.

Here's how it looks like: image

And notice how the mesh gets cut at the top left corners image

Fil commented 2 years ago

The mesh is optimized to allow a stroke to be added just once on each edge. In the use case you are describing, it is recommended to create a background (with rect?) below the mesh.

MocanuMarius commented 2 years ago

Is there such a thing as a hexagonal background ?

Fil commented 2 years ago

No, you'd have to fill a whole rect beneath.