Skip to content

Commit

Permalink
Fix typo and add padding tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondavies committed Jul 20, 2011
1 parent 8e13b18 commit 3c2cb84
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion d3.layout.js
Expand Up @@ -1897,7 +1897,7 @@ d3.layout.treemap = function() {
var type = typeof x;
pad = type === "function" ? padFunction
: type === "number" ? padNumber
: x == null ? d3_layout_treemapPadding
: x == null ? d3_layout_treemapPadNull
: padArray;

padding = x;
Expand Down
2 changes: 1 addition & 1 deletion d3.layout.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/layout/treemap.js
Expand Up @@ -188,7 +188,7 @@ d3.layout.treemap = function() {
var type = typeof x;
pad = type === "function" ? padFunction
: type === "number" ? padNumber
: x == null ? d3_layout_treemapPadding
: x == null ? d3_layout_treemapPadNull
: padArray;

padding = x;
Expand Down
9 changes: 9 additions & 0 deletions tests/test-layout-treemap.js
Expand Up @@ -41,3 +41,12 @@ console.log("{value: -1} ", treemap({value: -1})[0].area);
console.log("{value: NaN} ", treemap({value: NaN})[0].area);
console.log("{value: 1} ", treemap({value: 1})[0].area);
console.log("");

treemap.size([1, 1]);
var tree = {children: [{value: 1}]};
console.log("padding:");
console.log("1 ", treemap.padding(1)(tree)[1].dx);
console.log("[1, 1, 1, 1] ", treemap.padding([1, 1, 1, 1])(tree)[1].dx);
console.log("function(x) [1, 1, 1, 1] ", treemap.padding(function(x) { return [1, 1, 1, 1]; })(tree)[1].dx);
console.log("null ", treemap.padding(null)(tree)[1].dx);
console.log("");
6 changes: 6 additions & 0 deletions tests/test-layout-treemap.out
Expand Up @@ -27,3 +27,9 @@ size([NaN, NaN]):
{value: NaN} 0
{value: 1} 0

padding:
1 -1
[1, 1, 1, 1] -1
function(x) [1, 1, 1, 1] -1
null 1

0 comments on commit 3c2cb84

Please sign in to comment.