BarChart

Grouped and stacked bars, slender with a 4px top radius and 2px gaps between stacked segments; horizontal for rankings.

View source
Tokens by kind per day
CategoryInputCache readOutputReasoning
Oct 6840K712.5K560K382.5K
Oct 71.26M1.05M805K315K
Oct 81.08M902.5K700K472.5K
Oct 9900K760K595K405K
Oct 101.32M1.09M490K337.5K
Oct 111.14M950K735K495K
Oct 12960K807.5K630K427.5K
import { BarChart } from "@logicplanes/kaeso-ui";

Props

  • aria-label
    string

    The chart's accessible name ("Requests by model").

  • axisLabels
    string[]

    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).

  • categories
    string[]

    The names along the category axis, one per bar group, in order. They also head the tooltip and the data table.

  • dates
    readonly 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.

  • empty
    boolean

    Shows 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.

  • emptyText
    ReactNode

    What the empty state says. Defaults to "No data for this period" in the provider's language.

  • error
    ReactNode

    The 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 onRetry and otherwise a hint to reload the page. Errors are toasts, so the value isn't shown; pass true and 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.

  • height
    number = 240

    The plot's height in px (240 by default).

  • highlight
    number

    Highlight a category as the pointer does, with its tooltip: a linked view, or the states pages.

  • layout
    "horizontal" | "grouped" | "stacked" = grouped

    grouped puts each category's bars side by side (default), stacked stacks them, and horizontal draws bars across for rankings.

  • loading
    boolean

    The 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 first or last category 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". ongoing marks the last one as still counting, such as today, and says "so far".

  • series
    BarSeries[]

    The bars' series, each with an id, a label, one value per category and an optional color. Colors otherwise come from the series order by id; one series takes series 1. Negative values grow down from the zero line. With two or more, the legend shows and hides them.

  • shares
    boolean = true

    Shows 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.