Viewing a saved revision (read-only)
639d621bd0e743b6ba638a070d699cbb
A6 Diverging Color Scale Bar Chart
This example visualizes life expectancy in 1960 for a selection of countries using a diverging color scale bar chart. The bars are colored on a green-to-red gradient via a sequential scale with an RdYlGn interpolator, where higher life expectancies appear greener and lower ones redder. The chart uses D3 v7 to load data from a CSV file, create SVG bars with band and linear scales, and render axes with tick labels. A custom legend and axis titles are added using D3’s selection and axis methods, while the underlying data is sourced from a shortened TidyTuesday dataset.
AI-generated descriptionCountry,1960,1970,1980,1990,2000,2010,2020 United States,68.05,70.7353,73.7172,75.3699,76.8114,78.7724,77.4144 Afghanistan,32.53,37.41,39.6181,45.9672,55.2978,60.85,62.5751 Sweden,73.0364,74.622,75.743,77.5883,79.7382,81.5187,82.4274 Zimbabwe,53.2347,57.038,58.6743,59.4264,44.6864,50.6523,61.1242 Hong Kong,66.238,71.3052,74.8509,77.4724,80.7461,82.993,85.1968 Japan,67.6898,71.9874,76.1261,78.9838,81.1759,82.9193,84.6879 South Korea,54.3213,62.2668,65.3829,71.9401,76.4661,80.763,83.6089 North Korea,54.05,60.5707,66.1578,70.21,60.7631,70.4182,73.2741