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

Row vs Column Offset Issues #34

Closed snellcode closed 11 months ago

snellcode commented 11 months ago

Hi, first thanks for this great plugin!

I'm having an issue that the offset of rows and columns is different depending on the size of the radius. The code is..

d3hexbin.hexbin().radius(tileSize)

Depending on the size, the row shifts. Hard to explain, so will provide images. It also seems like it's different depending on machine and/or browser.

The relationship between row vs column seems unpredictable, which causes problems for my code. Would like to know if there's a way to make this predictable. Maybe there is some math I can do to make sure I get one state vs the other.

I call one good and one bad, but actually it doesn't matter to me, as long as it can be predictable.

Good State (tile size 39) good-state

Bad State (tile size 37) bad-state

code can be found here https://github.com/snellcode/insulam/blob/main/src/services/map.ts

snellcode commented 11 months ago

I found a fix. The error happens when the first row being plotted is an even number. So I can correct for that when I do the plotting.