Add Real Coordinates to Annotation Rectangle

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
lilo
Newbie
Newbie
Posts: 61
Joined: Thu Sep 23, 2010 12:00 am

Add Real Coordinates to Annotation Rectangle

Post by lilo » Fri Oct 15, 2010 2:27 pm

Suggestion: Please add real coordinates (axes coordinates) to position units of annotation rectangle. Same as Line Tool.

lilo
Newbie
Newbie
Posts: 61
Joined: Thu Sep 23, 2010 12:00 am

Re: Add Real Coordinates to Annotation Rectangle

Post by lilo » Fri Oct 15, 2010 10:20 pm

All of my text positions are coded using real coordinates. Also using pixels or percent could make exact repositioning of the annotation rectangle difficult when the chart is resized.

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

Re: Add Real Coordinates to Annotation Rectangle

Post by Sandra » Mon Oct 18, 2010 11:20 am

Hello lilo,

You have to recalculate the annotation or rectangular tool position with CalcXPos and CalcYPos methods every time the chart is drown or scrolled, or zoomed using AfterDraw event. You can do something similar as next example:

Code: Select all

        Steema.TeeChart.TChart tChart1;
        public Form1()
        {
            InitializeComponent();
            tChart1 = new Steema.TeeChart.TChart();
            this.Controls.Add(tChart1);
            tChart1.Dock = DockStyle.Fill;
            InitializeChart();
        }

        Steema.TeeChart.Styles.Line series1;
        Steema.TeeChart.Tools.RectangleTool tool1;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            series1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            Random rnd = new Random();
            series1.Add(1000);
            for (int i = 1; i < 25; i++)
            {
                series1.Add(series1.YValues.Value[i - 1] + rnd.Next(10));
            }
            tool1 = new Steema.TeeChart.Tools.RectangleTool(tChart1.Chart);
           
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
            tChart1.Zoomed += new EventHandler(tChart1_Zoomed);
            tChart1.Scroll += new EventHandler(tChart1_Scroll);
            tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
            tChart1.Draw();
        }

        void tChart1_UndoneZoom(object sender, EventArgs e)
        {
            tChart1.Draw();
        }

        void tChart1_Scroll(object sender, EventArgs e)
        {
            tChart1.Draw();
        }

        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            tool1.Left = tChart1.Axes.Bottom.CalcXPosValue(10);
            tool1.Top = tChart1.Axes.Left.CalcYPosValue(1070);
        }

        void tChart1_Zoomed(object sender, EventArgs e)
        {  
            tChart1.Draw();

        }
Could you please, tell us if previous code works as you want?

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

lilo
Newbie
Newbie
Posts: 61
Joined: Thu Sep 23, 2010 12:00 am

Re: Add Real Coordinates to Annotation Rectangle

Post by lilo » Tue Oct 19, 2010 9:31 am

What are the units of the returned value?

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

Re: Add Real Coordinates to Annotation Rectangle

Post by Sandra » Tue Oct 19, 2010 10:58 am

Hello lilo,

Please see next explanations extracted to TeeChart.Net help manual:

Method CalcXPosValue(double valueIndex): Returns the pixel Screen Horizontal coordinate of the specified Value. This coordinate is calculated using the Series associated Horizontal Axis.
Method CalcXPosValueI(double valueIndex): Returns the pixel Screen Vertical coordinate of the specified Value. This coordinate is calculated using the Series associated Vertical Axis.
Method CalcXPos(int valueIndex): Returns the pixel Screen Horizontal coordinate of the ValueIndex Series value. This coordinate is calculated using the Series associated Horizontal Axis.
Method CalcYPos(int valueIndex): Returns the pixel Screen Vertical coordinate of the ValueIndex Series value. This coordinate is calculated using the Series associated Vertical Axis.

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

lilo
Newbie
Newbie
Posts: 61
Joined: Thu Sep 23, 2010 12:00 am

Re: Add Real Coordinates to Annotation Rectangle

Post by lilo » Wed Oct 20, 2010 12:11 am

Sorry, I should have checked the help.
Method CalcXPosValue(double valueIndex): Returns the pixel Screen Horizontal coordinate of the specified Value. This coordinate is calculated using the Series associated Horizontal Axis.
Method CalcXPosValueI(double valueIndex): Returns the pixel Screen Vertical coordinate of the specified Value. This coordinate is calculated using the Series associated Vertical Axis.
This is exactly the solution...works fine...Thank you

Post Reply