Making a Bar Chart
✓ Published1🌍 Public
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 descriptionMIT Licensed