brush.clamp: return null if there are no scales.

Similarly, if there are no scales, setting a clamp does nothing.

For consistency with brush.extent.
This commit is contained in:
Jason Davies 2013-06-14 10:10:00 +01:00
Родитель 84f4a62c01
Коммит 85d156c3f7
4 изменённых файлов: 8 добавлений и 5 удалений

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

@ -8047,8 +8047,8 @@ d3 = function() {
return brush;
};
brush.clamp = function(z) {
if (!arguments.length) return x && y ? clamp : clamp[+!x];
if (x && y) clamp = [ !!z[0], !!z[1] ]; else clamp[+!x] = !!z;
if (!arguments.length) return x && y ? clamp : x || y ? clamp[+!x] : null;
if (x && y) clamp = [ !!z[0], !!z[1] ]; else if (x || y) clamp[+!x] = !!z;
return brush;
};
brush.extent = function(z) {

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

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

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

@ -287,9 +287,9 @@ d3.svg.brush = function() {
};
brush.clamp = function(z) {
if (!arguments.length) return x && y ? clamp : clamp[+!x];
if (!arguments.length) return x && y ? clamp : x || y ? clamp[+!x] : null;
if (x && y) clamp = [!!z[0], !!z[1]];
else clamp[+!x] = !!z;
else if (x || y) clamp[+!x] = !!z;
return brush;
};

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

@ -22,6 +22,9 @@ suite.addBatch({
},
"clamp": {
"returns null when no scales are attached": function(brush) {
assert.isNull(brush().clamp());
},
"returns a single boolean if only x is defined": function(brush) {
var b = brush().x(_.scale.linear());
assert.isTrue(b.clamp());