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