Respond to resize
This responsive scatter plot, built with D3 v4, visualizes World Happiness Report data, scaling both the chart and its axes to fill the screen. Unlike views that preserve aspect ratio, this block resizes width and height independently, so circles, axis fonts, and padding all grow proportionally with the chart. The animation responds smoothly to window resizing, with the x-axis representing GDP per capita and the y-axis showing life ladder scores across countries and years.
AI-generated descriptionBuilt with blockbuilder.org
The data comes from the World Happiness Report. Direct link to the data download can be found here.
The work for this block was developed locally using Curran Kelleher's dataviz-project-template as a starting point and also used the block World Happiness Ranking.
The focus of this block is to scale both the chart and axes to take up the full screen. We do not maintian view ratio. We scale for width and height individually. Note that as the chart gets bigger the circles in the scatter plot get bigger, same with axes fonts and chart padding for the axes.