Last active
June 21, 2016 04:07
-
-
Save lukehorvat/dd5a40b85b95ac61377c985beb63685c to your computer and use it in GitHub Desktop.
Get a color within a defined color range, based on a percentage number.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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