d3 / d3-contour

Compute contour polygons using marching squares.

Home Page:https://d3js.org/d3-contour

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support fractional bandwidths.

mbostock opened this issue · comments

d3.contourDensity internally rounds the bandwidth:

return r = Math.round((Math.sqrt(4 * _ * _ + 1) - 1) / 2), resize();

It would be nice to avoid rounding here so that arbitrary bandwidths could be used. Maybe this is possible if we switch to using array-blur, @Fil?

Yes, array-blur has a non-integer radius.

Remember that array-blur evolved from this module, but became faster (about 50% if I remember correctly), more versatile, well-tested etc.

I can incorporate it back into d3-contour (in src option A, or as a dependency option B), but my preference would still be option C, to make it part of d3-array (d3/d3-array#151, which I would have to update). It's true that the blur() method has a provision for a "width" that allows to grant a pixel matrix topology to the array, but width defaults to 1 and it's a useful 1-d transform, for example for time series.

blurring could also be a useful channel transform for Plot (as a complement to windowX, with pros and cons).

Let me know which route you'd prefer. Happy to do the change in any case.

If you are willing I think option C (incorporating Fil/array-blur into d3-array as d3.blur) would be my preference as well.