mbostock/d3 — pull request #440 by bbroeksema (2012-01-13 11:54:23+00:00)
Title: Make the voronoi implementation extensible.

This is a relative small change that makes d3.geom.voronoi more extensible. The current implementation assumes that users are only interested in the cell boundaries. However, for some code I'm working on I also need the neighbors of each cell.

In order to make this possible with as little changes as possible I propose this patch. In stead of calling d3.geom.voronoi only with a set of vertices it now also takes an optional callback parameter. This parameter should be an object that provides two methods:

* handle(e) // Handle edge addition
* result() // finalize and return results.

In my patch the default behavior of d3.geom.voronoi is unchanged as I moved the original anonymous function into a default edgehandler which is used when the handler parameter is undefined.

This patch allows me to install my own edgehandler which records the required information.

Comments, questions and suggestions for improvements welcome of course.

Cheers,

Bertjan