Page 1 of 1

Bottom Axis pixel positions

Posted: Tue Oct 26, 2010 6:55 am
by 8751509
Greetings,

I have a bottom axis that only stretches 97% across the screen to allow a small buffer at the rigth hand side.

I can find the pixel coord of the left hand side thus - int start = StockChart.Axes.Bottom.IStartPos

however - int end = StockChart.Axes.Bottom.IEndPos returns the position at 97% across ...
I need to draw a line from the axis start to the axis end (including the 3% empty space)

How can I find the the pixel 'x' position where the rigth hand axes are drawn.

Cheers Phil.

Re: Bottom Axis pixel positions

Posted: Tue Oct 26, 2010 10:20 am
by 10050769
Hello Phil,

I think you need add IStartPos and IEndPos of the Depth Axis of Chart. I recommend you do something as below code:

Code: Select all

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            int starBottom, endBottom;
            starBottom = tChart1.Axes.Bottom.IStartPos+tChart1.Axes.Depth.IStartPos;
            endBottom = tChart1.Axes.Bottom.IEndPos+tChart1.Axes.Depth.IEndPos;
            g.Pen.Color = Color.Red;
            g.Pen.Width = 2;
            g.Line(starBottom, tChart1.Axes.Bottom.Position - 50, endBottom, tChart1.Axes.Bottom.Position - 50);
        }
Could you please, tell us if previous code works as you want?


I hope will helps.

Thanks,

Re: Bottom Axis pixel positions

Posted: Tue Oct 26, 2010 11:17 pm
by 8751509
Hi Sandra,
Sadly no it didnt work for me ...

int val = StockChart.Chart.ChartRect.Right seems to work ..

But the VisualStudio is scaring me by warning "May cause runtime error as class is marshall-by-reference class .. "

but it works and doesnt seem to crash ...

Re: Bottom Axis pixel positions

Posted: Wed Oct 27, 2010 7:27 am
by narcis
Hi Phil,

To fix this warning you should do this:

Code: Select all

            Rectangle rect = StockChart.Chart.ChartRect;
            int val = rect.Right;