HapplyUI

Components

Bar Chart

One rounded column per bucket, scaled to the tallest, with every bucket labelled underneath. Built from flex rather than a charting library so no label is ever dropped.


Installation

bunx @happlyui/cli@latest add bar-chart

Dependencies

Registry dependencies

These are automatically installed when you add this component.

  • happly-ui-utils
  • chart-tooltip

Usage

import * as BarChart from "@/components/ui/bar-chart"

<BarChart.Root
  items={[{ label: "0 - 9", value: 111 }]}
  highlighted="0 - 9"
  dimension="Group"
  unit="Items"
/>

Examples

Default

One featured column. Hover a column for its count; dimension and unit name what the tooltip shows.

Card title

  • 0 - 9: 111 Items
  • 10 - 19: 168 Items
  • 20 - 29: 72 Items
  • 30 - 39: 58 Items
  • 40 - 49: 123 Items
  • 50 - 59: 144 Items
  • 60 - 69: 0 Items
  • 70+: 121 Items
<BarChart.Root
  items={items}
  highlighted="10 - 19"
  dimension="Group"
  unit="Items"
/>

Without highlight

Leave highlighted out when no bucket should stand out. The chart never picks the tallest for you.

Card title

  • 0 - 9: 111 Items
  • 10 - 19: 168 Items
  • 20 - 29: 72 Items
  • 30 - 39: 58 Items
  • 40 - 49: 123 Items
  • 50 - 59: 144 Items
  • 60 - 69: 0 Items
  • 70+: 121 Items
<BarChart.Root items={items} dimension="Group" unit="Items" />

API Reference

BarChart.Root

The columns and their label row. Fills its container's height.

PropTypeDefaultDescription
items{ label: string; value: number }[]-Columns left to right, in the order given
highlightedstring | null-Label of the column to feature. Omitted or null features none
dimensionstring-What the buckets are, after the bucket in the tooltip caption ("10 - 19 Group"). For ranges; leave it off where the bucket names itself
unitstring-What the value counts, beside it in the tooltip

Previous
Timeline Status Badge