Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Jul 20, 2011
2 parents a40876c + a8558d9 commit 6a9eda0
Show file tree
Hide file tree
Showing 142 changed files with 2,896 additions and 166 deletions.
111 changes: 73 additions & 38 deletions Makefile
Expand Up @@ -156,6 +156,23 @@ d3.time.js: \
src/time/format.js \
src/time/format-utc.js \
src/time/format-iso.js \
src/time/range.js \
src/time/second.js \
src/time/seconds.js \
src/time/minute.js \
src/time/minutes.js \
src/time/hour.js \
src/time/hours.js \
src/time/day.js \
src/time/days.js \
src/time/week.js \
src/time/weeks.js \
src/time/month.js \
src/time/months.js \
src/time/year.js \
src/time/years.js \
src/time/scale.js \
src/time/scale-utc.js \
src/end.js

d3.geom.js: \
Expand All @@ -169,44 +186,62 @@ d3.geom.js: \
src/geom/quadtree.js \
src/end.js

tests: \
tests/test-append.test \
tests/test-attr.test \
tests/test-classed.test \
tests/test-call.test \
tests/test-csv-parse.test \
tests/test-format.test \
tests/test-insert.test \
tests/test-interpolate.test \
tests/test-keys.test \
tests/test-max.test \
tests/test-min.test \
tests/test-sum.test \
tests/test-nest.test \
tests/test-permute.test \
tests/test-zip.test \
tests/test-remove.test \
tests/test-rgb.test \
tests/test-round.test \
tests/test-hsl.test \
tests/test-time-format.test \
tests/test-time-format-iso.test \
tests/test-time-format-utc.test \
tests/test-time-parse.test \
tests/test-time-parse-iso.test \
tests/test-time-parse-utc.test \
tests/test-transition.test \
tests/test-scale-linear.test \
tests/test-scale-polylinear.test \
tests/test-scale-log.test \
tests/test-scale-sqrt.test \
tests/test-scale-pow.test \
tests/test-scale-quantile.test \
tests/test-bisect.test \
tests/test-svg-arc.test \
tests/test-svg-area.test \
tests/test-svg-line.test \
tests/test-svg-symbol.test
test: \
test/core/test-append.test \
test/core/test-attr.test \
test/core/test-bisect.test \
test/core/test-call.test \
test/core/test-classed.test \
test/core/test-format.test \
test/core/test-hsl.test \
test/core/test-insert.test \
test/core/test-interpolate.test \
test/core/test-keys.test \
test/core/test-max.test \
test/core/test-min.test \
test/core/test-nest.test \
test/core/test-permute.test \
test/core/test-remove.test \
test/core/test-rgb.test \
test/core/test-round.test \
test/core/test-sum.test \
test/core/test-transition.test \
test/core/test-zip.test \
test/csv/test-parse.test \
test/layout/test-histogram.test \
test/layout/test-treemap.test \
test/scale/test-linear.test \
test/scale/test-log.test \
test/scale/test-polylinear.test \
test/scale/test-pow.test \
test/scale/test-quantile.test \
test/scale/test-sqrt.test \
test/svg/test-arc.test \
test/svg/test-area.test \
test/svg/test-line.test \
test/svg/test-symbol.test \
test/time/test-day.test \
test/time/test-days.test \
test/time/test-format-iso.test \
test/time/test-format-utc.test \
test/time/test-format.test \
test/time/test-hour.test \
test/time/test-hours.test \
test/time/test-minute.test \
test/time/test-minutes.test \
test/time/test-month.test \
test/time/test-months.test \
test/time/test-parse-iso.test \
test/time/test-parse-utc.test \
test/time/test-parse.test \
test/time/test-scale.test \
test/time/test-scale-utc.test \
test/time/test-second.test \
test/time/test-seconds.test \
test/time/test-week.test \
test/time/test-weeks.test \
test/time/test-year.test \
test/time/test-years.test

%.min.js: %.js Makefile
@rm -f $@
Expand Down
4 changes: 2 additions & 2 deletions d3.js
@@ -1,4 +1,4 @@
(function(){d3 = {version: "1.27.2"}; // semver
(function(){d3 = {version: "1.28.0"}; // semver
if (!Date.now) Date.now = function() {
return +new Date;
};
Expand Down Expand Up @@ -2280,7 +2280,7 @@ function d3_scale_linearRebind(scale, linear) {
scale.interpolate = d3.rebind(scale, linear.interpolate);
scale.clamp = d3.rebind(scale, linear.clamp);
return scale;
};
}

function d3_scale_linearNice(dx) {
dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1);
Expand Down
70 changes: 55 additions & 15 deletions d3.layout.js
Expand Up @@ -989,7 +989,7 @@ d3.layout.histogram = function() {
i = -1,
n = values.length,
m = thresholds.length - 1,
k = frequency ? 1 / n : 1,
k = frequency ? 1 : 1 / n,
x;

// Initialize the bins.
Expand Down Expand Up @@ -1713,33 +1713,36 @@ d3.layout.treemap = function() {
var hierarchy = d3.layout.hierarchy(),
round = Math.round,
size = [1, 1], // width, height
padding = null,
pad = d3_layout_treemapPadNull,
sticky = false,
stickies,
ratio = 0.5 * (1 + Math.sqrt(5)); // golden ratio

// Recursively compute the node area based on value & scale.
function scale(node, k) {
var children = node.children,
value = node.value;
node.area = isNaN(value) || value < 0 ? 0 : value * k;
if (children) {
var i = -1,
n = children.length;
while (++i < n) scale(children[i], k);
// Compute the area for each child based on value & scale.
function scale(children, k) {
var i = -1,
n = children.length,
child,
area;
while (++i < n) {
area = (child = children[i]).value * (k < 0 ? 0 : k);
child.area = isNaN(area) || area <= 0 ? 0 : area;
}
}

// Recursively arranges the specified node's children into squarified rows.
function squarify(node) {
if (!node.children) return;
var rect = {x: node.x, y: node.y, dx: node.dx, dy: node.dy},
var rect = pad(node),
row = [],
children = node.children.slice(), // copy-on-write
child,
best = Infinity, // the best row score so far
score, // the current row score
u = Math.min(rect.dx, rect.dy), // initial orientation
n;
scale(children, rect.dx * rect.dy / node.value);
row.area = 0;
while ((n = children.length) > 0) {
row.push(child = children[n - 1]);
Expand All @@ -1766,10 +1769,11 @@ d3.layout.treemap = function() {
// Preserves the existing layout!
function stickify(node) {
if (!node.children) return;
var rect = {x: node.x, y: node.y, dx: node.dx, dy: node.dy},
var rect = pad(node),
children = node.children.slice(), // copy-on-write
child,
row = [];
scale(children, rect.dx * rect.dy / node.value);
row.area = 0;
while (child = children.pop()) {
row.push(child);
Expand Down Expand Up @@ -1817,7 +1821,7 @@ d3.layout.treemap = function() {
o.x = x;
o.y = y;
o.dy = v;
x += o.dx = round(o.area / v);
x += o.dx = v ? round(o.area / v) : 0;
}
o.z = true;
o.dx += rect.x + rect.dx - x; // rounding error
Expand All @@ -1830,7 +1834,7 @@ d3.layout.treemap = function() {
o.x = x;
o.y = y;
o.dx = v;
y += o.dy = round(o.area / v);
y += o.dy = v ? round(o.area / v) : 0;
}
o.z = false;
o.dy += rect.y + rect.dy - y; // rounding error
Expand All @@ -1847,7 +1851,7 @@ d3.layout.treemap = function() {
root.dx = size[0];
root.dy = size[1];
if (stickies) hierarchy.revalue(root);
scale(root, size[0] * size[1] / root.value);
scale([root], root.dx * root.dy / root.value);
(stickies ? stickify : squarify)(root);
if (sticky) stickies = nodes;
return nodes;
Expand All @@ -1859,6 +1863,28 @@ d3.layout.treemap = function() {
return treemap;
};

treemap.padding = function(x) {
if (!arguments.length) return padding;

function padFunction(node) {
var p = x.call(treemap, node, node.depth);
return p == null
? d3_layout_treemapPadNull(node)
: d3_layout_treemapPad(node, typeof p === "number" ? [p, p, p, p] : p);
}

function padConstant(node) {
return d3_layout_treemapPad(node, x);
}

var type;
pad = (padding = x) == null ? d3_layout_treemapPadNull
: (type = typeof x) === "function" ? padFunction
: type === "number" ? (x = [x, x, x, x], padConstant)
: padConstant;
return treemap;
};

treemap.round = function(x) {
if (!arguments.length) return round != Number;
round = x ? Math.round : Number;
Expand All @@ -1880,4 +1906,18 @@ d3.layout.treemap = function() {

return d3_layout_hierarchyRebind(treemap, hierarchy);
};

function d3_layout_treemapPadNull(node) {
return {x: node.x, y: node.y, dx: node.dx, dy: node.dy};
}

function d3_layout_treemapPad(node, padding) {
var x = node.x + padding[3],
y = node.y + padding[0],
dx = node.dx - padding[1] - padding[3],
dy = node.dy - padding[0] - padding[2];
if (dx < 0) { x += dx / 2; dx = 0; }
if (dy < 0) { y += dy / 2; dy = 0; }
return {x: x, y: y, dx: dx, dy: dy};
}
})();
2 changes: 1 addition & 1 deletion d3.layout.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion d3.min.js

Large diffs are not rendered by default.

0 comments on commit 6a9eda0

Please sign in to comment.