"use client"; import { motion } from "framer-motion"; import { useState } from "react"; import { COLORS, VizFrame } from "./common"; const ORIGINAL = [ { name: "gate", n: 1820 }, { name: "drone", n: 320 }, { name: "post", n: 110 }, { name: "obstacle", n: 480 }, { name: "marker", n: 60 }, ]; function balanced(arr: typeof ORIGINAL) { const max = Math.max(...arr.map((a) => a.n)); return arr.map((a) => ({ ...a, n: Math.round(a.n + (max - a.n) * 0.7), })); } const PADDING_X = 80; const PADDING_Y = 40; export function ClassHist({ width = 720, height = 360, }: { width?: number; height?: number; }) { const [bal, setBal] = useState(false); const data = bal ? balanced(ORIGINAL) : ORIGINAL; const max = Math.max(...data.map((d) => d.n)); const innerW = width - PADDING_X * 2; const innerH = height - PADDING_Y * 2; const stepW = innerW / data.length; const baseY = height - PADDING_Y; return (