Skip to main content
100%

use the scaleLinear() to draw barchart1

✓ Published1🌍 Public
Ssgzzhinde
Last edited Jan 12, 2021
Created on Jan 12, 2021

This example uses a linear scale to draw a simple bar chart from a small array of numeric values. The d3.scaleLinear() function maps the domain from zero to the maximum data value into a pixel range from 0 to 800, determining each bar’s width. The code appends SVG rectangles, vertically spaced with a fixed height, and fills them green. It relies on D3 v5 selections and the SVG rendering approach within a React framework, with data hardcoded in the script.

AI-generated description

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

See also React Starter.

MIT Licensed

Similar vizzes