Skip to content

Commit

Permalink
Merge branch '3.0.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Feb 6, 2013
2 parents 183060d + a716468 commit 35ac9dd
Show file tree
Hide file tree
Showing 43 changed files with 424 additions and 301 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ all: \
src/end.js

d3.core.js: \
src/core/core.js \
src/core/format-$(LOCALE).js \
src/compat/date.js \
src/compat/style.js \
src/core/core.js \
src/core/class.js \
src/core/array.js \
src/core/map.js \
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "d3",
"version": "3.0.5",
"version": "3.0.6",
"main": "./d3.js"
}
210 changes: 97 additions & 113 deletions d3.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions globals.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
var document = global.document = require("jsdom").jsdom("<html><head></head><body></body></html>"),
window = global.window = document.createWindow(),
navigator = global.navigator = window.navigator,
getComputedStyle = global.getComputedStyle = window.getComputedStyle,
CSSStyleDeclaration = global.CSSStyleDeclaration = window.CSSStyleDeclaration;
window = global.window = document.createWindow();

// https://github.com/chad3814/CSSStyleDeclaration/issues/3
var CSSStyleDeclaration_setProperty = CSSStyleDeclaration.prototype.setProperty;
CSSStyleDeclaration.prototype.setProperty = function(name, value, priority) {
var CSSStyleDeclaration_prototype = window.CSSStyleDeclaration.prototype,
CSSStyleDeclaration_setProperty = CSSStyleDeclaration_prototype.setProperty;
CSSStyleDeclaration_prototype.setProperty = function(name, value, priority) {
return CSSStyleDeclaration_setProperty.call(this, name + "", value == null ? null : value + "", priority == null ? null : priority + "");
};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var globals = ["document", "window", "navigator", "CSSStyleDeclaration", "getComputedStyle", "d3"],
var globals = ["document", "window", "d3"],
globalValues = {};

globals.forEach(function(g) {
Expand Down
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": "3.0.5",
"version": "3.0.6",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
Expand Down
2 changes: 1 addition & 1 deletion src/behavior/drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ d3.behavior.drag = function() {
origin_ = point(),
moved = 0;

var w = d3.select(window)
var w = d3.select(d3_window)
.on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove)
.on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true);

Expand Down
46 changes: 10 additions & 36 deletions src/behavior/zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ d3.behavior.zoom = function() {
touchtime; // time of last touchstart (to detect double-tap)

function zoom() {
this
.on("mousedown.zoom", mousedown)
.on("mousewheel.zoom", mousewheel)
this.on("mousedown.zoom", mousedown)
.on("mousemove.zoom", mousemove)
.on("DOMMouseScroll.zoom", mousewheel)
.on(d3_behavior_zoomWheel + ".zoom", mousewheel)
.on("dblclick.zoom", dblclick)
.on("touchstart.zoom", touchstart)
.on("touchmove.zoom", touchmove)
Expand Down Expand Up @@ -95,10 +93,10 @@ d3.behavior.zoom = function() {
event_ = event.of(target, arguments),
eventTarget = d3.event.target,
moved = 0,
w = d3.select(window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup),
w = d3.select(d3_window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup),
l = location(d3.mouse(target));

window.focus();
d3_window.focus();
d3_eventCancel();

function mousemove() {
Expand Down Expand Up @@ -175,34 +173,10 @@ d3.behavior.zoom = function() {
return d3.rebind(zoom, event, "on");
};

var d3_behavior_zoomDiv, // for interpreting mousewheel events
d3_behavior_zoomInfinity = [0, Infinity]; // default scale extent

function d3_behavior_zoomDelta() {

// mousewheel events are totally broken!
// https://bugs.webkit.org/show_bug.cgi?id=40441
// not only that, but Chrome and Safari differ in re. to acceleration!
if (!d3_behavior_zoomDiv) {
d3_behavior_zoomDiv = d3.select("body").append("div")
.style("visibility", "hidden")
.style("top", 0)
.style("height", 0)
.style("width", 0)
.style("overflow-y", "scroll")
.append("div")
.style("height", "2000px")
.node().parentNode;
}

var e = d3.event, delta;
try {
d3_behavior_zoomDiv.scrollTop = 1000;
d3_behavior_zoomDiv.dispatchEvent(e);
delta = 1000 - d3_behavior_zoomDiv.scrollTop;
} catch (error) {
delta = e.wheelDelta || (-e.detail * 5);
}
var d3_behavior_zoomInfinity = [0, Infinity]; // default scale extent

return delta;
}
// https://developer.mozilla.org/en-US/docs/Mozilla_event_reference/wheel
var d3_behavior_zoomDelta, d3_behavior_zoomWheel
= "onwheel" in document ? (d3_behavior_zoomDelta = function() { return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); }, "wheel")
: "onmousewheel" in document ? (d3_behavior_zoomDelta = function() { return d3.event.wheelDelta; }, "mousewheel")
: (d3_behavior_zoomDelta = function() { return -d3.event.detail; }, "MozMousePixelScroll");
4 changes: 2 additions & 2 deletions src/compat/style.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try {
document.createElement("div").style.setProperty("opacity", 0, "");
d3_document.createElement("div").style.setProperty("opacity", 0, "");
} catch (error) {
var d3_style_prototype = CSSStyleDeclaration.prototype,
var d3_style_prototype = d3_window.CSSStyleDeclaration.prototype,
d3_style_setProperty = d3_style_prototype.setProperty;
d3_style_prototype.setProperty = function(name, value, priority) {
d3_style_setProperty.call(this, name, value + "", priority);
Expand Down
4 changes: 2 additions & 2 deletions src/component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require("./core/core");
var d3 = require("../index");

require("util").puts(JSON.stringify({
console.log(JSON.stringify({
"name": "d3",
"version": d3.version,
"main": "./d3.js"
Expand Down
2 changes: 1 addition & 1 deletion src/core/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function d3_arraySlice(pseudoarray) {
}

try {
d3_array(document.documentElement.childNodes)[0].nodeType;
d3_array(d3_document.documentElement.childNodes)[0].nodeType;
} catch(e) {
d3_array = d3_arrayCopy;
}
Expand Down
7 changes: 4 additions & 3 deletions src/core/core.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
d3 = {version: "3.0.5"}; // semver

var π = Math.PI,
ε = 1e-6,
d3 = {version: "3.0.6"}, // semver
d3_radians = π / 180,
d3_degrees = 180 / π;
d3_degrees = 180 / π,
d3_document = document,
d3_window = window;

function d3_target(d) {
return d.target;
Expand Down
4 changes: 2 additions & 2 deletions src/core/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ var d3_format_types = d3.map({
g: function(x, p) { return x.toPrecision(p); },
e: function(x, p) { return x.toExponential(p); },
f: function(x, p) { return x.toFixed(p); },
r: function(x, p) { return d3.round(x, p = d3_format_precision(x, p)).toFixed(Math.max(0, Math.min(20, p))); }
r: function(x, p) { return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p)))); }
});

function d3_format_precision(x, p) {
return p - (x ? 1 + Math.floor(Math.log(x + Math.pow(10, 1 + Math.floor(Math.log(x) / Math.LN10) - p)) / Math.LN10) : 1);
return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1);
}

function d3_format_typeDefault(x) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/formatPrefix.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var d3_formatPrefixes = ["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(d3_formatPrefix);
var d3_formatPrefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map(d3_formatPrefix);

d3.formatPrefix = function(value, precision) {
var i = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/core/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ d3.html = function(url, callback) {
};

function d3_html(request) {
var range = document.createRange();
range.selectNode(document.body);
var range = d3_document.createRange();
range.selectNode(d3_document.body);
return range.createContextualFragment(request.responseText);
}
7 changes: 3 additions & 4 deletions src/core/mouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ d3.mouse = function(container) {
};

// https://bugs.webkit.org/show_bug.cgi?id=44083
var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0;
var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0;

function d3_mousePoint(container, e) {
var svg = container.ownerSVGElement || container;
if (svg.createSVGPoint) {
var point = svg.createSVGPoint();
if (d3_mouse_bug44083 < 0 && (window.scrollX || window.scrollY)) {
svg = d3.select(document.body)
.append("svg")
if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) {
svg = d3.select(d3_document.body).append("svg")
.style("position", "absolute")
.style("top", 0)
.style("left", 0);
Expand Down
9 changes: 3 additions & 6 deletions src/core/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ d3.random = {
return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);
};
},
logNormal: function(µ, σ) {
var n = arguments.length;
if (n < 2) σ = 1;
if (n < 1) µ = 0;
var random = d3.random.normal();
logNormal: function() {
var random = d3.random.normal.apply(d3, arguments);
return function() {
return Math.exp(µ + σ * random());
return Math.exp(random());
};
},
irwinHall: function(m) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/selection-append.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ d3_selectionPrototype.append = function(name) {
name = d3.ns.qualify(name);

function append() {
return this.appendChild(document.createElementNS(this.namespaceURI, name));
return this.appendChild(d3_document.createElementNS(this.namespaceURI, name));
}

function appendNS() {
return this.appendChild(document.createElementNS(name.space, name.local));
return this.appendChild(d3_document.createElementNS(name.space, name.local));
}

return this.select(name.local ? appendNS : append);
Expand Down
4 changes: 2 additions & 2 deletions src/core/selection-insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ d3_selectionPrototype.insert = function(name, before) {

function insert() {
return this.insertBefore(
document.createElementNS(this.namespaceURI, name),
d3_document.createElementNS(this.namespaceURI, name),
d3_select(before, this));
}

function insertNS() {
return this.insertBefore(
document.createElementNS(name.space, name.local),
d3_document.createElementNS(name.space, name.local),
d3_select(before, this));
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/selection-root.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var d3_selectionRoot = d3_selection([[document]]);
var d3_selectionRoot = d3_selection([[d3_document]]);

d3_selectionRoot[0].parentNode = d3_selectRoot;

Expand Down
2 changes: 1 addition & 1 deletion src/core/selection-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ d3_selectionPrototype.sort = function(comparator) {
function d3_selection_sortComparator(comparator) {
if (!arguments.length) comparator = d3.ascending;
return function(a, b) {
return comparator(a && a.__data__, b && b.__data__);
return (!a - !b) || comparator(a.__data__, b.__data__);
};
}
2 changes: 1 addition & 1 deletion src/core/selection-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ d3_selectionPrototype.style = function(name, value, priority) {
}

// For style(string), return the computed style value for the first node.
if (n < 2) return getComputedStyle(this.node(), null).getPropertyValue(name);
if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name);

// For style(string, string) or style(string, function), use the default
// priority. The priority is ignored for style(string, null).
Expand Down
2 changes: 1 addition & 1 deletion src/core/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function d3_selection(groups) {

var d3_select = function(s, n) { return n.querySelector(s); },
d3_selectAll = function(s, n) { return n.querySelectorAll(s); },
d3_selectRoot = document.documentElement,
d3_selectRoot = d3_document.documentElement,
d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector,
d3_selectMatches = function(n, s) { return d3_selectMatcher.call(n, s); };

Expand Down
10 changes: 5 additions & 5 deletions src/core/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ function d3_timer_flush() {
return then;
}

var d3_timer_frame = window.requestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.oRequestAnimationFrame
|| window.msRequestAnimationFrame
var d3_timer_frame = d3_window.requestAnimationFrame
|| d3_window.webkitRequestAnimationFrame
|| d3_window.mozRequestAnimationFrame
|| d3_window.oRequestAnimationFrame
|| d3_window.msRequestAnimationFrame
|| function(callback) { setTimeout(callback, 17); };
2 changes: 1 addition & 1 deletion src/core/transform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
d3.transform = function(string) {
var g = document.createElementNS(d3.ns.prefix.svg, "g");
var g = d3_document.createElementNS(d3.ns.prefix.svg, "g");
return (d3.transform = function(string) {
g.setAttribute("transform", string);
var t = g.transform.baseVal.consolidate();
Expand Down
4 changes: 2 additions & 2 deletions src/core/transition-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ d3_transitionPrototype.style = function(name, value, priority) {
// For style(name, string) or style(name, string, priority), set the style
// property with the specified name, using the specified priority.
function styleString() {
var a = getComputedStyle(this, null).getPropertyValue(name), i;
var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i;
return a !== b && (i = interpolate(a, b), function(t) { this.style.setProperty(name, i(t), priority); });
}

Expand All @@ -43,7 +43,7 @@ d3_transitionPrototype.style = function(name, value, priority) {
d3_transitionPrototype.styleTween = function(name, tween, priority) {
if (arguments.length < 3) priority = "";
return this.tween("style." + name, function(d, i) {
var f = tween.call(this, d, i, getComputedStyle(this, null).getPropertyValue(name));
var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name));
return f && function(t) { this.style.setProperty(name, f(t), priority); };
});
};
2 changes: 1 addition & 1 deletion src/core/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ d3.xhr = function(url, mimeType, callback) {
dispatch = d3.dispatch("progress", "load", "error"),
headers = {},
response = d3_identity,
request = new (window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest);
request = new (d3_window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest);

"onload" in request
? request.onload = request.onerror = respond
Expand Down
2 changes: 1 addition & 1 deletion src/end.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
})();
return d3;})();
Loading

0 comments on commit 35ac9dd

Please sign in to comment.