d3v4 - Gradient Color Line Chart
✓ Published0🌍 Public
HHirosaji
Last edited Feb 19, 2020
Created on Jul 16, 2019
This example shows a line chart of temperature data over time, where the line’s color shifts through a red-gray-steelblue gradient based on value. The chart uses d3.v4's `d3.line()` with `d3.curveStep` to generate a stepped path, and a `linearGradient` with three `stop` elements, defined in SVG `defs`, applies the color scale via the `stroke` attribute. The data is loaded from a CSV of temperature readings, with x/y axes scaled using `d3.scaleLinear()`.
AI-generated description▶︎ What's this?: Line chart with a gradient to change the color of a line based on its value
▶︎ Reference: https://observablehq.com/@d3/gradient-encoding
[Gist] https://gist.github.com/Hirosaji/e34f1e2d45297193964e742c45fec027/
Built with blockbuilder.org
mit Licensed