Skip to main content
100%

Area graph with gradient in v5

✓ Published0🌍 Public
Dd3noob
Last edited Nov 28, 2019
Created on Nov 28, 2019

This example shows a time-series area chart of stock closing prices with a multi-color gradient that shifts from red through black to green based on the y-axis value. The area fills beneath the line, while the x-axis uses time scaling and the y-axis uses linear scaling. Built with D3 v5, it loads data from a CSV file and renders as SVG. The gradient is defined using an SVG `linearGradient` with `userSpaceOnUse` units, created via D3’s selection and data-join methods, and applied to a path generated with `d3.area`. Axis helpers `d3.axisBottom` and `d3.axisLeft` add the scales.

AI-generated description

This is a graph demonstrating the implimentation of a gradient on an area graph. This was written using d3.js v4 and is a follow on to the gradient line graph example here.

This graph is part of the code samples for the update to the book D3 Tips and Tricks to version 5 of d3.js.

mit Licensed

Similar vizzes