Skip to content

Chart

Download .md

A chart shows how numbers move over time or compare across categories, such as monthly streams per platform or royalty income.

  • Bar to compare amounts across a few categories or months.
  • Line for one or two measures over many points in time, such as income per month.
  • Area only for a single total over time; stacked areas are hard to read.
  • Use at most 5 series. Fold the rest into “Lainnya”, or split the chart.
  • With 4 or more series, label each line or bar group directly, not only in the legend.
  • In scatter plots and maps, where any color can sit next to any other, use at most 3 series.
  • One chart, one axis. Two measures on different scales get two charts.
  • A single headline number is a stat card, not a chart.
React
Streaming per bulan
Jun–Nov 2026, semua rilis
Streaming per bulan, Jun–Nov 2026
BulanSpotifyYouTube Music
Jun8.2005.100
Jul9.1005.600
Agu9.8006.900
Sep10.6007.300
Okt11.3008.100
Nov12.4008.800
Vue

Streaming per bulan

Jun–Nov 2026, semua rilis

Streaming per bulan, Jun–Nov 2026
BulanSpotifyYouTube Music
Jun8.2005.100
Jul9.1005.600
Agu9.8006.900
Sep10.6007.300
Okt11.3008.100
Nov12.4008.800
React
Pendapatan royalti
Jun–Nov 2026, dalam Rupiah
Pendapatan royalti, Jun–Nov 2026
BulanPendapatan
JunRp 1.250.000,00
JulRp 1.418.500,50
AguRp 1.377.250,00
SepRp 1.602.000,75
OktRp 1.745.300,00
NovRp 1.890.420,25
Vue

Pendapatan royalti

Jun–Nov 2026, dalam Rupiah

Pendapatan royalti, Jun–Nov 2026
BulanPendapatan
JunRp 1.250.000,00
JulRp 1.418.500,50
AguRp 1.377.250,00
SepRp 1.602.000,75
OktRp 1.745.300,00
NovRp 1.890.420,25
123
  1. 1Bar series in chart-1
  2. 2Line series in chart-2
  3. 3Axis

A Card with a title and a short description, the chart, a legend when there are two or more series, and a visually hidden table of the same numbers.

Part Style
Series chart-1 to chart-5, in order. chart-1 is the product’s own hue. Never a status color.
Grid Horizontal lines only, in border. No axis lines.
Axis labels text-xs, muted-foreground.
Bars 4px rounded tops, 2px apart.
Lines 2px, no dots until hover.
Tooltip The popover surface: rounded-lg, border, bg-popover, shadow-lg.
Numbers tabular-nums, in the product’s locale (12,400 in English, 12.400 in Indonesian), Rupiah with two decimals (Rp 1.890.420,25).

The chart colors are tokens with 3:1 contrast on background and card. Neighboring series, in their order, stay apart for color-blind readers; colors further apart in the order can look alike, which is why 4 or more series need direct labels. See Color.

React Vue Flutter Type Default Use
ChartContainer config ChartContainer :config colors from context.sosialoka.chart1… ChartConfig none Each series’ label and color, such as { color: "var(--chart-1)" }.
Recharts children Unovis children fl_chart BarChart, LineChart components none The chart itself.
ChartTooltipContent formatter formatter getTooltipItem function numbers in locale Formats a value, such as Rupiah.
ChartTooltipContent locale, ChartTable locale locale NumberFormat locale text en-GB How numbers read when there is no formatter, such as "id-ID" for 12.400.
ChartTable caption labelKey labelHeader data config format same Semantics label none The same numbers for screen readers. Always add it.
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import {
ChartContainer,
ChartLegend,
ChartLegendContent,
ChartTable,
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
} from "@/components/ui/chart"
const data = [
{ month: "Jun", spotify: 8200, youtube: 5100 },
{ month: "Jul", spotify: 9100, youtube: 5600 },
{ month: "Agu", spotify: 9800, youtube: 6900 },
{ month: "Sep", spotify: 10600, youtube: 7300 },
{ month: "Okt", spotify: 11300, youtube: 8100 },
{ month: "Nov", spotify: 12400, youtube: 8800 },
]
const config = {
spotify: { label: "Spotify", color: "var(--chart-1)" },
youtube: { label: "YouTube Music", color: "var(--chart-2)" },
} satisfies ChartConfig
const compact = (value: number) => new Intl.NumberFormat("id-ID", { notation: "compact" }).format(value)
export default function ChartDemo() {
return (
<Card className="w-full max-w-xl">
<CardHeader>
<CardTitle>Streaming per bulan</CardTitle>
<CardDescription>Jun–Nov 2026, semua rilis</CardDescription>
</CardHeader>
<CardContent>
<ChartContainer config={config} className="aspect-auto h-64 w-full">
<BarChart data={data} barGap={2}>
<CartesianGrid vertical={false} />
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
<YAxis tickLine={false} axisLine={false} tickMargin={8} width={48} tickFormatter={compact} />
<ChartTooltip cursor={false} content={<ChartTooltipContent locale="id-ID" />} />
<ChartLegend content={<ChartLegendContent />} />
<Bar dataKey="spotify" fill="var(--color-spotify)" radius={[4, 4, 0, 0]} maxBarSize={20} />
<Bar dataKey="youtube" fill="var(--color-youtube)" radius={[4, 4, 0, 0]} maxBarSize={20} />
</BarChart>
</ChartContainer>
<ChartTable locale="id-ID" caption="Streaming per bulan, Jun–Nov 2026" labelHeader="Bulan" labelKey="month" data={data} config={config} />
</CardContent>
</Card>
)
}
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { ChartContainer, ChartTable, ChartTooltip, ChartTooltipContent, type ChartConfig } from "@/components/ui/chart"
const data = [
{ month: "Jun", revenue: 1250000 },
{ month: "Jul", revenue: 1418500.5 },
{ month: "Agu", revenue: 1377250 },
{ month: "Sep", revenue: 1602000.75 },
{ month: "Okt", revenue: 1745300 },
{ month: "Nov", revenue: 1890420.25 },
]
const config = { revenue: { label: "Pendapatan" , color: "var(--chart-1)" } } satisfies ChartConfig
const rupiah = (value: unknown) =>
new Intl.NumberFormat("id-ID", { style: "currency", currency: "IDR", minimumFractionDigits: 2 }).format(Number(value))
const compact = (value: number) => new Intl.NumberFormat("id-ID", { notation: "compact" }).format(value)
export default function ChartLineDemo() {
return (
<Card className="w-full max-w-xl">
<CardHeader>
<CardTitle>Pendapatan royalti</CardTitle>
<CardDescription>Jun–Nov 2026, dalam Rupiah</CardDescription>
</CardHeader>
<CardContent>
<ChartContainer config={config} className="aspect-auto h-56 w-full">
<LineChart data={data} margin={{ right: 8 }}>
<CartesianGrid vertical={false} />
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} />
<YAxis tickLine={false} axisLine={false} tickMargin={8} width={48} tickFormatter={compact} />
<ChartTooltip cursor={false} content={<ChartTooltipContent formatter={(value) => rupiah(value)} hideIndicator />} />
<Line dataKey="revenue" type="monotone" stroke="var(--color-revenue)" strokeWidth={2} dot={false} activeDot={{ r: 4, strokeWidth: 2 }} />
</LineChart>
</ChartContainer>
<ChartTable caption="Pendapatan royalti, Jun–Nov 2026" labelHeader="Bulan" labelKey="month" data={data} config={config} format={rupiah} />
</CardContent>
</Card>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/chart.json

React draws with Recharts and Vue with Unovis; Flutter uses fl_chart.

  • Every chart has a text alternative: ChartTable renders a visually hidden table with the same numbers, and Flutter wraps the chart in a Semantics label that reads them.
  • The drawing is hidden from screen readers and kept out of the tab order, so the table is the one source.
  • The tooltip is never the only place a number lives.
  • A legend names the series whenever there are two or more, so color is never the only way to tell them apart.

Cover Clearance draws its charts with ApexCharts today. When a screen moves to this design system, its charts move to Chart: same data, the chart-n colors, and a ChartTable.