Skip to main content
Experimental. yRangeScale is available on LiveChart (line and candle modes) and LiveChartSeries. Opt into the built-in gesture with yAxis={{ scaleGesture: true }}.
LiveChart normally fits its Y-axis to the visible data. Pass a SharedValue<number> through yRangeScale to multiply that fitted range around its midpoint: 1 keeps auto-fit, values above 1 show more vertical range, and values between 0 and 1 zoom in. Static single-series charts also re-settle when the multiplier changes without replacing their data. minRange controls the fitted floor first; this manual multiplier applies afterward and can zoom below it.
Live example: app/demo/y-range-scale.tsx includes line/candle/multi-series toggles, preset buttons, a draggable price gutter, and double-tap reset. Turn on Zero floor and choose 8× to see how a nonNegative chart stops its zoom-out at 0.

Drag the price gutter to stretch or compress the fitted Y-range

Built-in price-axis gesture

Drag the price axis down to show more range, or up to zoom in. Double-tap it to animate back to auto-fit. The target follows the actual gutter, font, canvas size, left-side inset, and right-anchored label column. On single-series floating axes it follows the measured label column. Touches below the price plot, including candle volume and time labels, are excluded. Axis touches take priority over scrubbing, time scrolling, pinch zoom, and a parent’s scrolling. Start those gestures in the plot or time axis as usual. Interactive markers and reference-line badges retain their tap/drag priority. A scale drag remains owned by the axis even if the finger moves into the plot. Two-finger gestures should start in the plot.
These are the default options. The multiplier changes exponentially by startScale * exp(translationY / dragDistance); a larger dragDistance makes scaling less sensitive. All three numeric options must be positive and finite; invalid values use their defaults, and a maxScale below minScale is raised to minScale. Double-tap animates over 240 ms to 1, clamped to these bounds. Bounds apply to gesture writes, not programmatic writes to yRangeScale. When yRangeScale is omitted, each mounted chart keeps its own multiplier, initially 1. Disabling scaleGesture or hiding the axis stops gesture handling without resetting that multiplier. Use double-tap reset, a supplied SharedValue, or remount the chart to reset it. Left-side axes still require the caller to reserve label space with insets.left. float keeps its existing single-series behavior; it does not add floating-axis rendering to LiveChartSeries.

Custom controls

yRangeScale still works independently of the axis gesture. Leave scaleGesture off to drive the multiplier from buttons, sliders, or your own GestureDetector. If a custom control needs chart geometry, use the existing renderOverlay bridge; the built-in gesture does not require an overlay or a mirrored plot rectangle.

Behavior

  • The multiplier is applied after the normal margin and minimum-range fit, so auto-fit continues tracking the visible data while scaled.
  • On LiveChartSeries, the multiplier applies to the shared range after hidden series are excluded.
  • Series strokes, area fills, candles, and gap bridges are clipped to the price plot’s top and bottom, so zoomed-in data cannot cover the time-axis labels. Candle volume bars keep their automatically reserved band below the price plot; an explicit bottom inset keeps its existing layout override. Live dots, pulses, badges, and other overlays retain their own placement.
  • While the SharedValue changes, the displayed range tracks it without frame-lag. Once it stops, ordinary range changes use smoothing or the optional rangeAnimation overrides.
  • Reset with an animation such as withTiming(1) for the same smooth result whether the current scale is above or below 1.
  • On a nonNegative chart, zoom-out stops when the lower bound reaches 0. The upper bound does not keep growing after the floor is reached, so the values remain centered instead of being pinned to the bottom of the plot.
  • maxValue is applied after scaling, so that hard ceiling still wins.
  • Values must be positive and finite. Invalid values safely behave as 1; clamp gesture output to a product-appropriate range as shown above.
  • With priceScroll, a scaled axis arms the vertical price pan. Once the price window has been panned, an axis drag scales that window in place around its midpoint by the same step the multiplier takes, so the minScale / maxScale bounds still hold overall. The double tap then clears the panned window as well as the multiplier, and the floating resetButton does the same.
yRangeScale changes the value range only. It composes with timeScroll and zoom, which control the visible time window.

Animating automatic range changes

By default, both charts snap outward bounds immediately and ease inward bounds with smoothing. Opt into outward easing with rangeAnimation={{ animateExpansion: true }}. This also applies when a reference line enters the fit, without changing recorded values or moving the time window. For separate speeds, use the exported RangeAnimationConfig:
The return speed applies directly to contraction on the UI thread, so release needs no timer or temporary change to global smoothing. It also applies to other inward fits while configured. Omitted direction speeds inherit smoothing; expansionSmoothing only takes effect while animateExpansion is true. Each bound chooses its own direction, so one can expand while the other contracts. Finite speeds clamp to 0..1; non-finite speeds inherit smoothing. On initial fitting or a data change that moves the fitted range wholly above or below the displayed range, contraction is limited to the animated expansion speed until the ranges overlap. This keeps the Y-axis bounds ordered even with very slow or frozen expansion; normal independent speeds resume once the ranges overlap. These speeds are frame-rate-independent exponential easing fractions, not fixed durations. The 300 ms calculation assumes a stationary target; live data can continue moving the fit. smoothing={1} takes precedence over the overrides, as do snapKey changes, static mode, and active manual yRangeScale dragging. For reduced motion, use smoothing={1} and configure axis-label fades with metrics={{ grid: { fadeInSpeed: 1, fadeOutSpeed: 1 } }} as needed. Axis-label alpha transitions remain controlled by metrics.grid.fadeInSpeed and fadeOutSpeed. The chart, reference lines, and overlays using ChartOverlayContext.scale share the interpolated bounds throughout expansion and contraction. transitions continues to control reveal/mode changes separately.