Restore voronoi.links.
This commit is contained in:
Родитель
5bc83c30ad
Коммит
4f51b3f37f
|
@ -5114,8 +5114,7 @@ d3 = function() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d3_geom_voronoiClipEdges(bbox);
|
if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox);
|
||||||
d3_geom_voronoiCloseCells(bbox);
|
|
||||||
var diagram = {
|
var diagram = {
|
||||||
cells: d3_geom_voronoiCells,
|
cells: d3_geom_voronoiCells,
|
||||||
edges: d3_geom_voronoiEdges
|
edges: d3_geom_voronoiEdges
|
||||||
|
@ -5127,17 +5126,11 @@ d3 = function() {
|
||||||
return b.y - a.y || b.x - a.x;
|
return b.y - a.y || b.x - a.x;
|
||||||
}
|
}
|
||||||
d3.geom.voronoi = function(points) {
|
d3.geom.voronoi = function(points) {
|
||||||
var x = d3_svg_lineX, y = d3_svg_lineY, clipExtent = d3_geom_voronoiClipExtent;
|
var x = d3_svg_lineX, y = d3_svg_lineY, fx = x, fy = y, clipExtent = d3_geom_voronoiClipExtent;
|
||||||
if (points) return voronoi(points);
|
if (points) return voronoi(points);
|
||||||
function voronoi(data) {
|
function voronoi(data) {
|
||||||
var fx = d3_functor(x), fy = d3_functor(y), sites = data.map(function(d, i) {
|
var polygons = [];
|
||||||
return {
|
d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) {
|
||||||
x: fx(d, i),
|
|
||||||
y: fy(d, i),
|
|
||||||
i: i
|
|
||||||
};
|
|
||||||
}), polygons = [];
|
|
||||||
d3_geom_voronoi(sites, clipExtent).cells.forEach(function(cell, i) {
|
|
||||||
(polygons[i] = cell.edges.length ? cell.edges.map(function(edge) {
|
(polygons[i] = cell.edges.length ? cell.edges.map(function(edge) {
|
||||||
var start = edge.start();
|
var start = edge.start();
|
||||||
return [ start.x, start.y ];
|
return [ start.x, start.y ];
|
||||||
|
@ -5145,17 +5138,33 @@ d3 = function() {
|
||||||
});
|
});
|
||||||
return polygons;
|
return polygons;
|
||||||
}
|
}
|
||||||
|
function sites(data) {
|
||||||
|
return data.map(function(d, i) {
|
||||||
|
return {
|
||||||
|
x: fx(d, i),
|
||||||
|
y: fy(d, i),
|
||||||
|
i: i
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
voronoi.links = function(data) {
|
voronoi.links = function(data) {
|
||||||
throw new Error("not yet implemented");
|
return d3_geom_voronoi(sites(data)).edges.filter(function(edge) {
|
||||||
|
return edge.l && edge.r;
|
||||||
|
}).map(function(edge) {
|
||||||
|
return {
|
||||||
|
source: data[edge.l.i],
|
||||||
|
target: data[edge.r.i]
|
||||||
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
voronoi.triangles = function(data) {
|
voronoi.triangles = function(data) {
|
||||||
throw new Error("not yet implemented");
|
throw new Error("not yet implemented");
|
||||||
};
|
};
|
||||||
voronoi.x = function(_) {
|
voronoi.x = function(_) {
|
||||||
return arguments.length ? (x = _, voronoi) : x;
|
return arguments.length ? (fx = d3_functor(x = _), voronoi) : x;
|
||||||
};
|
};
|
||||||
voronoi.y = function(_) {
|
voronoi.y = function(_) {
|
||||||
return arguments.length ? (y = _, voronoi) : y;
|
return arguments.length ? (fy = d3_functor(y = _), voronoi) : y;
|
||||||
};
|
};
|
||||||
voronoi.clipExtent = function(_) {
|
voronoi.clipExtent = function(_) {
|
||||||
if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent;
|
if (!arguments.length) return clipExtent === d3_geom_voronoiClipExtent ? null : clipExtent;
|
||||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -6,18 +6,17 @@ import "geom";
|
||||||
d3.geom.voronoi = function(points) {
|
d3.geom.voronoi = function(points) {
|
||||||
var x = d3_svg_lineX,
|
var x = d3_svg_lineX,
|
||||||
y = d3_svg_lineY,
|
y = d3_svg_lineY,
|
||||||
|
fx = x,
|
||||||
|
fy = y,
|
||||||
clipExtent = d3_geom_voronoiClipExtent;
|
clipExtent = d3_geom_voronoiClipExtent;
|
||||||
|
|
||||||
// @deprecated; use voronoi(data) instead.
|
// @deprecated; use voronoi(data) instead.
|
||||||
if (points) return voronoi(points);
|
if (points) return voronoi(points);
|
||||||
|
|
||||||
function voronoi(data) {
|
function voronoi(data) {
|
||||||
var fx = d3_functor(x),
|
var polygons = [];
|
||||||
fy = d3_functor(y),
|
|
||||||
sites = data.map(function(d, i) { return {x: fx(d, i), y: fy(d, i), i: i}; }),
|
|
||||||
polygons = [];
|
|
||||||
|
|
||||||
d3_geom_voronoi(sites, clipExtent).cells.forEach(function(cell, i) {
|
d3_geom_voronoi(sites(data), clipExtent).cells.forEach(function(cell, i) {
|
||||||
(polygons[i] = cell.edges.length ? cell.edges.map(function(edge) {
|
(polygons[i] = cell.edges.length ? cell.edges.map(function(edge) {
|
||||||
var start = edge.start();
|
var start = edge.start();
|
||||||
return [start.x, start.y];
|
return [start.x, start.y];
|
||||||
|
@ -32,8 +31,19 @@ d3.geom.voronoi = function(points) {
|
||||||
return polygons;
|
return polygons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sites(data) {
|
||||||
|
return data.map(function(d, i) { return {x: fx(d, i), y: fy(d, i), i: i}; });
|
||||||
|
}
|
||||||
|
|
||||||
voronoi.links = function(data) {
|
voronoi.links = function(data) {
|
||||||
throw new Error("not yet implemented");
|
return d3_geom_voronoi(sites(data)).edges.filter(function(edge) {
|
||||||
|
return edge.l && edge.r;
|
||||||
|
}).map(function(edge) {
|
||||||
|
return {
|
||||||
|
source: data[edge.l.i],
|
||||||
|
target: data[edge.r.i]
|
||||||
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
voronoi.triangles = function(data) {
|
voronoi.triangles = function(data) {
|
||||||
|
@ -41,11 +51,11 @@ d3.geom.voronoi = function(points) {
|
||||||
};
|
};
|
||||||
|
|
||||||
voronoi.x = function(_) {
|
voronoi.x = function(_) {
|
||||||
return arguments.length ? (x = _, voronoi) : x;
|
return arguments.length ? (fx = d3_functor(x = _), voronoi) : x;
|
||||||
};
|
};
|
||||||
|
|
||||||
voronoi.y = function(_) {
|
voronoi.y = function(_) {
|
||||||
return arguments.length ? (y = _, voronoi) : y;
|
return arguments.length ? (fy = d3_functor(y = _), voronoi) : y;
|
||||||
};
|
};
|
||||||
|
|
||||||
voronoi.clipExtent = function(_) {
|
voronoi.clipExtent = function(_) {
|
||||||
|
|
|
@ -42,8 +42,7 @@ function d3_geom_voronoi(sites, bbox) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d3_geom_voronoiClipEdges(bbox);
|
if (bbox) d3_geom_voronoiClipEdges(bbox), d3_geom_voronoiCloseCells(bbox);
|
||||||
d3_geom_voronoiCloseCells(bbox);
|
|
||||||
|
|
||||||
var diagram = {cells: d3_geom_voronoiCells, edges: d3_geom_voronoiEdges};
|
var diagram = {cells: d3_geom_voronoiCells, edges: d3_geom_voronoiEdges};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче