resetButton floats a control
inside the plot while the view differs from the fitted live view and hides it again once the
chart is back where it started. One tap returns the time window, the price scale and the price
offset together.
Scale and pan candles or lines, then restore the live view with the reset button. The same reset also clears pinch zoom.
Live example:
app/demo/reset-view.tsx
opens this guide’s demo directly.
app/demo/time-scroll.tsx
shares the same interaction controls, and
app/showcase/fomo-perps.tsx
shows the button in a product layout.Try it in the example app
Open Demos → Interaction → Reset view (also available under Time scroll). The demo starts with price panning set to After scale, pinch zoom on, and the reset button enabled, in candle mode.- Drag the price-axis labels vertically to scale the range and arm price panning.
- Drag vertically inside the plot to move its price window, or diagonally to pan time and price together. Pinch with two fingers to change the time window.
- Tap the floating reset button to restore the fitted live view. The Reset view
controls also expose
resetView()and let you hide or show the button. - Switch Chart type to Line to try the same interactions on a line chart.
What shows the button
The button appears while any of these is true, and fades out (default 160 ms) when none is:- the window is scrolled back in time (
timeScroll), - the window width was pinched (
zoom), - the price axis was scaled (
yRangeScalediffers from1), - the price window was panned (
priceScroll).
showFor:
Placement and look
The built-in button is a round glyph inpalette colors, sitting margin px inside the plot
rect and clear of the price-axis gutter and the time labels.
scrubAction.icon and marker icons. If your font lacks the
default "↺", pass a glyph it has, or render your own button.
Custom button
renderResetButton replaces the visual only. The chart keeps the placement, the visibility and
fade, and the tap, so return a plain view, not a pressable. The element is measured with
onLayout, so any size works. Wire reset to onAccessibilityTap on iOS and an
activate accessibility action on Android so screen readers can activate it;
visible is a SharedValue you can use for your own animation. The built-in
button handles both platforms.
useCallback) so the chart’s memoized overlay does not re-render
each frame.
resetView() from outside
Both charts expose resetView() on the LiveChartHandle.
It runs on the UI thread and is safe when the view is already fitted:
- The pinch window is cleared and the right edge glides back to live with the
returnToLivetiming (instant whenreturnToLiveisfalse). - A price range written by
priceScrollor the axis-scale gesture is cleared.yRangeScalelands on1in one step in that case, so the display range eases from the panned window to the fit instead of jumping; without a panned range it animates to1over 240 ms, as the axis double tap does. - An app-written
viewport.rangeis left alone, as withresetZoom(). A later app write, includingmodify(), or a replacementviewport.rangegives ownership back to the app after a price pan. onResetViewfires on the JS thread after the reset overrides have been applied on the UI thread, for both button taps andresetView(). Return animations may still be running.
LiveChartSeries, resetView() is resetZoom() plus the eased yRangeScale reset.
Notes
- Gesture order. The button’s tap is composed ahead of the plot gestures and claims only touches that land on the visible button, so it never delays scrub, time-scroll, price pan or pinch.
- Hidden means hidden. While the button is faded out it is not focusable by screen readers and does not receive touches.
- Timeframe changes. A
snapKeyormodechange re-frames the chart and clears a gesture-written price range, so the button hides on its own.