Skip to content

Instantly share code, notes, and snippets.

@alexandersimoes
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexandersimoes/9629612 to your computer and use it in GitHub Desktop.
Save alexandersimoes/9629612 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Networks with D3plus</title>
<!-- load D3plus CSS -->
<link href="/css/d3plus.css" media="screen" rel="stylesheet" type="text/css" />
<!-- load D3js -->
<script type="text/javascript" src="/js/d3.js"></script>
<!-- load D3plus after D3js -->
<script src="/js/d3plus.js"></script>
</head>
<body>
<div id="viz"></div>
<script>
d3.tsv("/data/edges.tsv", function(edges){
d3.tsv("/data/nodes.tsv", function(nodes){
// cast our x, y coords to numbers
nodes.forEach(function(d){
d["x"] = parseFloat(d["x"])
d["y"] = parseFloat(d["y"])
})
/* Now here's where we actually create the network */
var visualization = d3plus.viz()
.id("artist_id") // the name of the id from our nodes file
.container("#viz") // container DIV to hold the visualization
.type("network") // visualization type
.nodes(nodes) // nodes array with 'x' and 'y' coords
.edges(edges) // the edges we'll use to create our network
.draw() // finally, draw the visualization!
})
})
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment