Skip to content

Instantly share code, notes, and snippets.

@shawngraham
Forked from sfsheath/index.html
Last active December 18, 2015 16:59
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 shawngraham/9623619 to your computer and use it in GitHub Desktop.
Save shawngraham/9623619 to your computer and use it in GitHub Desktop.
d3 bundled edges
{
"name": "archaeogaming",
"children": [
{
"name": "Real-world archaeology of video game hardware and software",
"children": [
{"name": "Atari Burial Ground"},
{"name": "History of use and object biography"},
{"name": "Conservation and preservation"},
{"name": "Establishing chronology and typology of games"},
{"name": "Gaming spaces eg arcages"},
{"name": "History of personal or commercial use"},
{"name": "Archiving and Game History"},
{"name": "Version control patches and damnatio memoriae"}
]
},
{
"name": "Videogame or virtual world as archaeological site",
"children": [
{"name": "Tool definition and creation for in-world archaeology"},
{"name": "Application of real-world methods to virtual spaces"},
{"name": "Glitches as artifacts"},
{"name": "Game as artifact or the space betwewen the hardware and the illusion of a world in game"},
{"name": "In-world garbology"},
{"name": "Survey Landscape Underwater Exoarchaeology"}
]
},
{
"name": "Philosophy",
"children": [
{"name": "Quantum entanglement in video games"},
{"name": "Perception"},
{"name": "Complexity and chaos and algorithms"},
{"name": "Deism and world-building"}
]
},
{
"name": "Reception",
"children": [
{"name": "Archaeologists as playable characters"},
{"name": "Archaeologists as non-playable characters or AI"},
{"name": "In-world looting and or auctioning of in-game inventory"},
{"name": "Public perception of archaeology and archaeologists"},
{"name": "Developer perception and promotion of archaeology and archaeologists"},
{"name": "In-game depictions or reenactments of real-world historical events"}
]
},
{
"name": "Game Development",
"children": [
{"name": "Archaeological consulting with studios"},
{"name": "Archaeologists as game makers"},
{"name": "Developer influence and design choices"},
{"name": "Games as archaeology teaching tools"},
{"name": "Augmented reality for play tourism or education"},
{"name": " 3d modeling and space-creation or recreations of antiquity both real or imagined"},
{"name": "Lore and lore communities"},
{"name": "Code and name as epigraphy and palaeography"}
]
},
{
"name": "Machine-created culture",
"children": [
{"name": "Virtual ethnography"},
{"name": "Procedurally generated environments and artifacts"}
]
},
{
"name": "The archaeology of ...game title...",
"children" : [
{"name": "Minecraft"},
{"name": "Elder Scrolls"},
{"name": "World of Warcraft"},
{"name": "Fallout"},
{"name": "Mass Effect"},
{"name": "etc"}
]
},
{
"name": "Material culture",
"children": [
{"name": "Real and virtual commerce economics and numismatics"},
{"name": "Real-world manifestation of virtual world artifacts"},
{"name": "Cosplay and game-derived experimental archaeology"},
{"name": "In-world museums"},
{"name": "Real-world museums"}
]
}
]
}

Mouseover any of the nodes in this network to see the incoming links (dependants) in green and the outgoing links (dependencies) in red.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
font: 300 11px "Helvetica Neue", Helvetica, Arial, sans-serif;
fill: #bbb;
}
.node:hover {
fill: #000;
}
.link {
stroke: steelblue;
stroke-opacity: .4;
fill: none;
pointer-events: none;
}
.node:hover,
.node--source,
.node--target {
font-weight: 700;
}
.node--source {
fill: #2ca02c;
}
.node--target {
fill: #d62728;
}
.link--target {
stroke-opacity: 1;
stroke-width: 2px;
}
.link--source {
stroke-opacity: 1;
stroke-width: 2px;
}
.link--source {
stroke: #d62728;
}
.link--target {
stroke: #2ca02c;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var diameter = 960,
radius = diameter / 2,
innerRadius = radius - 120;
var cluster = d3.layout.cluster()
.size([360, innerRadius])
.sort(null)
.value(function(d) { return d.size; });
var bundle = d3.layout.bundle();
var line = d3.svg.line.radial()
.interpolate("bundle")
.tension(.85)
.radius(function(d) { return d.y; })
.angle(function(d) { return d.x / 180 * Math.PI; });
var svg = d3.select("body").append("svg")
.attr("width", diameter)
.attr("height", diameter)
.append("g")
.attr("transform", "translate(" + radius + "," + radius + ")");
var link = svg.append("g").selectAll(".link"),
node = svg.append("g").selectAll(".node");
d3.json("readme-flare-imports.json", function(error, classes) {
var nodes = cluster.nodes(packageHierarchy(classes)),
links = packageImports(nodes);
link = link
.data(bundle(links))
.enter().append("path")
.each(function(d) { d.source = d[0], d.target = d[d.length - 1]; })
.attr("class", "link")
.attr("d", line);
node = node
.data(nodes.filter(function(n) { return !n.children; }))
.enter().append("text")
.attr("class", "node")
.attr("dx", function(d) { return d.x < 180 ? 8 : -8; })
.attr("dy", ".31em")
.attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")" + (d.x < 180 ? "" : "rotate(180)"); })
.style("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
.text(function(d) { return d.key; })
.on("mouseover", mouseovered)
.on("mouseout", mouseouted);
});
function mouseovered(d) {
node
.each(function(n) { n.target = n.source = false; });
link
.classed("link--target", function(l) { if (l.target === d) return l.source.source = true; })
.classed("link--source", function(l) { if (l.source === d) return l.target.target = true; })
.filter(function(l) { return l.target === d || l.source === d; })
.each(function() { this.parentNode.appendChild(this); });
node
.classed("node--target", function(n) { return n.target; })
.classed("node--source", function(n) { return n.source; });
}
function mouseouted(d) {
link
.classed("link--target", false)
.classed("link--source", false);
node
.classed("node--target", false)
.classed("node--source", false);
}
d3.select(self.frameElement).style("height", diameter + "px");
// Lazily construct the package hierarchy from class names.
function packageHierarchy(classes) {
var map = {};
function find(name, data) {
var node = map[name], i;
if (!node) {
node = map[name] = data || {name: name, children: []};
if (name.length) {
node.parent = find(name.substring(0, i = name.lastIndexOf(".")));
node.parent.children.push(node);
node.key = name.substring(i + 1);
}
}
return node;
}
classes.forEach(function(d) {
find(d.name, d);
});
return map[""];
}
// Return a list of imports for the given array of nodes.
function packageImports(nodes) {
var map = {},
imports = [];
// Compute a map from name to node.
nodes.forEach(function(d) {
map[d.name] = d;
});
// For each import, construct a link from the source to target node.
nodes.forEach(function(d) {
if (d.imports) d.imports.forEach(function(i) {
imports.push({source: map[d.name], target: map[i]});
});
});
return imports;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment