Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

use the scaleLinear() to draw barchart2

Public visualization

Viewing a saved revision (read-only)

6135d1526d2d4526bfd694ea0c3ac010

use the scaleLinear() to draw barchart2

0 stars1🌍 Public
Ssgzzhinde
Last edited Jan 12, 2021
Created on Jan 12, 2021

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 description

A bare minimum HTML page demonstrating use of CSS and JavaScript.

See also React Starter.