@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 39 lines 1.07 KB
Raw
1 import { Chart, Host, type ChartDataPoint } from "@expo/ui/swift-ui";
2 import { frame } from "@expo/ui/swift-ui/modifiers";
3
4 import type { DailyTotals } from "@t3tools/shared/usageMerge";
5
6 import { buildChartDays, type UsageChartMetric } from "./usageChartData";
7 import { useProviderColors } from "./usageProviders";
8
9 export interface UsageDailyChartProps {
10 readonly days: readonly string[];
11 readonly daily: readonly DailyTotals[];
12 readonly metric: UsageChartMetric;
13 readonly height: number;
14 }
15
16 export function UsageDailyChart({ days, daily, metric, height }: UsageDailyChartProps) {
17 const colors = useProviderColors();
18
19 const data: ChartDataPoint[] = buildChartDays(days, daily, metric).flatMap((day) =>
20 day.values.map((entry) => ({
21 x: day.day,
22 y: entry.value,
23 color: colors[entry.provider],
24 })),
25 );
26
27 return (
28 <Host style={{ height, width: "100%" }}>
29 <Chart
30 type="bar"
31 data={data}
32 animate
33 showGrid={false}
34 barStyle={{ cornerRadius: 2 }}
35 modifiers={[frame({ height })]}
36 />
37 </Host>
38 );
39 }