/** * Pomodoros per day — magnitude over time, so: bars, one hue, baseline at zero. * * The goal line is the only reference mark; days that cleared it are the darker * ramp step, which keeps "did I hit the goal" readable without a second colour. */ import { Box, Tooltip, Typography } from "@mui/material"; import { shortDate } from "../../lib/format"; import type { VizPalette } from "../../lib/viz"; import ChartFrame from "./ChartFrame"; interface Day { date: string; pomodoros: number; focus_minutes: number; goal_met: boolean; } const HEIGHT = 160; export default function FocusBars({ days, goal, palette, title = "Pomodoros per day", }: { days: Day[]; goal: number; palette: VizPalette; title?: string; }) { const max = Math.max(goal, ...days.map((day) => day.pomodoros), 1); const goalY = HEIGHT - (goal / max) * HEIGHT; const slotWidth = 100 / Math.max(days.length, 1); return ( {goal > 0 && ( goal )} {days.map((day) => { const height = (day.pomodoros / max) * HEIGHT; return ( {day.date} {day.pomodoros} pomodoros · {day.focus_minutes} min } > 0 ? 4 : 2), minHeight: 2, borderRadius: "4px 4px 0 0", bgcolor: day.pomodoros === 0 ? palette.empty : day.goal_met ? palette.sequential[4] : palette.sequential[2], transition: "height .3s", cursor: "default", }} /> ); })} {days.length ? shortDate(days[0].date) : ""} {days.length ? shortDate(days[days.length - 1].date) : ""} ); }