SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
2.0 KB · 30 lines tsx
Raw Blame History
1'use client';2import { useEffect, useState } from 'react';3import { InteractiveLineChart, Legend, ScatterChart, type ScatterPoint, type Series } from '@/components/charts';4import { fmtDate, fmtInt, fmtScore, fmtUsdPerM } from '@/lib/format';56/*7  Client wrappers that own their formatter functions: server pages cannot pass functions to client components, so the8  formatting choices (money, score, GB, GB/s, dates) live here and pages pass data only.9*/1011/** Quality vs cheapest output price (log x), Pareto set highlighted and joined by a dashed line. */12export function EfficiencyScatter({ points, frontier, highlight, yLabel, height = 380 }: { points: ScatterPoint[]; frontier: { x: number; y: number }[]; highlight: string[]; yLabel: string; height?: number }) {13  // Rendered after mount only: the log-scale pixel positions differ in the last float digits between Node and the browser,14  // which React reports as a hydration mismatch. The Pareto list below the chart is server-rendered for crawlers.15  const [mounted, setMounted] = useState(false);16  useEffect(() => setMounted(true), []);17  if (!mounted) return <div style={{ aspectRatio: `720 / ${height}` }} className="w-full animate-pulse bg-surface-2" aria-hidden />;18  return <ScatterChart points={points} xScale="log" yScale="linear" xLabel="Cheapest output price, USD / 1M tokens (log)" yLabel={yLabel} xFormat={(v) => fmtUsdPerM(v)} yFormat={(v) => fmtScore(v)} frontier={frontier} highlight={highlight} height={height} labelTop={0} />;19}2021/** Step chart of a hardware figure by release date (memory in GB or bandwidth in GB/s), one series per manufacturer. */22export function HardwareStepChart({ series, unit, yLabel, height = 280 }: { series: Series[]; unit: 'GB' | 'GB/s'; yLabel: string; height?: number }) {23  return (24    <>25      <InteractiveLineChart series={series} height={height} step showDots yFormat={(v) => `${fmtInt(v)} ${unit}`} yLabel={yLabel} xFormat={(x) => fmtDate(new Date(x).toISOString().slice(0, 10))} />26      <Legend series={series} className="mt-2" />27    </>28  );29}30