Skip to main content
100%

task2_q1

✓ Published0🌍 Public
Bbadiniswetha@gmail.com
Last edited Apr 6, 2025
Created on Apr 4, 2025
Forked from Hello VizHub

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 description

D3.js Stacked Bar Chart - Agricultural Data

Overview

This project visualizes agricultural trade data using a stacked bar chart created with D3.js.

Files

  • index.html - Main file containing the D3.js visualization.
  • style.css - Styles for the visualization.
  • README.md - Instructions on how to use the project.
  • Export.csv - The dataset (source file).

Setup & Usage

  1. Open index.html in a web browser.
  2. The stacked bar chart will display Import, Export, Production, and Consumption over the years.
  3. The colors represent different categories:
    • Blue: Import
    • Orange: Export
    • Green: Production
    • Red: Consumption

Dependencies

  • D3.js (included via CDN)

Customization

  • Modify the data array in index.html to use a different dataset.
  • Update style.css to change the chart appearance.

Preview

Stacked Bar Chart (Add a screenshot here)

License

This project is free to use and modify.


Enjoy exploring data with D3.js! 🚀

MIT Licensed

Similar vizzes