Loading component…
Loading component…
This component has not been implemented locally yet.
To reuse this local React demo, copy all files from the Code tab into the same folder, then import AIChat/RevenueAnalyst from ./ai-chat-revenue.
import { RevenueChatScreen, type ChartFocus } from "@/components/ui/ai-chat-revenue";
export default function Page() {
return (
<RevenueChatScreen
onAsk={async (question: string, focus?: ChartFocus) => {
// focus is set when the question is about part of a chart: { chart, from, to, label, detail }
const res = await fetch("/api/analyst", { method: "POST", body: JSON.stringify({ question, focus }) });
return res.json(); // { role: "assistant", text, kpis?, chart?, caption?, sources?, next? }
}}
onNavigate={(label) => router.push(routes[label])}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| onAsk | (question, focus?) => Answer \| Promise<Answer> | How the screen answers – return an answer or a promise of one. An answer is { role: "assistant", text, kpis?: { label; value; change? }[], chart?, caption?, sources?, next? }. Without it the screen answers the questions it offers from its sample, and works out answers about picked parts from the chart's own numbers | |
| focus | { chart; from; to; label; detail } | Passed to onAsk when the question is about part of a chart: the chart, the first and last point of the stretch dragged across (or the bar clicked), and how it reads – label "W32 – W34", detail "$284K · +18.3% on last year". The question shows in the chat with that above it, like a quote | |
| chart | { kind: "trend" \| "split" \| "forecast"; … } | "trend": { labels, current, previous, mark? } – this year against the last, drawn with Trend Chart as an area. "forecast": { labels, actual, forecast, target? } – what happened, then a dashed forecast and the target, drawn with Trend Chart. "split": { title, previous?, since?, groups: { name, parts: { name, value }[] }[] } – one bar per group with a segment per part, drawn with Model Usage. Line values are thousands of dollars, split values dollars | |
| turns | ChatTurn[] | The conversation so far – { role: "user", text, quote? } and answers as above | |
| chats | ShellChat[] | The chats in the sidebar | |
| loading | boolean | Gray lines, cards and chart in place of the conversation | |
| empty | boolean | A new chat – a short note and questions to start with | |
| onNavigate | (label: string) => void | Called with the label of a sidebar item | |
| className | string | Extra class on the root |
The sidebar starts folded to its icons so the chat has the room; the column stays at 760px in the middle, and cards and charts are as wide as the composer below
On phones the mark steps back, KPI cards sit two by two and the charts keep their height; sliding a finger sideways picks a stretch, up and down still scrolls, a tap picks a bar – the hint under the chart names the gesture of the device, and the field uses 16px text so iOS does not zoom in
Big numbers shorten – $1.24M, $2.28B – and a value too long for its card ends in … with the whole one on hover
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"