import { range } from 'd3' import { MinMax } from './types' export const getChartClass = (key: string | number) => `chart-id-${key}` export const getGroupClass = (key: string | number) => `group-id-${key}` export const getByAccessor = , R>(accessor: keyof DataType | ((d: DataType) => R)): ((d: DataType) => R) => { if (typeof accessor === 'function') return accessor return (d) => d[accessor] } export const getTicks = (domain: MinMax, count: number) => { const min = domain.min ?? 0 const max = domain.max ?? 0 const step = (max - min) / count return [...range(min, max, step), max] }