Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 1x 122x 122x 122x 122x 122x | "use client";
import { useT } from "@/lib/i18n/translate";
export function Sparkline({
data,
max,
color,
width = 80,
height = 24,
}: {
data: number[];
max: number;
color: string;
width?: number;
height?: number;
}) {
const t = useT("admin");
Eif (data.length < 2)
return (
<span className="text-[10px] text-(--text-secondary)">
{t("collecting…")}
</span>
);
const effectiveMax = max > 0 ? max : 1;
const points = data.map((v, i) => {
const x = (i / (data.length - 1)) * width;
const y =
height - (Math.min(v, effectiveMax) / effectiveMax) * (height - 2) - 1;
return `${x},${y}`;
});
return (
<svg width={width} height={height} className="inline-block">
<polyline
fill="none"
stroke={color}
strokeWidth="1.5"
strokeLinejoin="round"
points={points.join(" ")}
/>
</svg>
);
}
|