Created
June 2, 2020 02:36
-
-
Save nnnnnoel/89cbe1bd50f18a5cd64204703db52b82 to your computer and use it in GitHub Desktop.
Line Chart Formula
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
const getLineChartD = ({ data, size, width, padding, topSpacing }) => { | |
const min = Math.min(...data); | |
const max = Math.max(...data); | |
const d = data | |
.map((v, i) => { | |
return `${i === 0 ? 'M' : 'L'} ${(i * (width - padding * 5)) / data.length},${ | |
size - (v / (max - min)) * size + (topSpacing || 0) | |
}`; | |
}).join(' '); | |
return d; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment