Published
Edited
Jul 1, 2019
Insert cell
Insert cell
Insert cell
Insert cell
transition = {
const states = d3.selectAll('.states')
if (toggle == 'Map') {
states.transition().duration(t)
.attr('transform', d => {
const centroid = geoPath.centroid(d),
x = centroid[0],
y = centroid[1]
return `translate(${x},${y})`
+ `scale(${ Math.sqrt(1) })`
+ `translate(${-x},${-y})`
})
} else if (toggle == 'Cartogram') {
states.transition().duration(t)
.attr('transform', d => {
const centroid = geoPath.centroid(d),
x = centroid[0],
y = centroid[1]
return `translate(${x},${y})`
+ `scale(${ Math.sqrt(0.5) })`
+ `translate(${-x},${-y})`
})
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
topojson = require('topojson-client@3')
Insert cell
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