@alpic-ai/ui 0.0.0-dev.g23b48a1 → 0.0.0-dev.g23fdbf3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/accordion-card.d.mts +5 -6
- package/dist/components/accordion.d.mts +5 -6
- package/dist/components/alert.d.mts +9 -11
- package/dist/components/area-chart.d.mts +62 -0
- package/dist/components/area-chart.mjs +269 -0
- package/dist/components/attachment-tile.d.mts +1 -3
- package/dist/components/avatar.d.mts +8 -10
- package/dist/components/badge.d.mts +2 -4
- package/dist/components/bar-chart.d.mts +48 -0
- package/dist/components/bar-chart.mjs +245 -0
- package/dist/components/bar-list.d.mts +28 -0
- package/dist/components/bar-list.mjs +98 -0
- package/dist/components/breadcrumb.d.mts +10 -11
- package/dist/components/button.d.mts +6 -8
- package/dist/components/card.d.mts +9 -10
- package/dist/components/chart-card.d.mts +25 -0
- package/dist/components/chart-card.mjs +48 -0
- package/dist/components/chart-container.d.mts +20 -0
- package/dist/components/chart-container.mjs +37 -0
- package/dist/components/chart-legend.d.mts +16 -0
- package/dist/components/chart-legend.mjs +26 -0
- package/dist/components/chart-tooltip.d.mts +33 -0
- package/dist/components/chart-tooltip.mjs +52 -0
- package/dist/components/checkbox.d.mts +2 -3
- package/dist/components/collapsible.d.mts +4 -5
- package/dist/components/combobox.d.mts +12 -11
- package/dist/components/combobox.mjs +7 -4
- package/dist/components/command.d.mts +9 -10
- package/dist/components/copyable.d.mts +2 -3
- package/dist/components/description-list.d.mts +5 -6
- package/dist/components/dialog.d.mts +15 -17
- package/dist/components/donut-chart.d.mts +46 -0
- package/dist/components/donut-chart.mjs +185 -0
- package/dist/components/dropdown-menu.d.mts +18 -20
- package/dist/components/form.d.mts +38 -21
- package/dist/components/form.mjs +6 -6
- package/dist/components/github-button.d.mts +1 -2
- package/dist/components/grid-fx.d.mts +13 -0
- package/dist/components/grid-fx.mjs +188 -0
- package/dist/components/heatmap-chart.d.mts +40 -0
- package/dist/components/heatmap-chart.mjs +198 -0
- package/dist/components/input-group.d.mts +5 -7
- package/dist/components/input.d.mts +4 -5
- package/dist/components/input.mjs +2 -2
- package/dist/components/label.d.mts +2 -3
- package/dist/components/line-chart.d.mts +55 -0
- package/dist/components/line-chart.mjs +211 -0
- package/dist/components/page-loader.d.mts +1 -3
- package/dist/components/pagination.d.mts +3 -4
- package/dist/components/popover.d.mts +5 -6
- package/dist/components/radio-group.d.mts +3 -4
- package/dist/components/scroll-area.d.mts +3 -4
- package/dist/components/select-trigger-variants.d.mts +1 -3
- package/dist/components/select.d.mts +9 -10
- package/dist/components/separator.d.mts +2 -3
- package/dist/components/sheet.d.mts +11 -12
- package/dist/components/shimmer-text.d.mts +2 -2
- package/dist/components/sidebar.d.mts +34 -36
- package/dist/components/sidebar.mjs +10 -10
- package/dist/components/skeleton.d.mts +2 -4
- package/dist/components/sonner.d.mts +5 -6
- package/dist/components/spinner.d.mts +3 -5
- package/dist/components/stat.d.mts +30 -0
- package/dist/components/stat.mjs +107 -0
- package/dist/components/status-dot.d.mts +2 -4
- package/dist/components/switch.d.mts +2 -3
- package/dist/components/table.d.mts +10 -11
- package/dist/components/tabs.d.mts +12 -14
- package/dist/components/tag.d.mts +3 -5
- package/dist/components/task-progress.d.mts +1 -3
- package/dist/components/textarea.d.mts +3 -4
- package/dist/components/textarea.mjs +2 -2
- package/dist/components/toggle-group.d.mts +4 -6
- package/dist/components/toggle-group.mjs +3 -3
- package/dist/components/tooltip-icon-button.d.mts +1 -2
- package/dist/components/tooltip.d.mts +5 -6
- package/dist/components/typography.d.mts +4 -5
- package/dist/components/wizard.d.mts +4 -5
- package/dist/hooks/use-chart-theme.d.mts +18 -0
- package/dist/hooks/use-chart-theme.mjs +57 -0
- package/dist/hooks/use-mobile.mjs +3 -3
- package/dist/hooks/use-reduced-motion.d.mts +4 -0
- package/dist/hooks/use-reduced-motion.mjs +16 -0
- package/dist/lib/chart-palette.d.mts +4 -0
- package/dist/lib/chart-palette.mjs +95 -0
- package/dist/lib/chart.d.mts +14 -0
- package/dist/lib/chart.mjs +27 -0
- package/package.json +30 -29
- package/src/components/area-chart.tsx +339 -0
- package/src/components/bar-chart.tsx +300 -0
- package/src/components/bar-list.tsx +150 -0
- package/src/components/chart-card.tsx +63 -0
- package/src/components/chart-container.tsx +49 -0
- package/src/components/chart-legend.tsx +41 -0
- package/src/components/chart-tooltip.tsx +93 -0
- package/src/components/combobox.tsx +9 -2
- package/src/components/donut-chart.tsx +217 -0
- package/src/components/grid-fx.tsx +238 -0
- package/src/components/heatmap-chart.tsx +287 -0
- package/src/components/line-chart.tsx +264 -0
- package/src/components/stat.tsx +109 -0
- package/src/hooks/use-chart-theme.ts +75 -0
- package/src/hooks/use-reduced-motion.ts +17 -0
- package/src/lib/chart-palette.ts +110 -0
- package/src/lib/chart.ts +56 -0
- package/src/stories/area-chart.stories.tsx +200 -0
- package/src/stories/bar-chart.stories.tsx +169 -0
- package/src/stories/bar-list.stories.tsx +85 -0
- package/src/stories/donut-chart.stories.tsx +112 -0
- package/src/stories/heatmap-chart.stories.tsx +107 -0
- package/src/stories/line-chart.stories.tsx +146 -0
- package/src/stories/stat.stories.tsx +64 -0
- package/src/styles/tokens.css +63 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Story } from "@ladle/react";
|
|
2
|
+
|
|
3
|
+
import { BarList } from "../components/bar-list";
|
|
4
|
+
import { ChartCard } from "../components/chart-card";
|
|
5
|
+
import { GridFx } from "../components/grid-fx";
|
|
6
|
+
import { Stat } from "../components/stat";
|
|
7
|
+
|
|
8
|
+
export default { title: "Charts/Bar List" };
|
|
9
|
+
|
|
10
|
+
const TOP_TOOLS = [
|
|
11
|
+
{ tool: "search_codebase", calls: 18420 },
|
|
12
|
+
{ tool: "read_file", calls: 14110 },
|
|
13
|
+
{ tool: "run_command", calls: 9870 },
|
|
14
|
+
{ tool: "edit_file", calls: 8240 },
|
|
15
|
+
{ tool: "list_dir", calls: 5130 },
|
|
16
|
+
{ tool: "grep", calls: 3960 },
|
|
17
|
+
{ tool: "web_fetch", calls: 2210 },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const TOP_CLIENTS = [
|
|
21
|
+
{ client: "ChatGPT", sessions: 16222 },
|
|
22
|
+
{ client: "Claude Code", sessions: 9502 },
|
|
23
|
+
{ client: "Claude", sessions: 6859 },
|
|
24
|
+
{ client: "Anthropic", sessions: 4664 },
|
|
25
|
+
{ client: "Goose", sessions: 3389 },
|
|
26
|
+
{ client: "VS Code", sessions: 2771 },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const TOP_ROUTES = [
|
|
30
|
+
{ route: "POST /v1/messages", hits: 482000 },
|
|
31
|
+
{ route: "GET /v1/models", hits: 211400 },
|
|
32
|
+
{ route: "POST /v1/embeddings", hits: 98700 },
|
|
33
|
+
{ route: "GET /v1/usage", hits: 64200 },
|
|
34
|
+
{ route: "POST /v1/files", hits: 41900 },
|
|
35
|
+
{ route: "GET /v1/health", hits: 28800 },
|
|
36
|
+
{ route: "DELETE /v1/files", hits: 12400 },
|
|
37
|
+
{ route: "POST /v1/batches", hits: 8600 },
|
|
38
|
+
{ route: "GET /v1/batches", hits: 5300 },
|
|
39
|
+
{ route: "POST /v1/moderations", hits: 2100 },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const nf = (value: number) => value.toLocaleString("en-US");
|
|
43
|
+
const fmtK = (value: number) => {
|
|
44
|
+
if (value >= 1_000_000) {
|
|
45
|
+
return `${(value / 1_000_000).toFixed(2)}M`;
|
|
46
|
+
}
|
|
47
|
+
if (value >= 1000) {
|
|
48
|
+
return `${(value / 1000).toFixed(value >= 10000 ? 0 : 1)}k`;
|
|
49
|
+
}
|
|
50
|
+
return `${value}`;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const toolCallsTotal = TOP_TOOLS.reduce((sum, row) => sum + row.calls, 0);
|
|
54
|
+
|
|
55
|
+
export const AllVariants: Story = () => (
|
|
56
|
+
<div className="chart-canvas mx-auto max-w-[1600px] p-8">
|
|
57
|
+
<GridFx />
|
|
58
|
+
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3">
|
|
59
|
+
<ChartCard palette="magenta" kicker="Last 7d" title="Top tools" description="Ranked · magenta ramp">
|
|
60
|
+
<Stat value={fmtK(toolCallsTotal)} unit="calls" delta={{ value: 12.4, direction: "up" }} />
|
|
61
|
+
<BarList data={TOP_TOOLS} index="tool" dataKey="calls" valueFormatter={fmtK} />
|
|
62
|
+
</ChartCard>
|
|
63
|
+
|
|
64
|
+
<ChartCard palette="cyan" kicker="Last 7d" title="Top clients" description="Ranked · cyan ramp">
|
|
65
|
+
<BarList data={TOP_CLIENTS} index="client" dataKey="sessions" valueFormatter={nf} />
|
|
66
|
+
</ChartCard>
|
|
67
|
+
|
|
68
|
+
<ChartCard palette="magenta" kicker="Last 24h" title="Top routes" description="Long list · capped to 6">
|
|
69
|
+
<BarList data={TOP_ROUTES} index="route" dataKey="hits" maxItems={6} valueFormatter={fmtK} />
|
|
70
|
+
</ChartCard>
|
|
71
|
+
|
|
72
|
+
<ChartCard palette="cyan" kicker="Last 24h" title="Top routes" description="Full list · cyan ramp">
|
|
73
|
+
<BarList data={TOP_ROUTES} index="route" dataKey="hits" valueFormatter={fmtK} />
|
|
74
|
+
</ChartCard>
|
|
75
|
+
|
|
76
|
+
<ChartCard palette="magenta" kicker="State" title="Loading" description="Mono spinner placeholder">
|
|
77
|
+
<BarList data={[]} index="tool" dataKey="calls" loading />
|
|
78
|
+
</ChartCard>
|
|
79
|
+
|
|
80
|
+
<ChartCard palette="magenta" kicker="State" title="Empty" description="No data in range">
|
|
81
|
+
<BarList data={[]} index="tool" dataKey="calls" />
|
|
82
|
+
</ChartCard>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Story } from "@ladle/react";
|
|
2
|
+
|
|
3
|
+
import { ChartCard } from "../components/chart-card";
|
|
4
|
+
import { DonutChart } from "../components/donut-chart";
|
|
5
|
+
import { GridFx } from "../components/grid-fx";
|
|
6
|
+
import { Stat } from "../components/stat";
|
|
7
|
+
|
|
8
|
+
export default { title: "Charts/Donut Chart" };
|
|
9
|
+
|
|
10
|
+
const mulberry32 = (seed: number) => () => {
|
|
11
|
+
seed |= 0;
|
|
12
|
+
seed = (seed + 0x6d2b79f5) | 0;
|
|
13
|
+
let hash = Math.imul(seed ^ (seed >>> 15), 1 | seed);
|
|
14
|
+
hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
|
|
15
|
+
return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const CLIENTS = ["ChatGPT", "Claude Code", "Claude", "Anthropic", "Goose", "VS Code"];
|
|
19
|
+
const WEIGHTS = [0.42, 0.24, 0.12, 0.09, 0.07, 0.06];
|
|
20
|
+
|
|
21
|
+
const genClients = (seed: number) => {
|
|
22
|
+
const rnd = mulberry32(seed);
|
|
23
|
+
return CLIENTS.map((client, clientIndex) => ({
|
|
24
|
+
client,
|
|
25
|
+
sessions: Math.round(48000 * (WEIGHTS[clientIndex] ?? 0) * (0.8 + rnd() * 0.4)),
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const MODELS = [
|
|
30
|
+
"claude-opus-4-8",
|
|
31
|
+
"claude-sonnet-4-6",
|
|
32
|
+
"claude-haiku-4-5",
|
|
33
|
+
"gpt-5.2",
|
|
34
|
+
"gpt-5.2-mini",
|
|
35
|
+
"gemini-3-pro",
|
|
36
|
+
"gemini-3-flash",
|
|
37
|
+
"llama-4-405b",
|
|
38
|
+
"mistral-large-3",
|
|
39
|
+
"command-r-plus",
|
|
40
|
+
"qwen-3-72b",
|
|
41
|
+
"deepseek-v4",
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const genModels = (seed: number) => {
|
|
45
|
+
const rnd = mulberry32(seed);
|
|
46
|
+
return MODELS.map((model) => ({ model, tokens: Math.round(40000 + rnd() * 920000) }));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const genStatus = (seed: number) => {
|
|
50
|
+
const rnd = mulberry32(seed);
|
|
51
|
+
return [
|
|
52
|
+
{ state: "Success", count: Math.round(8200 + rnd() * 600) },
|
|
53
|
+
{ state: "Errored", count: Math.round(180 + rnd() * 90) },
|
|
54
|
+
{ state: "Timed out", count: Math.round(60 + rnd() * 40) },
|
|
55
|
+
];
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const clients = genClients(7);
|
|
59
|
+
const models = genModels(23);
|
|
60
|
+
const status = genStatus(41);
|
|
61
|
+
|
|
62
|
+
const nf = (value: number) => value.toLocaleString("en-US");
|
|
63
|
+
const fmtK = (value: number) => {
|
|
64
|
+
if (value >= 1_000_000) {
|
|
65
|
+
return `${(value / 1_000_000).toFixed(2)}M`;
|
|
66
|
+
}
|
|
67
|
+
if (value >= 1000) {
|
|
68
|
+
return `${(value / 1000).toFixed(value >= 10000 ? 0 : 1)}k`;
|
|
69
|
+
}
|
|
70
|
+
return `${value}`;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const clientsTotal = clients.reduce((sum, row) => sum + row.sessions, 0);
|
|
74
|
+
|
|
75
|
+
export const AllVariants: Story = () => (
|
|
76
|
+
<div className="chart-canvas mx-auto max-w-[1600px] p-8">
|
|
77
|
+
<GridFx />
|
|
78
|
+
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3">
|
|
79
|
+
<ChartCard palette="magenta" kicker="Last 7d" title="Sessions by client" description="Donut · share readout">
|
|
80
|
+
<Stat value={fmtK(clientsTotal)} unit="sessions" delta={{ value: 6.2, direction: "up" }} />
|
|
81
|
+
<DonutChart
|
|
82
|
+
data={clients}
|
|
83
|
+
index="client"
|
|
84
|
+
dataKey="sessions"
|
|
85
|
+
legend
|
|
86
|
+
centerLabel="sessions"
|
|
87
|
+
valueFormatter={nf}
|
|
88
|
+
/>
|
|
89
|
+
</ChartCard>
|
|
90
|
+
|
|
91
|
+
<ChartCard palette="cyan" kicker="Last 7d" title="Tokens by model" description="Many slices · scrollable table">
|
|
92
|
+
<DonutChart data={models} index="model" dataKey="tokens" legend centerLabel="tokens" valueFormatter={fmtK} />
|
|
93
|
+
</ChartCard>
|
|
94
|
+
|
|
95
|
+
<ChartCard palette="magenta" kicker="Last 24h" title="Request outcome" description="Ring · prominent total">
|
|
96
|
+
<DonutChart data={status} index="state" dataKey="count" variant="ring" legend valueFormatter={nf} />
|
|
97
|
+
</ChartCard>
|
|
98
|
+
|
|
99
|
+
<ChartCard palette="magenta" kicker="Last 7d" title="Tokens by model" description="Ring only · no readout">
|
|
100
|
+
<DonutChart data={models} index="model" dataKey="tokens" centerLabel="tokens" valueFormatter={fmtK} />
|
|
101
|
+
</ChartCard>
|
|
102
|
+
|
|
103
|
+
<ChartCard palette="cyan" kicker="State" title="Loading" description="Mono spinner placeholder">
|
|
104
|
+
<DonutChart data={[]} index="client" dataKey="sessions" loading />
|
|
105
|
+
</ChartCard>
|
|
106
|
+
|
|
107
|
+
<ChartCard palette="magenta" kicker="State" title="Empty" description="No data in range">
|
|
108
|
+
<DonutChart data={[]} index="client" dataKey="sessions" legend />
|
|
109
|
+
</ChartCard>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { Story } from "@ladle/react";
|
|
2
|
+
|
|
3
|
+
import { ChartCard } from "../components/chart-card";
|
|
4
|
+
import { GridFx } from "../components/grid-fx";
|
|
5
|
+
import { HeatmapChart } from "../components/heatmap-chart";
|
|
6
|
+
|
|
7
|
+
export default { title: "Charts/Heatmap" };
|
|
8
|
+
|
|
9
|
+
const DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
10
|
+
|
|
11
|
+
function mulberry32(seed: number) {
|
|
12
|
+
let state = seed;
|
|
13
|
+
return () => {
|
|
14
|
+
state |= 0;
|
|
15
|
+
state = (state + 0x6d2b79f5) | 0;
|
|
16
|
+
let mixed = Math.imul(state ^ (state >>> 15), 1 | state);
|
|
17
|
+
mixed = (mixed + Math.imul(mixed ^ (mixed >>> 7), 61 | mixed)) ^ mixed;
|
|
18
|
+
return ((mixed ^ (mixed >>> 14)) >>> 0) / 4294967296;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Long-format activity rows: one record per (day, hour) with a working-hours hump.
|
|
23
|
+
const ACTIVITY = (() => {
|
|
24
|
+
const random = mulberry32(99);
|
|
25
|
+
const rows: Array<{ day: string; hour: string; sessions: number }> = [];
|
|
26
|
+
DAYS.forEach((day, dayIndex) => {
|
|
27
|
+
const weekend = dayIndex >= 5;
|
|
28
|
+
for (let hour = 0; hour < 24; hour += 1) {
|
|
29
|
+
const work = Math.exp(-((hour - 14) ** 2) / 26) * (weekend ? 0.45 : 1);
|
|
30
|
+
const evening = Math.exp(-((hour - 21) ** 2) / 10) * 0.5;
|
|
31
|
+
const intensity = Math.max(0.02, Math.min(1, work + evening + random() * 0.28));
|
|
32
|
+
rows.push({ day, hour: String(hour).padStart(2, "0"), sessions: Math.round(intensity * 320) });
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return rows;
|
|
36
|
+
})();
|
|
37
|
+
|
|
38
|
+
const HOURS = Array.from({ length: 24 }, (_, hour) => String(hour).padStart(2, "0"));
|
|
39
|
+
|
|
40
|
+
const nf = (value: number) => value.toLocaleString("en-US");
|
|
41
|
+
|
|
42
|
+
export const AllVariants: Story = () => (
|
|
43
|
+
<div className="chart-canvas mx-auto max-w-[1600px] p-8">
|
|
44
|
+
<GridFx />
|
|
45
|
+
<div className="grid grid-cols-1 gap-6 xl:grid-cols-2">
|
|
46
|
+
<ChartCard palette="magenta" accent="left" kicker="Last 7d" title="Activity" description="Square · hour × day">
|
|
47
|
+
<HeatmapChart
|
|
48
|
+
data={ACTIVITY}
|
|
49
|
+
xKey="hour"
|
|
50
|
+
yKey="day"
|
|
51
|
+
dataKey="sessions"
|
|
52
|
+
variant="square"
|
|
53
|
+
xLabels={HOURS}
|
|
54
|
+
yLabels={DAYS}
|
|
55
|
+
valueFormatter={nf}
|
|
56
|
+
/>
|
|
57
|
+
</ChartCard>
|
|
58
|
+
|
|
59
|
+
<ChartCard palette="cyan" accent="left" kicker="Last 7d" title="Activity" description="Dots · hour × day">
|
|
60
|
+
<HeatmapChart
|
|
61
|
+
data={ACTIVITY}
|
|
62
|
+
xKey="hour"
|
|
63
|
+
yKey="day"
|
|
64
|
+
dataKey="sessions"
|
|
65
|
+
variant="dot"
|
|
66
|
+
xLabels={HOURS}
|
|
67
|
+
yLabels={DAYS}
|
|
68
|
+
valueFormatter={nf}
|
|
69
|
+
/>
|
|
70
|
+
</ChartCard>
|
|
71
|
+
|
|
72
|
+
<ChartCard palette="cyan" accent="left" kicker="Last 7d" title="Activity" description="Square · cyan ramp">
|
|
73
|
+
<HeatmapChart
|
|
74
|
+
data={ACTIVITY}
|
|
75
|
+
xKey="hour"
|
|
76
|
+
yKey="day"
|
|
77
|
+
dataKey="sessions"
|
|
78
|
+
variant="square"
|
|
79
|
+
xLabels={HOURS}
|
|
80
|
+
yLabels={DAYS}
|
|
81
|
+
valueFormatter={nf}
|
|
82
|
+
/>
|
|
83
|
+
</ChartCard>
|
|
84
|
+
|
|
85
|
+
<ChartCard palette="magenta" accent="left" kicker="Last 7d" title="Activity" description="Dots · magenta ramp">
|
|
86
|
+
<HeatmapChart
|
|
87
|
+
data={ACTIVITY}
|
|
88
|
+
xKey="hour"
|
|
89
|
+
yKey="day"
|
|
90
|
+
dataKey="sessions"
|
|
91
|
+
variant="dot"
|
|
92
|
+
xLabels={HOURS}
|
|
93
|
+
yLabels={DAYS}
|
|
94
|
+
valueFormatter={nf}
|
|
95
|
+
/>
|
|
96
|
+
</ChartCard>
|
|
97
|
+
|
|
98
|
+
<ChartCard palette="magenta" accent="left" kicker="State" title="Loading" description="Mono spinner placeholder">
|
|
99
|
+
<HeatmapChart data={[]} xKey="hour" yKey="day" dataKey="sessions" loading />
|
|
100
|
+
</ChartCard>
|
|
101
|
+
|
|
102
|
+
<ChartCard palette="magenta" accent="left" kicker="State" title="Empty" description="No data in range">
|
|
103
|
+
<HeatmapChart data={[]} xKey="hour" yKey="day" dataKey="sessions" />
|
|
104
|
+
</ChartCard>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { Story } from "@ladle/react";
|
|
2
|
+
|
|
3
|
+
import { ChartCard } from "../components/chart-card";
|
|
4
|
+
import { GridFx } from "../components/grid-fx";
|
|
5
|
+
import { LineChart } from "../components/line-chart";
|
|
6
|
+
import { Stat } from "../components/stat";
|
|
7
|
+
|
|
8
|
+
export default { title: "Charts/Line Chart" };
|
|
9
|
+
|
|
10
|
+
const mulberry32 = (seed: number) => () => {
|
|
11
|
+
seed |= 0;
|
|
12
|
+
seed = (seed + 0x6d2b79f5) | 0;
|
|
13
|
+
let hash = Math.imul(seed ^ (seed >>> 15), 1 | seed);
|
|
14
|
+
hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
|
|
15
|
+
return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const hourLabel = (index: number, length: number) =>
|
|
19
|
+
`${String(Math.round((index / (length - 1)) * 24)).padStart(2, "0")}:00`;
|
|
20
|
+
|
|
21
|
+
const genSeries = (seed: number, scale: number) => {
|
|
22
|
+
const rnd = mulberry32(seed);
|
|
23
|
+
const length = 30;
|
|
24
|
+
let value = scale * 0.6;
|
|
25
|
+
return Array.from({ length }, (_, index) => {
|
|
26
|
+
value = Math.max(scale * 0.12, value + (rnd() - 0.46) * scale * 0.18);
|
|
27
|
+
return { t: hourLabel(index, length), v: Math.round(value * (1 + Math.sin(index / 5) * 0.16)) };
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const genLatency = (seed: number) => {
|
|
32
|
+
const rnd = mulberry32(seed);
|
|
33
|
+
const length = 30;
|
|
34
|
+
let p50 = 240;
|
|
35
|
+
let p95 = 720;
|
|
36
|
+
return Array.from({ length }, (_, index) => {
|
|
37
|
+
p50 = Math.max(120, p50 + (rnd() - 0.48) * 40);
|
|
38
|
+
p95 = Math.max(p50 + 200, p95 + (rnd() - 0.46) * 120);
|
|
39
|
+
return { t: hourLabel(index, length), p50: Math.round(p50), p95: Math.round(p95 * (index === 19 ? 1.7 : 1)) };
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const genCompare = (seed: number) => {
|
|
44
|
+
const rnd = mulberry32(seed);
|
|
45
|
+
const length = 30;
|
|
46
|
+
let claude = 60;
|
|
47
|
+
let chatgpt = 80;
|
|
48
|
+
return Array.from({ length }, (_, index) => {
|
|
49
|
+
claude = Math.max(20, claude + (rnd() - 0.42) * 14);
|
|
50
|
+
chatgpt = Math.max(20, chatgpt + (rnd() - 0.5) * 12);
|
|
51
|
+
return { t: hourLabel(index, length), claude: Math.round(claude), chatgpt: Math.round(chatgpt) };
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const tokens = genSeries(11, 84000);
|
|
56
|
+
const latency = genLatency(31);
|
|
57
|
+
const compare = genCompare(23);
|
|
58
|
+
|
|
59
|
+
const nf = (value: number) => value.toLocaleString("en-US");
|
|
60
|
+
const fmtK = (value: number) => (value >= 1000 ? `${(value / 1000).toFixed(value >= 10000 ? 0 : 1)}k` : `${value}`);
|
|
61
|
+
const ms = (value: number) => `${value}ms`;
|
|
62
|
+
|
|
63
|
+
const tokensSpark = tokens.map((row) => row.v);
|
|
64
|
+
const latencyPeak = latency.reduce((best, row) => (row.p95 > best.p95 ? row : best));
|
|
65
|
+
|
|
66
|
+
export const AllVariants: Story = () => (
|
|
67
|
+
<div className="chart-canvas mx-auto max-w-[1600px] p-8">
|
|
68
|
+
<GridFx />
|
|
69
|
+
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3">
|
|
70
|
+
<ChartCard
|
|
71
|
+
palette="cyan"
|
|
72
|
+
accent="left"
|
|
73
|
+
kicker="Last 24h"
|
|
74
|
+
title="Sessions"
|
|
75
|
+
description="Full-width · left accent"
|
|
76
|
+
className="md:col-span-2 xl:col-span-3"
|
|
77
|
+
>
|
|
78
|
+
<LineChart
|
|
79
|
+
data={compare}
|
|
80
|
+
index="t"
|
|
81
|
+
series={[
|
|
82
|
+
{ key: "claude", name: "Claude" },
|
|
83
|
+
{ key: "chatgpt", name: "ChatGPT" },
|
|
84
|
+
]}
|
|
85
|
+
lastValueLabel
|
|
86
|
+
legend
|
|
87
|
+
valueFormatter={nf}
|
|
88
|
+
/>
|
|
89
|
+
</ChartCard>
|
|
90
|
+
|
|
91
|
+
<ChartCard palette="magenta" kicker="Last 24h" title="Output tokens" description="Single series · value flags">
|
|
92
|
+
<Stat value="1.4M" unit="tokens" delta={{ value: 8.1, direction: "up" }} sparkline={tokensSpark} />
|
|
93
|
+
<LineChart data={tokens} index="t" series={[{ key: "v", name: "tokens" }]} valueFlags valueFormatter={fmtK} />
|
|
94
|
+
</ChartCard>
|
|
95
|
+
|
|
96
|
+
<ChartCard palette="magenta" kicker="Last 24h" title="Request latency" description="p50 vs p95 · SLA band + peak">
|
|
97
|
+
<Stat value="240ms" unit="p50 · current" delta={{ value: 4.2, direction: "down", invert: true }} />
|
|
98
|
+
<LineChart
|
|
99
|
+
data={latency}
|
|
100
|
+
index="t"
|
|
101
|
+
series={[
|
|
102
|
+
{ key: "p50", name: "p50" },
|
|
103
|
+
{ key: "p95", name: "p95", dashed: true, color: "#9b5de5" },
|
|
104
|
+
]}
|
|
105
|
+
referenceLine={{ y: 1000, label: "SLA 1s", band: true }}
|
|
106
|
+
markers={[{ x: latencyPeak.t, y: latencyPeak.p95, label: "peak", color: "#9b5de5" }]}
|
|
107
|
+
legend
|
|
108
|
+
valueFormatter={ms}
|
|
109
|
+
/>
|
|
110
|
+
</ChartCard>
|
|
111
|
+
|
|
112
|
+
<ChartCard palette="cyan" kicker="Last 24h" title="Sessions" description="Claude vs ChatGPT · last values">
|
|
113
|
+
<LineChart
|
|
114
|
+
data={compare}
|
|
115
|
+
index="t"
|
|
116
|
+
series={[
|
|
117
|
+
{ key: "claude", name: "Claude" },
|
|
118
|
+
{ key: "chatgpt", name: "ChatGPT" },
|
|
119
|
+
]}
|
|
120
|
+
lastValueLabel
|
|
121
|
+
legend
|
|
122
|
+
valueFormatter={nf}
|
|
123
|
+
/>
|
|
124
|
+
</ChartCard>
|
|
125
|
+
|
|
126
|
+
<ChartCard palette="cyan" kicker="Last 24h" title="Throughput" description="Dots · stepped curve">
|
|
127
|
+
<LineChart
|
|
128
|
+
data={tokens}
|
|
129
|
+
index="t"
|
|
130
|
+
series={[{ key: "v", name: "tokens" }]}
|
|
131
|
+
curve="step"
|
|
132
|
+
dots
|
|
133
|
+
valueFormatter={fmtK}
|
|
134
|
+
/>
|
|
135
|
+
</ChartCard>
|
|
136
|
+
|
|
137
|
+
<ChartCard palette="magenta" kicker="State" title="Loading" description="Mono spinner placeholder">
|
|
138
|
+
<LineChart data={[]} index="t" series={[{ key: "v", name: "tokens" }]} loading />
|
|
139
|
+
</ChartCard>
|
|
140
|
+
|
|
141
|
+
<ChartCard palette="magenta" kicker="State" title="Empty" description="No data in range">
|
|
142
|
+
<LineChart data={[]} index="t" series={[{ key: "v", name: "tokens" }]} />
|
|
143
|
+
</ChartCard>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Story } from "@ladle/react";
|
|
2
|
+
|
|
3
|
+
import { ChartContainer } from "../components/chart-container";
|
|
4
|
+
import { Stat } from "../components/stat";
|
|
5
|
+
|
|
6
|
+
export default { title: "Charts/Stat" };
|
|
7
|
+
|
|
8
|
+
const mulberry32 = (seed: number) => () => {
|
|
9
|
+
seed |= 0;
|
|
10
|
+
seed = (seed + 0x6d2b79f5) | 0;
|
|
11
|
+
let hash = Math.imul(seed ^ (seed >>> 15), 1 | seed);
|
|
12
|
+
hash = (hash + Math.imul(hash ^ (hash >>> 7), 61 | hash)) ^ hash;
|
|
13
|
+
return ((hash ^ (hash >>> 14)) >>> 0) / 4294967296;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const spark = (seed: number, length = 24) => {
|
|
17
|
+
const rnd = mulberry32(seed);
|
|
18
|
+
let value = 40;
|
|
19
|
+
return Array.from({ length }, () => {
|
|
20
|
+
value = Math.max(8, value + (rnd() - 0.45) * 16);
|
|
21
|
+
return Math.round(value);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const Row = ({ label, children }: { label: string; children: React.ReactNode }) => (
|
|
26
|
+
<div className="flex flex-col gap-1.5">
|
|
27
|
+
<p className="type-text-xs font-medium text-subtle-foreground">{label}</p>
|
|
28
|
+
{children}
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const AllVariants: Story = () => (
|
|
33
|
+
<div className="grid max-w-3xl grid-cols-2 gap-8">
|
|
34
|
+
<Row label="Value + unit">
|
|
35
|
+
<Stat value="48,231" unit="sessions · 24h" />
|
|
36
|
+
</Row>
|
|
37
|
+
|
|
38
|
+
<Row label="Positive delta (up = good)">
|
|
39
|
+
<Stat value="1.4M" unit="tokens · 24h" delta={{ value: 8.1, direction: "up" }} />
|
|
40
|
+
</Row>
|
|
41
|
+
|
|
42
|
+
<Row label="Negative delta (down = bad)">
|
|
43
|
+
<Stat value="312" unit="errors · 24h" delta={{ value: 14.2, direction: "up", invert: true }} />
|
|
44
|
+
</Row>
|
|
45
|
+
|
|
46
|
+
<Row label="Inverted: latency down = good">
|
|
47
|
+
<Stat value="240ms" unit="p50 · current" delta={{ value: 4.2, direction: "down", invert: true }} />
|
|
48
|
+
</Row>
|
|
49
|
+
|
|
50
|
+
<Row label="With sparkline">
|
|
51
|
+
<Stat value="48,231" unit="sessions · 24h" delta={{ value: 12.4, direction: "up" }} sparkline={spark(7)} />
|
|
52
|
+
</Row>
|
|
53
|
+
|
|
54
|
+
<Row label="Custom delta label">
|
|
55
|
+
<Stat value="312" unit="errors · 24h" delta={{ value: 0, direction: "up", invert: true, label: "burst 16:00" }} />
|
|
56
|
+
</Row>
|
|
57
|
+
|
|
58
|
+
<Row label="Cyan palette (sparkline lead)">
|
|
59
|
+
<ChartContainer palette="cyan">
|
|
60
|
+
<Stat value="9,204" unit="tasks · 24h" delta={{ value: 22, direction: "up" }} sparkline={spark(53)} />
|
|
61
|
+
</ChartContainer>
|
|
62
|
+
</Row>
|
|
63
|
+
</div>
|
|
64
|
+
);
|
package/src/styles/tokens.css
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
--font-sans: "Inter", system-ui, sans-serif;
|
|
5
5
|
--font-display: "Inter", sans-serif;
|
|
6
6
|
--font-body: "Inter", sans-serif;
|
|
7
|
+
--font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
7
8
|
|
|
8
9
|
--color-background: #ffffff; /* Figma: bg-primary */
|
|
9
10
|
--color-foreground: #121e1e; /* Figma: fg-primary */
|
|
@@ -446,6 +447,68 @@
|
|
|
446
447
|
}
|
|
447
448
|
}
|
|
448
449
|
|
|
450
|
+
/* ─── Chart canvas — control-room atmosphere for analytics surfaces ───────────
|
|
451
|
+
Apply `.chart-canvas` to a dashboard/page container holding chart cards: a
|
|
452
|
+
dotted grid faded from the top, plus a dual brand glow in dark mode. The grid
|
|
453
|
+
is masked away so it never bleeds into the cards stacked above it. */
|
|
454
|
+
|
|
455
|
+
.chart-canvas {
|
|
456
|
+
position: relative;
|
|
457
|
+
isolation: isolate;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.chart-canvas::before {
|
|
461
|
+
content: "";
|
|
462
|
+
position: absolute;
|
|
463
|
+
inset: 0;
|
|
464
|
+
z-index: -1;
|
|
465
|
+
pointer-events: none;
|
|
466
|
+
background-image:
|
|
467
|
+
linear-gradient(var(--color-sidebar-border) 1px, transparent 1px),
|
|
468
|
+
linear-gradient(90deg, var(--color-sidebar-border) 1px, transparent 1px);
|
|
469
|
+
background-size:
|
|
470
|
+
46px 46px,
|
|
471
|
+
46px 46px;
|
|
472
|
+
opacity: 0.65;
|
|
473
|
+
-webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 100%);
|
|
474
|
+
mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 100%);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.dark .chart-canvas::before {
|
|
478
|
+
background-image:
|
|
479
|
+
radial-gradient(
|
|
480
|
+
900px 480px at 78% -8%,
|
|
481
|
+
color-mix(in oklab, var(--color-cta-accent) 12%, transparent),
|
|
482
|
+
transparent 60%
|
|
483
|
+
),
|
|
484
|
+
radial-gradient(820px 520px at 8% 4%, color-mix(in oklab, var(--color-primary) 12%, transparent), transparent 60%),
|
|
485
|
+
linear-gradient(var(--color-sidebar-border) 1px, transparent 1px),
|
|
486
|
+
linear-gradient(90deg, var(--color-sidebar-border) 1px, transparent 1px);
|
|
487
|
+
background-size:
|
|
488
|
+
100% 100%,
|
|
489
|
+
100% 100%,
|
|
490
|
+
46px 46px,
|
|
491
|
+
46px 46px;
|
|
492
|
+
opacity: 0.6;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
496
|
+
.chart-rise {
|
|
497
|
+
animation: chart-rise 0.65s cubic-bezier(0.2, 0.7, 0.2, 1) both;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
@keyframes chart-rise {
|
|
502
|
+
from {
|
|
503
|
+
opacity: 0;
|
|
504
|
+
transform: translateY(12px);
|
|
505
|
+
}
|
|
506
|
+
to {
|
|
507
|
+
opacity: 1;
|
|
508
|
+
transform: none;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
449
512
|
/* ─── Typography ──────────────────────────────────────────────────────────── */
|
|
450
513
|
|
|
451
514
|
:root {
|