Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Aug 27, 2011
2 parents fb7e69f + 18519d9 commit 1e0b80f
Show file tree
Hide file tree
Showing 19 changed files with 195 additions and 95 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down
83 changes: 44 additions & 39 deletions d3.js
Original file line number Diff line number Diff line change
@@ -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;
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions d3.layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion d3.layout.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/kde/kde.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions examples/zoom-pan/zoom-pan.html
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand All @@ -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);

Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/behavior/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
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.0.3"}; // semver
d3 = {version: "2.0.4"}; // semver
6 changes: 0 additions & 6 deletions src/core/select.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/core/selectAll.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/core/selection-root.js
Original file line number Diff line number Diff line change
@@ -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[]
};
5 changes: 1 addition & 4 deletions src/core/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
45 changes: 24 additions & 21 deletions src/core/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/layout/treemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 1e0b80f

Please sign in to comment.