Package Exports
- react-native-nitro-charts
Readme
react-native-nitro-charts
High-performance chart primitives for Expo and React Native, built with Skia, D3, and Nitro.
react-native-nitro-charts gives you ready-to-use chart components plus headless geometry utilities when you need to build your own chart interactions or layouts.
Features
- Skia-powered rendering
- Hooks-first API for derived geometry
- Interactive line, area, bar, and donut charts
- Native Nitro engine for hot paths on iOS and Android
- TypeScript fallback engine for web and unsupported native environments
- Headless helpers for custom chart experiences
Installation
Install the package and its required peers:
bun add react-native-nitro-charts @shopify/react-native-skia react-native-nitro-modules d3-array d3-scale d3-shapeIf you use npm:
npm install react-native-nitro-charts @shopify/react-native-skia react-native-nitro-modules d3-array d3-scale d3-shapePeer dependencies
exporeactreact-native@shopify/react-native-skia
Native builds
On iOS and Android, the package will use the Nitro-native engine when available. If the native engine is not available, it falls back to the TypeScript implementation.
For managed Expo apps, use a development build when you want the native path available.
Quick Start
import * as React from 'react';
import { View } from 'react-native';
import { LineChart } from 'react-native-nitro-charts';
const series = Array.from({ length: 120 }, (_, index) => ({
timestamp: index,
value: 100 + Math.sin(index / 10) * 18,
}));
export function RevenueChart() {
const [active, setActive] = React.useState<(typeof series)[number] | null>(null);
return (
<View>
<LineChart
data={series}
xKey="timestamp"
yKey="value"
width={720}
height={280}
color="#14b8a6"
downsampleTo={400}
onActivePointChange={(datum) => setActive(datum)}
/>
</View>
);
}Components
LineChart
Best for time-series and continuous numeric data.
Key props:
dataxKeyyKeywidthheightcolorstrokeWidthprogresspaddingdownsampleToonActivePointChange
AreaChart
Uses the same cartesian API as LineChart, but fills the area beneath the path.
BarChart
For categorical comparisons.
Key props:
datacategoryKeyvalueKeywidthheightselectedIndexprogresspaddingonBarPress
DonutChart
For part-to-whole visualizations.
Key props:
datawidthheightinnerRadiusouterRadiuspadAngleselectedIndexprogressonSlicePress
Hooks
useLineChart(props)
Returns computed line geometry:
pathpoints
useAreaChart(props)
Returns computed area geometry:
pathpoints
useBarChart(props)
Returns:
barsgetBarAt(x, y)
useDonutChart(props)
Returns:
slicesgetSliceAt(x, y)
useNearestPoint(props, x, y?)
Computes the nearest rendered point for a cartesian chart.
useChartPressState<T>()
Tiny helper for storing the currently active datum with React transitions.
Headless Utilities
The package also exports geometry helpers from headless/models for custom rendering and interaction layers:
computeLineGeometrycomputeAreaGeometrycomputeBarGeometrycomputeDonutGeometryfindNearestPointfindNearestBarfindNearestDonutSlice
These are useful when you want the chart math without the built-in components.
Engine Behavior
The exported chartEngine exposes:
downsampleSeriesfindNearestDatum
Engine names you may observe:
native-nitrotypescript-webtypescript-fallback
Development
From the repository root:
bun install
bun run build
bun test
bun run exampleContributing
See CONTRIBUTING.md for local setup, coding expectations, and pull request guidance.
License
MIT. See LICENSE.