This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
This is documentation for the next SDK version.
Chart A SwiftUI Chart component for displaying data visualizations using Swift Charts.
Expo UI Chart wraps Apple's Swift Charts framework, and supports rendering line, point, bar, area, pie, and rectangle charts with reference lines.
Installation
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui
If you are installing this in an existing React Native app , make sure to install expo in your project.
Usage
Line chart
import { Host , Chart } from '@expo/ui/swift-ui' ;
export default function LineChartExample ( ) {
return (
< Host style = { { flex: 1 } } >
< Chart
type = " line"
data = { [
{ x: 'Jan' , y: 15 } ,
{ x: 'Feb' , y: 25 } ,
{ x: 'Mar' , y: 18 } ,
{ x: 'Apr' , y: 32 } ,
] }
/>
</ Host >
) ;
}
Bar chart
import { Host , Chart } from '@expo/ui/swift-ui' ;
export default function BarChartExample ( ) {
return (
< Host style = { { flex: 1 } } >
< Chart
type = " bar"
data = { [
{ x: 'Q1' , y: 75 } ,
{ x: 'Q2' , y: 85 } ,
{ x: 'Q3' , y: 65 } ,
{ x: 'Q4' , y: 95 } ,
] }
showLegend
/>
</ Host >
) ;
}
Pie chart
Pie charts require iOS 17 and later, or tvOS 17 and later. On older versions, the chart shows no slices.
import { Host , Chart } from '@expo/ui/swift-ui' ;
export default function PieChartExample ( ) {
return (
< Host style = { { flex: 1 } } >
< Chart
type = " pie"
data = { [
{ x: 'Direct' , y: 45 } ,
{ x: 'Social' , y: 30 } ,
{ x: 'Email' , y: 25 } ,
] }
pieStyle = { { innerRadius: 0.5 , angularInset: 2 } }
showLegend
/>
</ Host >
) ;
}
Point and area charts
import { Host , Chart , VStack } from '@expo/ui/swift-ui' ;
import { frame } from '@expo/ui/swift-ui/modifiers' ;
const data = [
{ x: 0 , y: 10 } ,
{ x: 1.5 , y: 25 } ,
{ x: 3 , y: 18 } ,
{ x: 4.5 , y: 32 } ,
] ;
export default function PointAreaExample ( ) {
return (
< Host style = { { flex: 1 } } >
< VStack spacing = { 16 } >
< Chart
type = " point"
data = { data}
pointStyle = { { pointStyle: 'diamond' , pointSize: 8 } }
modifiers = { [ frame ( { height: 150 } ) ] }
/>
< Chart
type = " area"
data = { data}
areaStyle = { { color: '#10B981' } }
modifiers = { [ frame ( { height: 150 } ) ] }
/>
</ VStack >
</ Host >
) ;
}
Per-point colors
Set color on a data point to choose its color in bar, pie, point, and rectangle charts. line and area charts ignore it. In bar and pie charts, any per-point color turns off the automatic category colors and the legend.
import { Host , Chart } from '@expo/ui/swift-ui' ;
export default function PerPointColorExample ( ) {
return (
< Host style = { { flex: 1 } } >
< Chart
type = " bar"
data = { [
{ x: 'Mon' , y: 20 , color: '#4A90E2' } ,
{ x: 'Tue' , y: 22 , color: '#50C8D8' } ,
{ x: 'Wed' , y: 18 , color: '#5AD67D' } ,
] }
/>
</ Host >
) ;
}
Reference lines
Use referenceLines to draw a horizontal rule at each entry's y value, for example to highlight a target or average value. The chart does not draw an entry's x value, but each entry needs a unique x. Style the rules with ruleStyle.
ReferenceLinesExample.tsx import { Host , Chart } from '@expo/ui/swift-ui' ;
export default function ReferenceLinesExample ( ) {
return (
< Host style = { { flex: 1 } } >
< Chart
type = " line"
data = { [
{ x: 'Jan' , y: 15 } ,
{ x: 'Feb' , y: 25 } ,
{ x: 'Mar' , y: 18 } ,
{ x: 'Apr' , y: 32 } ,
] }
referenceLines = { [ { x: 'Average' , y: 22.5 } ] }
ruleStyle = { {
color: '#FF6B6B' ,
lineWidth: 2 ,
dashArray: [ 5 , 5 ] ,
} }
/>
</ Host >
) ;
}
Styling and animation
Pass showGrid, showLegend, and animate to control the chart's appearance, and use the per-type style props (lineStyle, barStyle, pieStyle, and so on) to customize individual mark types.
import { Host , Chart } from '@expo/ui/swift-ui' ;
export default function StyledChartExample ( ) {
return (
< Host style = { { flex: 1 } } >
< Chart
type = " line"
data = { [
{ x: 'Jan' , y: 15 } ,
{ x: 'Feb' , y: 25 } ,
{ x: 'Mar' , y: 18 } ,
{ x: 'Apr' , y: 32 } ,
] }
showGrid = { false }
animate = { false }
lineStyle = { {
color: '#6366F1' ,
width: 3 ,
dashArray: [ 5 , 5 ] ,
pointStyle: 'square' ,
pointSize: 8 ,
} }
/>
</ Host >
) ;
}
API
import { Chart } from '@expo/ui/swift-ui' ;
Component Type: React.Element < ChartProps & {
style: StyleProp< ViewStyle >
} >
Renders a native Chart component using Swift Charts.
Optional • Type: boolean
Whether to animate chart changes.
Optional • Type:
BarChartStyle Bar chart specific styling options.
Array of data points to display.
Optional • Type:
PieChartStyle Pie chart specific styling options.
Rectangle chart specific styling options.
Optional • Type:
ChartDataPoint[] Optional reference lines to overlay on the chart as rule marks.
Optional • Type: boolean
Whether to show grid lines.
Optional • Type: boolean
Whether to show chart legend.
Only works when individual dataPoint colors are NOT provided (uses categorical styling)
Useful for bar and pie charts (shows category colors)
Not applicable for line and area charts (single-series data)
If dataPoint has individual colors, legend won't appear - use data without colors to see legend
Types Area chart specific styling options.
Bar chart specific styling options.
Data point for the chart.
Literal type: string
The type of chart to display.
line charts show continuous lines with optional dash array, width, point symbols, and color.
point charts show discrete colored points with optional point style (circle, square, diamond) and size.
bar charts show vertical bars using system colors or individual ChartDataPoint colors, with optional corner radius and width styling.
area charts show filled areas under lines with color.
pie charts show pie slices with optional inner radius and angular inset. Pie charts require iOS 17.0+.
rectangle charts show rectangular data visualization.
Acceptable values are: 'line' | 'point' | 'bar' | 'area' | 'pie' | 'rectangle'
Line chart specific styling options.
Pie chart specific styling options.
Point chart specific styling options.
Literal type: string
Point symbol style options.
Acceptable values are: 'circle' | 'square' | 'diamond'