Permalink
Browse files

Merge branch 'v2.7.5'

  • Loading branch information...
2 parents 80e0e78 + 1643aa9 commit 230d8e908095a5650ea63bf29179f9bc1f842425 @mbostock mbostock committed Feb 18, 2012
View
@@ -265,7 +265,9 @@ install:
npm install
package.json: d3.js src/package.js
+ @rm -f $@
node src/package.js > $@
+ @chmod a-w $@
clean:
rm -f d3*.js
View
39 d3.js
@@ -10,7 +10,7 @@ try {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
-d3 = {version: "2.7.4"}; // semver
+d3 = {version: "2.7.5"}; // semver
var d3_array = d3_arraySlice; // conversion for NodeLists
function d3_arrayCopy(pseudoarray) {
@@ -391,11 +391,6 @@ function d3_splitter(d) {
function d3_collapse(s) {
return s.replace(/(^\s+)|(\s+$)/g, "").replace(/\s+/g, " ");
}
-/**
- * @param {number} start
- * @param {number=} stop
- * @param {number=} step
- */
d3.range = function(start, stop, step) {
if (arguments.length < 3) {
step = 1;
@@ -404,14 +399,22 @@ d3.range = function(start, stop, step) {
start = 0;
}
}
- if ((stop - start) / step == Infinity) throw new Error("infinite range");
+ if ((stop - start) / step === Infinity) throw new Error("infinite range");
var range = [],
+ k = d3_range_integerScale(Math.abs(step)),
i = -1,
j;
- if (step < 0) while ((j = start + step * ++i) > stop) range.push(j);
- else while ((j = start + step * ++i) < stop) range.push(j);
+ start *= k, stop *= k, step *= k;
+ if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k);
+ else while ((j = start + step * ++i) < stop) range.push(j / k);
return range;
};
+
+function d3_range_integerScale(x) {
+ var k = 1;
+ while (x * k % 1) k *= 10;
+ return k;
+}
d3.requote = function(s) {
return s.replace(d3_requote_re, "\\$&");
};
@@ -545,7 +548,7 @@ function d3_dispatch_event(dispatch) {
};
return event;
-};
+}
// TODO align
d3.format = function(specifier) {
var match = d3_format_re.exec(specifier),
@@ -2430,7 +2433,7 @@ function d3_scale_linear(domain, range, interpolate, clamp) {
input;
function rescale() {
- var linear = domain.length == 2 ? d3_scale_bilinear : d3_scale_polylinear,
+ var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear,
uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
output = linear(domain, range, uninterpolate, interpolate);
input = linear(range, domain, uninterpolate, d3.interpolate);
@@ -2492,7 +2495,7 @@ function d3_scale_linear(domain, range, interpolate, clamp) {
};
return rescale();
-};
+}
function d3_scale_linearRebind(scale, linear) {
return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
@@ -2542,7 +2545,7 @@ function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
var u = [],
i = [],
j = 0,
- k = domain.length - 1;
+ k = Math.min(domain.length, range.length) - 1;
// Handle descending domains.
if (domain[k] < domain[0]) {
@@ -2626,7 +2629,7 @@ function d3_scale_log(linear, log) {
};
return d3_scale_linearRebind(scale, linear);
-};
+}
var d3_scale_logFormat = d3.format(".0e");
@@ -2692,7 +2695,7 @@ function d3_scale_pow(linear, exponent) {
};
return d3_scale_linearRebind(scale, linear);
-};
+}
function d3_scale_powPow(e) {
return function(x) {
@@ -2782,7 +2785,7 @@ function d3_scale_ordinal(domain, ranger) {
};
return scale.domain(domain);
-};
+}
/*
* This product includes color specifications and designs developed by Cynthia
* Brewer (http://colorbrewer.org/). See lib/colorbrewer for more information.
@@ -2879,7 +2882,7 @@ function d3_scale_quantile(domain, range) {
};
return rescale();
-};
+}
d3.scale.quantize = function() {
return d3_scale_quantize(0, 1, [0, 1]);
};
@@ -2915,7 +2918,7 @@ function d3_scale_quantize(x0, x1, range) {
};
return rescale();
-};
+}
d3.svg = {};
d3.svg.arc = function() {
var innerRadius = d3_svg_arcInnerRadius,
View
@@ -255,6 +255,9 @@ d3.layout.force = function() {
}
function tick() {
+ // simulated annealing, basically
+ if ((alpha *= .99) < .005) return true;
+
var n = nodes.length,
m = links.length,
q,
@@ -319,9 +322,6 @@ d3.layout.force = function() {
}
event.tick({type: "tick", alpha: alpha});
-
- // simulated annealing, basically
- return (alpha *= .99) < .005;
}
force.nodes = function(x) {
@@ -1346,7 +1346,8 @@ function d3_layout_packPlace(a, b, c) {
c.y = a.y;
}
}
-// Implements a hierarchical layout using the cluster (or dendogram) algorithm.
+// Implements a hierarchical layout using the cluster (or dendrogram)
+// algorithm.
d3.layout.cluster = function() {
var hierarchy = d3.layout.hierarchy().sort(null).value(null),
separation = d3_layout_treeSeparation,
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
- <title>Flare Dendogram</title>
+ <title>Flare Dendrogram</title>
<script type="text/javascript" src="../../d3.js"></script>
<script type="text/javascript" src="../../d3.layout.js"></script>
<link type="text/css" rel="stylesheet" href="cluster.css"/>
@@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
- <title>Flare Dendogram</title>
+ <title>Flare Dendrogram</title>
<script type="text/javascript" src="../../d3.js"></script>
<script type="text/javascript" src="../../d3.layout.js"></script>
<link type="text/css" rel="stylesheet" href="cluster.css"/>
@@ -65,11 +65,7 @@
.attr("class", "node")
.attr("r", 3.5)
.attr("cx", function(d) { return d.parent.x0; })
- .attr("cy", function(d) { return d.parent.y0; })
- .transition()
- .duration(duration)
- .attr("cx", x)
- .attr("cy", y);
+ .attr("cy", function(d) { return d.parent.y0; });
// Transition nodes to their new position.
node.transition()
@@ -87,10 +83,7 @@
.attr("d", function(d) {
var o = {x: d.source.x0, y: d.source.y0};
return diagonal({source: o, target: o});
- })
- .transition()
- .duration(duration)
- .attr("d", diagonal);
+ });
// Transition links to their new position.
link.transition()
@@ -129,10 +129,7 @@
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
- })
- .transition()
- .duration(duration)
- .attr("d", diagonal);
+ });
// Transition links to their new position.
link.transition()
View
@@ -0,0 +1,26 @@
+var self = this,
+ globals = ["document", "window", "navigator", "CSSStyleDeclaration", "d3"],
+ globalValues = {};
+
+globals.forEach(function(global) {
+ if (global in self) globalValues[global] = self[global];
+});
+
+document = require("jsdom").jsdom("<html><head></head><body></body></html>");
+window = document.createWindow();
+navigator = window.navigator;
+CSSStyleDeclaration = window.CSSStyleDeclaration;
+
+require("./d3");
+require("./d3.csv");
+require("./d3.geo");
+require("./d3.geom");
+require("./d3.layout");
+require("./d3.time");
+
+module.exports = d3;
+
+globals.forEach(function(global) {
+ if (global in globalValues) self[global] = globalValues[global];
+ else delete self[global];
+});
View
@@ -1,6 +1,6 @@
{
"name": "d3",
- "version": "2.7.4",
+ "version": "2.7.5",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
@@ -19,7 +19,7 @@
"type": "git",
"url": "http://github.com/mbostock/d3.git"
},
- "main": "d3.js",
+ "main": "index.js",
"dependencies": {
"jsdom": "0.2.10"
},
View
@@ -1 +1 @@
-d3 = {version: "2.7.4"}; // semver
+d3 = {version: "2.7.5"}; // semver
View
@@ -58,4 +58,4 @@ function d3_dispatch_event(dispatch) {
};
return event;
-};
+}
View
@@ -1,8 +1,3 @@
-/**
- * @param {number} start
- * @param {number=} stop
- * @param {number=} step
- */
d3.range = function(start, stop, step) {
if (arguments.length < 3) {
step = 1;
@@ -11,11 +6,19 @@ d3.range = function(start, stop, step) {
start = 0;
}
}
- if ((stop - start) / step == Infinity) throw new Error("infinite range");
+ if ((stop - start) / step === Infinity) throw new Error("infinite range");
var range = [],
+ k = d3_range_integerScale(Math.abs(step)),
i = -1,
j;
- if (step < 0) while ((j = start + step * ++i) > stop) range.push(j);
- else while ((j = start + step * ++i) < stop) range.push(j);
+ start *= k, stop *= k, step *= k;
+ if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k);
+ else while ((j = start + step * ++i) < stop) range.push(j / k);
return range;
};
+
+function d3_range_integerScale(x) {
+ var k = 1;
+ while (x * k % 1) k *= 10;
+ return k;
+}
View
@@ -1,4 +1,5 @@
-// Implements a hierarchical layout using the cluster (or dendogram) algorithm.
+// Implements a hierarchical layout using the cluster (or dendrogram)
+// algorithm.
d3.layout.cluster = function() {
var hierarchy = d3.layout.hierarchy().sort(null).value(null),
separation = d3_layout_treeSeparation,
View
@@ -44,6 +44,9 @@ d3.layout.force = function() {
}
function tick() {
+ // simulated annealing, basically
+ if ((alpha *= .99) < .005) return true;
+
var n = nodes.length,
m = links.length,
q,
@@ -108,9 +111,6 @@ d3.layout.force = function() {
}
event.tick({type: "tick", alpha: alpha});
-
- // simulated annealing, basically
- return (alpha *= .99) < .005;
}
force.nodes = function(x) {
View
@@ -9,7 +9,7 @@ require("util").puts(JSON.stringify({
"homepage": "http://mbostock.github.com/d3/",
"author": {"name": "Mike Bostock", "url": "http://bost.ocks.org/mike"},
"repository": {"type": "git", "url": "http://github.com/mbostock/d3.git"},
- "main": "d3.js",
+ "main": "index.js",
"dependencies": {
"jsdom": "0.2.10"
},
View
@@ -7,7 +7,7 @@ function d3_scale_linear(domain, range, interpolate, clamp) {
input;
function rescale() {
- var linear = domain.length == 2 ? d3_scale_bilinear : d3_scale_polylinear,
+ var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear,
uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
output = linear(domain, range, uninterpolate, interpolate);
input = linear(range, domain, uninterpolate, d3.interpolate);
@@ -69,7 +69,7 @@ function d3_scale_linear(domain, range, interpolate, clamp) {
};
return rescale();
-};
+}
function d3_scale_linearRebind(scale, linear) {
return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
View
@@ -64,7 +64,7 @@ function d3_scale_log(linear, log) {
};
return d3_scale_linearRebind(scale, linear);
-};
+}
var d3_scale_logFormat = d3.format(".0e");
View
@@ -78,4 +78,4 @@ function d3_scale_ordinal(domain, ranger) {
};
return scale.domain(domain);
-};
+}
View
@@ -2,7 +2,7 @@ function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
var u = [],
i = [],
j = 0,
- k = domain.length - 1;
+ k = Math.min(domain.length, range.length) - 1;
// Handle descending domains.
if (domain[k] < domain[0]) {
View
@@ -45,7 +45,7 @@ function d3_scale_pow(linear, exponent) {
};
return d3_scale_linearRebind(scale, linear);
-};
+}
function d3_scale_powPow(e) {
return function(x) {
Oops, something went wrong.

0 comments on commit 230d8e9

Please sign in to comment.