Built with blockbuilder.org
Last active
October 23, 2017 17:23
-
-
Save romsson/a4bcb8b273686b4d513392177e7cd72a to your computer and use it in GitHub Desktop.
minimalistic treemap hierarchy command line example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://d3js.org/d3-hierarchy.v1.min.js"></script> | |
<script> | |
var treemap = d3.treemap() | |
.size([10, 10]) | |
.padding(10); | |
var stratify = d3.stratify() | |
.id(function(d) { return d.id; }) | |
.parentId(function(d) { return d.parent_id; }); | |
var root = stratify([ | |
{"id": "root", "parent_id": ""}, | |
{"id": "child", "parent_id": "root"} | |
]); | |
var tree = treemap(root); | |
tree.leaves() | |
console.log(tree, tree.leaves()); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment