Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '2.9.3'

  • Loading branch information...
commit b6153d213d520cbe7064beab423d70ca767c45f4 2 parents dd2a424 + 0d31c17
@mbostock authored
View
37 d3.v2.js
@@ -10,7 +10,7 @@ try {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
-d3 = {version: "2.9.2"}; // semver
+d3 = {version: "2.9.3"}; // semver
function d3_class(ctor, properties) {
try {
for (var key in properties) {
@@ -2813,11 +2813,11 @@ function d3_scale_log(linear, log) {
scale.tickFormat = function(n, format) {
if (arguments.length < 2) format = d3_scale_logFormat;
if (arguments.length < 1) return format;
- var k = n / scale.ticks().length,
+ var k = Math.max(.1, n / scale.ticks().length),
f = log === d3_scale_logn ? (e = -1e-12, Math.floor) : (e = 1e-12, Math.ceil),
e;
return function(d) {
- return d / pow(f(log(d) + e)) < k ? format(d) : "";
+ return d / pow(f(log(d) + e)) <= k ? format(d) : "";
};
};
@@ -3547,19 +3547,21 @@ function d3_svg_lineBasisClosed(points) {
}
function d3_svg_lineBundle(points, tension) {
- var n = points.length - 1,
- x0 = points[0][0],
- y0 = points[0][1],
- dx = points[n][0] - x0,
- dy = points[n][1] - y0,
- i = -1,
- p,
- t;
- while (++i <= n) {
- p = points[i];
- t = i / n;
- p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
- p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
+ var n = points.length - 1;
+ if (n) {
+ var x0 = points[0][0],
+ y0 = points[0][1],
+ dx = points[n][0] - x0,
+ dy = points[n][1] - y0,
+ i = -1,
+ p,
+ t;
+ while (++i <= n) {
+ p = points[i];
+ t = i / n;
+ p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
+ p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
+ }
}
return d3_svg_lineBasis(points);
}
@@ -9035,7 +9037,8 @@ function d3_time_formatIsoNative(date) {
}
d3_time_formatIsoNative.parse = function(string) {
- return new Date(string);
+ var date = new Date(string);
+ return isNaN(date) ? null : date;
};
d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
View
8 d3.v2.min.js
4 additions, 4 deletions not shown
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "d3",
- "version": "2.9.2",
+ "version": "2.9.3",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
View
2  src/core/core.js
@@ -1 +1 @@
-d3 = {version: "2.9.2"}; // semver
+d3 = {version: "2.9.3"}; // semver
View
4 src/scale/log.js
@@ -51,11 +51,11 @@ function d3_scale_log(linear, log) {
scale.tickFormat = function(n, format) {
if (arguments.length < 2) format = d3_scale_logFormat;
if (arguments.length < 1) return format;
- var k = n / scale.ticks().length,
+ var k = Math.max(.1, n / scale.ticks().length),
f = log === d3_scale_logn ? (e = -1e-12, Math.floor) : (e = 1e-12, Math.ceil),
e;
return function(d) {
- return d / pow(f(log(d) + e)) < k ? format(d) : "";
+ return d / pow(f(log(d) + e)) <= k ? format(d) : "";
};
};
View
28 src/svg/line.js
@@ -298,19 +298,21 @@ function d3_svg_lineBasisClosed(points) {
}
function d3_svg_lineBundle(points, tension) {
- var n = points.length - 1,
- x0 = points[0][0],
- y0 = points[0][1],
- dx = points[n][0] - x0,
- dy = points[n][1] - y0,
- i = -1,
- p,
- t;
- while (++i <= n) {
- p = points[i];
- t = i / n;
- p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
- p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
+ var n = points.length - 1;
+ if (n) {
+ var x0 = points[0][0],
+ y0 = points[0][1],
+ dx = points[n][0] - x0,
+ dy = points[n][1] - y0,
+ i = -1,
+ p,
+ t;
+ while (++i <= n) {
+ p = points[i];
+ t = i / n;
+ p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
+ p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
+ }
}
return d3_svg_lineBasis(points);
}
View
3  src/time/format-iso.js
@@ -7,7 +7,8 @@ function d3_time_formatIsoNative(date) {
}
d3_time_formatIsoNative.parse = function(string) {
- return new Date(string);
+ var date = new Date(string);
+ return isNaN(date) ? null : date;
};
d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
View
18 test/scale/log-test.js
@@ -179,7 +179,7 @@ suite.addBatch({
"can generate fewer ticks, if desired": function(log) {
var x = log();
assert.deepEqual(x.ticks().map(x.tickFormat(5)), [
- "1e+0", "2e+0", "3e+0", "4e+0", "", "", "", "", "",
+ "1e+0", "2e+0", "3e+0", "4e+0", "5e+0", "", "", "", "",
"1e+1"
]);
var x = log().domain([100, 1]);
@@ -189,6 +189,22 @@ suite.addBatch({
"1e+2"
]);
},
+ "generates powers-of-ten ticks, even for huge domains": function(log) {
+ var x = log().domain([1e10, 1]);
+ assert.deepEqual(x.ticks().map(x.tickFormat(10)), [
+ "1e+0", "", "", "", "", "", "", "", "",
+ "1e+1", "", "", "", "", "", "", "", "",
+ "1e+2", "", "", "", "", "", "", "", "",
+ "1e+3", "", "", "", "", "", "", "", "",
+ "1e+4", "", "", "", "", "", "", "", "",
+ "1e+5", "", "", "", "", "", "", "", "",
+ "1e+6", "", "", "", "", "", "", "", "",
+ "1e+7", "", "", "", "", "", "", "", "",
+ "1e+8", "", "", "", "", "", "", "", "",
+ "1e+9", "", "", "", "", "", "", "", "",
+ "1e+10"
+ ]);
+ },
"can override the tick format": function(log) {
var x = log().domain([1000.1, 1]);
assert.deepEqual(x.ticks().map(x.tickFormat(10, d3.format("+,d"))), [
View
4 test/svg/line-test.js
@@ -134,6 +134,10 @@ suite.addBatch({
"observes the specified tension": function(line) {
var l = line().interpolate("bundle").tension(1);
assert.pathEqual(l([[0, 0], [1, 1], [2, 0], [3, 1], [4, 0]]), line().interpolate("basis")([[0, 0], [1, 1], [2, 0], [3, 1], [4, 0]]));
+ },
+ "supports a single-element array": function(line) {
+ var l = line().interpolate("bundle").tension(1);
+ assert.pathEqual(l([[0, 0]]), "M0,0");
}
},
View
1  test/time/format-test.js
@@ -461,6 +461,7 @@ suite.addBatch({
var p = format.parse;
assert.deepEqual(p("1990-01-01T00:00:00.000Z"), utc(1990, 0, 1, 0, 0, 0));
assert.deepEqual(p("2011-12-31T23:59:59.000Z"), utc(2011, 11, 31, 23, 59, 59));
+ assert.isNull(p("1990-01-01T00:00:00.000X"));
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.