Keeping Series Centered Vertically in View While Zooming

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
plotter
Posts: 41
Joined: Thu Apr 06, 2017 2:29 am

Keeping Series Centered Vertically in View While Zooming

Post by plotter » Sat May 06, 2017 1:35 pm

Good Morning,

I have a single Y axis and point line series in a chart.
I have a requirement to keep the series centered vertically in the chart while I am zooming vertically.
This way, the users will always see the series, so they know where they are at, when they are zooming manually.

How do I calculate and position the series so the mid-point of the Y range is centered in the view?
This functionality will be selectable so the user can position the series vertically when they desire.

Is there some built in functionality to do this?

Thank You,

Heather

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Keeping Series Centered Vertically in View While Zooming

Post by ArctionKestutis » Mon May 08, 2017 12:59 pm

Hello Heather,

You should mentioned what kind of zooming you have in mind. You could have zooming effect with 'zoom rectangle' or with mouse-wheel; you could zoom above graph area or over axis.
LightningChart allow a lot of flexibility for this action. Please see 'Zooming and panning' chapter (No 6.21 in User's Manual v8.0). The easiest way to experiment with all those properties is to run WinForms Demo App, select example and modify properties through 'Property grid'. Any change on properties will be seen immediately.

If you want zoom rectangle to be drawn around certain point, set following properties:

Code: Select all

ViewXY.ZoomPanOptions.RectangleZoomAboutOrigin = true;
xAxis.ZoomOrigin = xValue;
yAxis.ZoomOrigin = yValue;

If you would like center zooming with mouse wheel, you could use ZoomByFactor method and MouseWheel event. For example,

Code: Select all

            _chart.MouseWheel += _chart_MouseWheel;
            _chart.ViewXY.ZoomPanOptions.MouseWheelZooming = MouseWheelZooming.Off;

        void _chart_MouseWheel(object sender, MouseEventArgs e)
        {
            AxisX xAxis = _chart.ViewXY.XAxes[0];
            AxisY yAxis = _chart.ViewXY.YAxes[0];
            PointInt pCenter;
            double dZoomFactor;

            // convert Axis values to screen coordinates
            pCenter.X = (int)xAxis.ValueToCoord(10, false);
            pCenter.Y = (int)yAxis.ValueToCoord(50, false);

            // set ZoomFactor
            if (e.Delta > 0)
                dZoomFactor = 2;
            else
                dZoomFactor = 0.5;

            // zoom with a center point and a zoom factor
            _chart.ViewXY.ZoomByFactor(pCenter, dZoomFactor, true, true);
        }
Even more straightforward and accurate is to use Axis.SetRange() method instead of ZoomByFactor.

Hope this helps.
All the best,
Kestutis

plotter
Posts: 41
Joined: Thu Apr 06, 2017 2:29 am

Re: Keeping Series Centered Vertically in View While Zooming

Post by plotter » Mon May 08, 2017 6:14 pm

Thank you for your helpful reply.

I need to provide multi-touch zoom functionality for use on a Microsoft Surface Studio.
(It has a 28" screen that is 4500x3000px and must run at 200% scaling to be useful)

After testing with the demo samples, I am experiencing great difficulties using pinch and stretch zooming. Often the plots seem to jitter back and forth while trying to place two fingers to start the stretch or pinch gesture. Or the zoom seems to run away to extremes.
Or sometimes it starts as a pinch/stretch then switches into a rectangle zoom.
(I think I will need to disable rectangle zooming if pinch and stretch are in use as it seems like it's too easy for one action to be interpreted as the other and so on.)

The pinch and stretch gestures seem very touchy and appear even more so when screen scaling is above 100%.

There appear to be certain chart objects that handle touch VERY, VERY WELL.
AnnotationXY objects behave perfectly, so does the Y-Axis positioning scale and the Band positioning.
Other objects seem to be very touchy, or maybe they just have a very small touch trigger region. Sorry this is deviating from the original zoom topic... but there is a point to all this...

Since the pinch and stretch zooming are difficult for me to perform accurately and consistently, couldn't I detect the touched screen coordinates, create transparent AnnotationXY objects under my fingers, then use them as touch pads to determine the amount and direction of the zoom and apply that from code, to manage such things more precisely as rate of zoom, extent limits of zoom, and direction of zoom?. Then discard those annotations when the fingers are lifted.

The touch pinch stretch zoom functionality I need to implement must operate in a very consistent and smooth manner. (Similar to a Touch Enabled Oscilloscope)

Finally, should I be setting my host form to use font or dpi scaling?

Your thoughts and suggestions on this (or some other means to achieve a good touch zoom result) would be greatly appreciated!!

Thanks Again,
Heather

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Keeping Series Centered Vertically in View While Zooming

Post by ArctionKestutis » Tue May 09, 2017 6:15 am

Hello Heather,

Sorry for all the trouble with multi-touch zoom functionality. Yes, we aware that that part of LightningChart code was not modified for quite some time and some things have been broken after v8 introduce new features :oops: .
The current revision have significant modification, which should fix many of issues you are experiencing. Please drop an email to support account if you interested in testing the release candidate (RC1) of LightningChart v8.1. The official version of LightningChart 8.1 will be released in 2-3 weeks.

P.S. DPI awareness is the top in its own. Please see some of details here: viewtopic.php?f=15&t=841

All the best,
Kestutis

Post Reply