Line chart
Compare measured time series with scrubbing, keyed transitions and optional areas.
npx @swipeui/cli add line-chartWhen to use it
- Compare measured time series with scrubbing, keyed transitions and optional areas.
When not to use it
- Use Metric card when one headline number answers the question without a full plot.
Installation
Installs with a Pro licence
Everything on this page is public except the source. Founder pre-sale opens around 5 January 2027.
Usage
import { LineChart } from '@/components/swipeui/chart/line-chart';
<LineChart
label="Revenue"
series={[
{
id: 'sales',
label: 'Sales',
data: [
{ id: 'mon', x: 1, y: 120, label: 'Mon' },
{ id: 'tue', x: 2, y: 150, label: 'Tue' },
],
},
]}
/>;Examples
revenue, area, ticker, watchlist, detail. App and public preview use the same original scenario data; ticker symbols, companies and prices are invented. Range and feature controls stay outside the component.
- ticker:
MarketTicker, an auto-scrolling strip of quote tiles with a morphing play/pause button. - watchlist: rows with a symbol and company, a small fading trend against a dashed previous close, the price, and a change pill at the bottom right that switches between the change and the percentage.
- detail: one quote with a range picker, a large price chart with a scrub head, prices on the right and time guides, and stat columns that scroll sideways.
Price detail
<LineChart
label="ORBT today"
series={[{ id: 'orbt', label: 'ORBT', data: points }]}
area
areaStyle="fade"
trendColor
yAxisSide="end"
verticalGrid
scrubHead
referenceValue={previousClose}
legend={false}
height={280}
/>Press and drag on the plot: the scrub head rides the time and price above the plot, over a solid rule with a dot on the line. The space above the plot is kept so nothing jumps.
Ticker
import { MarketTicker } from '@/components/swipeui/chart/market-ticker';
<MarketTicker label="Market movers" items={quotes} onItemPress={(quote) => openQuote(quote.id)} />;Each item has an id, label, value, signed change, data and an optional referenceValue. The strip moves one transform per frame on the UI thread, so tiles never redraw while they travel. It loops without a seam, pauses while held and from its morphing play/pause button, and stops offscreen and in the background. Reduce Motion or a running screen reader shows a still row that scrolls by hand. It installs Sparkline for the tile trends.
| Prop | Default | Behaviour |
|---|---|---|
items | — | Quotes in reading order. |
label | — | Accessible name of the strip. |
speed | 28 | Travel speed in points per second. |
paused / defaultPaused / onPausedChange | false | Controlled or uncontrolled pause state. |
pauseOnPress | true | Hold a finger on the strip to stop it. |
pauseControl | true | Show the play/pause button. Moving content needs a way to stop it. |
direction | start | Travel toward the start or the end edge. |
gap | 12 | Space between tiles. |
itemWidth | 216 | Width of each tile. |
onItemPress | — | Called with a tapped quote. |
renderItem | built-in tile | Replace the tile. |
formatValue / locale | device locale | Value formatting. |
messages | Pause / Play | Strings for the control. |
motion | — | Inherited motion feel. |
active | true | Stop on hidden routes. |
Settings
| Prop | Default | Behaviour |
|---|---|---|
tooltipPlacement | plot | Place inspection inside the plot or above it. |
tooltipWidth | 184 | Readout width bounded by the visible plot. |
renderTooltip | default card | Custom inspection content; streamgraph supplies a coloured multi-row comparison. |
dismissOnOutsidePress | true | Clear floating inspection when touching outside a chart under ChartInteractionProvider. |
series | — | Identified series with ascending, distinct x values. |
curve | 'smooth' | Monotone smooth curves or straight segments. |
area | false | A wash below the first line. |
markers | false | Show observed-point dots. |
referenceValue | — | Horizontal comparison guide. |
grid | true | Draw horizontal guides. |
xAxis | true | Show category labels. |
yAxis | true | Show numeric ticks. |
yAxisSide | start | Put the numeric ticks on the start or end edge. |
areaStyle | wash | wash fills to zero; fade fits the scale to the data and fades out toward the bottom. |
trendColor | false | Tint a rising first series green and a falling one red. |
verticalGrid | false | Vertical guides at the labelled observations. |
scrubHead | false | Ride the selected label and values above the plot on a rule with a dot, instead of the floating card. |
hiddenSeries | — | Controlled invisible series IDs. |
defaultHiddenSeries | [] | Initially invisible series. |
onHiddenSeriesChange | — | Changes to series visibility. |
label | — | Short accessible chart name. |
summary | — | Written description of the pattern, in the caller's words. |
loading | false | Show shimmer placeholders and expose the busy state. |
invalid | false | Explicitly unavailable dataset. |
interactive | true | Enable plot interaction and accessible value stepping. |
tooltip | true | Compact floating value card over the selected observation. |
legend | true | Show a labelled series/category key. |
legendPosition | 'bottom' | Put the key under the plot or 'top' above it. |
haptics | true | Tick when a different observation is selected. |
reveal | true | Reveal geometry on first appearance. |
animateData | true | Morph data changes; resize snaps. |
active | true | Pause ambient effects on hidden routes. |
selectedId | — | Controlled observation ID; null clears selection. |
defaultSelectedId | null | Initial observation when uncontrolled. |
onSelectionChange | — | Called only when semantic selection changes. |
locale | — | Device locale unless overridden. |
formatValue | — | Override value formatting. |
messages | — | Translatable built-in strings. |
motion | — | Inherited SwipeUI motion feel. |
height | 208 | Plot height in points; text flows outside it. |
className | — | Root class escape hatch. |
style | — | Root native layout escape hatch. |
testID | — | Stable root identifier. |
Accessibility
The plot exposes its name, summary and original values. Accessible value stepping and labelled keys supplement touch. Decorative marks do not repeat the readout. Reduced motion removes geometry travel.
Layout and data
Measure from the parent; let labels and keys wrap. Use stable IDs. Missing observations are gaps, not zeros. Parts of a whole and flows require nonnegative finite values. Native runtime, screen-reader, haptic and device-performance checks remain pending.
Outside dismissal
Wrap the app or chart screen in ChartInteractionProvider from @/components/swipeui/lib/chart-core. It observes native touches without taking the responder; controls keep their normal behaviour. dismissOnOutsidePress={false} retains a caller-managed selection. Browser demonstrations use pointer observation and Escape.
Behavior and gestures
- Select a labelled observation by touch or accessible value stepping. The caller can control the selection.
- Data changes animate independently from reveal, selection feedback and optional ambient effects.
- Finance options, each independent: yAxisSide='end' puts prices on the right, areaStyle='fade' fits the scale to the data and fades the area out, trendColor tints a rising price green and a falling one red, verticalGrid adds guides at the time labels, and scrubHead rides the selected time and price above the plot on a solid rule with a dot on the line.
- MarketTicker: a strip of quote tiles that glides on its own, loops without a seam, pauses while held and from a morphing play/pause button, and stops offscreen and in the background.
Accessibility
- The chart has a written summary and named values. Decorative SVG geometry is hidden from assistive technologies.
- Value stepping, labelled legends and text readouts supplement colour. Native screen-reader runtime validation remains pending.
- MarketTicker reads each quote once (the looping copy is hidden), labels its pause/play button, and shows a still, scrollable row under Reduce Motion or a running screen reader.
Motion
- Uses the
morph,selectandambientmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Geometry transitions use the shared morph role; reduced motion swaps immediately.
- Ambient effects pause offscreen and in the background.
Performance
- Display geometry is bounded for time series; selection retains original data. Native device performance is not yet verified.
Notes for AI
- Use stable IDs and caller-owned data/state. Provide an accessible label and a useful written summary.
- Use ChartCard for an interactive chart composition; keep MetricCard sparkline content decorative.
- Finance demos use invented symbols, companies and prices; never ship real market data without a licensed feed.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.