Compare categories: grouped, stacked or sideways bars, with negative values below the line.
| Day | Open | Pending | Solved |
|---|---|---|---|
| Mon | 42 | 18 | 61 |
| Tue | 51 | 22 | 58 |
| Wed | 38 | 19 | 64 |
| Thu | 47 | 25 | 52 |
| Fri | 55 | 21 | 70 |
| Sat | 12 | 8 | 15 |
| Sun | 9 | 6 | 11 |
import type { Html } from "@effect/ui/html"import { Chart } from "./ui/uicontext/components/charts/Chart.ts"import { ticketsByStatus } from "./metrics.ts"// Support tickets this week, grouped by status. Hover a day to read all three.export const TicketsByDay = <M>(h: Html.H<M>) => Chart(h, { props: { type: "bar", label: "Tickets by status, this week", series: ticketsByStatus, x: { kind: "category", label: "Day" }, }, onEmit: { Highlighted: () => undefined, Selected: () => undefined, Toggled: () => undefined, RequestedRetry: () => undefined }, })Installation
pnpm dlx shadcn@latest add checkfu/uicontext/bar-chartUsage
import { Chart } from "./ui/uicontext/components/charts/Chart.ts"import type { ChartSeries } from "./ui/uicontext/components/charts/Data.ts"export const TicketsByDay = <M>(h: Html.H<M>, series: ReadonlyArray<ChartSeries>) => Chart(h, { props: { type: "bar", label: "Tickets by status, this week", series }, onEmit: { Highlighted: () => undefined, Selected: () => undefined, Toggled: () => undefined, RequestedRetry: () => undefined }, })Examples
Sideways
Ranked bars with long names and values at the tips. Up and Down step through them.
| Seat | Hours this month |
|---|---|
| Priya Raman | 128 hr |
| Mateo Alvarez | 117 hr |
| Hana Kobayashi | 96 hr |
| Ben Okafor | 88 hr |
| Aleksandra Wiśniewska-Kowalczyk | 74 hr |
| Sam Lee | 31 hr |
| Jo | 4 hr |
import type { Html } from "@effect/ui/html"import { Chart } from "./ui/uicontext/components/charts/Chart.ts"import { usagePerSeat } from "./metrics.ts"// Who used the product most this month. Sideways bars give long names room, and each bar carries// its value at the tip.export const UsagePerSeat = <M>(h: Html.H<M>) => Chart(h, { props: { type: "bar", horizontal: true, label: "Hours of use per seat, this month", series: usagePerSeat, x: { kind: "category", label: "Seat" }, format: { style: "unit", unit: "hour", digits: 0 }, height: 280, }, onEmit: { Highlighted: () => undefined, Selected: () => undefined, Toggled: () => undefined, RequestedRetry: () => undefined }, })Below zero
Negative values stack down from zero, rounded at their own end.
| Category | Seats added | Seats removed |
|---|---|---|
| Jun | 412 | -120 |
| Jul | 388 | -164 |
| Aug | 455 | -98 |
| Sep | 501 | -210 |
| Oct | 476 | -142 |
| Nov | 530 | -188 |
import type { Html } from "@effect/ui/html"import { Chart } from "./ui/uicontext/components/charts/Chart.ts"import type { ChartSeries } from "./ui/uicontext/components/charts/Data.ts"const months = ["Jun", "Jul", "Aug", "Sep", "Oct", "Nov"]const added = [412, 388, 455, 501, 476, 530]const removed = [-120, -164, -98, -210, -142, -188]const seats: ReadonlyArray<ChartSeries> = [ { id: "added", label: "Seats added", color: 3, points: months.map((x, i) => ({ x, y: added[i] ?? 0 })) }, { id: "removed", label: "Seats removed", color: 8, points: months.map((x, i) => ({ x, y: removed[i] ?? 0 })) },]// Seats added and removed each month. Removals grow down from the zero line, which is drawn// stronger than the grid.export const SeatChanges = <M>(h: Html.H<M>) => Chart(h, { props: { type: "bar", stacked: "stacked", label: "Seats added and removed per month", series: seats }, onEmit: { Highlighted: () => undefined, Selected: () => undefined, Toggled: () => undefined, RequestedRetry: () => undefined }, })Stacked
Ninety bars, stacked, with a total in the tooltip. Labels thin out to fit.
| Day | Succeeded | Failed |
|---|---|---|
| Wed, Sep 2, 2026 | 11 | 0 |
| Thu, Sep 3, 2026 | 8 | 1 |
| Fri, Sep 4, 2026 | 8 | 1 |
| Sat, Sep 5, 2026 | 2 | 0 |
| Sun, Sep 6, 2026 | 1 | 0 |
| Mon, Sep 7, 2026 | 17 | 3 |
| Tue, Sep 8, 2026 | 20 | 1 |
| Wed, Sep 9, 2026 | 7 | 2 |
| Thu, Sep 10, 2026 | 12 | 2 |
| Fri, Sep 11, 2026 | 17 | 0 |
| Sat, Sep 12, 2026 | 2 | 1 |
| Sun, Sep 13, 2026 | 1 | 0 |
| Mon, Sep 14, 2026 | 14 | 3 |
| Tue, Sep 15, 2026 | 15 | 1 |
| Wed, Sep 16, 2026 | 15 | 1 |
| Thu, Sep 17, 2026 | 14 | 2 |
| Fri, Sep 18, 2026 | 11 | 0 |
| Sat, Sep 19, 2026 | 1 | 0 |
| Sun, Sep 20, 2026 | 0 | 0 |
| Mon, Sep 21, 2026 | 20 | 0 |
| Tue, Sep 22, 2026 | 18 | 3 |
| Wed, Sep 23, 2026 | 21 | 0 |
| Thu, Sep 24, 2026 | 19 | 0 |
| Fri, Sep 25, 2026 | 13 | 1 |
| Sat, Sep 26, 2026 | 2 | 0 |
| Sun, Sep 27, 2026 | 0 | 0 |
| Mon, Sep 28, 2026 | 12 | 2 |
| Tue, Sep 29, 2026 | 16 | 1 |
| Wed, Sep 30, 2026 | 11 | 2 |
| Thu, Oct 1, 2026 | 14 | 1 |
| Fri, Oct 2, 2026 | 11 | 0 |
| Sat, Oct 3, 2026 | 0 | 0 |
| Sun, Oct 4, 2026 | 2 | 0 |
| Mon, Oct 5, 2026 | 16 | 3 |
| Tue, Oct 6, 2026 | 9 | 2 |
| Wed, Oct 7, 2026 | 15 | 3 |
| Thu, Oct 8, 2026 | 9 | 2 |
| Fri, Oct 9, 2026 | 16 | 2 |
| Sat, Oct 10, 2026 | 1 | 0 |
| Sun, Oct 11, 2026 | 0 | 0 |
| Mon, Oct 12, 2026 | 12 | 3 |
| Tue, Oct 13, 2026 | 10 | 2 |
| Wed, Oct 14, 2026 | 9 | 1 |
| Thu, Oct 15, 2026 | 18 | 1 |
| Fri, Oct 16, 2026 | 20 | 2 |
| Sat, Oct 17, 2026 | 0 | 0 |
| Sun, Oct 18, 2026 | 2 | 0 |
| Mon, Oct 19, 2026 | 20 | 2 |
| Tue, Oct 20, 2026 | 15 | 1 |
| Wed, Oct 21, 2026 | 18 | 2 |
| Thu, Oct 22, 2026 | 9 | 1 |
| Fri, Oct 23, 2026 | 12 | 1 |
| Sat, Oct 24, 2026 | 2 | 0 |
| Sun, Oct 25, 2026 | 3 | 0 |
| Mon, Oct 26, 2026 | 20 | 1 |
| Tue, Oct 27, 2026 | 16 | 2 |
| Wed, Oct 28, 2026 | 14 | 1 |
| Thu, Oct 29, 2026 | 12 | 1 |
| Fri, Oct 30, 2026 | 11 | 0 |
| Sat, Oct 31, 2026 | 0 | 0 |
| Sun, Nov 1, 2026 | 0 | 0 |
| Mon, Nov 2, 2026 | 11 | 1 |
| Tue, Nov 3, 2026 | 17 | 1 |
| Wed, Nov 4, 2026 | 10 | 0 |
| Thu, Nov 5, 2026 | 16 | 1 |
| Fri, Nov 6, 2026 | 18 | 1 |
| Sat, Nov 7, 2026 | 0 | 0 |
| Sun, Nov 8, 2026 | 0 | 0 |
| Mon, Nov 9, 2026 | 9 | 1 |
| Tue, Nov 10, 2026 | 11 | 1 |
| Wed, Nov 11, 2026 | 14 | 2 |
| Thu, Nov 12, 2026 | 12 | 1 |
| Fri, Nov 13, 2026 | 16 | 1 |
| Sat, Nov 14, 2026 | 1 | 0 |
| Sun, Nov 15, 2026 | 1 | 0 |
| Mon, Nov 16, 2026 | 10 | 1 |
| Tue, Nov 17, 2026 | 11 | 1 |
| Wed, Nov 18, 2026 | 13 | 3 |
| Thu, Nov 19, 2026 | 10 | 0 |
| Fri, Nov 20, 2026 | 16 | 0 |
| Sat, Nov 21, 2026 | 0 | 0 |
| Sun, Nov 22, 2026 | 0 | 0 |
| Mon, Nov 23, 2026 | 16 | 1 |
| Tue, Nov 24, 2026 | 15 | 1 |
| Wed, Nov 25, 2026 | 18 | 3 |
| Thu, Nov 26, 2026 | 17 | 0 |
| Fri, Nov 27, 2026 | 22 | 0 |
| Sat, Nov 28, 2026 | 0 | 0 |
| Sun, Nov 29, 2026 | 3 | 0 |
| Mon, Nov 30, 2026 | 16 | 2 |
import type { Html } from "@effect/ui/html"import { Chart } from "./ui/uicontext/components/charts/Chart.ts"import { deploysPerDay } from "./metrics.ts"// Ninety days of production deploys, failures stacked on top in red. Weekends sit low.export const DeploysPerDay = <M>(h: Html.H<M>) => Chart(h, { props: { type: "bar", stacked: "stacked", label: "Deploys per day, last 90 days", series: deploysPerDay, x: { kind: "time", unit: "day", label: "Day" }, empty: "No deploys in this period.", }, onEmit: { Highlighted: () => undefined, Selected: () => undefined, Toggled: () => undefined, RequestedRetry: () => undefined }, })API reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
typerequired | ChartType | — | — |
labelrequired | string | — | What the chart shows, for screen readers and the table's caption: "Monthly recurring revenue" |
seriesrequired | ChartSeries[] | — | — |
x | ChartXAxis | — | The x axis: categories in the order given (the default), or time |
format | ChartFormat | — | How values read; a series' own format wins for it |
endFormat | ChartFormat | — | A combo chart's end axis format |
stacked | "none" | "stacked" | "percent" | — | Stack areas or bars; percent shows each x as shares of 100% |
horizontal | boolean | — | Bars run sideways, categories down the side: for long names or ranked lists |
curve | "linear" | "smooth" | "step" | — | — |
markers | boolean | — | A dot on every point, when there's room for them |
zero | boolean | True | Start the value axis at zero; bars and areas always do. True by default |
height | number | 240 | The plot's height in pixels, axes included; 240 by default |
hidden | string[] | — | Series ids to hide. Leave it out and the chart keeps track itself; pass it to own it |
legend | boolean | — | False hides the legend; it shows by default for two or more series |
tableToggle | boolean | — | False drops the View as table button; the hidden table for screen readers stays |
status | ChartStatus | — | — |
error | string | — | What went wrong, said plainly, under "Couldn't load this chart." |
empty | string | — | What an empty chart says: "No deploys in this period." |
locale | string | — | — |
Events
| Event | Payload | Description |
|---|---|---|
Highlighted | { x: ChartX | null } | The x being read changed, by pointer or keyboard; null when reading stops |
Selected | { x: ChartX } | A click, a tap or Enter on a point |
Toggled | { id: string; hidden: boolean } | The legend asked to hide or show a series |
RequestedRetry | {} | — |
Accessibility
- The arrow keys step through the categories, Up and Down for sideways bars, and announce every series at that category.
- Long category names are shortened on the axis only; the tooltip, the announcement and the table use them in full.