Page 1 of 1

Detecting too small plot area?

Posted: Fri Nov 20, 2009 9:58 pm
by 9641603
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

Re: Detecting too small plot area?

Posted: Mon Nov 23, 2009 11:28 am
by 10050769
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,

Re: Detecting too small plot area?

Posted: Mon Nov 23, 2009 10:31 pm
by 9641603
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