Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
2 parents fb7e69f + 18519d9 commit 1e0b80fb3a8d3fe8133c1e89b6f5cd4d738c80e7 @mbostock mbostock committed Aug 27, 2011
View
@@ -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 \
View
83 d3.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);
-
- for (var tween in tweens) {
- if (tween = tweens[tween].call(node, d, i)) {
- tweened.push(tween);
- }
- }
+ if (lock.active > id) return stop();
+ lock.active = id;
- d3.timer(tick, 0, then);
+ for (var tween in tweens) {
+ if (tween = tweens[tween].call(node, d, i)) {
+ tweened.push(tween);
+ }
}
- 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;
View
@@ -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;
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -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 @@
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 @@
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 @@
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);
View
@@ -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;
View
@@ -1 +1 @@
-d3 = {version: "2.0.3"}; // semver
+d3 = {version: "2.0.4"}; // semver
View
@@ -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
-};
View
@@ -1,5 +0,0 @@
-d3.selectAll = function(selector) {
- return typeof selector === "string"
- ? d3_selectionRoot.selectAll(selector)
- : d3_selection([selector]); // assume node[]
-};
View
@@ -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[]
+};
View
@@ -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;
View
@@ -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);
-
- for (var tween in tweens) {
- if (tween = tweens[tween].call(node, d, i)) {
- tweened.push(tween);
- }
- }
+ if (lock.active > id) return stop();
+ lock.active = id;
- d3.timer(tick, 0, then);
+ for (var tween in tweens) {
+ if (tween = tweens[tween].call(node, d, i)) {
+ tweened.push(tween);
+ }
}
- 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;
View
@@ -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;
Oops, something went wrong.

0 comments on commit 1e0b80f

Please sign in to comment.