Skip to main content
100%

Colour gradient for an area fill

✓ Published0🌍 Public
Dd3noob
Last edited Nov 30, 2019
Created on Jun 23, 2014

This example shows a line chart with a gradient-filled area beneath it, where the fill color shifts from red through black to lawngreen based on the y-axis position. Data from a CSV file is plotted with d3.time.scale and d3.scale.linear axes. The code uses d3.svg.area to generate the area path and defines a linearGradient with multiple stop elements, referenced via a CSS url(#area-gradient) fill. The SVG rendering includes time-formatted x-axis ticks and a y-axis scaled to the maximum close value.

AI-generated description

This is a follow on from the simple d3.js graph used as an example in the book D3 Tips and Tricks.

It is aimed at demonstrating the application of a gradient fill to an area of a graph using d3.js. It should be taken in context with the text of the book which can be downloaded for free from Leanpub.

mit Licensed

Similar vizzes