Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Making a Bar Chart with D3.js and SVG

Public visualization

Making a Bar Chart with D3.js and SVG

0 stars1🌍 Public
XXin Li
Last edited Mar 20, 2021
Created on Mar 20, 2021

This example displays a horizontal bar chart of country populations using D3.js v6 and SVG, with data loaded from a CSV file via `d3.csv`. It shows the population of each country scaled linearly on the x-axis and categorically on the y-axis using `scaleLinear` and `scaleBand`. The chart renders axes with `axisLeft` and `axisBottom`, and applies a fixed top, right, bottom, and left margin to position the plot area. Bars are appended as SVG rectangles with steelblue fill, and the code uses `select`, `max`, and `csv` from the D3 module.

AI-generated description

An example including some commonly used features of SVG.

Comments

Sign in to join the discussion.

MIT Licensed