Skip to content

Instantly share code, notes, and snippets.

@ZoeLeBlanc
Last active March 21, 2018 17:12
Show Gist options
  • Save ZoeLeBlanc/32011a489bfa4bae622e0b4b5eef014b to your computer and use it in GitHub Desktop.
Save ZoeLeBlanc/32011a489bfa4bae622e0b4b5eef014b to your computer and use it in GitHub Desktop.
SNA Graph
license: mit
source target
Jeremy Boggs American Studies
Rafael Alvarado Anthropology
Francesca Fiorani Art
Francesca Fiorani Arts & Sciences
Ian Baucom Arts & Sciences
Center for Digital Editing Arts & Sciences
Erica Cavenaugh Center for Digital Editing
Worthy Martin Computer Science
Robbie Hott Computer Science
Pete Alonzi Data Science Institute
Rafael Alvarado Data Science Institute
Phil Bourne Data Science Institute
Scholars' Lab DH Graduate Fellows
Scholars' Lab DH Graduate Prototyping Fellows
Rennie Mapp DH@UVa
Bill Ferster Education
Alison Booth English
John Unsworth English
Robbie Bingler IATH
Shayne Brandon IATH
Cindy Girard IATH
Worthy Martin IATH
John Unsworth Library
Sarah Wells IATH
Lauren Masari IATH
Doug Ross IATH
Robbie Hott IATH
Provost IATH
IATH IATH Associate Fellows
IATH IATH Resident Fellows
John Unsworth Library
DH@UVa Library
DH@UVa VPIT
Rafael Alvarado Media Studies
Scholars' Lab Praxis Graduate Fellows
Archie Holmes Provost
Data Science Institute Provost
David Germano Religious Studies
Pete Alonzi Research Data Services
Arin Bennett Scholars' Lab
Jeremy Boggs Scholars' Lab
Alison Booth Scholars' Lab
Chris Gist Scholars' Lab
Ammon Shepherd Scholars' Lab
Zoe LaBlanc Scholars' Lab
Will Rourk Scholars' Lab
Drew Macqueen Scholars' Lab
Ronda Grizzle Scholars' Lab
Laura Miller Scholars' Lab
Shane Lin Scholars' Lab
Amanda Visconti Scholars' Lab
Brandon Walsh Scholars' Lab
Library Scholars' Lab
Bill Ferster SHANTI
David Germano SHANTI
Yuji Shinozake SHANTI
Rennie Mapp SHANTI
Chris Jewell SHANTI
John Alexander SHANTI
VPIT SHANTI
Melinda Bauman UVA Library
Daniel Pitti UVA Library
Nadim Al-Jarroud VPIT
Ron Hutchins VPIT
DH@UVa VPIT
Source Target
Jeremy Boggs American Studies
Rafael Alvarado Anthropology
Francesca Fiorani Art
Francesca Fiorani Arts & Sciences
Ian Baucom Arts & Sciences
Center for Digital Editing Arts & Sciences
Erica Cavenaugh Center for Digital Editing
Worthy Martin Computer Science
Robbie Hott Computer Science
Pete Alonzi Data Science Institute
Rafael Alvarado Data Science Institute
Phil Bourne Data Science Institute
Scholars' Lab DH Graduate Fellows
Scholars' Lab DH Graduate Prototyping Fellows
Rennie Mapp DH@UVa
Bill Ferster Education
Alison Booth English
John Unsworth English
Robbie Bingler IATH
Shayne Brandon IATH
Cindy Girard IATH
Worthy Martin IATH
John Unsworth Library
Sarah Wells IATH
Lauren Masari IATH
Doug Ross IATH
Robbie Hott IATH
Provost IATH
IATH IATH Associate Fellows
IATH IATH Resident Fellows
John Unsworth Library
DH@UVa Library
DH@UVa VPIT
Rafael Alvarado Media Studies
Scholars' Lab Praxis Graduate Fellows
Archie Holmes Provost
Data Science Institute Provost
David Germano Religious Studies
Pete Alonzi Research Data Services
Arin Bennett Scholars' Lab
Jeremy Boggs Scholars' Lab
Alison Booth Scholars' Lab
Chris Gist Scholars' Lab
Ammon Shepherd Scholars' Lab
Zoe LaBlanc Scholars' Lab
Will Rourk Scholars' Lab
Drew Macqueen Scholars' Lab
Ronda Grizzle Scholars' Lab
Laura Miller Scholars' Lab
Shane Lin Scholars' Lab
Amanda Visconti Scholars' Lab
Brandon Walsh Scholars' Lab
Library Scholars' Lab
Bill Ferster SHANTI
David Germano SHANTI
Yuji Shinozake SHANTI
Rennie Mapp SHANTI
Chris Jewell SHANTI
John Alexander SHANTI
VPIT SHANTI
Melinda Bauman UVA Library
Daniel Pitti UVA Library
Nadim Al-Jarroud VPIT
Ron Hutchins VPIT
DH@UVa VPIT
source target
Jeremy Boggs American Studies
Rafael Alvarado Anthropology
Francesca Fiorani Art
Francesca Fiorani Arts & Sciences
Ian Baucom Arts & Sciences
Center for Digital Editing Arts & Sciences
Erica Cavenaugh Center for Digital Editing
Worthy Martin Computer Science
Robbie Hott Computer Science
Pete Alonzi Data Science Institute
Rafael Alvarado Data Science Institute
Phil Bourne Data Science Institute
Scholars' Lab DH Graduate Fellows
Scholars' Lab DH Graduate Prototyping Fellows
Rennie Mapp DH@UVa
Bill Ferster Education
Alison Booth English
John Unsworth English
Robbie Bingler IATH
Shayne Brandon IATH
Cindy Girard IATH
Worthy Martin IATH
John Unsworth Library
Sarah Wells IATH
Lauren Masari IATH
Doug Ross IATH
Robbie Hott IATH
Provost IATH
IATH IATH Associate Fellows
IATH IATH Resident Fellows
John Unsworth Library
DH@UVa Library
DH@UVa VPIT
Rafael Alvarado Media Studies
Scholars' Lab Praxis Graduate Fellows
Archie Holmes Provost
Data Science Institute Provost
David Germano Religious Studies
Pete Alonzi Research Data Services
Arin Bennett Scholars' Lab
Jeremy Boggs Scholars' Lab
Alison Booth Scholars' Lab
Chris Gist Scholars' Lab
Ammon Shepherd Scholars' Lab
Zoe LaBlanc Scholars' Lab
Will Rourk Scholars' Lab
Drew Macqueen Scholars' Lab
Ronda Grizzle Scholars' Lab
Laura Miller Scholars' Lab
Shane Lin Scholars' Lab
Amanda Visconti Scholars' Lab
Brandon Walsh Scholars' Lab
Library Scholars' Lab
Bill Ferster SHANTI
David Germano SHANTI
Yuji Shinozake SHANTI
Rennie Mapp SHANTI
Chris Jewell SHANTI
John Alexander SHANTI
VPIT SHANTI
Melinda Bauman UVA Library
Daniel Pitti UVA Library
Nadim Al-Jarroud VPIT
Ron Hutchins VPIT
DH@UVa VPIT
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
</head>
<style>
.links line {
stroke: #999;
stroke-opacity: 0.6;
}
.nodes circle {
stroke: #fff;
stroke-width: 1.5px;
}
text {
pointer-events: none;
font: 10px sans-serif;
}
</style>
<svg width="960" height="600"></svg>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height"),
radius = 5;
var simulation = d3.forceSimulation()
.force("link", d3.forceLink().id(function(d) {
return d.id; }))
.force('charge',
d3.forceManyBody().strength(-200)
)
// .force("center", d3.forceCenter(width / 2, height / 2));
.force('center', d3.forceCenter(width / 2, height / 2))
.force('y', d3.forceY(0))
.force('x', d3.forceX(0));
function nodeByName(name) {
return nodesByName[name] || (nodesByName[name] = {name: name});
}
var nodesByName = {};
d3.queue()
.defer(d3.csv, "nodes_viz.csv")
.defer(d3.csv, "edges_viz2.csv")
.await(function(error, file1, file2) {
if (error) {
console.error('Oh dear, something went wrong: ' + error);
}
else {
var nodes = {};
file2.forEach(function(link) {
if (Object.keys(link).length === 0) {
} else {
link.source = nodeByName(link.source);
link.target = nodeByName(link.target);
// Extract the array of nodes from the map by name.
}
});
var nodes = d3.values(nodesByName);
console.log(nodes, file2);
buildGraph(nodes, file2);
}
});
function buildGraph(nodes, edges){
var link = svg.append("g")
.attr("class", "links")
.selectAll("line")
.data(edges)
.enter().append("line")
.attr("stroke-width", '1');
var node = svg.append("g")
.attr("class", "nodes")
.selectAll("circle")
.data(nodes)
.enter().append("circle")
.attr("r", 5)
.attr("fill", 'black')
.call(d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended));
var nodeLabel = svg.append("g")
.selectAll('text')
.data(nodes)
.enter().append('text')
.attr('class', 'labels')
.attr('dx', 12)
.attr('dy', '.35em')
.text(d => d.name);
simulation
.nodes(nodes)
.on("tick", ticked);
simulation.force("link")
.links(edges);
function ticked() {
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("transform", function(d) { return "translate(" + Math.max(radius, Math.min(width - radius, d.x)) + "," + Math.max(radius, Math.min(height - radius, d.y)) + ")"; });
// node.attr("cx", function(d) { return d.x = Math.max(radius, Math.min(width - radius, d.x)); })
// .attr("cy", function(d) { return d.y = Math.max(radius, Math.min(height - radius, d.y)); });
nodeLabel.attr('x', d => d.x)
.attr('y', d => d.y);
}
}
function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}
function dragged(d) {
d.fx = d3.event.x;
d.fy = d3.event.y;
}
function dragended(d) {
if (!d3.event.active) simulation.alphaTarget(0);
d.fx = d.x;
d.fy = d.y;
}
</script>
</body>
Name Label
Jeremy Boggs Jeremy Boggs
Rafael Alvarado Rafael Alvarado
Francesca Fiorani Francesca Fiorani
Ian Baucom Ian Baucom
Center for Digital Editing Center for Digital Editing
Erica Cavenaugh Erica Cavenaugh
Worthy Martin Worthy Martin
Robbie Hott Robbie Hott
Pete Alonzi Pete Alonzi
Phil Bourne Phil Bourne
Scholars' Lab Scholars' Lab
Rennie Mapp Rennie Mapp
Bill Ferster Bill Ferster
Alison Booth Alison Booth
John Unsworth John Unsworth
Robbie Bingler Robbie Bingler
Shayne Brandon Shayne Brandon
Cindy Girard Cindy Girard
Sarah Wells Sarah Wells
Lauren Masari Lauren Masari
Doug Ross Doug Ross
Provost Provost
IATH IATH
DH@UVa DH@UVa
Archie Holmes Archie Holmes
Data Science Institute Data Science Institute
David Germano David Germano
Arin Bennett Arin Bennett
Chris Gist Chris Gist
Ammon Shepherd Ammon Shepherd
Zoe LaBlanc Zoe LaBlanc
Will Rourk Will Rourk
Drew Macqueen Drew Macqueen
Ronda Grizzle Ronda Grizzle
Laura Miller Laura Miller
Shane Lin Shane Lin
Amanda Visconti Amanda Visconti
Brandon Walsh Brandon Walsh
Library Library
Yuji Shinozake Yuji Shinozake
Chris Jewell Chris Jewell
John Alexander John Alexander
VPIT VPIT
Melinda Bauman Melinda Bauman
Daniel Pitti Daniel Pitti
Nadim Al-Jarroud Nadim Al-Jarroud
Ron Hutchins Ron Hutchins
American Studies American Studies
Anthropology Anthropology
Art Art
Arts & Sciences Arts & Sciences
Computer Science Computer Science
DH Graduate Fellows DH Graduate Fellows
DH Graduate Prototyping Fellows DH Graduate Prototyping Fellows
Education Education
English English
IATH Associate Fellows IATH Associate Fellows
IATH Resident Fellows IATH Resident Fellows
Media Studies Media Studies
Praxis Graduate Fellows Praxis Graduate Fellows
Religious Studies Religious Studies
Research Data Services Research Data Services
SHANTI SHANTI
UVA Library UVA Library
VPIT VPIT
Name Label
Jeremy Boggs Jeremy Boggs
Rafael Alvarado Rafael Alvarado
Francesca Fiorani Francesca Fiorani
Ian Baucom Ian Baucom
Center for Digital Editing Center for Digital Editing
Erica Cavenaugh Erica Cavenaugh
Worthy Martin Worthy Martin
Robbie Hott Robbie Hott
Pete Alonzi Pete Alonzi
Phil Bourne Phil Bourne
Scholars' Lab Scholars' Lab
Rennie Mapp Rennie Mapp
Bill Ferster Bill Ferster
Alison Booth Alison Booth
John Unsworth John Unsworth
Robbie Bingler Robbie Bingler
Shayne Brandon Shayne Brandon
Cindy Girard Cindy Girard
Sarah Wells Sarah Wells
Lauren Masari Lauren Masari
Doug Ross Doug Ross
Provost Provost
IATH IATH
DH@UVa DH@UVa
Archie Holmes Archie Holmes
Data Science Institute Data Science Institute
David Germano David Germano
Arin Bennett Arin Bennett
Chris Gist Chris Gist
Ammon Shepherd Ammon Shepherd
Zoe LaBlanc Zoe LaBlanc
Will Rourk Will Rourk
Drew Macqueen Drew Macqueen
Ronda Grizzle Ronda Grizzle
Laura Miller Laura Miller
Shane Lin Shane Lin
Amanda Visconti Amanda Visconti
Brandon Walsh Brandon Walsh
Library Library
Yuji Shinozake Yuji Shinozake
Chris Jewell Chris Jewell
John Alexander John Alexander
VPIT VPIT
Melinda Bauman Melinda Bauman
Daniel Pitti Daniel Pitti
Nadim Al-Jarroud Nadim Al-Jarroud
Ron Hutchins Ron Hutchins
American Studies American Studies
Anthropology Anthropology
Art Art
Arts & Sciences Arts & Sciences
Computer Science Computer Science
DH Graduate Fellows DH Graduate Fellows
DH Graduate Prototyping Fellows DH Graduate Prototyping Fellows
Education Education
English English
IATH Associate Fellows IATH Associate Fellows
IATH Resident Fellows IATH Resident Fellows
Media Studies Media Studies
Praxis Graduate Fellows Praxis Graduate Fellows
Religious Studies Religious Studies
Research Data Services Research Data Services
SHANTI SHANTI
UVA Library UVA Library
VPIT VPIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment