Get StartedComponentsStylingThemingMath & Science
MCP

Charts

useChart

Charts are plain SVG themed by IndokuUI, with no extra dependency. Install @indoku/ui and import what you need.

useChart shares colors, number formatting and legend highlighting between charts and your own markup.

Markdown

Import

tsx
import { useChart, ChartLegend, sortChartData, chartTokens } from "@indoku/ui"

Examples

Legend highlighting

Hover a legend item to dim the other series.

050100150200250300JanFebMarAprMayJun

Formatting

Pass format to change how numbers print.

$1234k and $87k

Sorting

sortChartData sorts without mutating.

02004006008001KCoffeeSodaTeaJuice

Size and spacing tokens

sizes {"sm":160,"md":220,"lg":300} spacing {"sm":4,"md":8,"lg":16}

Props

useChart(options)

PropTypeDefaultDescription
series{ name?; color? }[]–Used to resolve colors.
format(v: number) => string–Number formatter. Default: compact.
highlightnumber | null–Force the highlighted series.

Returned object

PropTypeDefaultDescription
colorsstring[]–Resolved series colors.
active / setActivenumber | null–Highlighted series.
opacity(i)number–1, or 0.2 when dimmed.
legendProps(i)object–Spread on your own legend item.
format(v)string–Formatter.
tokensobject–chartTokens: size, spacing, padding.

* required. Style props and HTML attributes are accepted as well.

Created by @indokudev