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/9628608 to your computer and use it in GitHub Desktop.
Save alexandersimoes/9628608 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" rel="stylesheet" type="text/css" />
<!-- load D3js -->
<script src="/js/d3.js"></script>
<!-- load D3plus after D3js -->
<script src="/js/d3plus.js"></script>
</head>
<body>
<div id="viz"></div>
<script>
var edges = [
{
"target": 1,
"source": 2,
"strength": 5.234897
},
{
"source": 1,
"target": 4,
"strength": 2.34987
},
{
"source": 4,
"target": 5,
"strength": 4.12087
},
{
"source": 4,
"target": 3,
"strength": 3.09875
}
]
var attrs = {
1: {"name": "one"},
2: {"name": "two"},
3: {"name": "three"},
4: {"name": "four"},
5: {"name": "five"},
6: {"name": "six"}
}
/* Now here's where we actually create the network */
var visualization = d3plus.viz()
.container("#viz") // container DIV to hold the visualization
.type("network") // visualization type
.attrs(attrs) // our list of name attributes
.text("name") // key to use for display text
.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