-
Notifications
You must be signed in to change notification settings - Fork 4
Voronoi Geom
Wiki ▸ API Reference ▸ Geometry ▸ Voronoi Geom
Voronoi layouts are particularly useful for invisible interactive regions, as demonstrated in Nate Vack’s Voronoi picking example. See Tovi Grossman’s paper on bubble cursors for a related concept.
# d3.geom.voronoi()
Creates a Voronoi layout with default accessors.
# voronoi(data)
Returns an array of polygons, one for each input vertex in the specified data array. If any vertices are coincident or have NaN positions, the behavior of this method is undefined: most likely, invalid polygons will be returned! You should filter invalid vertices, and consolidate coincident vertices, before computing the tessellation.
# voronoi.x([x])
If x is specified, sets the x-coordinate accessor. If x is not specified, returns the current x-coordinate accessor, which defaults to:
function(d) { return d[0]; }
# voronoi.y([y])
If y is specified, sets the y-coordinate accessor. If y is not specified, returns the current y-coordinate accessor, which defaults to:
function(d) { return d[1]; }
# voronoi.clipExtent([extent])
Gets or sets the clip extent of the Voronoi layout; see this example. This implementation does not clip the returned polygons by default, but will clip them to a given rectangle if specified; this is strongly recommended, as unclipped polygons may have large coordinates which do not display correctly.
Alternatively, you can also employ custom clipping without specifying a size, either in SVG or by post-processing with polygon.clip.
# voronoi.links(data)
…
# voronoi.triangles(data)
Returns an array of triangles.