🌍 Public
Viewing a saved revision (read-only)
d60fe640edec4eeabf5af919a54a8962
task2_q1
This stacked bar chart shows agricultural trade data for Afghanistan from 2014 to 2018, displaying Import, Export, Production, and Consumption values per year. Each bar segment represents one category, with colors distinguishing the four metrics. The visualization uses D3.js v7 with `d3.stack()` to compute the stacked series, `d3.scaleBand()` for the x-axis years, and `d3.scaleLinear()` for the y-axis values. Data is hardcoded in the script rather than loaded from the accompanying CSV file. The chart renders as SVG with axis generators `d3.axisBottom()` and `d3.axisLeft()`.
AI-generated descriptionStacked Bar Chart - Air Pollution in China
This project visualizes average air pollution levels by city using a stacked bar chart with D3.js.
Files
index.html: Main HTML file containing D3.js visualization.style.css: Styling for the page and chart.air_pollution_china.csv: Dataset containing pollution and environmental data.README.md: Project overview and instructions.
How to Use
- Make sure all files are in the same directory.
- Open
index.htmlin a web browser. - The chart will load and display average pollution levels by city.
Requirements
- No local server needed. Just open
index.htmldirectly. - Internet connection required to load D3.js from CDN.