Gradient Encoding
This line chart shows daily temperature readings over a year, using a linear gradient as a redundant color encoding alongside the y-axis position. The gradient spans from steelblue at cooler temperatures through gray to red at warmer ones, making temperature ranges immediately visible. The code uses d3.svg.line with basis interpolation to draw the path, while d3.svg.axis creates the time and temperature axes. The gradient is defined with `gradientUnits` set to `userSpaceOnUse`, positioning color stops at explicit y-coordinates from the d3.scale.linear output, applied via the stroke attribute referencing the SVG linearGradient element.
AI-generated descriptionThis variation of a line chart demonstrates how to use a linear gradient as a quantitative color encoding redundant with y-position. The gradient units are defined as userSpaceOnUse, such that the gradient stops can be positioned explicitly rather than based on the line’s bounding box.