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

In RubberBandXyZoomModifier it is possible to zoom only in X axis direction by setting IsXAxisOnly property. Is there way to zoom only in Y axis direction? Unfortunately there is no such property like IsYAxisOnly..

  • You must to post comments
0
0

I also had the issue of the rectangle not covering the full x-axis. I found that this was caused by having the Y axis on the left side, and the GetBoundsRelative isn’t accounting for that space.

Here’s my implementation, but with an added XyDirection property to allow switching between X and Y zoom modes (similar to other modifiers):

public static readonly DependencyProperty XyDirectionProperty = DependencyProperty.Register("XyDirection", typeof(XyDirection), typeof(SciChartRubberBandZoomModifier), new PropertyMetadata(XyDirection.XYDirection));

public XyDirection XyDirection
{
    get { return (XyDirection)GetValue(XyDirectionProperty); }
    set { SetValue(XyDirectionProperty, value); }
}

public override void OnModifierMouseDown(ModifierMouseArgs e)
{
    Rect cb = this.ModifierSurface.GetBoundsRelativeTo(this.ModifierSurface);

    ModifierMouseArgs mm = e;
    switch (this.XyDirection)
    {
        case XyDirection.XDirection:
            mm.MousePoint = new Point(e.MousePoint.X, cb.Bottom);
            break;
        case XyDirection.YDirection:
            double axisOffset = 0;
            if (ParentSurface is SciChartSurface && (ParentSurface as SciChartSurface).AxisAreaLeft != null && !double.IsNaN((ParentSurface as SciChartSurface).AxisAreaLeft.ActualWidth))
                axisOffset = (ParentSurface as SciChartSurface).AxisAreaLeft.ActualWidth;

            mm.MousePoint = new Point(cb.Right + axisOffset, e.MousePoint.Y);
            break;
        default:
            break;
    }

    base.OnModifierMouseDown(mm);
}

public override void OnModifierMouseUp(ModifierMouseArgs e)
{
    ModifierMouseArgs mm = e;

    Rect cb = this.ModifierSurface.GetBoundsRelativeTo(this.ModifierSurface);

    switch (this.XyDirection)
    {
        case XyDirection.XDirection:
            mm.MousePoint = new Point(e.MousePoint.X, 0);
            break;
        case XyDirection.YDirection:
            mm.MousePoint = new Point(cb.Left, e.MousePoint.Y);
            break;
        default:
            break;
    }


    base.OnModifierMouseUp(mm);
}

public override void OnModifierMouseMove(ModifierMouseArgs e)
{
    Rect cb = this.ModifierSurface.GetBoundsRelativeTo(this.ModifierSurface);

    ModifierMouseArgs mm = e;
    switch (this.XyDirection)
    {
        case XyDirection.XDirection:
            mm.MousePoint = new Point(e.MousePoint.X, cb.Top);
            break;
        case XyDirection.YDirection:
            mm.MousePoint = new Point(cb.Left, e.MousePoint.Y);
            break;
        default:
            break;
    }

    base.OnModifierMouseMove(mm);
}
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.