Last active
November 1, 2019 16:32
-
-
Save cogs15/c2e6941f2d454136b7dad042e98ad8ab to your computer and use it in GitHub Desktop.
DI-MLAX-Twitter-Force-Connection
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
source | target | value | |
---|---|---|---|
https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.4834 | |
https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | 0.4822 | |
https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.4756 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | 0.4564 | |
https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.4542 | |
https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.4458 | |
https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.4409 | |
https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.4394 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | 0.4388 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | 0.4364 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | 0.4204 | |
https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.4092 | |
https://raw.github.com/cogs15/DITeamLogos/master/hartford.gif | https://raw.github.com/cogs15/DITeamLogos/master/siena.gif | 0.4092 | |
https://raw.github.com/cogs15/DITeamLogos/master/hobart.gif | https://raw.github.com/cogs15/DITeamLogos/master/siena.gif | 0.4091 | |
https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | 0.4079 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | 0.4072 | |
https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.4069 | |
https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | 0.4058 | |
https://raw.github.com/cogs15/DITeamLogos/master/cornell.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.4043 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.4034 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | 0.4024 | |
https://raw.github.com/cogs15/DITeamLogos/master/bryant.gif | https://raw.github.com/cogs15/DITeamLogos/master/siena.gif | 0.3978 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.3957 | |
https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.395 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | 0.3911 | |
https://raw.github.com/cogs15/DITeamLogos/master/hartford.gif | https://raw.github.com/cogs15/DITeamLogos/master/vermont.gif | 0.3908 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | 0.3895 | |
https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.389 | |
https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.3868 | |
https://raw.github.com/cogs15/DITeamLogos/master/jhu.gif | https://raw.github.com/cogs15/DITeamLogos/master/loyola.gif | 0.3863 | |
https://raw.github.com/cogs15/DITeamLogos/master/cornell.gif | https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | 0.3851 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | 0.3838 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.3836 | |
https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | 0.3834 | |
https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | 0.3828 | |
https://raw.github.com/cogs15/DITeamLogos/master/bryant.gif | https://raw.github.com/cogs15/DITeamLogos/master/hobart.gif | 0.3824 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | 0.3821 | |
https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.3821 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.3762 | |
https://raw.github.com/cogs15/DITeamLogos/master/hartford.gif | https://raw.github.com/cogs15/DITeamLogos/master/sbu.gif | 0.3759 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | 0.3731 | |
https://raw.github.com/cogs15/DITeamLogos/master/binghamton.gif | https://raw.github.com/cogs15/DITeamLogos/master/hartford.gif | 0.3714 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | 0.37 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | 0.3697 | |
https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.3692 | |
https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | 0.3689 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | 0.3685 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.3675 | |
https://raw.github.com/cogs15/DITeamLogos/master/binghamton.gif | https://raw.github.com/cogs15/DITeamLogos/master/sbu.gif | 0.3667 | |
https://raw.github.com/cogs15/DITeamLogos/master/hartford.gif | https://raw.github.com/cogs15/DITeamLogos/master/hobart.gif | 0.3654 | |
https://raw.github.com/cogs15/DITeamLogos/master/bryant.gif | https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | 0.3639 | |
https://raw.github.com/cogs15/DITeamLogos/master/cornell.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.3637 | |
https://raw.github.com/cogs15/DITeamLogos/master/bryant.gif | https://raw.github.com/cogs15/DITeamLogos/master/hartford.gif | 0.3629 | |
https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.3616 | |
https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | 0.3593 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | 0.3589 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.3589 | |
https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | 0.3587 | |
https://raw.github.com/cogs15/DITeamLogos/master/bryant.gif | https://raw.github.com/cogs15/DITeamLogos/master/providence.gif | 0.3585 | |
https://raw.github.com/cogs15/DITeamLogos/master/cornell.gif | https://raw.github.com/cogs15/DITeamLogos/master/penn.gif | 0.3574 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | 0.3565 | |
https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.3554 | |
https://raw.github.com/cogs15/DITeamLogos/master/gtown.gif | https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | 0.3551 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/cornell.gif | 0.3546 | |
https://raw.github.com/cogs15/DITeamLogos/master/bryant.gif | https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | 0.3523 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.3518 | |
https://raw.github.com/cogs15/DITeamLogos/master/brown.gif | https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | 0.3499 | |
https://raw.github.com/cogs15/DITeamLogos/master/fairfield.gif | https://raw.github.com/cogs15/DITeamLogos/master/hartford.gif | 0.349 | |
https://raw.github.com/cogs15/DITeamLogos/master/loyola.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.3485 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/cornell.gif | 0.348 | |
https://raw.github.com/cogs15/DITeamLogos/master/sbu.gif | https://raw.github.com/cogs15/DITeamLogos/master/vermont.gif | 0.3478 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/fairfield.gif | 0.347 | |
https://raw.github.com/cogs15/DITeamLogos/master/fairfield.gif | https://raw.github.com/cogs15/DITeamLogos/master/sbu.gif | 0.347 | |
https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | https://raw.github.com/cogs15/DITeamLogos/master/umass.gif | 0.3455 | |
https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | 0.3449 | |
https://raw.github.com/cogs15/DITeamLogos/master/bryant.gif | https://raw.github.com/cogs15/DITeamLogos/master/fairfield.gif | 0.3446 | |
https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.3445 | |
https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | https://raw.github.com/cogs15/DITeamLogos/master/hofstra.gif | 0.3445 | |
https://raw.github.com/cogs15/DITeamLogos/master/loyola.gif | https://raw.github.com/cogs15/DITeamLogos/master/yale.gif | 0.3441 | |
https://raw.github.com/cogs15/DITeamLogos/master/harvard.gif | https://raw.github.com/cogs15/DITeamLogos/master/umass.gif | 0.3425 | |
https://raw.github.com/cogs15/DITeamLogos/master/binghamton.gif | https://raw.github.com/cogs15/DITeamLogos/master/siena.gif | 0.3409 | |
https://raw.github.com/cogs15/DITeamLogos/master/delaware.gif | https://raw.github.com/cogs15/DITeamLogos/master/fairfield.gif | 0.3406 | |
https://raw.github.com/cogs15/DITeamLogos/master/siena.gif | https://raw.github.com/cogs15/DITeamLogos/master/sbu.gif | 0.34 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/umass.gif | 0.3398 | |
https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | https://raw.github.com/cogs15/DITeamLogos/master/umass.gif | 0.3388 | |
https://raw.github.com/cogs15/DITeamLogos/master/fairfield.gif | https://raw.github.com/cogs15/DITeamLogos/master/siena.gif | 0.3382 | |
https://raw.github.com/cogs15/DITeamLogos/master/siena.gif | https://raw.github.com/cogs15/DITeamLogos/master/vermont.gif | 0.3382 | |
https://raw.github.com/cogs15/DITeamLogos/master/bucknell.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.3378 | |
https://raw.github.com/cogs15/DITeamLogos/master/jhu.gif | https://raw.github.com/cogs15/DITeamLogos/master/princeton.gif | 0.3367 | |
https://raw.github.com/cogs15/DITeamLogos/master/bryant.gif | https://raw.github.com/cogs15/DITeamLogos/master/colgate.gif | 0.3358 | |
https://raw.github.com/cogs15/DITeamLogos/master/denver.gif | https://raw.github.com/cogs15/DITeamLogos/master/loyola.gif | 0.3338 | |
https://raw.github.com/cogs15/DITeamLogos/master/cornell.gif | https://raw.github.com/cogs15/DITeamLogos/master/villanova.gif | 0.3334 | |
https://raw.github.com/cogs15/DITeamLogos/master/hobart.gif | https://raw.github.com/cogs15/DITeamLogos/master/sbu.gif | 0.3331 | |
https://raw.github.com/cogs15/DITeamLogos/master/cornell.gif | https://raw.github.com/cogs15/DITeamLogos/master/lehigh.gif | 0.3315 |
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> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v3.js"></script> | |
<style> | |
path.link { | |
fill: none; | |
stroke: #666; | |
stroke-width: 1.5px; | |
} | |
circle { | |
fill: #ccc; | |
stroke: #fff; | |
stroke-width: 1.5px; | |
} | |
text { | |
fill: #000; | |
font: 10px sans-serif; | |
pointer-events: none; | |
} | |
</style> | |
<body> | |
<script> | |
// get the data | |
d3.csv("force.csv", function(error, links) { | |
var nodes = {}; | |
// Compute the distinct nodes from the links. | |
links.forEach(function(link) { | |
link.source = nodes[link.source] || | |
(nodes[link.source] = {name: link.source}); | |
link.target = nodes[link.target] || | |
(nodes[link.target] = {name: link.target}); | |
link.value = +link.value; | |
}); | |
var root = // any svg.select(...) that has a single node like a container group by #id | |
function lapsedZoomFit(ticks, transitionDuration) { | |
for (var i = ticks || 100; i > 0; --i) force.tick(); | |
force.stop(); | |
zoomFit(transitionDuration); | |
} | |
function zoomFit(transitionDuration) { | |
var bounds = root.node().getBBox(); | |
var parent = root.node().parentElement; | |
var fullWidth = parent.clientWidth || parent.parentNode.clientWidth, | |
fullHeight = parent.clientHeight || parent.parentNode.clientHeight; | |
var width = bounds.width, | |
height = bounds.height; | |
var midX = bounds.x + width / 2, | |
midY = bounds.y + height / 2; | |
if (width == 0 || height == 0) return; // nothing to fit | |
var scale = 0.85 / Math.max(width / fullWidth, height / fullHeight); | |
var translate = [fullWidth / 2 - scale * midX, fullHeight / 2 - scale * midY]; | |
console.trace("zoomFit", translate, scale); | |
root | |
.transition() | |
.duration(transitionDuration || 0) // milliseconds | |
.call(zoom.translate(translate).scale(scale).event); | |
} | |
var width = 960, | |
height = 500; | |
var force = d3.layout.force() | |
.nodes(d3.values(nodes)) | |
.links(links) | |
.size([width, height]) | |
.linkDistance(60) | |
.charge(-300) | |
.on("tick", tick) | |
.start(); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
// build the arrow. | |
svg.append("svg:defs").selectAll("marker") | |
.data(["end"]) // Different link/path types can be defined here | |
.enter().append("svg:marker") // This section adds in the arrows | |
.attr("id", String) | |
.attr("viewBox", "0 -5 10 10") | |
.attr("refX", 15) | |
.attr("refY", -1.5) | |
.attr("markerWidth", 6) | |
.attr("markerHeight", 6) | |
.attr("orient", "auto") | |
.append("svg:path") | |
.attr("d", "M0,-5L10,0L0,5"); | |
// add the links and the arrows | |
var path = svg.append("svg:g").selectAll("path") | |
.data(force.links()) | |
.enter().append("svg:path") | |
// .attr("class", function(d) { return "link " + d.type; }) | |
.attr("class", "link") | |
//.attr("marker-end", "url(#end)") | |
; | |
// define the nodes | |
var node = svg.selectAll(".node") | |
.data(force.nodes()) | |
.enter().append("g") | |
.attr("class", "node") | |
.call(force.drag); | |
// add the nodes | |
node.append("circle") | |
.attr("r", 5); | |
var logo = function (d) {return d.name}; | |
var thelink = "https://raw.github.com/cogs15/DITeamLogos/master/" + node.text(logo) + ".gif" | |
// add the text | |
//node.append("text") | |
// .attr("x", 12) | |
// .attr("dy", ".35em") | |
// .text(logo); | |
node.append("image") | |
.attr("xlink:href", function(d) { return d.name; }) | |
// }) | |
.attr("x", -8) | |
.attr("y", -8) | |
.attr("width", 16) | |
.attr("height", 16); | |
// add the curvy lines | |
function tick() { | |
path.attr("d", function(d) { | |
var dx = d.target.x - d.source.x, | |
dy = d.target.y - d.source.y, | |
dr = Math.sqrt(dx * dx + dy * dy); | |
return "M" + | |
d.source.x + "," + | |
d.source.y + "A" + | |
dr + "," + dr + " 0 0,1 " + | |
d.target.x + "," + | |
d.target.y; | |
}); | |
node | |
.attr("transform", function(d) { | |
return "translate(" + d.x + "," + d.y + ")"; }); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment