Last active
May 22, 2017 15:29
-
-
Save neogeek/ae23d8294aa10b89eb72565ed3961e67 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const scaleLinear = (domain, range, value) => { | |
const sortedRange = range.slice().sort(); | |
return Math.min(Math.max(range[0] + ((range[1] - range[0]) / 100) * ((value - domain[0]) / (domain[1] - domain[0]) * 100), sortedRange[0]), sortedRange[1]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment