SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
1

Hello. I would like to load data as needed when the user pans or zooms. I’ve looked at the examples but don’t see an example of a method being called when a pan/zoom occurs. I’ve tried adding MouseUp=”chart2D_panZoomEvent” MouseWheel=”chart2D_panZoomEvent” to my chart definition but the methods don’t appear to be called.

Thanks,
Daryl.

Version
4.2.2.9777
  • You must to post comments
0
0

Hi Daryl,

We don’t have such events but there are some other things you can do.

1 You can subscribe to AxisBase.VisibleRangeChanged event.

This event occurs whenever the axis range changes, such as after a Zoom, Pan operation or after an autorange operation. The event args for this event contain a flag ‘IsAnimating’. When true the visible range change was the result of an animated event such as an animated Zoom Extents. There will always be one more event raised at the end of an operation with IsAnimating=false.

2 You can override MouseUp, MouseWheel on the modifiers

For example, given ZoomPanModifier, create a class ZoomPanModifierEx and override OnModifierMouseUp. When the base MouseUp has been called, the pan operation is completed.

public class ZoomPanModifierEx : ZoomPanModifier
{
    public override void OnModifierMouseUp(ModifierMouseArgs e)
    {
        bool wasPanning = IsDragging;
        base.OnModifierMouseUp(e);
        if (wasPanning)
        {
            // Pan operation has completed 
        }
    }
}

You can do the same with the MouseWheelToZoomPanModifier by overriding OnModifierMouseWheel etc…

Let me know if either of these help.

Best regards,
Andrew

  • Daryl Wilding-McBride
    This is good – thanks Andrew.
  • Martin Gawlita
    Hi! Are there new ways to react on zoom or panning events or are the named recommendations still valid? Best, Martin
  • Andrew Burnett-Thompson
    Hi Martin – For the ZoomPanModifier specifically this is the best way to do it, override a method and you can add an event as you wish. You can also subscribe to Axis.VisibleRangeChanged event which provides a callback every time the axis range changes (from any kind of zoom or pan operation).
  • Martin Gawlita
    Hi Andrew, thank you for your quick response and the information. I’ve also sent a support request to link to this post because I wasn’t sure if I get notified when I get an answer here. This wasn’t the case for your answer. But I’ve also got the same answer from Yuriy in the meantime via your support ticket system. Is there a way to enable notifications for your forum?
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.