Create a gist now

Instantly share code, notes, and snippets.

Print media ownership in Australia

Australian Print Media Ownership

Browsing the Austalian media ownership information from wikipedia, I wanted a quick way to visualise it, so I hacked this up. Only focuses on print media for now.

Requires a big screen (1500x900 minimum) because I am too lazy to do it properly. Be sure to click that "open in new window" button on blocks, here it is again in case you are as lazy as me. You can click and drag stuff around too.

Suggestions, improvements and hatemail to danielkinsman@gmail.com (gnupg public key).

{
"nodes":
[
{ "name": "The Australian" },
{ "name": "Australian Associated Press" },
{ "name": "News Limited" },
{ "name": "Fairfax" },
{ "name": "Seven West Media Limited" },
{ "name": "The Daily Telegraph" },
{ "name": "mX" },
{ "name": "The Sportsman" },
{ "name": "Herald Sun" },
{ "name": "The Courier-Mail" },
{ "name": "The Advertiser" },
{ "name": "Sunday Mail" },
{ "name": "The Sunday Times" },
{ "name": "The Mercury" },
{ "name": "Northern Territory News" },
{ "name": "NewsLocal" },
{ "name": "Leader" },
{ "name": "Quest" },
{ "name": "Messenger" },
{ "name": "Community" },
{ "name": "Geelong Advertiser" },
{ "name": "Gold Coast Bulletin" },
{ "name": "The Age" },
{ "name": "The Sydney Morning Herald" },
{ "name": "The Australian Financial Review" },
{ "name": "Illawarra Mercury" },
{ "name": "The Newcastle Herald" },
{ "name": "The Border Mail" },
{ "name": "The Warrnambool Standard" },
{ "name": "The Courier" },
{ "name": "The Bendigo Advertiser" },
{ "name": "The Canberra Times" },
{ "name": "The Land" },
{ "name": "The West Australian" },
{ "name": "Socialist Alliance" },
{ "name": "Green Left Weekly" },
{ "name": "Informa Australia" },
{ "name": "Lloyd's List Australia" }
],
"links":
[
{ "source": 0, "target" : 2, "share": 1.0 },
{ "source": 1, "target" : 2, "share": 0.45 },
{ "source": 1, "target" : 3, "share": 0.47 },
{ "source": 1, "target" : 4, "share": 0.08 },
{ "source": 5, "target" : 2, "share": 1.0 },
{ "source": 6, "target" : 2, "share": 1.0 },
{ "source": 7, "target" : 2, "share": 1.0 },
{ "source": 8, "target" : 2, "share": 1.0 },
{ "source": 9, "target" : 2, "share": 1.0 },
{ "source": 10, "target" : 2, "share": 1.0 },
{ "source": 11, "target" : 2, "share": 1.0 },
{ "source": 12, "target" : 2, "share": 1.0 },
{ "source": 13, "target" : 2, "share": 1.0 },
{ "source": 14, "target" : 2, "share": 1.0 },
{ "source": 15, "target" : 2, "share": 1.0 },
{ "source": 16, "target" : 2, "share": 1.0 },
{ "source": 17, "target" : 2, "share": 1.0 },
{ "source": 18, "target" : 2, "share": 1.0 },
{ "source": 19, "target" : 2, "share": 1.0 },
{ "source": 20, "target" : 2, "share": 1.0 },
{ "source": 21, "target" : 2, "share": 1.0 },
{ "source": 22, "target" : 3, "share": 1.0 },
{ "source": 23, "target" : 3, "share": 1.0 },
{ "source": 24, "target" : 3, "share": 1.0 },
{ "source": 25, "target" : 3, "share": 1.0 },
{ "source": 26, "target" : 3, "share": 1.0 },
{ "source": 27, "target" : 3, "share": 1.0 },
{ "source": 28, "target" : 3, "share": 1.0 },
{ "source": 29, "target" : 3, "share": 1.0 },
{ "source": 30, "target" : 3, "share": 1.0 },
{ "source": 31, "target" : 3, "share": 1.0 },
{ "source": 32, "target" : 3, "share": 1.0 },
{ "source": 33, "target" : 4, "share": 1.0 },
{ "source": 35, "target" : 34, "share": 1.0 },
{ "source": 37, "target" : 36, "share": 1.0 }
]
}
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.nodecircle {
stroke: #fff;
stroke-width: 1.5px;
}
.link {
stroke: black;
stroke-opacity: .25;
}
marker {
fill-opacity: 0.25;
stroke-opacity: 0.25;
}
marker#triangle {
stroke: blue;
fill: blue;
}
marker#square {
stroke: purple;
fill: purple;
}
text {
font: 15px sans-serif;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var width = 1500,
height = 900;
var color = d3.scale.category20();
var force = d3.layout.force()
.charge(-650)
.linkDistance(180)
.size([width, height]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("corps.json", function(error, graph) {
force
.nodes(graph.nodes)
.links(graph.links)
.start();
svg.append("svg:defs").selectAll("marker")
.data(["triangle"])
.enter().append("svg:marker")
.attr("id", String)
.attr("viewBox", "0 0 10 10")
.attr("refX", 0)
.attr("refY", 5)
.attr("markerWidth", 2)
.attr("markerHeight", 2)
.attr("orient", "auto")
.attr("class", "triangle")
.append("svg:path")
.attr("d", "M 10 10 L 0 5 L 10 0 z");
svg.append("svg:defs").selectAll("marker")
.data(["square"])
.enter().append("svg:marker")
.attr("id", String)
.attr("viewBox", "0 0 10 10")
.attr("refX", 0)
.attr("refY", 5)
.attr("markerWidth", 1)
.attr("markerHeight", 1)
.attr("orient", "auto")
.attr("class", "square")
.append("svg:path")
.attr("d", "M 0 0 L 10 0 L 10 10 L 0 10 z");
var link = svg.selectAll(".link")
.data(graph.links)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) { return Math.max(d.share, 0.3) * 10; })
.attr("marker-start", "url(#triangle)")
.attr("marker-end", "url(#square)");
var node = svg.selectAll(".node")
.data(graph.nodes);
var gee = node.enter().append("svg:g")
.attr("class", "node")
.attr("transform", function(d){return "translate(" + d.x + "," + d.y + ")";})
.call(force.drag);
/*gee.append("svg:circle")
.attr("cx", "0")
.attr("cy", "0")
.attr("r", "5")
.attr("class", "nodecircle");*/
gee.append("text").text(function(d){return d.name;});
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("transform", function(d){return "translate(" + d.x + "," + d.y + ")";});
});
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment