< Summary

Information
Class: sparkline.tsx
Assembly: app.components
File(s): /home/runner/work/ClutterStock/ClutterStock/frontend/app/components/sparkline.tsx
Tag: 58_25416222083
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 20
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/ClutterStock/ClutterStock/frontend/app/components/sparkline.tsx

#LineLine coverage
 01export function Sparkline({ seed }: { seed: number }) {
 02  const w = 56, h = 20, n = 7;
 03  const pts = Array.from({ length: n }, (_, i) => i).reduce<number[]>((acc, i) => {
 04    const prev = acc.length > 0 ? acc[acc.length - 1]! : Math.max(1, seed * 0.5);
 05    const noise = ((seed * (i * 13 + 7)) % 7) - 3;
 06    const next = Math.max(1, prev + (seed - prev) * 0.35 + noise);
 07    acc.push(i === n - 1 ? seed : Math.round(next));
 08    return acc;
 9  }, []);
 010  const max = Math.max(...pts, 1);
 011  const coords = pts
 012    .map((p, i) => `${((i / (n - 1)) * w).toFixed(1)},${(h - (p / max) * h).toFixed(1)}`)
 13    .join(" ");
 014  return (
 15    <svg width={w} height={h} style={{ flexShrink: 0, overflow: "visible" }}>
 16      <polyline fill="none" stroke="var(--c-accent)" strokeWidth="1.4"
 17        strokeLinecap="round" strokeLinejoin="round" points={coords} opacity="0.8" />
 18    </svg>
 19  );
 20}