mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Fixed d3 definitions for d3.geom.voronoi
This commit is contained in:
+4
-1
@@ -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();
|
||||
|
||||
Vendored
+51
-5
@@ -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<Vertice>): Array<Polygon>;
|
||||
/**
|
||||
* 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<Vertice>): Array<Polygon>;
|
||||
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<Array<number>>;
|
||||
/**
|
||||
* Set the clip extent.
|
||||
*
|
||||
* @param extent The new clip extent.
|
||||
*/
|
||||
(extent: Array<Array<number>>): Voronoi;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user