Last active
June 8, 2022 15:20
-
-
Save krystalcampioni/f16dc01f9876453763c9c1c4a288fe74 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
export function getBarId(id: string, groupIndex: number, seriesIndex: number) { | |
return `${id}-series-${groupIndex}-${seriesIndex}`; | |
} | |
export function removeFalsyValues(object) { | |
return Object.entries(object) | |
.filter(([_, value]) => value != null) | |
.reduce((acc, [key, value]) => ({...acc, [key]: value}), {}); | |
} | |
export const createGradient = (...colors: string[]): GradientStop[] => { | |
const scale = scaleLinear() | |
.domain([0, colors.length - 1]) | |
.range([0, 100]); | |
return colors.map((color, index) => ({ | |
offset: scale(index), | |
color, | |
})); | |
}; | |
// etc, etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment