Making a bar chart!
✓ Published1🌍 Public
This example shows a horizontal bar chart of population data for nine countries, with the country names on the y-axis and population counts on the x-axis. It loads data from a CSV file, then uses d3.scaleBand for the categorical country axis and d3.scaleLinear for the continuous population axis, with d3.axisLeft and d3.axisBottom for tick labels. Bars are rendered as SVG rect elements with a steelblue fill, and the chart is drawn in an SVG canvas with margins calculated from the viewport dimensions.
AI-generated descriptionLoading the d3 script from UNPKG puts a d3 variable in the global namespace. (Take out "browse" from that link to load it.
MIT Licensed