Loading component…
Loading component…
Usage per day as soft gradient bars drifting from blue to lilac, with a live bar for today that keeps growing, a Real-time badge and rolling totals
To reuse this local React demo, copy all files from the Code tab into the same folder, then import MeteringChart from ./metering-chart.
import { MeteringChart } from "@/components/ui/metering-chart";
export function ApiCalls() {
return (
<MeteringChart
title="API calls"
live
period="Sep 1 – Sep 21"
data={[
{ label: "Sep 1", value: 1870 },
{ label: "Sep 2", value: 2290 },
{ label: "Sep 3", value: 2860 },
]}
totals={[
{ label: "Total volume", value: 50390, format: (n) => `$${Math.round(n).toLocaleString()}` },
{ label: "Total events", value: 36000 },
]}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| title | string | Heading of the card | |
| data | MeteringDay[] | { label, value, breakdown? } per day, oldest first; a missing or broken value leaves an empty slot. breakdown: { label, value, logo? }[] – shown with its logo in the tag as whole percentages that add up to 100, largest first | |
| totals | MeteringTotal[] | { label, value, format? } – figures under the title that roll to their new values | |
| period | string | The span on the right, e.g. "Sep 1 – Sep 21" | |
| live | boolean | false | The last bar is today and still counting: accent color, a running sheen, a turning spinner in the pink badge |
| badge | string | "Real-time" when live | Text next to the title; empty for none |
| format | (n: number) => string | 1,284 | Formats the tag and the totals |
| axisFormat | (n: number) => string | Shorter numbers for the value axis, e.g. 4.5k | |
| colors | string[] | light blue → lilac → mauve | Colors the bars drift through from left to right |
| accent | string | "#5e5cff" | Color of the live bar |
| height | number | 168 | Height of the plot in px |
| emptyText | string | "No usage yet" | Quiet text when there is nothing to draw |
| breakdownLimit | number | 4 | How many parts the tag lists – the smaller ones fold into one row |
| otherLabel | string | "Other" | Label of the folded row |
| className | string | Extra class on the card |
Fills its container; bars stay 11px wide and thin out on narrow cards, the period moves under the title
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"