Skip to content

Instantly share code, notes, and snippets.

Created December 3, 2012 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4193607 to your computer and use it in GitHub Desktop.
Save anonymous/4193607 to your computer and use it in GitHub Desktop.
{
"libraries": [
"d3"
],
"mode": "javascript",
"layout": "sketchpad mode"
}
svg {
position: absolute;
}
.node {
stroke: #fff;
stroke-width: 3px;
}
.link {
stroke: #999;
stroke-opacity: .6;
}
var width = 960,
height = 500;
var color = d3.scale.category20();
var force = d3.layout.force()
.charge(-990)
.linkDistance(111)
.size([width, height]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
force
.nodes(livecoding.json.nodes)
.links(livecoding.json.links)
.start();
var link = svg.selectAll("line.link")
.data(livecoding.json.links)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) { return Math.sqrt(d.value); });
var node = svg.selectAll("circle.node")
.data(livecoding.json.nodes)
.enter().append("circle")
.attr("class", "node")
.attr("r", function(d) {return d.value;} )
.style("fill", function(d) { return color(d.group); })
.call(force.drag);
node.append("title")
.text(function(d) { return d.name; });
force.on("tick", function() {
link.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
node.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
});
{"nodes":[
{"name":"198.129.254.30"},
{"name":"198.129.254.29"},
{"name":"134.55.217.41"},
{"name":"134.55.49.117"},
{"name":"134.55.50.202"},
{"name":"134.55.49.58"},
{"name":"134.55.43.81"},
{"name":"134.55.36.46"},
{"name":"134.55.219.85"},
{"name":"198.124.238.158"}
],"links":[
{"source":0,"target":1,"value":4,"colorValue":0.04141666666666667},
{"source":1,"target":2,"value":4,"colorValue":0.15952083333333333},
{"source":2,"target":3,"value":6,"colorValue":0.44469444444444445},
{"source":3,"target":4,"value":5,"colorValue":4.159866666666667},
{"source":4,"target":5,"value":6,"colorValue":1.7579074074074075},
{"source":5,"target":6,"value":5,"colorValue":2.1812533333333333},
{"source":6,"target":7,"value":6,"colorValue":2.8529999999999998},
{"source":7,"target":8,"value":2,"colorValue":1.9522500000000012},
{"source":8,"target":9,"value":2,"colorValue":-0.0009166666666651224},
{"source":7,"target":9,"value":4,"colorValue":0.9750833333333331},
{"source":9,"target":8,"value":4,"colorValue":0.0007500000000009166},
{"source":0,"target":2,"value":2,"colorValue":0.4059166666666667},
{"source":3,"target":1,"value":1,"colorValue":18.566666666666663},
{"source":1,"target":4,"value":1,"colorValue":2.399666666666672},
{"source":5,"target":1,"value":1,"colorValue":5.930333333333337},
{"source":1,"target":6,"value":1,"colorValue":4.912000000000006}
]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment