Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get a color within a defined color range, based on a percentage number.
import { scaleLinear } from "d3-scale";
const getColor = scaleLinear().domain([0, 100]).range(["#ccc", "#419fcf"]);
getColor(0); // 0% = #ccc
getColor(80); // 80% = #5da8ce
getColor(100); // 100% = #419fcf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.