Skip to main content
100%

Making a barchart

✓ Published0🌍 Public
Mmylavarapus
Last edited Dec 27, 2020
Created on Dec 26, 2020

This example displays a horizontal bar chart of country populations using D3 v6, loading data from a CSV file and rendering it as SVG rectangles. The code imports `select`, `csv`, `scaleLinear`, `max`, and `scaleBand` from D3 to create linear and band scales that map population values to bar widths and country names to vertical positions. The bars are appended to an SVG element with dimensions specified in the HTML, and the population values are converted to numbers before rendering. The example also demonstrates loading D3 via UNPKG and using local ES6 modules for data generation and formatting utilities.

AI-generated description

An example showing the capabilities of VizHub:

  • Loads D3 via UNPKG.
  • Demonstrates use of import from "d3".
  • Demonstrates use of import from local ES6 modules.
MIT Licensed

Similar vizzes