Last active
August 29, 2015 14:04
-
-
Save jbwhit/05f41642412c4622a85d to your computer and use it in GitHub Desktop.
Flights while based in Australia.
This file contains 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"> | |
<style> | |
body { | |
background: #fcfcfa; | |
} | |
.stroke { | |
fill: none; | |
stroke: #000; | |
stroke-width: 3px; | |
} | |
.fill { | |
fill: #fff; | |
} | |
.graticule { | |
fill: none; | |
stroke: #777; | |
stroke-width: .5px; | |
stroke-opacity: .5; | |
} | |
.land { | |
fill: #bbb; | |
} | |
.boundary { | |
fill: none; | |
stroke: #fff; | |
stroke-width: .5px; | |
} | |
.points circle { | |
fill: #fff; | |
stroke: black; | |
stroke-width: 1px; | |
} | |
.points text { | |
font: 11px sans-serif; | |
text-anchor: middle; | |
text-shadow: 0 1px 0 #fff, 0 -1px 0 #fff, 1px 0 0 #fff, -1px 0 0 #fff; | |
} | |
.route { | |
fill: none; | |
stroke: black; | |
stroke-width: 1px; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/d3.geo.projection.v0.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script> | |
var width = 602, | |
height = 357; | |
var places = { | |
AKL: [+174.791667, -37.008056], | |
AMS: [+4.763889, +52.308613], | |
ANF: [-70.445100, -23.444478], | |
CDG: [+2.550000, +49.012779], | |
CJC: [-68.903575, -22.498175], | |
DCA: [-77.037722, +38.852083], | |
DFW: [-97.037997, +32.896828], | |
DOH: [+51.565056, +25.261125], | |
DXB: [+55.364444, +25.252778], | |
FCO: [+12.250797, +41.804475], | |
FRA: [+8.543125, +50.026421], | |
GLA: [-4.433056, +55.871944], | |
HBA: [+147.510278, -42.836111], | |
HNL: [-157.922428, +21.318681], | |
ITO: [-155.048469, +19.721375], | |
KOA: [-156.045631, +19.738767], | |
KUL: [+101.6981, +2.743], | |
LAX: [-118.408075, +33.942536], | |
LHR: [-0.461389, +51.477500], | |
MEL: [+144.843333, -37.673333], | |
NTL: [+151.830000, -32.780000], | |
PHX: [-112.011583, +33.434278], | |
SAN: [-117.189667, +32.733556], | |
SCL: [-70.785803, -33.392975], | |
SFO: [-122.374889, +37.618972], | |
SIN: [+103.994433, +1.350189], | |
STN: [+0.235000, +51.885000], | |
SYD: [+151.177222, -33.946111], | |
TRS: [+13.472222, +45.827500], | |
TXL: [+13.287711, +52.559686], | |
VCE: [+12.351944, +45.505278], | |
ZRH: [+8.549167, +47.464722], | |
}; | |
var route = { | |
type: "LineString", | |
coordinates: [ | |
places.DFW, | |
places.LAX, | |
places.LAX, | |
places.MEL, | |
places.MEL, | |
places.AKL, | |
places.AKL, | |
places.SCL, | |
places.SCL, | |
places.ANF, | |
places.ANF, | |
places.SCL, | |
places.SCL, | |
places.AKL, | |
places.AKL, | |
places.MEL, | |
places.MEL, | |
places.SYD, | |
places.SYD, | |
places.MEL, | |
places.MEL, | |
places.LAX, | |
places.LAX, | |
places.MEL, | |
places.MEL, | |
places.NTL, | |
places.NTL, | |
places.MEL, | |
places.MEL, | |
places.HNL, | |
places.HNL, | |
places.KOA, | |
places.KOA, | |
places.HNL, | |
places.HNL, | |
places.DFW, | |
places.DFW, | |
places.HNL, | |
places.HNL, | |
places.SYD, | |
places.SYD, | |
places.MEL, | |
places.MEL, | |
places.DOH, | |
places.DOH, | |
places.FCO, | |
places.FCO, | |
places.TRS, | |
places.TRS, | |
places.FCO, | |
places.FCO, | |
places.DOH, | |
places.DOH, | |
places.MEL, | |
places.MEL, | |
places.SYD, | |
places.SYD, | |
places.AKL, | |
places.AKL, | |
places.SCL, | |
places.SCL, | |
places.ANF, | |
places.CJC, | |
places.SCL, | |
places.SCL, | |
places.AKL, | |
places.AKL, | |
places.SYD, | |
places.SYD, | |
places.MEL, | |
places.MEL, | |
places.SYD, | |
places.SYD, | |
places.HNL, | |
places.HNL, | |
places.ITO, | |
places.ITO, | |
places.HNL, | |
places.HNL, | |
places.SYD, | |
places.SYD, | |
places.MEL, | |
places.MEL, | |
places.SYD, | |
places.SYD, | |
places.SFO, | |
places.SFO, | |
places.LAX, | |
places.LAX, | |
places.DFW, | |
places.DFW, | |
places.LAX, | |
places.LAX, | |
places.SFO, | |
places.SFO, | |
places.SYD, | |
places.SYD, | |
places.MEL, | |
places.MEL, | |
places.SYD, | |
places.SYD, | |
places.HNL, | |
places.HNL, | |
places.SYD, | |
places.SYD, | |
places.MEL, | |
places.MEL, | |
places.DXB, | |
places.DXB, | |
places.VCE, | |
places.FRA, | |
places.DXB, | |
places.DXB, | |
places.KUL, | |
places.KUL, | |
places.MEL, | |
places.MEL, | |
places.LAX, | |
places.LAX, | |
places.DFW, | |
places.DFW, | |
places.DCA, | |
places.DCA, | |
places.DFW, | |
places.DFW, | |
places.PHX, | |
places.PHX, | |
places.SAN, | |
places.SAN, | |
places.LAX, | |
places.LAX, | |
places.MEL, | |
places.MEL, | |
places.HBA, | |
places.HBA, | |
places.MEL, | |
places.MEL, | |
places.SIN, | |
places.SIN, | |
places.FRA, | |
places.FRA, | |
places.CDG, | |
places.AMS, | |
places.ZRH, | |
places.ZRH, | |
places.LHR, | |
places.LHR, | |
places.GLA, | |
places.GLA, | |
places.STN, | |
places.STN, | |
places.TXL, | |
places.TXL, | |
places.FRA, | |
places.FRA, | |
places.SIN, | |
places.SIN, | |
places.MEL, | |
places.MEL, | |
places.SYD, | |
places.SYD, | |
places.MEL, | |
] | |
}; | |
var projection = d3.geo.kavrayskiy7() | |
.scale(120) | |
.rotate([-140, 0]) | |
.translate([width / 2, height / 2]) | |
.precision(.1); | |
var path = d3.geo.path() | |
.projection(projection); | |
var graticule = d3.geo.graticule(); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
svg.append("defs").append("path") | |
.datum({type: "Sphere"}) | |
.attr("id", "sphere") | |
.attr("d", path); | |
svg.append("use") | |
.attr("class", "stroke") | |
.attr("xlink:href", "#sphere"); | |
svg.append("use") | |
.attr("class", "fill") | |
.attr("xlink:href", "#sphere"); | |
svg.append("path") | |
.datum(graticule) | |
.attr("class", "graticule") | |
.attr("d", path); | |
svg.append("path") | |
.datum(route) | |
.attr("class", "route") | |
.attr("d", path); | |
var point = svg.append("g") | |
.attr("class", "points") | |
.selectAll("g") | |
.data(d3.entries(places)) | |
.enter().append("g") | |
.attr("transform", function(d) { return "translate(" + projection(d.value) + ")"; }); | |
point.append("circle") | |
.attr("r", 1.5); | |
// point.append("text") | |
// .attr("y", 10) | |
// .attr("dy", ".71em") | |
// .text(function(d) { return d.key; }); | |
d3.json("/mbostock/raw/4090846/world-50m.json", function(error, world) { | |
svg.insert("path", ".graticule") | |
.datum(topojson.feature(world, world.objects.land)) | |
.attr("class", "land") | |
.attr("d", path); | |
svg.insert("path", ".graticule") | |
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; })) | |
.attr("class", "boundary") | |
.attr("d", path); | |
}); | |
d3.select(self.frameElement).style("height", height + "px"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment