Get StartedComponentsStylingThemingMath & Science
MCP

Charts

Overview

Pure SVG charts with no extra dependency. Every chart reads colors from the theme tokens, so light and dark mode work out of the box.

The family: LineChart, AreaChart, BarChart, BarSegment, Histogram, RangeBarChart, CandlestickChart, PieChart, DonutChart, RadarChart, ScatterChart and Sparkline. Shared pieces are useChart, ChartLegend, CartesianGrid and ChartAxis.

Markdown

Import

tsx
import { Chart } from "@indoku/ui"​// <Chart.LineChart />, <Chart.BarChart />, Chart.useChart(), ...

Anatomy

Chart.LineChart | AreaChart | BarChart | ...  CartesianGrid (grid lines)  ChartAxis (bottom / left / right)  ChartLegend (interactive, driven by useChart)

Examples

Installation

Charts ship inside @indoku/ui. Only React and Emotion are required.

050100150200250300JanFebMarAprMayJun

useChart

Shared tokens, number formatting and legend highlight.

$0k$50k$100k$150k$200k$250k$300kJanFebMarAprMayJun

Sorting

sortChartData and compactFormat helpers.

01020304050OrganicDirectReferralSocial

Bar: grouped

020406080100120Q1Q2Q3Q4

Bar: stacked

020406080100120MonTueWedThuFri

Bar: percent

020406080100ABCD

Bar segment

One segmented bar for composition.

Histogram

0123456701.83.65.47.2

Range bar

05101520253035MonTueWedThu

Candlestick

02040608010012014012345

Line: dashed series

010203040JanFebMarAprMay

Line: gradient area

020406080100JanFebMarAprMayJun

Line: biaxial

Per-series axis with rightTickFormat.

0501001502002500%1%2%3%4%JanFebMarAprMay

Line: connect nulls + series labels

01020304050JanFebMarAprMayJunSignups

Area: gradient fill

010203040506070JanFebMarAprMayJun

Area: percent

020406080100JanFebMarAprMay

Area: reference area and dots

Promo0102030405060JanFebMarAprMayJun

Pie: padding and detached segment

Donut: radial text

100visits

Radar: filled grid

SpeedPowerRangeArmorStealth

Radar: circle grid

HTMLCSSJSTSNode

Scatter: groups and trend lines

0123450123456

Scatter: connected dots

02468012345

Sparkline

Plain, trend-colored with area, and interactive tooltip.

Grid, axis and reference lines

SLA0 ms10 ms20 ms30 ms40 ms50 ms60 ms70 msMTWTF

Props

ChartLegend

PropTypeDefaultDescription
items*{ name: string; color: string }[]–
chart*ChartApi–

CartesianGrid

PropTypeDefaultDescription
x0*number–
x1*number–
y0*number–
y1*number–
horizontalnumber[]–Posisi y (px) tiap garis horizontal.
verticalnumber[]–Posisi x (px) tiap garis vertikal.

ChartAxis

PropTypeDefaultDescription
orientation*"bottom" | "left" | "right"–
at*number–Posisi garis sumbu (px): y untuk bottom, x untuk left/right.
ticks*{ pos: number; label: string }[]–

LineChart

PropTypeDefaultDescription
series*ChartSeries[]–
categoriesstring[]–Label for each data point (x axis), used for the point's aria-label.
areabooleanfalseFill the area under the line (area chart).
gradientboolean–Isi area pakai gradient (memudar ke bawah).
showDotsboolean–
dashedboolean–Semua garis putus-putus (atau per series lewat series[i].dashed).
connectNullsboolean–Sambung garis melewati nilai null.
seriesLabelsboolean–Tampilkan nama series di ujung garis.
rightTickFormatChartFormat–

AreaChart

PropTypeDefaultDescription
series*ChartSeries[]–
categoriesstring[]–
mode"overlap" | "stacked" | "percent"–"overlap" (default), "stacked" (ditumpuk) atau "percent" (ditumpuk, 0-100%).
gradientbooleantrueIsi pakai gradient.
showDotsboolean–Tanda titik di tiap data.
referenceArea{ from: number; to: number; label?: string }–Blok warna di antara dua index kategori.

BarChart

PropTypeDefaultDescription
series*ChartSeries[]–
categoriesstring[]–
mode"grouped" | "stacked" | "percent"–"grouped" (default), "stacked" atau "percent" (ditumpuk, 0-100%).
gapnumber0.3Gap between category groups, 0–1 (share of the slot width).
joinedboolean–Hilangkan jarak antar bar (histogram).

Histogram

PropTypeDefaultDescription
values*number[]–
binsnumberakar jumlah data (aturan Sturges sederhana)Jumlah bin.
colorstring–
namestring–

RangeBarChart

PropTypeDefaultDescription
data*RangeDatum[]–
colorstring–
gapnumber–

CandlestickChart

PropTypeDefaultDescription
data*CandleDatum[]–
upColorstring–Warna naik / turun (token warna).
downColorstring–

BarSegment

PropTypeDefaultDescription
data*BarSegmentDatum[]–
barHeightnumber12Tinggi bar (px).
showLegendbooleantrueTampilkan legend dengan nilai & persentase.
formatChartFormat–

PieChart

PropTypeDefaultDescription
data*PieDatum[]–
sizenumber–
innerRadiusRationumber00 = full pie, e.g. 0.6 = donut with a 60% radius hole.
padAnglenumber0Celah antar segmen (derajat).
detachednumber[]–Index segmen yang digeser keluar.
detachDistancenumber8Jarak geser segmen (px).
radialText{ label: string; sublabel?: string }–Teks di tengah (donut): label besar + sublabel kecil.
legendboolean–Legend interaktif.

RadialText

PropTypeDefaultDescription
x*number–
y*number–
label*string–
sublabelstring–

RadarChart

PropTypeDefaultDescription
axes*string[]–Nama tiap sumbu (minimal 3).
series*ChartSeries[]–
sizenumber–
levelsnumber4Jumlah lingkaran/poligon grid.
grid"polygon" | "circle" | "filled"–Bentuk grid: "polygon" (default), "circle" atau "filled" (selang-seling terisi).
pointLabelsbooleantrueLabel di tiap sumbu.
maxnumbernilai terbesar dataNilai maksimum sumbu.
legendboolean–
highlightnumber | null–

ScatterChart

PropTypeDefaultDescription
series*ScatterSeries[]–Satu atau lebih grup data.
trendLineboolean–Garis tren regresi linear per grup.
connectboolean–Sambungkan titik berurutan dengan garis.
dotSizenumber4Radius titik.
referenceLinesReferenceLineSpec[]–

Sparkline

PropTypeDefaultDescription
values*number[]–
widthnumber–
heightnumber–
colorstring–Token warna, atau "trend" (hijau kalau naik, merah kalau turun).
areaboolean–Isi area di bawah garis.
interactivebooleanfalseTampilkan nilai titik yang di-hover (tooltip).
formatChartFormat–

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

Accessibility

  • Charts are decorative SVG; pair them with a table or text summary for screen readers.
  • Legend items are focusable and highlight their series on focus.

Notes

  • null values create gaps unless connectNulls is set.
  • Series colors accept a palette name (blue) or a full token (blue.500).

Created by @indokudev