Merge branch 'release'
This commit is contained in:
Коммит
1e0b80fb3a
3
Makefile
3
Makefile
|
@ -78,8 +78,6 @@ d3.core.js: \
|
|||
src/core/uninterpolate.js \
|
||||
src/core/rgb.js \
|
||||
src/core/hsl.js \
|
||||
src/core/select.js \
|
||||
src/core/selectAll.js \
|
||||
src/core/selection.js \
|
||||
src/core/selection-select.js \
|
||||
src/core/selection-selectAll.js \
|
||||
|
@ -104,6 +102,7 @@ d3.core.js: \
|
|||
src/core/selection-empty.js \
|
||||
src/core/selection-node.js \
|
||||
src/core/selection-transition.js \
|
||||
src/core/selection-root.js \
|
||||
src/core/transition.js \
|
||||
src/core/transition-select.js \
|
||||
src/core/transition-selectAll.js \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function(){d3 = {version: "2.0.3"}; // semver
|
||||
(function(){d3 = {version: "2.0.4"}; // semver
|
||||
if (!Date.now) Date.now = function() {
|
||||
return +new Date;
|
||||
};
|
||||
|
@ -1183,17 +1183,6 @@ function d3_hsl_rgb(h, s, l) {
|
|||
|
||||
return d3_rgb(vv(h + 120), vv(h), vv(h - 120));
|
||||
}
|
||||
// TODO fast singleton implementation!
|
||||
d3.select = function(selector) {
|
||||
return typeof selector === "string"
|
||||
? d3_selectionRoot.select(selector)
|
||||
: d3_selection([[selector]]); // assume node
|
||||
};
|
||||
d3.selectAll = function(selector) {
|
||||
return typeof selector === "string"
|
||||
? d3_selectionRoot.selectAll(selector)
|
||||
: d3_selection([selector]); // assume node[]
|
||||
};
|
||||
function d3_selection(groups) {
|
||||
d3_arraySubclass(groups, d3_selectionPrototype);
|
||||
return groups;
|
||||
|
@ -1208,10 +1197,7 @@ if (typeof Sizzle === "function") {
|
|||
d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
|
||||
}
|
||||
|
||||
var d3_selectionPrototype = [],
|
||||
d3_selectionRoot = d3_selection([[document]]);
|
||||
|
||||
d3_selectionRoot[0].parentNode = document.documentElement;
|
||||
var d3_selectionPrototype = [];
|
||||
|
||||
d3.selection = function() {
|
||||
return d3_selectionRoot;
|
||||
|
@ -1737,6 +1723,22 @@ d3_selectionPrototype.transition = function() {
|
|||
|
||||
return d3_transition(subgroups, d3_transitionInheritId || ++d3_transitionId);
|
||||
};
|
||||
var d3_selectionRoot = d3_selection([[document]]);
|
||||
|
||||
d3_selectionRoot[0].parentNode = document.documentElement;
|
||||
|
||||
// TODO fast singleton implementation!
|
||||
d3.select = function(selector) {
|
||||
return typeof selector === "string"
|
||||
? d3_selectionRoot.select(selector)
|
||||
: d3_selection([[selector]]); // assume node
|
||||
};
|
||||
|
||||
d3.selectAll = function(selector) {
|
||||
return typeof selector === "string"
|
||||
? d3_selectionRoot.selectAll(selector)
|
||||
: d3_selection([selector]); // assume node[]
|
||||
};
|
||||
function d3_transition(groups, id) {
|
||||
d3_arraySubclass(groups, d3_transitionPrototype);
|
||||
|
||||
|
@ -1772,50 +1774,53 @@ function d3_transition(groups, id) {
|
|||
node = this,
|
||||
delay = groups[j][i].delay,
|
||||
duration = groups[j][i].duration,
|
||||
lock = node.__transition__;
|
||||
lock = node.__transition__ || (node.__transition__ = {active: 0, count: 0});
|
||||
|
||||
++lock.count;
|
||||
|
||||
if (!lock) lock = node.__transition__ = {active: 0, owner: id};
|
||||
else if (lock.owner < id) lock.owner = id;
|
||||
delay <= elapsed ? start() : d3.timer(start, delay, then);
|
||||
|
||||
function start() {
|
||||
if (lock.active <= id) {
|
||||
lock.active = id;
|
||||
event.start.dispatch.call(node, d, i);
|
||||
if (lock.active > id) return stop();
|
||||
lock.active = id;
|
||||
|
||||
for (var tween in tweens) {
|
||||
if (tween = tweens[tween].call(node, d, i)) {
|
||||
tweened.push(tween);
|
||||
}
|
||||
for (var tween in tweens) {
|
||||
if (tween = tweens[tween].call(node, d, i)) {
|
||||
tweened.push(tween);
|
||||
}
|
||||
|
||||
d3.timer(tick, 0, then);
|
||||
}
|
||||
return true;
|
||||
|
||||
event.start.dispatch.call(node, d, i);
|
||||
d3.timer(tick, 0, then);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function tick(elapsed) {
|
||||
if (lock.active !== id) return true;
|
||||
if (lock.active !== id) return stop();
|
||||
|
||||
var t = Math.min(1, (elapsed - delay) / duration),
|
||||
e = ease(t),
|
||||
n = tweened.length;
|
||||
|
||||
while (--n >= 0) {
|
||||
tweened[n].call(node, e);
|
||||
while (n > 0) {
|
||||
tweened[--n].call(node, e);
|
||||
}
|
||||
|
||||
if (t === 1) {
|
||||
lock.active = 0;
|
||||
if (lock.owner === id) delete node.__transition__;
|
||||
stop();
|
||||
d3_transitionInheritId = id;
|
||||
event.end.dispatch.call(node, d, i);
|
||||
d3_transitionInheritId = 0;
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (!--lock.count) delete node.__transition__;
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
return true;
|
||||
return 1;
|
||||
}, 0, then);
|
||||
|
||||
return groups;
|
||||
|
@ -3794,7 +3799,7 @@ d3.behavior.zoom = function() {
|
|||
this
|
||||
.on("mousedown.zoom", mousedown)
|
||||
.on("mousewheel.zoom", mousewheel)
|
||||
.on("DOMMouseScroll.zoom", dblclick)
|
||||
.on("DOMMouseScroll.zoom", mousewheel)
|
||||
.on("dblclick.zoom", dblclick)
|
||||
.on("touchstart.zoom", touchstart);
|
||||
|
||||
|
@ -3899,7 +3904,7 @@ function d3_behavior_zoomDelta() {
|
|||
d3_behavior_zoomDiv.dispatchEvent(e);
|
||||
delta = 1000 - d3_behavior_zoomDiv.scrollTop;
|
||||
} catch (error) {
|
||||
delta = e.wheelDelta || -e.detail;
|
||||
delta = e.wheelDelta || (-e.detail * 5);
|
||||
}
|
||||
|
||||
return delta * .005;
|
||||
|
|
|
@ -1754,7 +1754,7 @@ d3.layout.treemap = function() {
|
|||
v = u ? round(row.area / u) : 0,
|
||||
o;
|
||||
if (u == rect.dx) { // horizontal subdivision
|
||||
if (flush || v > rect.dy) v = rect.dy; // over+underflow
|
||||
if (flush || v > rect.dy) v = v ? rect.dy : 0; // over+underflow
|
||||
while (++i < n) {
|
||||
o = row[i];
|
||||
o.x = x;
|
||||
|
@ -1767,7 +1767,7 @@ d3.layout.treemap = function() {
|
|||
rect.y += v;
|
||||
rect.dy -= v;
|
||||
} else { // vertical subdivision
|
||||
if (flush || v > rect.dx) v = rect.dx; // over+underflow
|
||||
if (flush || v > rect.dx) v = v ? rect.dx : 0; // over+underflow
|
||||
while (++i < n) {
|
||||
o = row[i];
|
||||
o.x = x;
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -4,7 +4,7 @@ d3.json("../data/faithful.json", function(faithful) {
|
|||
var w = 800,
|
||||
h = 400,
|
||||
x = d3.scale.linear().domain([30, 110]).range([0, w]);
|
||||
bins = d3.layout.histogram().frequency(true).bins(x.ticks(60))(data),
|
||||
bins = d3.layout.histogram().frequency(false).bins(x.ticks(60))(data),
|
||||
max = d3.max(bins, function(d) { return d.y; }),
|
||||
y = d3.scale.linear().domain([0, .1]).range([0, h]),
|
||||
kde = science.stats.kde().sample(data);
|
||||
|
|
|
@ -44,8 +44,8 @@ var svg = d3.select("body").append("svg:svg")
|
|||
svg.append("svg:rect")
|
||||
.attr("width", size[0])
|
||||
.attr("height", size[1])
|
||||
.attr("stroke", stroke)
|
||||
.attr("fill", "none");
|
||||
.attr("stroke", "none")
|
||||
.style("fill", "#fff");
|
||||
|
||||
svg.append("svg:a")
|
||||
.attr("xlink:href", "http://mbostock.github.com/d3/")
|
||||
|
@ -70,7 +70,7 @@ function redraw() {
|
|||
gx.select("text")
|
||||
.text(fx);
|
||||
|
||||
var gxe = gx.enter().insert("svg:g", "rect")
|
||||
var gxe = gx.enter().insert("svg:g", "a")
|
||||
.attr("class", "x")
|
||||
.attr("transform", tx);
|
||||
|
||||
|
@ -95,7 +95,7 @@ function redraw() {
|
|||
gy.select("text")
|
||||
.text(fy);
|
||||
|
||||
var gye = gy.enter().insert("svg:g", "rect")
|
||||
var gye = gy.enter().insert("svg:g", "a")
|
||||
.attr("class", "y")
|
||||
.attr("transform", ty);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ d3.behavior.zoom = function() {
|
|||
this
|
||||
.on("mousedown.zoom", mousedown)
|
||||
.on("mousewheel.zoom", mousewheel)
|
||||
.on("DOMMouseScroll.zoom", dblclick)
|
||||
.on("DOMMouseScroll.zoom", mousewheel)
|
||||
.on("dblclick.zoom", dblclick)
|
||||
.on("touchstart.zoom", touchstart);
|
||||
|
||||
|
@ -113,7 +113,7 @@ function d3_behavior_zoomDelta() {
|
|||
d3_behavior_zoomDiv.dispatchEvent(e);
|
||||
delta = 1000 - d3_behavior_zoomDiv.scrollTop;
|
||||
} catch (error) {
|
||||
delta = e.wheelDelta || -e.detail;
|
||||
delta = e.wheelDelta || (-e.detail * 5);
|
||||
}
|
||||
|
||||
return delta * .005;
|
||||
|
|
|
@ -1 +1 @@
|
|||
d3 = {version: "2.0.3"}; // semver
|
||||
d3 = {version: "2.0.4"}; // semver
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
// TODO fast singleton implementation!
|
||||
d3.select = function(selector) {
|
||||
return typeof selector === "string"
|
||||
? d3_selectionRoot.select(selector)
|
||||
: d3_selection([[selector]]); // assume node
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
d3.selectAll = function(selector) {
|
||||
return typeof selector === "string"
|
||||
? d3_selectionRoot.selectAll(selector)
|
||||
: d3_selection([selector]); // assume node[]
|
||||
};
|
|
@ -0,0 +1,16 @@
|
|||
var d3_selectionRoot = d3_selection([[document]]);
|
||||
|
||||
d3_selectionRoot[0].parentNode = document.documentElement;
|
||||
|
||||
// TODO fast singleton implementation!
|
||||
d3.select = function(selector) {
|
||||
return typeof selector === "string"
|
||||
? d3_selectionRoot.select(selector)
|
||||
: d3_selection([[selector]]); // assume node
|
||||
};
|
||||
|
||||
d3.selectAll = function(selector) {
|
||||
return typeof selector === "string"
|
||||
? d3_selectionRoot.selectAll(selector)
|
||||
: d3_selection([selector]); // assume node[]
|
||||
};
|
|
@ -12,10 +12,7 @@ if (typeof Sizzle === "function") {
|
|||
d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
|
||||
}
|
||||
|
||||
var d3_selectionPrototype = [],
|
||||
d3_selectionRoot = d3_selection([[document]]);
|
||||
|
||||
d3_selectionRoot[0].parentNode = document.documentElement;
|
||||
var d3_selectionPrototype = [];
|
||||
|
||||
d3.selection = function() {
|
||||
return d3_selectionRoot;
|
||||
|
|
|
@ -33,50 +33,53 @@ function d3_transition(groups, id) {
|
|||
node = this,
|
||||
delay = groups[j][i].delay,
|
||||
duration = groups[j][i].duration,
|
||||
lock = node.__transition__;
|
||||
lock = node.__transition__ || (node.__transition__ = {active: 0, count: 0});
|
||||
|
||||
++lock.count;
|
||||
|
||||
if (!lock) lock = node.__transition__ = {active: 0, owner: id};
|
||||
else if (lock.owner < id) lock.owner = id;
|
||||
delay <= elapsed ? start() : d3.timer(start, delay, then);
|
||||
|
||||
function start() {
|
||||
if (lock.active <= id) {
|
||||
lock.active = id;
|
||||
event.start.dispatch.call(node, d, i);
|
||||
if (lock.active > id) return stop();
|
||||
lock.active = id;
|
||||
|
||||
for (var tween in tweens) {
|
||||
if (tween = tweens[tween].call(node, d, i)) {
|
||||
tweened.push(tween);
|
||||
}
|
||||
for (var tween in tweens) {
|
||||
if (tween = tweens[tween].call(node, d, i)) {
|
||||
tweened.push(tween);
|
||||
}
|
||||
|
||||
d3.timer(tick, 0, then);
|
||||
}
|
||||
return true;
|
||||
|
||||
event.start.dispatch.call(node, d, i);
|
||||
d3.timer(tick, 0, then);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function tick(elapsed) {
|
||||
if (lock.active !== id) return true;
|
||||
if (lock.active !== id) return stop();
|
||||
|
||||
var t = Math.min(1, (elapsed - delay) / duration),
|
||||
e = ease(t),
|
||||
n = tweened.length;
|
||||
|
||||
while (--n >= 0) {
|
||||
tweened[n].call(node, e);
|
||||
while (n > 0) {
|
||||
tweened[--n].call(node, e);
|
||||
}
|
||||
|
||||
if (t === 1) {
|
||||
lock.active = 0;
|
||||
if (lock.owner === id) delete node.__transition__;
|
||||
stop();
|
||||
d3_transitionInheritId = id;
|
||||
event.end.dispatch.call(node, d, i);
|
||||
d3_transitionInheritId = 0;
|
||||
return true;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (!--lock.count) delete node.__transition__;
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
return true;
|
||||
return 1;
|
||||
}, 0, then);
|
||||
|
||||
return groups;
|
||||
|
|
|
@ -106,7 +106,7 @@ d3.layout.treemap = function() {
|
|||
v = u ? round(row.area / u) : 0,
|
||||
o;
|
||||
if (u == rect.dx) { // horizontal subdivision
|
||||
if (flush || v > rect.dy) v = rect.dy; // over+underflow
|
||||
if (flush || v > rect.dy) v = v ? rect.dy : 0; // over+underflow
|
||||
while (++i < n) {
|
||||
o = row[i];
|
||||
o.x = x;
|
||||
|
@ -119,7 +119,7 @@ d3.layout.treemap = function() {
|
|||
rect.y += v;
|
||||
rect.dy -= v;
|
||||
} else { // vertical subdivision
|
||||
if (flush || v > rect.dx) v = rect.dx; // over+underflow
|
||||
if (flush || v > rect.dx) v = v ? rect.dx : 0; // over+underflow
|
||||
while (++i < n) {
|
||||
o = row[i];
|
||||
o.x = x;
|
||||
|
|
|
@ -69,8 +69,8 @@ module.exports = {
|
|||
"sets an exclusive lock on transitioning nodes": function(result) {
|
||||
var id = result.id;
|
||||
assert.isTrue(id > 0);
|
||||
assert.equal(result.selection[0][0].__transition__.owner, id);
|
||||
assert.equal(result.selection[0][1].__transition__.owner, id);
|
||||
assert.equal(result.selection[0][0].__transition__.count, 1);
|
||||
assert.equal(result.selection[0][1].__transition__.count, 1);
|
||||
assert.equal(result.selection[0][0].__transition__.active, id);
|
||||
assert.equal(result.selection[0][1].__transition__.active, id);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ module.exports = {
|
|||
},
|
||||
"inherits the same transition id": function(result) {
|
||||
assert.isTrue(result.id > 0);
|
||||
assert.equal(result.node.__transition__.owner, result.id);
|
||||
assert.equal(result.node.__transition__.count, 1);
|
||||
assert.equal(result.node.__transition__.active, result.id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
require("../env");
|
||||
require("../../d3");
|
||||
|
||||
var assert = require("assert");
|
||||
|
||||
module.exports = {
|
||||
topic: function() {
|
||||
return d3.select("body").append("div").transition()
|
||||
.delay(100)
|
||||
.duration(150)
|
||||
.ease("bounce");
|
||||
},
|
||||
|
||||
"inherits the delay": function(t1) {
|
||||
var t2 = t1.transition();
|
||||
assert.equal(t2[0][0].delay, 100);
|
||||
},
|
||||
"inherits the duration": function(t1) {
|
||||
var t2 = t1.transition();
|
||||
assert.equal(t2[0][0].duration, 150);
|
||||
},
|
||||
"inherits easing": function(t1) {
|
||||
// TODO how to test this?
|
||||
},
|
||||
"inherits the transition id": function(t1) {
|
||||
var t2 = t1.transition();
|
||||
assert.equal(t2.id, t1.id);
|
||||
},
|
||||
|
||||
"while transitioning": {
|
||||
topic: function(t1) {
|
||||
var t2 = t1.transition(),
|
||||
cb = this.callback;
|
||||
t2.each("start", function() {
|
||||
d3.timer(function() {
|
||||
cb(null, t2);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
},
|
||||
"increments the lock's reference count": function(t2) {
|
||||
assert.isTrue(t2[0][0].node.__transition__.count > 1);
|
||||
}
|
||||
},
|
||||
|
||||
"after transitioning": {
|
||||
topic: function(t1) {
|
||||
var cb = this.callback;
|
||||
t1.each("end", function() {
|
||||
d3.timer(function() {
|
||||
cb(null, t1);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
},
|
||||
"decrements the lock's reference count": function(t1) {
|
||||
assert.isFalse("__transition__" in t1[0][0].node);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -40,6 +40,7 @@ suite.addBatch({
|
|||
// Subtransitions
|
||||
"select": require("./transition-test-select"),
|
||||
"selectAll": require("./transition-test-selectAll"),
|
||||
"transition": require("./transition-test-transition"),
|
||||
|
||||
// Content
|
||||
"attr": require("./transition-test-attr"),
|
||||
|
|
|
@ -134,6 +134,36 @@ suite.addBatch({
|
|||
{x: 1, y: 556, dx: 599, dy: 277},
|
||||
{x: 1, y: 1, dx: 599, dy: 555}
|
||||
]);
|
||||
},
|
||||
"no negatively sized rectangles": function(treemap) {
|
||||
var t = treemap().size([615, 500]).sort(function(a, b) { return a.value - b.value; }).padding(29),
|
||||
nodes = t.nodes({"children": [
|
||||
{"value": 1},
|
||||
{"value": 9},
|
||||
{"value": 3},
|
||||
{"value": 15},
|
||||
{"value": 44},
|
||||
{"value": 28},
|
||||
{"value": 32},
|
||||
{"value": 41},
|
||||
{"value": 50},
|
||||
{"value": 60},
|
||||
{"value": 64},
|
||||
{"value": 75},
|
||||
{"value": 76},
|
||||
{"value": 84},
|
||||
{"value": 88},
|
||||
{"value": 100},
|
||||
{"value": 140},
|
||||
{"value": 142},
|
||||
{"value": 363},
|
||||
{"value": 657},
|
||||
{"value": 670},
|
||||
{"value": 822},
|
||||
{"value": 1173},
|
||||
{"value": 1189}
|
||||
]}).map(layout);
|
||||
assert.equal(nodes.filter(function(n) { return n.dx < 0 || n.dy < 0; }).length, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче