Linear Gradient
✓ Published0🌍 Public
EEfratVil
Last edited Jan 15, 2018
Created on Nov 25, 2017
Two horizontal SVG rects demonstrate linear gradients: a static HTML/SVG version with hardcoded stops and a dynamic D3 v4 version using `d3.scaleLinear` for the color range. The D3 code programmatically appends `stop` elements to a `linearGradient` definition, mapping five color values across offsets from 0% to 100%. Both rects are stroked in black, and the example contrasts explicit markup with data-driven gradient creation. The gradient fills are applied via the `fill` attribute referencing the gradient IDs, with the D3 version relying on the `d3-selection` API to construct the SVG structure.
AI-generated descriptionLinear Gradient <br/> Reference: https://www.w3.org/TR/SVG/pservers.html