Usage forecast (Pro)
ProIncluded in $99Not how much was used, but when it runs out: the recent pace carried forward, said as a date with its likely range, on a chart you can read day by day.
On this page
Installation
Needs chatcn Pro
This command works with a Pro license, along with every Pro component.
Or start free: sign up and get three Pro components on us, with a new one every month.
Usage
import { UsageForecast } from "@/components/ui/chatcn/pro/usage-forecast"
<UsageForecast
daily={creditsPerDay}
limit={10_000}
periodStart={period.start}
periodEnd={period.end}
action={<Button size="sm" variant="outline">Top up</Button>}
/>The pace is the average of the last window days (7 by default), carried forward to the end of the period. If that crosses the limit first, the headline is the date it does, in amber, and the chart marks the point; if not, the headline says how much of the plan will be used. The chart shows use so far as a solid line, the projection dashed and the limit as a rule. With fewer than three days of data it says it is too early rather than guessing. daysLeftAtPace gives the same pace as a number for banners. Under the line, each day's use is a bar and the days the pace is read from are a shade darker, so a sudden jump explains itself. The projection sits inside a shaded range from your slower to your busier recent days, and the line under the headline turns that into dates. Once the limit is crossed the chart marks the point in red. Move along the chart, or focus it and use the arrow keys, Home and End, to read any day, past or projected; beyond the run out the reading stops at the limit.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
daily | number[] | Use per day this period, oldest first |
limit, unit | number, string | Default unit credits |
periodStart, periodEnd | Date | string | |
window | number | Days the pace is read from. Default 7 |
action | ReactNode | Top up, change plan |
locale, labels | Formatting and every string |
Accessibility
- The chart is a slider over the days of the period, labelled with the headline and the usage; each step announces the day and its value, marked projected when it is.
- Arrow keys follow the reading direction, so in right to left layouts the left arrow moves forward.
- Amber and red always come with the sentence that explains them.
Motion
None. The forecast is a reading, not an animation.