Set Axis and Zoom in Form Load Wonky

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
jzarech
Newbie
Newbie
Posts: 58
Joined: Mon Jul 07, 2008 12:00 am

Set Axis and Zoom in Form Load Wonky

Post by jzarech » Sun Jul 31, 2022 8:00 am

Hi Steema -
I'm building an app and trying to set the TChart Axes and Zoom during form Load -
The Set Axes works but not the Zoom -
But if I set the Axes and Zoom with the same code from buttons on the form once loaded it works.

I'm sure it's an event sequencing issue of some sort but can't figure it out.

I distilled the problem reproducing code into a simple one-page c# .net WinForms app to see if it's solvable.

I've also attached some screenshots.

Thanks so much for your help!

Joseph
I only attached the form1 c# code because I couldn't attach the solution rar because it was too large. But if you need the VS2019 Solution ping me.
Attachments
Form1.rar
(712 Bytes) Downloaded 876 times
ClickingWorks.jpg
ClickingWorks.jpg (104.73 KiB) Viewed 9778 times
OnLoadWonky.png
OnLoadWonky.png (39.93 KiB) Viewed 9778 times

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Set Axis and Zoom in Form Load Wonky

Post by Marc » Mon Aug 01, 2022 3:36 pm

Hello,

The chart needs to render before it can run the zoom on what would be the rendered dimensions. You could achieve that this way, removing the call to SetZoom from the initialisation code and adding a one-time call in the Chart OnAfterdraw event:

Code: Select all

        bool hasLoaded = false;
        private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.IGraphics3D g)
        {

            if (!hasLoaded)
            {
                hasLoaded = true;
                SetZoom();
            }

        }
Regards,
Marc Meumann
Steema Support

jzarech
Newbie
Newbie
Posts: 58
Joined: Mon Jul 07, 2008 12:00 am

Re: Set Axis and Zoom in Form Load Wonky

Post by jzarech » Mon Aug 01, 2022 3:57 pm

I will give this a try. Thanks very much Marc!

jzarech
Newbie
Newbie
Posts: 58
Joined: Mon Jul 07, 2008 12:00 am

Re: Set Axis and Zoom in Form Load Wonky

Post by jzarech » Wed Aug 03, 2022 6:17 pm

Hi Marc,
I tried the AfterDraw code change you suggested and the Zoom still doesn't work. I tried messing around a little bit with UndoZoom first and DoEvents but still no Zoom using AfterDraw.

I've attached my code in case that's helpful and have the whole VS 2019 Project with just the repro code if it's helpful as well.

Thanks,
Joseph
MovedZoomToAfterDraw.jpg
MovedZoomToAfterDraw.jpg (110.19 KiB) Viewed 9734 times
Attachments
Form1.rar
(781 Bytes) Downloaded 929 times

Post Reply