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:
Родитель
84f4a62c01
Коммит
85d156c3f7
|
@ -8047,8 +8047,8 @@ d3 = function() {
|
||||||
return brush;
|
return brush;
|
||||||
};
|
};
|
||||||
brush.clamp = function(z) {
|
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;
|
if (x && y) clamp = [ !!z[0], !!z[1] ]; else if (x || y) clamp[+!x] = !!z;
|
||||||
return brush;
|
return brush;
|
||||||
};
|
};
|
||||||
brush.extent = function(z) {
|
brush.extent = function(z) {
|
||||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -287,9 +287,9 @@ d3.svg.brush = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
brush.clamp = function(z) {
|
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]];
|
if (x && y) clamp = [!!z[0], !!z[1]];
|
||||||
else clamp[+!x] = !!z;
|
else if (x || y) clamp[+!x] = !!z;
|
||||||
return brush;
|
return brush;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,9 @@ suite.addBatch({
|
||||||
},
|
},
|
||||||
|
|
||||||
"clamp": {
|
"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) {
|
"returns a single boolean if only x is defined": function(brush) {
|
||||||
var b = brush().x(_.scale.linear());
|
var b = brush().x(_.scale.linear());
|
||||||
assert.isTrue(b.clamp());
|
assert.isTrue(b.clamp());
|
||||||
|
|
Загрузка…
Ссылка в новой задаче