Getting Started
Charts
- Charts
- Line Chart
- Bar Chart
- Area Chart
- Scatter Chart
- Pie Chart
- Donut Chart
- Dot Plot Chart
- Lollipop Chart
- Dumbbell Chart
- Slope Chart
- Range Chart
- Proportion Bar
- Histogram Chart
- Box Plot Chart
- Violin Chart
- Polar Chart
- Parallel Coordinates
- SPLOM Chart
- Parcats Chart
- Candlestick Chart
- OHLC Chart
- Waterfall Chart
- Funnel Chart
- Heatmap Chart
- Contour Chart
- Density Chart
- Ternary Chart
- Radar Chart
- Treemap Chart
- Sunburst Chart
- Sankey Chart
- Gauge Chart
- Radial Progress Chart
- Bullet Chart
- Icicle Chart
- Network Graph
- Dendrogram
- Choropleth Chart
- Needs45 %
- Transportation20 %
- Entertainment10 %
"use client"
import { ProportionBar } from "@/components/ui/charts"
// Shares of income, so the track is a full 100 and the gap is what is left.
const breakdown = [
{ label: "Needs", value: 45, color: "var(--chart-series-1)" },
{ label: "Transportation", value: 20, color: "var(--chart-series-5)" },
{ label: "Entertainment", value: 10, color: "var(--chart-series-2)" },
]
export function ProportionBarDemo() {
return (
<ProportionBar
className="max-w-sm"
data={breakdown}
total={100}
height={32}
/>
)
}
About
A Proportion Bar shows how one total divides into parts, along a single
track. Reach for it over a pie or donut whenever the parts are few and the
reader needs to compare shares rather than admire angles — and pass a
total larger than the sum when the headroom left over is the point
(budget remaining, quota unused).
It renders as CSS rather than SVG: the whole mark is rectangles, so there is
nothing an <svg> would buy.
Installation
pnpm dlx shadcn@latest add https://ui.simplifyingai.com/r/proportion-bar.json
Usage
import { ProportionBar } from "@/components/ui/charts"<ProportionBar
data={[
{ label: "Needs", value: 45 },
{ label: "Transportation", value: 20 },
{ label: "Entertainment", value: 10 },
]}
total={100}
/>API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
data | ProportionSegment[] | — | { label, value, color?, pattern? } per segment. |
total | number | sum of value | Denominator. Larger than the sum leaves a visible remainder. |
height | number | 28 | Track height in px. |
gap | number | 6 | Space between segments in px. |
radius | number | height / 2 | Corner radius. Defaults to a full pill. |
showTrack | boolean | true | Paint the unfilled remainder. |
trackColor | string | var(--muted) | Colour of that remainder. |
pattern | ChartPatternKind | theme | Texture over every segment. |
showLegend | boolean | true | Render the label/share rows. |
legendValue | "percent" | "value" | "none" | "percent" | What the legend prints on the right. |
valueFormatter | (value: number) => string | toLocaleString | Formats raw values. |
Ask Your Database Anything with ChatPlotDB
Connect your database, ask questions in plain English, and get answers as charts, tables, and dashboards. No SQL required.
Join the ChatPlotDB waitlist