Skip to content

Commit

Permalink
Merge branch '2.9.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jun 14, 2012
2 parents dd2a424 + 0d31c17 commit b6153d2
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 40 deletions.
37 changes: 20 additions & 17 deletions d3.v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) : "";
};
};

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions d3.v2.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d3 = {version: "2.9.2"}; // semver
d3 = {version: "2.9.3"}; // semver
4 changes: 2 additions & 2 deletions src/scale/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) : "";
};
};

Expand Down
28 changes: 15 additions & 13 deletions src/svg/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion src/time/format-iso.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
18 changes: 17 additions & 1 deletion test/scale/log-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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"))), [
Expand Down
4 changes: 4 additions & 0 deletions test/svg/line-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
},

Expand Down
1 change: 1 addition & 0 deletions test/time/format-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
}
Expand Down

0 comments on commit b6153d2

Please sign in to comment.