SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & 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!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

Answered
0
0

I want to zoom the chart using mouse wheel. But not zoom at mouse point center, but at the specified point center I set.

How can I do it?
Is there any properties for MouseWheelZoomModifier?

Version
v5.1.1.11473
  • You must to post comments
Best Answer
1
1

Hi there

You can override MouseWheelZoomModifier.OnModifierMouseWheel() to customize the behaviour

For example

    /// <summary>
    /// Called when the Mouse Wheel is scrolled on the parent <see cref="SciChartSurface"/>
    /// </summary>
    /// <param name="e">Arguments detailing the mouse wheel operation</param>
    /// <remarks></remarks>
    public override void OnModifierMouseWheel(ModifierMouseArgs e)
    {
        base.OnModifierMouseWheel(e);

        e.Handled = true;

        const double mouseWheelDeltaCoef = 120;

        using (ParentSurface.SuspendUpdates())
        {
            double value = -e.Delta / mouseWheelDeltaCoef;

            var currDirection = XyDirection;
            var currAction = ActionType;

            OverrideKeyboardAction(e.Modifier);

           // THIS is where we get the mouse point
            var mousePoint = GetPointRelativeTo(e.MousePoint, ModifierSurface);
            _performAction(mousePoint, value);

            TryStoreRangesToZoomHistoryManager();

            this.SetCurrentValue(XyDirectionProperty, currDirection);
            this.SetCurrentValue(ActionTypeProperty, currAction);
    }

Or … the much simpler way – to pass a different point to the base

    public class MouseWheelModifierEx : MouseWheelZoomModifier
    {
        public override void OnModifierMouseWheel(ModifierMouseArgs e)
        {
            // Override the mouse point
            e.MousePoint = new Point(10, 20);

            // Call base
            base.OnModifierMouseWheel(e);
        }
    }

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.