Detecting too small plot area?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Detecting too small plot area?

Post by Michal Blazejczyk » Fri Nov 20, 2009 9:58 pm

Hi,

In BeforeDrawSeries my code is trying to calculate how big is the area within the axes (all the values here are in pixels):

Code: Select all

int topEdge = Chart.ChartBounds.Top + Axes.Top.Position + 1;
int bottomEdge = Axes.Left.CalcPosValue( Axes.Left.Inverted ? Axes.Left.Maximum : Axes.Left.Minimum  );
int leftRange = bottomEdge - topEdge;
But when the chart window is getting too small, the area within the axes becomes invisible and then suddenly leftRange becomes as big as the entire chart height. It seems that CalcPosValue() doesn't return the right value in such a case. Have anyone seen this behavior? How to go around it?

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Detecting too small plot area?

Post by Sandra » Mon Nov 23, 2009 11:28 am

Hello Michal,
But when the chart window is getting too small, the area within the axes becomes invisible and then suddenly leftRange becomes as big as the entire chart height. It seems that CalcPosValue() doesn't return the right value in such a case. Have anyone seen this behavior? How to go around it?
I think it is related with last thread if you submit us http://www.teechart.net/support/viewtop ... 078#p44078 . May be, when solved one, the other will be solved too.

On the other hand, I recommend using tChart.Rect instead of tChart.Bounds, because when you calculate values of chart and her axis you calculate values of chartRect. For example you could do next:

Code: Select all

            
            Rectangle rect = new Rectangle();
            rect = tChart1.Chart.ChartRect;
            int topEdge =rect.Top + tChart1.Axes.Top.Position + 1;
            int bottomEdge =tChart1.Axes.Left.CalcPosValue(tChart1.Axes.Left.Inverted ? tChart1.Axes.Left.Maximum : tChart1.Axes.Left.Minimum);
            int leftRange = bottomEdge - topEdge;

As you see, the only change that I made in your code is Chart.Rect. Please, check if it is a solution for you.

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Re: Detecting too small plot area?

Post by Michal Blazejczyk » Mon Nov 23, 2009 10:31 pm

Hi Sandra,

No, your code doesn't work either.

But I have checked this on the most recent version of TeeChart, and it seems like it works fine there. I'll have to try to upgrade.

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

Post Reply