Skip to content

Instantly share code, notes, and snippets.

@krystalcampioni
Last active June 8, 2022 15:20
Show Gist options
  • Save krystalcampioni/f16dc01f9876453763c9c1c4a288fe74 to your computer and use it in GitHub Desktop.
Save krystalcampioni/f16dc01f9876453763c9c1c4a288fe74 to your computer and use it in GitHub Desktop.
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