export function linearScale(domain: number[], [min, max]: [number, number]) {
  const domainMin = Math.min(...domain)
  const domainMax = Math.max(...domain)

  const slope = (max - min) / (domainMax - domainMin)

  return (value: number) => min + slope * (value - domainMin)
}

export function generatePath(points: { x: number; y: number }[]) {
  let result = `M${points[0].x},${points[0].y}`

  for (let i = 1; i < points.length; i++) {
    const point = points[i]
    result += `L${point.x},${point.y}`
  }

  return result
}
