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

2
0

I’m currently using the MouseWheelZoomModifier to allow the user to zoom into charts (XyDirection=”XYDirection”), but I’ve now had a request to provide an way for the user to zoom X only, Y only, or both. I realise it’s possible to change the XyDirection property (e.g. using checkboxes, like in your demo), but the PM is asking if a more “user friendly” solution is possible.

One option might be to change the zoom direction based on where the mouse is, e.g. if it’s over the X-axis then zoom X only, over the Y-axis then zoom Y only, otherwise zoom XY.

Another option may be to use modifier keys, e.g. wheel + Ctrl = X only, wheel + Shift = Y only, wheel on its own = XY.

Can you offer some pointers towards a suitable solution, if such a thing is possible? Ideally it would be nice if I could implement a customer modifier, if it’s not too complicated, rather than combining the out-of-the-box modifier with mouse events.

  • You must to post comments
1
1

Hi Alexey,

The base implementation checks for any key modifiers and adjust modifier’s behavior correspondingly. To override this, you should set ModifierMouseArgs.Modifier to “None” before calling the base implementation.

I agree that this is not something that most of people would expect. Please let me log this and we will consider making changes to the modifier to improve user experience with it.

Hope this helps!

Best regards,
Yuriy

  • Alexey
    Thank you, this approach works for me.FYI, according tickets engine, everytime I am clicking on star (mark favorite) or arrows up/down (this post is useful/unuseful), I am disconnecting with message: Your token is expired.
  • You must to post comments
0
0

Hi,

Thanks for your inquiry! It is possible to implement this requirement in an easy way. You need to extend existing MouseWheelZoomModifier and override OnModifierMouseWheel in the following way:

        public override void OnModifierMouseWheel(ModifierMouseArgs e)
        {
            switch (e.Modifier)
            {
                case MouseModifier.Ctrl:
                    XyDirection = SciChart.XyDirection.XDirection;
                    break;
                case MouseModifier.Shift:
                    XyDirection = SciChart.XyDirection.YDirection;
                    break;
                default:
                    XyDirection = SciChart.XyDirection.XYDirection;
                    break;
            }

            base.OnModifierMouseWheel(e);
}

Also I think the other variant is possible too, you should hit-test an axis, check if the cursor hovers it and configure the modifier correspondingly.

Hope this helps!

Best regards,
Yuriy

  • andyste1
    That's great. Thanks once again for your help and keep up the good work with SciChart!
  • You must to post comments
0
0

`Why this doesn’t work for me (shift doesn’t zoom)?

public class MyMouseWheelZoomModifier : MouseWheelZoomModifier
{
    public override void OnModifierMouseWheel(ModifierMouseArgs e)
    {
        switch (e.Modifier)
        {
            case MouseModifier.Shift:
                ActionType = ActionType.Zoom;
                break;
            default:
                ActionType = ActionType.Pan;
                break;
        }

        base.OnModifierMouseWheel(e);
    }
}
  • Andrew
    Not really sure. The use of SHIFT/CTRL to pan in X or Y direction should be demonstrated in the Mouse Wheel example here: https://www.scichart.com/wpf-chart-example-mousewheel-zoom-and-scroll. Can you try it? It uses very similar code (tests e.Modifier). Best regards, Andrew
  • Alexey
    @Andrew, this example doesn’t cover my case. I don’t need change X/Y direction here. The example switches actions by button (control). I am looking how to switch action by key (Shift) pressed.
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.