Published
Edited
May 13, 2019
Fork of Globe
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
width = 960

Insert cell
height = 500
Insert cell
projection = d3.geoOrthographic()
.scale(250)
.translate([width / 2, height / 2])
.clipAngle(90)
Insert cell
path = d3.geoPath()
.projection(projection)
Insert cell
λ = d3.scaleLinear()
.domain([0, width])
.range([-180, 180])
Insert cell
φ = d3.scaleLinear()
.domain([0, height])
.range([90, -90])
Insert cell
world = d3.json("https://unpkg.com/world-atlas@1/world/110m.json")
Insert cell
el = d3.select(svg)
Insert cell
{
el.on("mouseover", function() {
var p = d3.mouse(this);
projection.rotate([λ(p[0]), φ(p[1])]);
el.selectAll("path").attr("d", path);
})

el.append("circle")
.attr('cx', width/2)
.attr('cy', height/2)
.attr('r', Math.min(width, height)/2)
.attr('fill', '#ccc')
el.append("path")
.datum(topojson.feature(world, world.objects.countries))
.attr("stroke", "#f00")
.attr("d", path);
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more