Skip to content

Commit

Permalink
Test treemap against D3 3.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 15, 2016
1 parent 141f5a6 commit 6e7a4b0
Show file tree
Hide file tree
Showing 6 changed files with 4,747 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"rw": "1"
},
"devDependencies": {
"d3-queue": "2",
"json2module": "0.0",
"rollup": "0.25",
"tape": "4",
Expand Down
8 changes: 5 additions & 3 deletions src/treemap/squarify.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default (function ratio(phi) {
export default (function custom(ratio) {

function squarify(parent, x0, y0, x1, y1) {
var nodes = parent.children,
Expand All @@ -21,7 +21,7 @@ export default (function ratio(phi) {
while (i0 < n) {
dx = x1 - x0, dy = y1 - y0;
sumValue = minValue = maxValue = nodes[i0].value;
alpha = Math.max(dy / dx, dx / dy) / (value * phi);
alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
beta = sumValue * sumValue * alpha;
minRatio = Math.max(maxValue / beta, beta / minValue);

Expand Down Expand Up @@ -58,7 +58,9 @@ export default (function ratio(phi) {
}
}

squarify.ratio = ratio;
squarify.ratio = function(x) {
return custom((x = +x) > 1 ? x : 1);
};

return squarify;
})((1 + Math.sqrt(5)) / 2);
Loading

0 comments on commit 6e7a4b0

Please sign in to comment.