Kinetik UI

Brush Chart

.md

A long series with an overview strip: drag the window or its handles and the chart above zooms to it.

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 brush-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/brush-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/brush-chart.tsx
    View source files

Usage

import { BrushChart } from '@/components/kinetik/brush-chart';

<BrushChart
  accessibilityLabel="Daily visitors"
  data={visitors}
  labels={dates}
  initialWindow={[0.7, 1]}
  onWindowChange={([from, to]) => load(from, to)}
/>;

When to use

  • Long time series where people need both the shape of the whole and the detail of a part: traffic, prices, sensor readings.
  • Dashboards where the visible range drives other figures, via onWindowChange.

When not to use

  • A handful of points. Use Line Chart or Bar Chart.
  • Comparing several series. Use Line Chart with a legend.

Notes

  • Drag inside the window to move it, pull either handle to zoom, or tap outside it to jump there.
  • The main chart is rebuilt on the UI thread from the window and rescales to the visible range; the overview is drawn once per size.
  • The readout shows the last visible value and the change across the window, and updates when the window settles. The range is an adjustable element: screen readers step it by half a window.
  • onWindowChange receives the first and last visible point indices when the window settles.

Props

BrushChartProps

PropTypeDefaultDescription
datarequiredreadonly number[]—The series, oldest first.
accessibilityLabelrequiredstring—What the series is, e.g. "Daily visitors".
labelsreadonly string[]—One label per point, e.g. dates. Defaults to the point numbers.
initialWindowreadonly [number, number][2 / 3, 1]The part shown at first, as fractions of the series. Defaults to the last third.
onWindowChange(range: [number, number]) => void—
formatValue(value: number) => string(v) => String(Math.round(v))Formats values in the readout and for screen readers.
heightnumber180Main chart height. Defaults to 180.
hapticsbooleantrueA tick when the window settles. Defaults to true.
testIDstring—
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
Two Skia canvases. The visible part is rebuilt on the UI thread while dragging; the overview path is built once per size. Nothing runs at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 0.94× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 163 MB app memory. Before the window stopped re-rendering React on every drag frame this was 32 ms median with 36% janky frames.

Real-device measurement pending.

Accessibility

Reduced motion
Screen reader steps move the window at once instead of springing.
Screen readers
The chart is an image that reads the visible range and its first and last values; the strip is an adjustable range.
Touch target
The whole strip is the target, 52 pt tall; handles respond 22 pt either side.

Source files

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