🌍 Public
Viewing a saved revision (read-only)
6135d1526d2d4526bfd694ea0c3ac010
use the scaleLinear() to draw barchart2
This example demonstrates how to draw a simple bar chart using D3.js version 5’s `scaleLinear()` function to map data values to pixel widths. A hardcoded array of five numeric values is transformed into green rectangular bars, each with a fixed height and spacing, rendered as SVG within a React-equipped HTML page. The code explicitly creates a linear scale with a domain from zero to the maximum data value and a range of 0 to 400 pixels, then applies that scale to each rectangle’s width attribute via D3’s data join and selection methods.
AI-generated descriptionA bare minimum HTML page demonstrating use of CSS and JavaScript.
See also React Starter.