Skip to content

Instantly share code, notes, and snippets.

@chrismartinezb
Last active February 27, 2019 11:31
Show Gist options
  • Save chrismartinezb/e35f6c6b7a4def1dc56eea92d8897d40 to your computer and use it in GitHub Desktop.
Save chrismartinezb/e35f6c6b7a4def1dc56eea92d8897d40 to your computer and use it in GitHub Desktop.
fresh block
license: mit
{
"nodes": [
{"id": "Melisandre", "group": 0},
{"id": "Stannis", "group": 0},
{"id": "Davos", "group": 0},
{"id": "Ramsay", "group": 1},
{"id": "Robb", "group": 1},
{"id": "Theon", "group": 1},
{"id": "Catelyn", "group": 1},
{"id": "Walder", "group": 1},
{"id": "Euron", "group": 1},
{"id": "Yara", "group": 1},
{"id": "Roose", "group": 1},
{"id": "Podrick", "group": 2},
{"id": "Jaime", "group": 2},
{"id": "Brienne", "group": 2},
{"id": "Bronn", "group": 2},
{"id": "Loras", "group": 3},
{"id": "Margaery", "group": 3},
{"id": "Tommen", "group": 3},
{"id": "Olenna", "group": 3},
{"id": "Sparrow", "group": 3},
{"id": "Jorah", "group": 4},
{"id": "Viserys", "group": 4},
{"id": "Worm", "group": 4},
{"id": "Barristan", "group": 4},
{"id": "Daenerys", "group": 4},
{"id": "Hizdahr", "group": 4},
{"id": "Missandei", "group": 4},
{"id": "Daario", "group": 4},
{"id": "Osha", "group": 5},
{"id": "Meera", "group": 5},
{"id": "Luwin", "group": 5},
{"id": "Brann", "group": 5},
{"id": "Clegane", "group": 6},
{"id": "Jaqen", "group": 6},
{"id": "Gendry", "group": 6},
{"id": "Arya", "group": 6},
{"id": "Waif", "group": 6},
{"id": "Beric", "group": 6},
{"id": "Joffrey", "group": 7},
{"id": "Petyr", "group": 7},
{"id": "Ned", "group": 7},
{"id": "Sansa", "group": 7},
{"id": "Robert", "group": 7},
{"id": "Renly", "group": 7},
{"id": "Varys", "group": 8},
{"id": "Pycelle", "group": 8},
{"id": "Shae", "group": 8},
{"id": "Tyrion", "group": 8},
{"id": "Cersei", "group": 8},
{"id": "Qyburn", "group": 8},
{"id": "Oberyn", "group": 8},
{"id": "Tywin", "group": 8},
{"id": "Marwyn", "group": 9},
{"id": "Jon", "group": 9},
{"id": "Aemon", "group": 9},
{"id": "Samwell", "group": 9},
{"id": "Tormund", "group": 9},
{"id": "Gilly", "group": 9},
{"id": "Ygritte", "group": 9},
{"id": "Janos", "group": 9},
{"id": "Alliser", "group": 9},
{"id": "Grenn", "group": 9},
{"id": "Jeor", "group": 9},
{"id": "Edd", "group": 9},
{"id": "Mance", "group": 9} ],
"links": [
{"source": "Tyrion", "target": "Jon", "value": 168},
{"source": "Tyrion", "target": "Cersei", "value": 289},
{"source": "Tyrion", "target": "Daenerys", "value": 328},
{"source": "Tyrion", "target": "Jaime", "value": 183},
{"source": "Tyrion", "target": "Sansa", "value": 64},
{"source": "Tyrion", "target": "Davos", "value": 47},
{"source": "Tyrion", "target": "Jorah", "value": 140},
{"source": "Tyrion", "target": "Bronn", "value": 160},
{"source": "Tyrion", "target": "Catelyn", "value": 44},
{"source": "Tyrion", "target": "Tywin", "value": 205},
{"source": "Tyrion", "target": "Joffrey", "value": 140},
{"source": "Tyrion", "target": "Missandei", "value": 92},
{"source": "Tyrion", "target": "Janos", "value": 44},
{"source": "Tyrion", "target": "Oberyn", "value": 60},
{"source": "Tyrion", "target": "Shae", "value": 105},
{"source": "Tyrion", "target": "Varys", "value": 278},
{"source": "Tyrion", "target": "Worm", "value": 78},
{"source": "Jon", "target": "Cersei", "value": 51},
{"source": "Jon", "target": "Daenerys", "value": 185},
{"source": "Jon", "target": "Sansa", "value": 230},
{"source": "Jon", "target": "Arya", "value": 59},
{"source": "Jon", "target": "Samwell", "value": 291},
{"source": "Jon", "target": "Ned", "value": 89},
{"source": "Jon", "target": "Davos", "value": 198},
{"source": "Jon", "target": "Jorah", "value": 41},
{"source": "Jon", "target": "Robb", "value": 41},
{"source": "Jon", "target": "Stannis", "value": 132},
{"source": "Jon", "target": "Ramsay", "value": 76},
{"source": "Jon", "target": "Tormund", "value": 173},
{"source": "Jon", "target": "Robert", "value": 46},
{"source": "Jon", "target": "Melisandre", "value": 69},
{"source": "Jon", "target": "Janos", "value": 44},
{"source": "Jon", "target": "Alliser", "value": 81},
{"source": "Jon", "target": "Jeor", "value": 60},
{"source": "Jon", "target": "Edd", "value": 74},
{"source": "Jon", "target": "Grenn", "value": 71},
{"source": "Jon", "target": "Aemon", "value": 64},
{"source": "Jon", "target": "Ygritte", "value": 60},
{"source": "Jon", "target": "Mance", "value": 103},
{"source": "Cersei", "target": "Daenerys", "value": 61},
{"source": "Cersei", "target": "Jaime", "value": 360},
{"source": "Cersei", "target": "Sansa", "value": 77},
{"source": "Cersei", "target": "Ned", "value": 122},
{"source": "Cersei", "target": "Petyr", "value": 83},
{"source": "Cersei", "target": "Tywin", "value": 106},
{"source": "Cersei", "target": "Margaery", "value": 110},
{"source": "Cersei", "target": "Joffrey", "value": 125},
{"source": "Cersei", "target": "Robert", "value": 109},
{"source": "Cersei", "target": "Olenna", "value": 82},
{"source": "Cersei", "target": "Tommen", "value": 96},
{"source": "Cersei", "target": "Qyburn", "value": 91},
{"source": "Cersei", "target": "Loras", "value": 44},
{"source": "Cersei", "target": "Pycelle", "value": 46},
{"source": "Cersei", "target": "Varys", "value": 62},
{"source": "Cersei", "target": "Sparrow", "value": 144},
{"source": "Daenerys", "target": "Jorah", "value": 312},
{"source": "Daenerys", "target": "Daario", "value": 131},
{"source": "Daenerys", "target": "Missandei", "value": 66},
{"source": "Daenerys", "target": "Viserys", "value": 62},
{"source": "Daenerys", "target": "Barristan", "value": 83},
{"source": "Daenerys", "target": "Varys", "value": 89},
{"source": "Daenerys", "target": "Hizdahr", "value": 76},
{"source": "Jaime", "target": "Ned", "value": 71},
{"source": "Jaime", "target": "Bronn", "value": 231},
{"source": "Jaime", "target": "Catelyn", "value": 59},
{"source": "Jaime", "target": "Tywin", "value": 75},
{"source": "Jaime", "target": "Robb", "value": 51},
{"source": "Jaime", "target": "Brienne", "value": 106},
{"source": "Jaime", "target": "Robert", "value": 40},
{"source": "Jaime", "target": "Olenna", "value": 52},
{"source": "Jaime", "target": "Tommen", "value": 48},
{"source": "Jaime", "target": "Sparrow", "value": 41},
{"source": "Sansa", "target": "Arya", "value": 197},
{"source": "Sansa", "target": "Ned", "value": 73},
{"source": "Sansa", "target": "Petyr", "value": 246},
{"source": "Sansa", "target": "Davos", "value": 48},
{"source": "Sansa", "target": "Theon", "value": 85},
{"source": "Sansa", "target": "Brann", "value": 43},
{"source": "Sansa", "target": "Brienne", "value": 86},
{"source": "Sansa", "target": "Ramsay", "value": 121},
{"source": "Sansa", "target": "Joffrey", "value": 143},
{"source": "Sansa", "target": "Roose", "value": 40},
{"source": "Arya", "target": "Ned", "value": 104},
{"source": "Arya", "target": "Brienne", "value": 60},
{"source": "Arya", "target": "Joffrey", "value": 48},
{"source": "Arya", "target": "Jaqen", "value": 123},
{"source": "Arya", "target": "Gendry", "value": 50},
{"source": "Arya", "target": "Waif", "value": 74},
{"source": "Arya", "target": "Clegane", "value": 103},
{"source": "Samwell", "target": "Gilly", "value": 224},
{"source": "Samwell", "target": "Alliser", "value": 47},
{"source": "Samwell", "target": "Marwyn", "value": 80},
{"source": "Samwell", "target": "Grenn", "value": 55},
{"source": "Samwell", "target": "Aemon", "value": 57},
{"source": "Ned", "target": "Petyr", "value": 128},
{"source": "Ned", "target": "Catelyn", "value": 84},
{"source": "Ned", "target": "Robert", "value": 205},
{"source": "Ned", "target": "Pycelle", "value": 65},
{"source": "Ned", "target": "Varys", "value": 97},
{"source": "Petyr", "target": "Catelyn", "value": 40},
{"source": "Petyr", "target": "Roose", "value": 46},
{"source": "Petyr", "target": "Varys", "value": 87},
{"source": "Davos", "target": "Stannis", "value": 212},
{"source": "Davos", "target": "Tormund", "value": 41},
{"source": "Davos", "target": "Melisandre", "value": 84},
{"source": "Davos", "target": "Gendry", "value": 44},
{"source": "Theon", "target": "Brann", "value": 51},
{"source": "Theon", "target": "Robb", "value": 101},
{"source": "Theon", "target": "Ramsay", "value": 110},
{"source": "Theon", "target": "Roose", "value": 65},
{"source": "Theon", "target": "Yara", "value": 122},
{"source": "Theon", "target": "Luwin", "value": 43},
{"source": "Jorah", "target": "Daario", "value": 92},
{"source": "Jorah", "target": "Viserys", "value": 57},
{"source": "Brann", "target": "Robb", "value": 58},
{"source": "Brann", "target": "Osha", "value": 87},
{"source": "Brann", "target": "Meera", "value": 52},
{"source": "Brann", "target": "Luwin", "value": 72},
{"source": "Catelyn", "target": "Robb", "value": 156},
{"source": "Catelyn", "target": "Walder", "value": 60},
{"source": "Tywin", "target": "Joffrey", "value": 62},
{"source": "Tywin", "target": "Oberyn", "value": 50},
{"source": "Robb", "target": "Roose", "value": 44},
{"source": "Robb", "target": "Walder", "value": 53},
{"source": "Stannis", "target": "Melisandre", "value": 107},
{"source": "Stannis", "target": "Renly", "value": 55},
{"source": "Brienne", "target": "Podrick", "value": 111},
{"source": "Ramsay", "target": "Roose", "value": 111},
{"source": "Margaery", "target": "Olenna", "value": 71},
{"source": "Margaery", "target": "Tommen", "value": 107},
{"source": "Margaery", "target": "Loras", "value": 58},
{"source": "Margaery", "target": "Sparrow", "value": 101},
{"source": "Olenna", "target": "Sparrow", "value": 48},
{"source": "Missandei", "target": "Worm", "value": 90},
{"source": "Tommen", "target": "Sparrow", "value": 64},
{"source": "Loras", "target": "Renly", "value": 59},
{"source": "Loras", "target": "Sparrow", "value": 53},
{"source": "Clegane", "target": "Beric", "value": 76} ]
}
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.links line {
stroke: #999;
stroke-opacity: 357.12;
}
.nodes circle {
stroke: #fff;
stroke-width: -40.5px;
}
</style>
<svg width="2200" height="1800"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var color = d3.scaleOrdinal(d3.schemeCategory20);
var simulation = d3.forceSimulation()
.force("link", d3.forceLink().id(function(d) { return d.id; }))
.force("charge", d3.forceManyBody().strength(-400).distanceMax(150).distanceMin(10))
.force("center", d3.forceCenter(width / 4.698948083712, height / 6.76));
d3.json("GoT_interactions_draft.json", function(error, graph) {
if (error) throw error;
var link = svg.append("g")
.attr("class", "links")
.selectAll("line")
.data(graph.links)
.enter().append("line")
.attr("stroke-width", function(d) { return d.value/170; });
var nodes = svg.append("g")
.attr("class", "nodes")
.selectAll("circle")
.data(graph.nodes)
.enter().append("g")
nodes.append("circle")
.attr("r", 5)
.attr("fill", function(d) { return color(d.group); })
.call(d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended));
nodes.append("text")
.attr("dx", 8)
.attr("dy", ".35em")
.text(function(d) { return d.id });
simulation
.nodes(graph.nodes)
.on("tick", ticked);
simulation.force("link")
.links(graph.links);
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; });
nodes
.attr("transform", function(d) { return "translate("+[d.x,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 = null;
d.fy = null;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment