Set an SVG Element's Width Based on a D3 Linear Scale in React

InstructorAndy Van Slaars

Share this video with your friends

Send Tweet

Drawing data accurately requires a consistent and precise mechanism for mapping data values to pixels on the screen. We can accomplish this mapping in D3 using scales. There are various scales available in D3, depending on your needs. In this lesson we'll using a linear scale to map a data domain of continuous values to continuous range of pixel values. We'll render a new SVG element, setting its width from our scale.