From 43fdc7cb6a3f0795e9e81d08993f41bad8508abe Mon Sep 17 00:00:00 2001 From: Greg Smith Date: Fri, 7 Mar 2014 17:48:31 -0600 Subject: [PATCH] Fixed d3 definitions for d3.geom.voronoi --- d3/d3-tests.ts | 5 ++++- d3/d3.d.ts | 56 +++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 02623aa9f..362f31ea0 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -1168,6 +1168,9 @@ function voroniTesselation() { return [Math.random() * width, Math.random() * height]; } ); + var voronoi = d3.geom.voronoi() + .clipExtent([[0, 0], [width, height]]); + var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height) @@ -1185,7 +1188,7 @@ function voroniTesselation() { redraw(); function redraw() { - path = path.data(d3.geom.voronoi(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String); + path = path.data(voronoi(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String); path.exit().remove(); path.enter().append("path").attr("class", function (d, i) { return "q" + (i % 9) + "-9"; } ).attr("d", String); path.order(); diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 8435e9fe4..9f6965cfa 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -3211,10 +3211,11 @@ declare module D3 { // Geometry export module Geom { export interface Geom { + voronoi(): Voronoi; /** * compute the Voronoi diagram for the specified points. */ - voronoi: Voronoi + voronoi(vertices?: Array): Array; /** * compute the Delaunay triangulation for the specified points. */ @@ -3296,14 +3297,59 @@ declare module D3 { } export interface Voronoi { + /** + * compute the Voronoi diagram for the specified points. + */ (vertices?: Array): Array; x: { - (): (d: any) => any; - (accesor: (d: any) => any): any; + /** + * Get the x-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Voronoi; + (accessor: (data: any, index: number) => number): Voronoi; + /** + * Set the x-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): Voronoi; } y: { - (): (d: any) => any; - (accesor: (d: any) => any): any; + /** + * Get the y-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y-coordinate accessor. + * + * @param accessor The new accessor function. + */ + (accessor: (data: any) => number): Voronoi; + (accessor: (data: any, index: number) => number): Voronoi; + /** + * Set the y-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): Voronoi; + } + clipExtent: { + /** + * Get the clip extent. + */ + (): Array>; + /** + * Set the clip extent. + * + * @param extent The new clip extent. + */ + (extent: Array>): Voronoi; } }