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

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

1
0

Hello,

I have ClipModeX=”ClipAtExtents” on my ZoomPanModifier. I need the same behavior on the y-axis, but there is no “ClipModeY”.

How do I prevent y-axis data from panning off the chart?

Thanks,
Neville

  • You must to post comments
1
0

Hi Neville,

Thanks for your inquiry. We’ve been asked several times for this behavior and we’ve got a solution for you. Fortunately, it can be implemented quite easily. Everything you need is to extend ZoomPanModifier and override the Pan method:

 public class ZoomPanModifierEx : ZoomPanModifier 
{    
    public static readonly DependencyProperty ClipModeYProperty = DependencyProperty.Register("ClipModeY", typeof(ClipMode), typeof(ZoomPanModifierBase), new PropertyMetadata(ClipMode.StretchAtExtents));

    public ClipMode ClipModeY

    {
        get { return (ClipMode)GetValue(ClipModeXProperty); }
        set { SetValue(ClipModeXProperty, value); }
    }

   public ZoomPanModifierEx () : base()  
   {
        this.ZoomExtentsY = false;
   }

    public override void Pan(Point currentPoint, Point lastPoint, Point startPoint)
    {
        base.Pan(currentPoint, lastPoint, startPoint);

        var xDelta = currentPoint.X - lastPoint.X;

        var yDelta = lastPoint.Y - currentPoint.Y;

        // Computation of a new Y-Range
        foreach (var yAxis in YAxes)
        {
            yAxis.Scroll(yAxis.IsHorizontalAxis ? -xDelta : yDelta, ClipModeY);
        }   
    }
}

Please try this code and let us know if it does the trick,

Best regards,
Yuriy

  • You must to post comments
0
0

Hello Yuriy,

Thanks for the solution. I tried it out and it seemed to work, but it autoscaled my chart as soon as I started panning. Is there a way to prevent it from autoscaling?

This is how I’m calling it: (Note: when ClipModeX and ClipModeY are set to “None”, it doesn’t autoscale the chart)

<localHelpers:ZoomPanModifierEx IsEnabled="True" ExecuteOn="MouseLeftButton" ReceiveHandledEvents="True" ClipModeX="ClipAtExtents" ClipModeY="ClipAtExtents"/>

I have a video showing the behavior, but it’s 1.73Mb and can’t be uploaded. Can you enlarge the max file size to something that would allow videos to be uploaded (e.g., 5Mb)? 1Mb seems quite limiting.

Thanks,
Neville

  • Andrew
    I know I’m late to the party, but I’m investigating this for another support request and I discovered you need to set ZoomExtentsY = false for the ZoomPanModifier to work correctly in this case.
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.