e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import type { DataPoint } from "heat-graph";
|
|
|
|
function seededRandom(seed: number) {
|
|
let s = seed;
|
|
return () => {
|
|
s = (s * 16807 + 0) % 2147483647;
|
|
return s / 2147483647;
|
|
};
|
|
}
|
|
|
|
export function generateSampleData(
|
|
end: Date = new Date(),
|
|
days = 365,
|
|
): DataPoint[] {
|
|
const data: DataPoint[] = [];
|
|
const rand = seededRandom(42);
|
|
|
|
for (let i = 0; i < days; i++) {
|
|
const date = new Date(end);
|
|
date.setDate(date.getDate() - (days - 1 - i));
|
|
|
|
const dayOfWeek = date.getDay();
|
|
const isWeekend = dayOfWeek === 0 || dayOfWeek === 6;
|
|
|
|
// Base activity: higher on weekdays
|
|
const base = isWeekend ? 2 : 8;
|
|
const noise = rand();
|
|
|
|
// Create some streaks and gaps
|
|
const monthProgress = date.getDate() / 31;
|
|
const monthBoost = Math.sin(monthProgress * Math.PI) * 5;
|
|
|
|
// Some days have no activity
|
|
if (noise < 0.15) {
|
|
continue;
|
|
}
|
|
|
|
const count = Math.max(0, Math.round(base + monthBoost + noise * 12 - 3));
|
|
|
|
if (count > 0) {
|
|
data.push({ date, count });
|
|
}
|
|
}
|
|
|
|
return data;
|
|
}
|