Skip to content

Chart ​

Beautiful charts drawn natively with ArkUI Path shapes, styled with the chart-1…5 tokens. Describe series once with SparkChartConfig; every chart measures its own width, thins its labels, animates in with motion key "chart", and shows a shadcn tooltip on hover, tap or horizontal pan.

Usage ​

Approximate web preview — the HarmonyOS rendering is the reference.

Responsive ​

No breakpoints: cartesian charts default to a 16:9 box of their own width (160–320vp), skip category labels that would overlap and adapt the number of value ticks to the height.

Sparkline ​

A tiny inline trend for stat cards and table cells.

Approximate web preview — the HarmonyOS rendering is the reference.

Empty state ​

SChartContainer({ empty }) shows a muted placeholder.

Approximate web preview — the HarmonyOS rendering is the reference.

API ​

Extracted from the @Param / @Event / @BuilderParam declarations in the library sources.

SChartContainer ​

shadcn ChartContainer: card-friendly frame around one or more charts. Shares series visibility with the charts inside it (SparkContext), renders the legend (legend, tap to toggle) and an empty state. It measures its own width: the legend tightens when the container is narrow.

PropTypeDefaultDescription
configSparkChartConfignew SparkChartConfig([])
legendbooleanfalse
legendPlacementSparkChartLegendPlacement
SparkChartLegendPlacement = 'top' | 'bottom'
'bottom'
legendTogglebooleantruelegend entries toggle their series
emptybooleanfalseshow the empty state instead of the content
emptyTextResourceStr$r('app.string.spark_no_data')
emptyHeightnumber200

Slots: children (trailing closure)

SChartLegend ​

shadcn ChartLegend + ChartLegendContent: centred, wrapping row of swatches. With interactive, tapping an entry hides / shows that series (shared through state).

PropTypeDefaultDescription
configSparkChartConfignew SparkChartConfig([])
stateSparkChartState | undefinedundefined
keysstring[] | undefinedundefinedkeys to list (default: every series of the config); pie charts pass their slice keys
interactivebooleantrue
compactbooleanfalse

SChartTooltipCard ​

shadcn ChartTooltipContent: label + one row per series (indicator, name, value).

PropTypeDefaultDescription
titlestring''
itemsSparkChartTooltipItem[][]
indicatorSparkChartIndicator
SparkChartIndicator = 'dot' | 'line' | 'dashed'
'dot'

SChartEmpty ​

Muted "no data" block.

PropTypeDefaultDescription
textResourceStr$r('app.string.spark_no_data')
boxHeightnumber200

SSparkline ​

Tiny inline trend line (no axes, no tooltip) — e.g. inside a stat card or a table cell. Fills the width it gets; the value range is the data extent (not forced through 0). Draws in like the other charts.

PropTypeDefaultDescription
valuesnumber[][]
colorstring'chart-1'token name ('chart-1', 'primary' …) or '#hex'
filledbooleantrue
curveSparkChartCurve
SparkChartCurve = 'linear' | 'monotone' | 'step'
'monotone'
chartHeightnumber32
lineWidthnumber1.5
endDotbooleanfalsedot on the last value

MIT Licensed