SciChart iOS v2.x API > Axis APIs > Axis Ranging - How to Listen to VisibleRange Changes
Axis Ranging - How to Listen to VisibleRange Changes

How to Listen to VisibleRange Changes

It is possible to subscribe to VisibleRange Changes using a SCIAxisVisibleRangeChanged callback:

// Register a VisibleRangeChanged callback
SCICallbackHelperProtocol * helper = [axis registerVisibleRangeChangedCallback:
               ^(id<SCIRangeProtocol> newRange, id<SCIRangeProtocol> oldRange, BOOL isAnimated, id sender) {
                   // TODO: Do something on range change
                   // isAnimated will be TRUE if the current operation is an animated zoom or pan
               }];

// When finished, unsubscribe to the callback
[helper remove];
// Register a VisibleRangeChanged callback
var helper: SCICallbackHelperProtocol? = axis.registerVisibleRangeChangedCallback({(_ newRange: SCIRangeProtocol, _ oldRange: SCIRangeProtocol, _ isAnimated: Bool, _ sender: Any) -> Void in
        // TODO: Do something on range change
        // isAnimated will be TRUE if the current operation is an animated zoom or pan
    }) 

// When finished, unsubscribe to the callback
helper?.remove()
// Register a VisibleRangeChanged callback
var helper = axis.RegisterVisibleRangeChangedCallback((newRange, oldRange, isAnimated, sender) =>
{
    // TODO: Do something on range change
    // isAnimated will be TRUE if the current operation is an animated zoom or pan               
});
helper.Remove();
helper.Dispose();
Note that you can differentiate between changes that were part of an animation by checking the isAnimated parameter. For example, an animated zoom to extents operation will fire the callback many times with isAnimated = true, then once at the end with isAnimated = false.

See Also