BarChart
Grouped and stacked bars, slender with a 4px top radius and 2px gaps between stacked segments; horizontal for rankings.
| Category | Input | Cache read | Output | Reasoning |
|---|---|---|---|---|
| Oct 6 | 840K | 712.5K | 560K | 382.5K |
| Oct 7 | 1.26M | 1.05M | 805K | 315K |
| Oct 8 | 1.08M | 902.5K | 700K | 472.5K |
| Oct 9 | 900K | 760K | 595K | 405K |
| Oct 10 | 1.32M | 1.09M | 490K | 337.5K |
| Oct 11 | 1.14M | 950K | 735K | 495K |
| Oct 12 | 960K | 807.5K | 630K | 427.5K |
function Stacked() {
const { formatTokens } = useFormatters();
const series = useSeries();
return (
<div className="w-full">
<BarChart aria-label="Tokens by kind per day" categories={days} series={series} layout="stacked" formatValue={formatTokens} />
</div>
);
}import { BarChart } from "@logicplanes/kaeso-ui";Props
aria-labelstringThe chart's accessible name ("Requests by model").
axisLabelsstring[]Shorter names under the bars, one per category ("3 Aug" for "Week of 3 Aug"); the tooltip, the table and screen readers keep the categories. Name the year where one begins ("Aug", "Dec", "2026", "Feb"), and pass
dates: where the labels don't all fit, the axis keeps every nth, and keeps that one before the newest (axisLabelIndexes).categoriesstring[]The names along the category axis, one per bar group, in order. They also head the tooltip and the data table.
datesreadonly AxisDate[]The day each category begins, one per category: a
Date, or an ISO day ("2026-01-05"). Where the axis thins its labels, it keeps the ones where a year begins (the month after December, the first week in January), read from these, so every language keeps the same labels.emptybooleanShows the empty state (
emptyText) in place of the data, over the baseline and the category axis. By default it shows when there is no value at all; zeros are data.emptyTextReactNodeWhat the empty state says. Defaults to "No data for this period" in the provider's language.
errorReactNodeThe data failed to load: the chart keeps its height, hides its legend and table toggle, and says so quietly, with Try again when there is
onRetryand otherwise a hint to reload the page. Errors are toasts, so the value isn't shown; passtrueand toast the message where the request fails.formatValue((v: number) => string)Formats values in the tooltip, the table and beside horizontal bars. Without it, values are written in full and the axis in short form (1.2M); the axis takes the room its widest label needs, and long category names in a ranking end in an ellipsis with the full name on hover.
heightnumber = 240The plot's height in px (240 by default).
highlightnumberHighlight a category as the pointer does, with its tooltip: a linked view, or the states pages.
layout"horizontal" | "grouped" | "stacked" = groupedgroupedputs each category's bars side by side (default),stackedstacks them, andhorizontaldraws bars across for rankings.loadingbooleanThe data is loading: the chart keeps its height and is marked busy; data already on screen dims and breathes, and with none yet the plot is a skeleton.
onRetry(() => void)Called when Try again is pressed after
error; without it, the button doesn't show.partial{ first?: boolean; last?: boolean; ongoing?: boolean; }Marks the
firstorlastcategory as covering only part of its span: its bars are drawn faint with a dashed edge, like a partial line, and its tooltip says "partial".ongoingmarks the last one as still counting, such as today, and says "so far".seriesBarSeries[]The bars' series, each with an
id, alabel, one value per category and an optionalcolor. Colors otherwise come from the series order byid; one series takes series 1. Negative values grow down from the zero line. With two or more, the legend shows and hides them.sharesboolean = trueShows each series' share of the category's total in the tooltip (on by default). Turn it off when one series is part of another, such as errors within requests.