MCPcopy Create free account
hub / github.com/Noumena-Network/code / generateXAxisLabels

Function generateXAxisLabels

src/components/Stats.tsx:1020–1057  ·  view source on GitHub ↗
(data: DailyModelTokens[], _chartWidth: number, yAxisOffset: number)

Source from the content-addressed store, hash-verified

1018 };
1019}
1020function generateXAxisLabels(data: DailyModelTokens[], _chartWidth: number, yAxisOffset: number): string {
1021 if (data.length === 0) return '';
1022
1023 // Show 3-4 date labels evenly spaced, but leave room for last label
1024 const numLabels = Math.min(4, Math.max(2, Math.floor(data.length / 8)));
1025 // Don't use the very last position - leave room for the label text
1026 const usableLength = data.length - 6; // Reserve ~6 chars for last label (e.g., "Dec 7")
1027 const step = Math.floor(usableLength / (numLabels - 1)) || 1;
1028 const labelPositions: {
1029 pos: number;
1030 label: string;
1031 }[] = [];
1032 for (let i = 0; i < numLabels; i++) {
1033 const idx = Math.min(i * step, data.length - 1);
1034 const date = new Date(data[idx]!.date);
1035 const label = date.toLocaleDateString('en-US', {
1036 month: 'short',
1037 day: 'numeric'
1038 });
1039 labelPositions.push({
1040 pos: idx,
1041 label
1042 });
1043 }
1044
1045 // Build the label string with proper spacing
1046 let result = ' '.repeat(yAxisOffset);
1047 let currentPos = 0;
1048 for (const {
1049 pos,
1050 label
1051 } of labelPositions) {
1052 const spaces = Math.max(1, pos - currentPos);
1053 result += ' '.repeat(spaces) + label;
1054 currentPos = pos + label.length;
1055 }
1056 return result;
1057}
1058
1059// Screenshot functionality
1060async function handleScreenshot(stats: ClaudeCodeStats, activeTab: 'Overview' | 'Models', setStatus: (status: string | null) => void): Promise<void> {

Callers 1

generateTokenChartFunction · 0.85

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected