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.
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
priceScalePan on your own axis-gutter view with GestureDetector. Keeping that gesture
outside the chart lets you choose its hit area and compose it with the rest of your screen.
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. - While the SharedValue changes, the displayed range tracks it without frame-lag. Once it stops,
ordinary live-data changes use the chart’s configured
smoothingagain. - Reset with an animation such as
withTiming(1)for the same smooth result whether the current scale is above or below1. - On a
nonNegativechart, zoom-out stops when the lower bound reaches0. 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. maxValueis 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.
yRangeScale changes the value range only. It composes with timeScroll and zoom,
which control the visible time window.