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

0
0

We have a different legacy chart in our older applications. In this chart zooming happens when we pull down and to the right. We remove the zoom (zoom out to initial size) when we pull up to the left. Of course, this is all with the left mouse button pressed.

SciChart zooms, in my opinion, much better and more specific. However I’m sure my company would prefer the mouse down, pull up to the left to reset the zoom much like our legacy product.

Is this possible? Can I override the zoom effect?

Version
5.2
  • You must to post comments
0
0

I like that you said SciChart is better! Nevertheless, we understand the pull of familiar.

You will hopefully think it’s even better when I share about the Custom ChartModifier API for creating your own zoom operators 🙂

Have a look at Custom Modifiers – ChartModifierBase API documentation for some background. You will need to create a class which inherits ChartModifierBase and overrides OnModifierMouseDown, OnModifierMouseMove, OnModifierMouseUp,

public class TestChartModifier : ChartModifierBase
{
   /// <summary>
   /// Called when a Mouse Button is pressed on the parent <see cref="SciChartSurface" />
   /// </summary>
   /// <param name="e">Arguments detailing the mouse button operation</param>
   public override void OnModifierMouseDown(ModifierMouseArgs e)
   {
      base.OnModifierMouseDown(e);
   }

   /// <summary>
   /// Called when the Mouse is moved on the parent <see cref="SciChartSurface" />
   /// </summary>
   /// <param name="e">Arguments detailing the mouse move operation</param>
   public override void OnModifierMouseMove(ModifierMouseArgs e)
   {
      base.OnModifierMouseMove(e);
   }

   /// <summary>
   /// Called when a Mouse Button is released on the parent <see cref="SciChartSurface" />
   /// </summary>
   /// <param name="e">Arguments detailing the mouse button operation</param>
   public override void OnModifierMouseUp(ModifierMouseArgs e)
   {
      base.OnModifierMouseUp(e);
   }
}

In there, do your logic to detect zoom conditions. Once you have computed a zoom factor, you can use the following APIs to actually perform zooming.

Axis Zooming APIs

For some concrete examples we have a series of (old) articles over here, but with up to date code over here.

  1. Old article: Custom ChartModifiers – Part 2 – Custom ZoomPanModifier and Zooming on KeyPress
  2. Updated code sample for above Github

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.