Skip to main content
100%

Question 2

✓ Published0🌍 Public
Rragasrikakarla27@gmail.com
Last edited Oct 30, 2025
Created on Oct 30, 2025
Forked from D3 Starter

This stacked bar chart visualizes energy consumption by source across five countries (USA, China, India, Germany, Brazil) for 2023. The chart uses D3 v7 with `d3.scaleBand` for the x-axis and `d3.scaleLinear` for the y-axis, rendering stacked segments via `d3.stack().keys()` to represent Coal, Oil, Natural Gas, Renewable, and Nuclear proportions. Data loads from `energy_data.csv` using `d3.csv()`. A legend, generated with SVG groups, identifies each energy source, while custom colors are assigned through `d3.scaleOrdinal`.

AI-generated description
MIT Licensed

Similar vizzes