Page 1 of 1

Howto get painting area right screen coordinate

Posted: Fri Aug 07, 2009 12:36 pm
by 9641771
I have a chart and I whant to draw a horizontal line within chart painting area (I mean rectangle between axes) from left to right. Printing area left coordinate I can calculate as tChart1.Axes.Left.Position.
How can I get prinring area rigth coordinate?

BTW using tChart1.Axes.Right.Position returnes position even more left than tChart1.Axes.Left.Position :shock: and using tChart1.ClientRectangle.Right returnes right coordinate of whole chart but not painting area.

Re: Howto get painting area right screen coordinate

Posted: Mon Aug 10, 2009 10:47 am
by 10050769
Hello bairog,

I made a simple example that you can use in your application, using after draw event and chart rect. Please see next code and check that works as you want:

Code: Select all

     private void InitializeChart()
        {

            Steema.TeeChart.Styles.Bar bar = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
            bar.FillSampleValues();
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
                 
        }
        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            Rectangle rect = new Rectangle();
            //------Calculate depth position----------------//
            int wall1 = (int)((-(Math.Cos(60)) * (tChart1.Axes.Depth.IAxisSize)) + tChart1.Axes.Depth.Maximum);
            rect = tChart1.Chart.ChartRect;
            //-------If tChart.Aspect.view3D=true use wall1 but if false not.//
            if (tChart1.Aspect.View3D)
            {
                g.HorizontalLine(rect.Left, rect.Right + wall1, rect.Height / 2);
            }
            else
            {
                g.HorizontalLine(rect.Left, rect.Right, rect.Height / 2);
            }
        }
I hope will helps.

Thanks