Skip to main content
100%

14 - Colour gradient for an area fill

✓ Published0🌍 Public
Aadry34160
Last edited Nov 1, 2016
Created on Nov 1, 2016

This example shows a line chart with an area fill whose color transitions from red to black to green as the y-value increases, providing a visual gradient tied to the data’s magnitude. The area is rendered as an SVG path using `d3.svg.area`, while the gradient is defined as a linearGradient element with multiple stop points. The code loads date and closing-value data from a CSV file, scales the axes with `d3.time.scale` and `d3.linear.scale`, and draws the axes via `d3.svg.axis`. The gradient’s color stops are explicitly set for specific vertical positions, creating the segmented color effect.

AI-generated description

Built with blockbuilder.org

forked from <a href='http://bl.ocks.org/adry34160/'>adry34160</a>'s block: <a href='http://bl.ocks.org/adry34160/4e6492eba6a7a5f5958579103b11aeba'>10 - Simple d3.js tooltip</a>

forked from <a href='http://bl.ocks.org/adry34160/'>adry34160</a>'s block: <a href='http://bl.ocks.org/adry34160/5d7fe0af1c6ca50c28aaeb4905bfaba9'>11 - Filtering in d3.js</a>

forked from <a href='http://bl.ocks.org/adry34160/'>adry34160</a>'s block: <a href='http://bl.ocks.org/adry34160/975b03fd11b013f435b81db37c68ecce'>12 - If selection in d3.js</a>

forked from <a href='http://bl.ocks.org/adry34160/'>adry34160</a>'s block: <a href='http://bl.ocks.org/adry34160/b8e46057442a44d7ec338723dfdaeb3b'>13 - Colour gradient on a graph line</a>

gnuplot Licensed

Similar vizzes