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})`
})
}
}