Skip to main content

Charts Pro

Fifteen charts for phones and the web, from one codebase. They take rows of data the way recharts and shadcn's charts do ({ month: 'Jan', revenue: 120 }), so moving data in is a rename, and they move: they grow in on mount and glide to new values when your data changes, so a live feed looks alive instead of flickering.

import {
AreaChart, BarChart, ComboChart, DonutChart, FunnelChart, GaugeChart, HeatmapChart, LineChart,
PieChart, RadarChart, RadialChart, SankeyChart, ScatterChart, Sparkline, StatusTracker,
} from '@patine-ui/pro';

Charts are part of Patine Pro and draw with react-native-svg, an optional peer that runs in Expo Go and on the web: npx expo install react-native-svg. Everything else in Patine needs no peer at all.

ChartUse it forPage
LineChart, AreaChartTrends over time; stacked and 100% areas, forecastsLine & Area
BarChartComparing categories; grouped, stacked, 100%, horizontal, with goalsBar
ComboChartBars and lines together, with a second axisCombo
PieChart, DonutChartParts of a whole; half donutsPie & Donut
RadialChartProgress toward goals, as activity ringsRadial
GaugeChartOne value against its rangeGauge
HeatmapChartActivity per day, as a contribution calendarHeatmap
ScatterChartHow two measures relate; bubbles, trend lineScatter & Bubble
FunnelChartConversion through stagesFunnel
SankeyChartWhere an amount goes: income into spending, traffic into pagesSankey
RadarChartSeveral measures of a few thingsRadar
SparklineA small trend beside a numberSparkline
StatusTrackerUptime or health per periodStatus tracker

What every chart does​

  • Moves with your data: bars grow, lines glide, slices turn and rings fill to new values; nothing animates when the OS asks to reduce motion, or with animate={false}.
  • Reads under the finger: drag across a chart on a phone to scrub it, hover on the web, or focus it and use the arrow keys, Home, End and Escape. onPointSelect hears every move (and null when the cursor leaves): call your haptics there, or show the value in a header. renderTooltip draws your own tooltip.
  • Legend toggles: press a legend item to turn its series off and on; the last one showing stays on. defaultHidden starts some off.
  • Formats values: valueFormat="currency" (with currency), "percent" (values are fractions), "compact" or "number"; axes get the short form ($1.2K), tooltips the full one ($1,234.50). valueFormatter takes over entirely.
  • Has states: loading shows a pulsing placeholder, error a message, and no data emptyLabel.
  • Readable without color: each series has its own marker shape in the legend and tooltip, and the palette (the theme's primary, then its colour-blind-safe theme.chart series colours) is nudged to 3:1 contrast against the background, light or dark.
  • Read aloud: a chart is one image to a screen reader, named by your accessibilityLabel and a summary generated from the data: the range, the highest and lowest values and the trend (or shares, conversion, correlation).
  • Right to left: in an RTL app (or with rtl) time runs leftward and the value axis swaps sides.
  • Follows the design: Swift Charts' hairline grid and trailing value axis on iOS, Material 3's baseline and fully rounded bars, the web's dashed grid, and Patine's brand look; light and dark.
  • Fits its container: it measures its width on layout; pass width to fix it, and height for the drawing.

Shared props​

PropTypeDefaultDescription
dataobject[]—One row per x value (or slice, ring, stage, day).
heightnumber240The drawing's height; the legend sits outside it.
widthnumberfills the container
showLegendbooleanmore than one series
legendPosition'top' | 'bottom''bottom'
showTooltipbooleantrueAlso turns off scrubbing and keyboard focus.
renderTooltip(readout) => ReactNode—Your own tooltip from { title, items, x, y }.
onPointSelect(selection | null) => void—{ index, row, label } on each move of the cursor.
valueFormat'number' | 'compact' | 'currency' | 'percent''number'
currencystring'USD'For valueFormat="currency".
valueFormatter(value: number) => string—Wins over valueFormat, on axes too.
loadingbooleanfalseA pulsing placeholder.
errorstring—Shown in place of the drawing.
emptyLabelstring'No data'Shown when there's nothing to draw.
rtlbooleanthe app's direction
accessibilityLabelstring—The chart's title for screen readers.
animatebooleantrueGrow in and glide to new data.
styleStyleProp<ViewStyle>—
theme / designprovider's

Cartesian props​

Line, area, bar and combo charts also take:

PropTypeDefaultDescription
xKeystring—The row field on the x axis: categories, numbers or Dates (a time axis).
series{ key, label?, color?, dashed?, dashFrom? }[]—Colors come from the theme's validated palette unless you set them.
grid'value' | 'category' | 'both' | 'none''value'Which gridlines; showGrid={false} is 'none'.
showXAxis / showYAxisbooleantrue
minValue / maxValuenumberfrom the dataPin the value axis's ends.
tickCountnumberone per 44pxAbout this many value ticks.
referenceLines{ value, label?, color?, dashed? }[]—Lines at values: a target, an average, a limit.
referenceBands{ from, to, label?, color? }[]—Shaded ranges: a target zone, normal limits.
defaultHiddenstring[]—Series keys turned off at first.
xFormatter(x) => string—Formats x values on the axis and in the tooltip.

Haptics on scrub​

Patine has no native code, so it leaves the buzz to you: onPointSelect fires once per point as the finger crosses it.

import * as Haptics from 'expo-haptics';

<LineChart {...props} onPointSelect={(point) => point && Haptics.selectionAsync()} />;