Kinetik UI

Line Chart

.md

A smooth line chart that draws itself in; drag across it and a guide, a dot and a label follow the finger.

v1.0.0Live on web@shopify/react-native-skiareact-native-gesture-handlerreact-native-reanimatedreact-native-worklets
Component preview

Installation

Kinetik CLI
npx kinetik-ui add line-chart

The CLI copies the source and installs native dependencies with npx expo install, so versions match your Expo SDK. With shadcn: npx shadcn@latest add https://kinetik-ui.dev/r/line-chart.json

Install manually

  1. Install dependencies
    npx expo install @shopify/react-native-skia react-native-gesture-handler react-native-reanimated react-native-worklets
  2. Copy the source files
    • components/kinetik/line-chart.tsx
    View source files

Usage

import { LineChart } from '@/components/kinetik/line-chart';

<LineChart
  accessibilityLabel="Revenue, last 12 months"
  data={revenue}
  labels={months}
  formatValue={(v) => `$${(v / 1000).toFixed(1)}k`}
  onScrub={(i) => setFocus(i)}
/>;

The chart fills its parent's width. The curve passes through every value without overshooting, so a dip never draws below its real number. onScrub reports the index under the finger (and null when it lifts), which is handy for a headline figure above the chart.

When to use

  • Trends over time: revenue, steps, heart rate, prices.
  • Dashboards where people want to read the exact value at a moment.

When not to use

  • Comparing separate categories. Use Bar Chart.
  • Dense data with thousands of points; down-sample first.

Notes

  • The line draws in whenever the data changes, with the area revealed behind it.
  • The latest point pulses a few times after the line draws in, a quiet "this is live", then rests so a chart on screen costs no frames.
  • Screen readers step through the points with the adjustable increment and decrement actions.

Props

LineChartProps

PropTypeDefaultDescription
datarequiredreadonly number[]—Values, oldest first. At least two.
accessibilityLabelrequiredstring—A summary of what the chart shows, e.g. "Revenue, last 12 months".
labelsreadonly string[]—One label per value (dates, months). Shown while scrubbing and under the chart's ends.
heightnumber200Height of the chart. Defaults to 200.
colorstring—Line colour. Defaults to the theme ember.
areabooleantrueFill the area under the line with a fading gradient. Defaults to true.
formatValue(value: number) => string(v) => String(Math.round(v * 100) / 100)
onScrub(index: number | null) => void—Called with the index under the finger, and null when it lifts.
hapticsbooleantrueA tick as the finger moves from point to point. Defaults to true.
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
The curve is built once per data change; drawing in, scrubbing and three pulses of the latest point are shared values read by one Skia canvas. Nothing is drawn at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 1.05× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 162 MB app memory. Pulses three times after drawing in, then draws nothing at rest (0 frames in 5 s). It used to pulse forever.

Real-device measurement pending.

Accessibility

Reduced motion
The line appears complete, without drawing in, and the latest point does not pulse.
Screen readers
Adjustable: swipe up and down to step through the points; each reads its label and value.
Touch target
The whole chart is the scrub area.

Source files

components/kinetik/line-chart.tsx is in the Code tab of the preview above.