d3.geom.voronoi: return the configured size.

This commit is contained in:
Jason Davies 2013-03-19 15:10:29 +00:00
Родитель 7c7366155f
Коммит 7643e22714
4 изменённых файлов: 19 добавлений и 7 удалений

11
d3.js поставляемый
Просмотреть файл

@ -4150,8 +4150,8 @@ d3 = function() {
if (_ == null) {
clip = null;
} else {
var w = +_[0], h = +_[1];
clip = d3.geom.polygon([ [ 0, 0 ], [ 0, h ], [ w, h ], [ w, 0 ] ]).clip;
size = [ +_[0], +_[1] ];
clip = d3.geom.polygon([ [ 0, 0 ], [ 0, size[1] ], size, [ size[0], 0 ] ]).clip;
}
return voronoi;
};
@ -4483,6 +4483,8 @@ d3 = function() {
});
}
} else {
x1 = y1 = Infinity;
x2 = y2 = -Infinity;
while (++i < n) {
points.push(d = {
x: +fx.call(this, d = data[i], i),
@ -4543,9 +4545,12 @@ d3 = function() {
if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];
if (_ == null) {
x1 = y1 = x2 = y2 = null;
} else {
} else if (Array.isArray(_[0])) {
x1 = +_[0][0], y1 = +_[0][1];
x2 = +_[1][0], y2 = +_[1][1];
} else {
x1 = y1 = 0;
x2 = +_[0], y2 = +_[1];
}
return quadtree;
};

4
d3.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -143,8 +143,8 @@ d3.geom.voronoi = function(vertices) {
if (_ == null) {
clip = null;
} else {
var w = +_[0], h = +_[1];
clip = d3.geom.polygon([[0, 0], [0, h], [w, h], [w, 0]]).clip;
size = [+_[0], +_[1]];
clip = d3.geom.polygon([[0, 0], [0, size[1]], size, [size[0], 0]]).clip;
}
return voronoi;
};

Просмотреть файл

@ -15,6 +15,13 @@ suite.addBatch({
"has no defined size": function(v) {
assert.isNull(v.size());
},
"returns the configured size": function(v) {
try {
assert.deepEqual(v.size([100, 100]).size(), [100, 100]);
} finally {
v.size(null);
}
},
"has the default x-accessor, d[0]": function(v) {
assert.strictEqual(v.x()([42, 43]), 42);
},