Merge branch 'master' into fix-interpolate-rotate

This commit is contained in:
Mike Bostock 2012-06-21 17:37:34 -07:00
Родитель 4059d3b3f5 ad43a2e843
Коммит e4f4a31252
13 изменённых файлов: 84 добавлений и 53 удалений

41
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.4"}; // semver
function d3_class(ctor, properties) {
try {
for (var key in properties) {
@ -494,7 +494,7 @@ d3.xhr = function(url, mime, callback) {
req.onreadystatechange = function() {
if (req.readyState === 4) {
var s = req.status;
callback(s >= 200 && s < 300 || s === 304 ? req : null);
callback(!s && req.response || s >= 200 && s < 300 || s === 304 ? req : null);
}
};
req.send(null);
@ -1515,7 +1515,7 @@ var d3_select = function(s, n) { return n.querySelector(s); },
// Prefer Sizzle, if available.
if (typeof Sizzle === "function") {
d3_select = function(s, n) { return Sizzle(s, n)[0]; };
d3_select = function(s, n) { return Sizzle(s, n)[0] || null; };
d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
d3_selectMatches = Sizzle.matchesSelector;
}
@ -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;

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

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

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

@ -1,6 +1,6 @@
{
"name": "d3",
"version": "2.9.2",
"version": "2.9.4",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",

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

@ -1 +1 @@
d3 = {version: "2.9.2"}; // semver
d3 = {version: "2.9.4"}; // semver

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

@ -11,7 +11,7 @@ var d3_select = function(s, n) { return n.querySelector(s); },
// Prefer Sizzle, if available.
if (typeof Sizzle === "function") {
d3_select = function(s, n) { return Sizzle(s, n)[0]; };
d3_select = function(s, n) { return Sizzle(s, n)[0] || null; };
d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
d3_selectMatches = Sizzle.matchesSelector;
}

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

@ -7,7 +7,7 @@ d3.xhr = function(url, mime, callback) {
req.onreadystatechange = function() {
if (req.readyState === 4) {
var s = req.status;
callback(s >= 200 && s < 300 || s === 304 ? req : null);
callback(!s && req.response || s >= 200 && s < 300 || s === 304 ? req : null);
}
};
req.send(null);

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

@ -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) : "";
};
};

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

@ -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);
}

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

@ -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;

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

@ -34,32 +34,36 @@ suite.export(module);
var suite = vows.describe("transition");
// Subtransitions
suite.addBatch({
// Subtransitions
"select": require("./transition-test-select"),
"selectAll": require("./transition-test-selectAll"),
"transition": require("./transition-test-transition"),
"transition": require("./transition-test-transition")
});
// Content
// Content
suite.addBatch({
"attr": require("./transition-test-attr"),
"attrTween": require("./transition-test-attrTween"),
"style": require("./transition-test-style"),
"styleTween": require("./transition-test-styleTween"),
"text": require("./transition-test-text"),
"remove": require("./transition-test-remove"),
"remove": require("./transition-test-remove")
});
// Animation
// Animation
suite.addBatch({
"delay": require("./transition-test-delay"),
"duration": require("./transition-test-duration"),
"duration": require("./transition-test-duration")
});
// Control
// Control
suite.addBatch({
"each": require("./transition-test-each"),
"call": require("./transition-test-call"),
"tween": require("./transition-test-tween"),
"id": require("./transition-test-id"),
"time": require("./transition-test-time")
});
suite.export(module);

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

@ -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"))), [

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

@ -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");
}
},

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

@ -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"));
}
}
}