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!

3
0

I have a realtime linear chart with multiple x/y axes. When I am zooming the surface, I am changing the X/Y AutoRange mode from AutoRange.Always to AutoRange.Never, which allows me to have Modifiers zooming and panning on a realtime AutoRange chart.

After, I want to re-enable AutoRange when ZoomExtents (double click) occurs.

See below:

    public class ZoomExtentsXAxesModifier : ZoomExtentsModifier
    {
        private Point _startPoint;
        private bool _isMouseDoubleClick;

        public override void OnModifierMouseDown(ModifierMouseArgs e)
        {
            base.OnModifierMouseDown(e);

            if(e.Modifier == MouseModifier.Ctrl) return;

            if (e.MouseButtons == MouseButtons.Left)
                _startPoint = e.MousePoint;

            _isMouseDoubleClick = false;
        }

        public override void OnModifierMouseUp(ModifierMouseArgs e)
        {
            base.OnModifierMouseUp(e);

            if (e.Modifier == MouseModifier.Ctrl) return;

            if (e.MouseButtons != MouseButtons.Left || _startPoint == e.MousePoint || _isMouseDoubleClick) return;

            using (ParentSurface.SuspendUpdates())
            {
                foreach (var axise in XAxes.Where(axise => axise.AutoRange != AutoRange.Never))
                {
                    axise.AutoRange = AutoRange.Never;
                    axise.Zoom(_startPoint.X, e.MousePoint.X);
                }

                foreach (var axise in YAxes.Where(axise => axise.AutoRange != AutoRange.Never))
                {
                    axise.AutoRange = AutoRange.Never;
                    axise.Zoom(_startPoint.Y, e.MousePoint.Y);
                }
            }
        }

        public override void OnModifierDoubleClick(ModifierMouseArgs e)
        {
            base.OnModifierDoubleClick(e);

            if (e.Modifier == MouseModifier.Ctrl) return;

            foreach (var axise in XAxes)
                axise.AutoRange = AutoRange.Always;

            foreach (var axise in YAxes)
                axise.AutoRange = AutoRange.Always;

            _isMouseDoubleClick = true;
        }
    }

For the one chart it is working ok, but when I have more then 2 charts, it is zooming incorect? What can I solve this? I need to recieve one event, when user is zooming, panning or resizing chart. Is it possible?

Thanks,
Arthur

  • You must to post comments
4
0

Hi,

Please, try translating the mouse point relative to ModifierSurface before using it. Refer to the following code:

_startPoint = GetPointRelativeTo(e.MousePoint, ModifierSurface);

Thing are done in this way in modifiers code. Also, maybe you need to play around with the ReceiveHandledEvents property (if your modifiers are connected together via MouseEventGroup).

Regarding the second question, we don’t provide such an event, but there is the SciChartSurface.Rendered event, which will be fired after each redraw (initiated either by pan, or zoom, or resize operation). Alternatively, you can subscribe to the AxisBase.VisibleRangeChanged event or extend modifiers classes and introduce your own events for them. So in this case you need to subscribe to the SizeChanged event.

Hope this helps,

Best regards,
Yuriy

  • You must to post comments
2
0

You can also check if the mouse is on a specific Axis, or on the main chart area by using this technique: ChartModifierBase Get Notification of MouseDown on Axis or Chart

We also explain how to translate points relative to the central chart area (the Modifier Surface) here: ChartModifierBase OnModifierMouseDown reports coordinates incorrectly.

Hope this helps!
Andrew

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.