Kinetik UI

Stream Graph

.md

Layered streams on a centred baseline that morph between datasets; tap a layer to lift it and read its share.

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

Installation

Kinetik CLI
npx kinetik-ui add stream-graph

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/stream-graph.json

Install manually

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

Usage

import { StreamGraph } from '@/components/kinetik/stream-graph';

<StreamGraph
  accessibilityLabel="Hours of listening by genre"
  layers={[
    { key: 'pop', label: 'Pop', values: [32, 38, 35, 42] },
    { key: 'jazz', label: 'Jazz', values: [12, 14, 18, 16] },
  ]}
  formatValue={(v) => `${Math.round(v)} h`}
/>;

When to use

  • How a whole is made up over time, when the overall flow matters more than exact values: listening by genre, traffic by source.
  • Switching between periods or segments, where the morph shows what changed.

When not to use

  • Exact comparisons between layers. Use Bar Chart or Line Chart.
  • Data with negative values. Streams can only stack amounts.

Notes

  • Layers stack around a centred baseline and are smoothed with Catmull-Rom curves. Every layer needs the same number of values.
  • New data morphs each shape into place; the first draw grows out of the middle line.
  • Tap a layer, or its key, to isolate it: the others fade and the readout shows its total and share. Tap again to let go.
  • Data is compared by value, so passing a new but equal array does not replay the morph.

Props

StreamGraphProps

PropTypeDefaultDescription
layersrequiredreadonly StreamLayer[]—
accessibilityLabelrequiredstring—What the graph shows, e.g. "Listening by genre".
heightnumber200Plot height. Defaults to 200.
formatValue(value: number) => string(v) => String(Math.round(v))Formats totals in the readout and for screen readers.
hapticsbooleantrueA tick when a layer is isolated. Defaults to true.
testIDstring—
styleStyleProp<ViewStyle>—

Performance and accessibility

Performance

Budget
One Skia canvas, one path per layer; a morph interpolates the paths on the UI thread. Shapes are built once per dataset. Nothing runs at rest.
Measured

Pixel 9 emulator, API 35, release build · interaction median 1.00× the system Settings app on the same emulator (indicative only) · no frames drawn at rest · 147 MB app memory

Real-device measurement pending.

Accessibility

Reduced motion
New data replaces the shapes at once; isolating a layer still fades the others.
Screen readers
The graph is an image that reads each layer's total; each key is a button with a selected state.
Touch target
The keys are 44 pt tall; the whole graph can be tapped.

Source files

components/kinetik/stream-graph.tsx is in the Code tab of the preview above.