SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
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.
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
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
`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);
}
}
Please login first to submit.