About this animation
A React Native animated bar chart can combine overview and detail without opening a separate tooltip for every value. This statistics card grows its bars with a staggered entrance, rolls the selected total like an odometer, and lets a tap or horizontal drag explore each period. Gesture Handler maps the finger directly to a bar, while Reanimated keeps the selection, spring guide, fills, glow, and number transitions responsive on the UI thread. Use it for compact analytics, revenue summaries, activity history, or progress dashboards. Supply your own data and formatting function, customize active and muted colors, and control selection through a callback or ref. The component also formats its default values with American English grouping.
When to use it
- Explore monthly analytics in a compact card.
- Highlight a selected period while dragging.
- Animate updated dashboard data.
- Show positive and negative metric changes.
Related guides
A bar chart with growing bars, a rolling total, and draggable detail, with configurable data, headings, bar color, and fonts.
Why this one
Most compact bar charts make every change feel like a page refresh. This one lets a finger scrub directly across the data, keeps a fine guide aligned with the active month, and rolls only the number characters that change. Bars also replay their staggered growth whenever the data prop changes, so live dashboards retain a polished entrance without extra orchestration.
How it works
- The component measures its own container and derives card, chart, bar, and type sizes from that space.
- A zero-distance pan gesture maps the finger's horizontal position to a bar, so a tap and a drag use the same interaction path.
- One shared selection value drives the active fills and glow, while a spring keeps the vertical guide fluid and interruptible.
- Each bar grows from its bottom edge with a 40 ms stagger and restarts when its normalized value changes.
- The selected value is formatted with
Intl.NumberFormat('en-US'); each character commits with its animation reset inuseLayoutEffectto avoid stale frames.
Install
npx expo install react-native-gesture-handler react-native-reanimated react-native-workletsUsage
import CountingBarChart from './CountingBarChart';
const data = [
{ label: 'January', value: 42480 },
{ label: 'February', value: 51620 },
{ label: 'March', value: 47890 },
{ label: 'April', value: 63840 },
{ label: 'May', value: 71240 },
{ label: 'June', value: 77318 },
];
export function AnalyticsScreen() {
return <CountingBarChart data={data} />;
}Add metrics, brand colors, fonts, and external control:
import { useRef } from 'react';
import CountingBarChart, { type CountingBarChartRef } from './CountingBarChart';
export function DetailedAnalytics() {
const chartRef = useRef<CountingBarChartRef>(null);
return (
<CountingBarChart
ref={chartRef}
data={monthlyData}
caption="Growth overview"
barColor="#376DE5"
mutedColor="#DFE7FA"
positiveColor="#188461"
negativeColor="#C94E4E"
fontFamily="YourSansFont"
numberFontFamily="YourNumberFont"
title={(datum) => `${datum.value.toLocaleString('en-US')} total`}
onSelect={(index) => trackMonth(index)}
/>
);
}The forwarded ref exposes select(index).
Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | BarDatum[] | Required | Monthly values and optional detail metrics. |
initialIndex | number | 0 | Initially selected bar. |
title | (datum: BarDatum) => string | undefined | Formats the large value for a datum. Defaults to en-US grouped digits. |
caption | string | 'Last 6 months' | Supporting label below the large value. |
barColor | string | '#2E9E7B' | Active bar and focus color. |
mutedColor | string | '#D7EEE6' | Inactive bar color. |
positiveColor | string | '#21845F' | Positive metric color. |
negativeColor | string | '#D45B54' | Negative metric color. |
fontFamily | string | undefined | Font family for labels and metrics. |
numberFontFamily | string | undefined | Font family for changing numbers. |
onSelect | (index: number) => void | undefined | Called when a different bar is selected. |
style | StyleProp<ViewStyle> | undefined | Optional style for the outer container. |
testID | string | undefined | Test identifier applied to the outer container. |
duration | number | 360 | Chart selection highlight fade duration in milliseconds. Spring physics and reduced-motion timing are unchanged. |
Compatibility
- Expo SDK 58
- React Native 0.88
- Reanimated 4.7 and Worklets 0.13
- iOS: supported
- Android: supported
- Web: supported
- Works in Expo Go because Gesture Handler, Reanimated, and Worklets are included in the SDK
Accessibility
The chart is exposed as an adjustable control. Screen readers hear the selected period and value, such as “June: 77,318 visitors,” and can move month by month with increment and decrement actions. Reduced Motion replaces rolling and spring movement with short fades and keeps bars fully visible.
FAQ
- Does the animated bar chart work in Expo Go?
- Yes. Gesture Handler, Reanimated, and Worklets are bundled with Expo SDK 58 and Expo SDK 57. It supports iOS, Android, and web. Each published piece is reviewed on physical iPhone and Android devices with Expo Go before release.
- Can I provide my own data and number format?
- Yes. Pass BarDatum values, choose the initial selection, and provide a title formatter. Colors, fonts, captions, callbacks, and imperative selection are configurable.
- How can screen-reader users explore the chart?
- The chart is an adjustable control that announces the selected period and value and supports increment and decrement actions. Reduce Motion replaces rolls and springs with short fades.




