Built with blockbuilder.org
Created
April 16, 2019 16:27
-
-
Save a3igner/7dacf0c231ba0bea3ec49580843a6c24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 hidden or 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
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
</style> | |
</head> | |
<body> | |
<script> | |
var height = 200; | |
var width = 500; | |
var margin = {left: 50,right:50,top:40,bottom:0}; | |
//var tree = d3.tree().size([width,height]); | |
var svg = d3.select('body').append('svg').attr('width','100%').attr('height','100%'); | |
var chartGroup = svg.append('g').attr('transform','translate('+margin.left+','+margin.top+')'); | |
d3.json("keyedJSON-Lever.json").get(function(error,data){ | |
console.log(data); | |
// console.log(data[0].children); | |
// console.log(data[0].children[0].children[1].name); | |
var nestedData = d3.nest().key(function(d){ return d.country; }).entries(data); | |
console.log(nestedData); | |
var treeData = d3.stratify() | |
.id(function(d) { return d.stock; }) | |
.parentId(function(d) { return d.country; }) | |
(data); | |
console.log(treeData); | |
}); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment