Page 1 of 1

Add Real Coordinates to Annotation Rectangle

Posted: Fri Oct 15, 2010 2:27 pm
by 15057312
Suggestion: Please add real coordinates (axes coordinates) to position units of annotation rectangle. Same as Line Tool.

Re: Add Real Coordinates to Annotation Rectangle

Posted: Fri Oct 15, 2010 10:20 pm
by 15057312
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.

Re: Add Real Coordinates to Annotation Rectangle

Posted: Mon Oct 18, 2010 11:20 am
by 10050769
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,

Re: Add Real Coordinates to Annotation Rectangle

Posted: Tue Oct 19, 2010 9:31 am
by 15057312
What are the units of the returned value?

Re: Add Real Coordinates to Annotation Rectangle

Posted: Tue Oct 19, 2010 10:58 am
by 10050769
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,

Re: Add Real Coordinates to Annotation Rectangle

Posted: Wed Oct 20, 2010 12:11 am
by 15057312
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