Avara UI

Shadcn Chart

Animated bar, line, area, pie, donut and radar charts with hover tooltips, built without a charting library.

One data array of { label, value } drives the bar, line, pie and donut charts. Series charts (multi-area, radar) take labels and series instead, and two share charts, donut-legend and stacked-bar, are the ones on the Book Appointment page.

Applies to this page's previews only

About Shadcn Chart

What it is. Shadcn Chart (ChartBlock) draws eleven chart types from a type prop: bar, line, pie, donut, donut-legend, stacked-bar, traffic-sources, visitors-by-country, metrics-overview, multi-area and radar. Most read a data array of { label, value }. multi-area and radar read labels and series, and metrics-overview reads metrics.

How it is built. Plain SVG and HTML with no recharts, chart.js or gsap. Marks animate in once the chart scrolls into view, every chart opens a tooltip on hover or keyboard focus, and the colours are shades of the theme accent, so every preset on the Themes page restyles it. Installing it also adds the animated icon set.

When to use it. Analytics cards, revenue trends, category breakdowns and reporting dashboards.

For AI agents

Hand your agent this brief or the Markdown page, not a screenshot.

When to use

  • Analytics cards, revenue trends
  • Category breakdowns, version or score comparisons, reporting dashboards

When not to use

  • Editable, spreadsheet-style data: use Data Grid
  • Data plotted on a world map: use Data Maps

Agent notes

  • ChartBlock takes type ("bar" | "line" | "pie" | "donut" | "donut-legend" | "stacked-bar" | "traffic-sources" | "visitors-by-country" | "metrics-overview" | "multi-area" | "radar").
  • data is { label, value }[]. multi-area and radar take labels: string[] plus series: { label, values: number[] }[]; radar also takes baseline.
  • There is no "area" type. Use type="line" for one series, or multi-area for several. showArea={false} gives a bare line.
  • Width is 100% responsive. height defaults to 300 for bar, line, pie and donut, and 240 for multi-area. The card charts size to their content.
  • Bar and line charts scale from 0 to a rounded maximum, so there is no negative axis.
  • The card charts (traffic-sources, visitors-by-country, metrics-overview, multi-area, radar) bring their own surface. Wrap the others in a card.
Install
npx shadcn@latest add https://avaraui.com/r/chart.json
Registry name
@avara-ui/chart, through the shadcn MCP server
Index
llms.txt lists every page, or add the agent skill once

Props Reference

PropTypeDefaultDescription
data{ label: string, value: number, color?: string, code?: string }[][]The points for every type except multi-area, radar and metrics-overview. color pins one share's colour; code is a 2-letter ISO country code.
type"bar" | "line" | "pie" | "donut" | "donut-legend" | "stacked-bar" | "traffic-sources" | "visitors-by-country" | "metrics-overview" | "multi-area" | "radar""bar"Which chart to draw.
color

"indigo" | "rose" | "emerald" | "amber" | "blue" | "zinc" | string

"var(--primary)"

The base colour. Bars, lines and strokes use it directly; share charts shade it from full to light. Accepts hex codes or a CSS var(...).

heightnumber300

Pixel height of the chart area. multi-area defaults to 240. The legend, breakdown and card charts size to their content.

colorsstring[]

shades of color

One colour per share in the share charts, wrapping if there are more shares than colours. A point's own color wins.

title, caption

stringundefined

Heading and subheading for the card charts, and the header of donut-legend.

showGridbooleantrue

Horizontal gridlines on the bar, line and multi-area charts.

showAreabooleantrue

Line only: the gradient fill under the curve.

valuePrefix, valueSuffix

string""

Added to tooltip, axis and legend values, such as "$" or "%".

labelsstring[][]

Multi-area and radar: the x labels, or the radar axes (three or more).

series{ id?: string, label: string, color?: string, values: number[] }[][]

Multi-area and radar: one entry per layer or tab, with one value per label. The first layer sits on top and takes the accent; later ones are greys. Radar opens on the last series.

baseline{ label: string, values: number[] }undefined

Radar only: a dashed outline to compare each version against.

centerLabel, hoverLabel

string

"largest", the share's name

Donut with legend: the caption under the centre value at rest, and while a share is hovered.

showTotalbooleanfalse

Donut with legend: show the total in the centre at rest instead of the largest share.

signUpsnumber412

Traffic sources only: sign-ups in the period, for the conversion rate.

showCodesbooleantrue

Visitors by country only: the 2-letter ISO badges.

metricsMetricTabItem[]

4 sample tabs

Metrics overview only: tabs with points, icon, currency and a change percentage.

classNamestringundefinedClasses for the outer wrapper.

Works with other components

  • Combine ChartBlock with Data Grid for editable metrics tables, Data Maps for geographic breakdowns, and Card for dashboard KPI panels.
  • Place it inside a Dashboard layout alongside tables and filters.

Does ChartBlock depend on Recharts or Chart.js?

No. ChartBlock draws everything with SVG and HTML. The registry item adds only the animated icon set, and the file imports nothing from next/*.

How do I prevent vertical layout shift when charts load?

Pass a fixed pixel height, for example height={300}, which is already the default for bar, line, pie and donut. Width stays 100% responsive. The legend and card charts size to their content, so give their wrapper a min-height if you need to reserve space.

How do I make an area chart with ChartBlock?

There is no "area" type. Use type="line" for one series, where showArea fills a gradient under the curve, or type="multi-area" with labels and series to stack several. The curve is smooth and never overshoots your data, so there is no option for straight segments.

How do I show currency or units on ChartBlock values?

Set valuePrefix="$" or valueSuffix="%"; both apply to the tooltip, the axis and the legend. Axis labels are abbreviated (1.2K), tooltips show the full number. In metrics-overview, give a tab currency: "USD" and its values are formatted with Intl.NumberFormat.

How do I set the colour of each share?

Give a data point its own color to pin it, such as grey for an "Other" bucket. Other shares take colors in order, wrapping when there are more shares than colours. With no colors, shares are shades of color (the theme accent by default), so presets restyle them.

Is ChartBlock keyboard and screen-reader accessible?

Mostly. Bar, line, area and metrics charts take focus: ArrowLeft, ArrowRight, Home and End step through the points and Escape clears the tooltip. Pie and donut slices and legend rows are focusable and show the same tooltip, and the tabs and toggles are real tablists and radio groups. Radar axes show their tooltip on hover only. Under prefers-reduced-motion charts render in their final state with no entrance or morph.