ChartZoomState class

Immutable zoom + pan state for one axis (X).

xStart and xEnd are normalised fractions of the full data range 0..1. The visible window is [xStart, xEnd].

Constructors

ChartZoomState({double xStart = 0, double xEnd = 1, double velocityX = 0, double minWindowFraction = 0.02})
factory

Properties

All breadcrumb labels from root to current level.
no setter
canPop bool
True when there is zoom history to pop back to.
no setter
currentLabel String?
Label of the current drill-down level (topmost history entry).
no setter
currentMetadata Map<String, dynamic>
Metadata stored with the current drill-down entry.
no setter
depth int
How many history levels deep we are (= drill-down depth).
no setter
hashCode int
The hash code for this object.
no setteroverride
hasMomentum bool
no setter
isIdentity bool
True when showing the full data range.
no setter
minWindowFraction double
Maximum allowed zoom ratio (visible fraction of data, e.g. 0.02 = 2%).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
velocityX double
Current horizontal pan velocity (data-units per frame), used for fling.
final
windowSize double
Current visible window size as a fraction of total data.
no setter
xEnd double
Visible window end — normalised 0..1 fraction of full data range.
final
xStart double
Visible window start — normalised 0..1 fraction of full data range.
final

Methods

advanceFling({double friction = 0.9}) ChartZoomState
Advance one fling frame — decays velocity and applies pan.
canvasToFraction(double canvasX, double canvasWidth) double
Convert a canvas x-pixel to a data fraction.
centreOn(double frac) ChartZoomState
Pan to centre frac in the viewport.
drillDown(double start, double end, {required String label, Map<String, dynamic>? metadata}) ChartZoomState
Push current state onto history and zoom to start..end.
endIndex(int dataLength) int
Last visible data index.
fractionToCanvas(double frac, double canvasWidth) double
Convert a data fraction to a canvas x-pixel.
fractionToIndex(double frac, int dataLength) int
Convert a normalised fraction 0..1 to a data index in 0..dataLength-1.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
panBy(double deltaFraction) ChartZoomState
Pan by deltaFraction — positive = move viewport right (data moves left).
panTo(double frac) ChartZoomState
Pan so that frac is at the left edge of the viewport.
pop() ChartZoomState
Pop the most recent history entry, returning to the previous zoom level.
popAll() ChartZoomState
Pop all history entries and return to full view.
reset() ChartZoomState
Reset to full view without pushing history.
startIndex(int dataLength) int
First visible data index.
toString() String
A string representation of this object.
override
visibleCount(int dataLength) int
Number of visible data points.
withVelocity(double vx) ChartZoomState
Apply fling velocity.
withVisibleRange(double start, double end) ChartZoomState
Replace the visible data fraction range without pushing history.
zoomAroundCanvas(double focalX, double canvasWidth, double scaleDelta, {bool pushHistory = false, String historyLabel = ''}) ChartZoomState
Zoom centred on screen-relative position focalX in 0..canvasWidth.
zoomAroundFraction(double focalFraction, double scaleDelta, {bool pushHistory = false, String historyLabel = ''}) ChartZoomState
Zoom so that [focalFraction - halfWindow .. focalFraction + halfWindow] is visible, where focalFraction is the pinch focal point in 0..1.
zoomToRange(double start, double end, {String label = 'Zoom'}) ChartZoomState
Zoom to a specific data fraction range, pushing current state to history.

Operators

operator ==(Object other) bool
The equality operator.
override

Constants

identity → const ChartZoomState