d3.geom.voronoi: return the configured size.
This commit is contained in:
Родитель
7c7366155f
Коммит
7643e22714
|
@ -4150,8 +4150,8 @@ d3 = function() {
|
||||||
if (_ == null) {
|
if (_ == null) {
|
||||||
clip = null;
|
clip = null;
|
||||||
} else {
|
} else {
|
||||||
var w = +_[0], h = +_[1];
|
size = [ +_[0], +_[1] ];
|
||||||
clip = d3.geom.polygon([ [ 0, 0 ], [ 0, h ], [ w, h ], [ w, 0 ] ]).clip;
|
clip = d3.geom.polygon([ [ 0, 0 ], [ 0, size[1] ], size, [ size[0], 0 ] ]).clip;
|
||||||
}
|
}
|
||||||
return voronoi;
|
return voronoi;
|
||||||
};
|
};
|
||||||
|
@ -4483,6 +4483,8 @@ d3 = function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
x1 = y1 = Infinity;
|
||||||
|
x2 = y2 = -Infinity;
|
||||||
while (++i < n) {
|
while (++i < n) {
|
||||||
points.push(d = {
|
points.push(d = {
|
||||||
x: +fx.call(this, d = data[i], i),
|
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 (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ];
|
||||||
if (_ == null) {
|
if (_ == null) {
|
||||||
x1 = y1 = x2 = y2 = null;
|
x1 = y1 = x2 = y2 = null;
|
||||||
} else {
|
} else if (Array.isArray(_[0])) {
|
||||||
x1 = +_[0][0], y1 = +_[0][1];
|
x1 = +_[0][0], y1 = +_[0][1];
|
||||||
x2 = +_[1][0], y2 = +_[1][1];
|
x2 = +_[1][0], y2 = +_[1][1];
|
||||||
|
} else {
|
||||||
|
x1 = y1 = 0;
|
||||||
|
x2 = +_[0], y2 = +_[1];
|
||||||
}
|
}
|
||||||
return quadtree;
|
return quadtree;
|
||||||
};
|
};
|
||||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -143,8 +143,8 @@ d3.geom.voronoi = function(vertices) {
|
||||||
if (_ == null) {
|
if (_ == null) {
|
||||||
clip = null;
|
clip = null;
|
||||||
} else {
|
} else {
|
||||||
var w = +_[0], h = +_[1];
|
size = [+_[0], +_[1]];
|
||||||
clip = d3.geom.polygon([[0, 0], [0, h], [w, h], [w, 0]]).clip;
|
clip = d3.geom.polygon([[0, 0], [0, size[1]], size, [size[0], 0]]).clip;
|
||||||
}
|
}
|
||||||
return voronoi;
|
return voronoi;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,6 +15,13 @@ suite.addBatch({
|
||||||
"has no defined size": function(v) {
|
"has no defined size": function(v) {
|
||||||
assert.isNull(v.size());
|
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) {
|
"has the default x-accessor, d[0]": function(v) {
|
||||||
assert.strictEqual(v.x()([42, 43]), 42);
|
assert.strictEqual(v.x()([42, 43]), 42);
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче