Commit 90d06cf0 authored by Mike Bostock's avatar Mike Bostock
Browse files

Fix crash in ticks for empty d3.time.scale domain.

Fixes #1525. This was only an issue because the domain is extended by one
millisecond when it is empty (for an inclusive upper bound).
parent 5f8056c1
......@@ -8887,7 +8887,7 @@ d3 = function() {
range: interval
}, skip ];
if (method) interval = method[0], skip = method[1];
return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip);
return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip);
};
scale.tickFormat = function() {
return format;
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ function d3_time_scale(linear, methods, format) {
if (method) interval = method[0], skip = method[1];
return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip); // inclusive upper bound
return interval.range(extent[0], d3_time_scaleDate(+extent[1] + 1), skip < 1 ? 1 : skip); // inclusive upper bound
};
scale.tickFormat = function() {
......
......@@ -313,6 +313,10 @@ suite.addBatch({
local(1500, 0, 1, 0, 0),
local(2000, 0, 1, 0, 0)
]);
},
"returns one tick for degenerate empty domain": function(scale) {
var x = scale().domain([local(2014, 2, 2), local(2014, 2, 2)]);
assert.deepEqual(x.ticks(6), [local(2014, 2, 2)]);
}
},
......@@ -617,6 +621,10 @@ suite.addBatch({
utc(1500, 0, 1, 0, 0),
utc(2000, 0, 1, 0, 0)
]);
},
"returns one tick for degenerate empty domain": function(scale) {
var x = scale().domain([utc(2014, 2, 2), utc(2014, 2, 2)]);
assert.deepEqual(x.ticks(6), [utc(2014, 2, 2)]);
}
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment