Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

Making a Bar Chart

Public visualization

Viewing a saved revision (read-only)

743c4c8ccac348c09ad68256a3e307a4

Making a Bar Chart

0 stars1🌍 Public
NNikki-gea
Last edited Aug 24, 2020
Created on Aug 24, 2020

This example shows a horizontal bar chart of names and ages from a CSV file, with the x-axis mapping age and the y-axis mapping names. It uses d3.csv to load the data, d3.scaleLinear for the x scale, d3.scaleBand for the y scale, and d3.axisLeft and d3.axisBottom to render the axes. Bars are drawn as SVG rectangles with steelblue fill, and the chart is positioned inside an SVG element using margins. The code dynamically adjusts the scales based on the data’s maximum value and number of entries.

AI-generated description