[ Launch: Tributary inlet ] b6fcdb9aa098782d37b8 by ramnathv
-
-
Save ramnathv/b6fcdb9aa098782d37b8 to your computer and use it in GitHub Desktop.
Tributary inlet
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
.link { | |
fill: none; | |
stroke: #aaa; | |
} | |
.node text { | |
font: 10px sans-serif; | |
} | |
.node circle { | |
stroke: #fff; | |
stroke-width: 1.5px; | |
} | |
.node.active { | |
fill: red; | |
} |
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
{"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"species.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"app.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/PYEdaCY.png"} |
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
var margin = {top: 40, right: 40, bottom: 40, left: 80}, | |
width = 586 - margin.left - margin.right, | |
height = 500 - margin.top - margin.bottom; | |
var svg = d3.select("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
var tree = d3.layout.tree() | |
.size([height, width]); | |
var diagonal = d3.svg.diagonal() | |
.projection(function(d) { return [d.y, d.x]; }); | |
root = tributary.species | |
var nodes = tree.nodes(root), | |
links = tree.links(nodes); | |
// Create the link lines. | |
svg.selectAll(".link") | |
.data(links) | |
.enter().append("path") | |
.attr("class", "link") | |
.attr("d", diagonal); | |
// Create the node circles. | |
var node = svg.selectAll(".node") | |
.data(nodes) | |
.enter().append("g") | |
.attr("class", function(d) { return "node " + d.type; }) | |
.attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; }) | |
.on("mouseover", function(d) { highlight(d.type); }) | |
.on("mouseout", function(d) { highlight(null); }); | |
node.append("circle") | |
.attr("r", 4.5); | |
node.append("text") | |
.attr("x", -6) | |
.attr("dy", ".35em") | |
.attr("text-anchor", "end") | |
.text(function(d) { return d.name; }); | |
function highlight(type) { | |
if (type == null) d3.selectAll(".node").classed("active", false); | |
else d3.selectAll(".node." + type).classed("active", true); | |
} |
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
{ | |
"name": "Carnivora", | |
"children": [ | |
{ | |
"name": "Felidae", | |
"children": [ | |
{ | |
"name": "Felis", | |
"children": [ | |
{ | |
"name": "catus", | |
"type": "domesticated" | |
} | |
] | |
}, | |
{ | |
"name": "Panthera", | |
"children": [ | |
{ | |
"name": "tigris", | |
"type": "wild" | |
}, | |
{ | |
"name": "leo", | |
"type": "wild" | |
}, | |
{ | |
"name": "onca", | |
"type": "wild" | |
}, | |
{ | |
"name": "pardus", | |
"type": "wild" | |
} | |
] | |
} | |
] | |
}, | |
{ | |
"name": "Canidae", | |
"children": [ | |
{ | |
"name": "Canis", | |
"children": [ | |
{ | |
"name": "lupus", | |
"type": "domesticated" | |
}, | |
{ | |
"name": "latrans", | |
"type": "wild" | |
}, | |
{ | |
"name": "aureus", | |
"type": "wild" | |
} | |
] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment