While zooming chart annotation misplaced

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Quant
Advanced
Posts: 142
Joined: Tue Dec 30, 2014 12:00 am

While zooming chart annotation misplaced

Post by Quant » Tue Mar 10, 2015 5:38 am

i placed annotation on my chart using following code

Code: Select all

 Steema.TeeChart.Tools.Annotation tAnnotation = new Steema.TeeChart.Tools.Annotation();
tAnnotation.Shape.Font.Color = Color.White;
tAnnotation.Shape.Font.Size = 10;
tAnnotation.Shape.Color = Color.Black;
tAnnotation.Text = strVal;
tAnnotation.Shape.CustomPosition = true;
tAnnotation.Shape.Left = e.X;
tAnnotation.Shape.Top = e.Y;
tAnnotation.Shape.Shadow.Visible = false;
tAnnotation.Shape.Transparent = true;
tChartMain.Tools.Add(tAnnotation);
after placing perfectly if i zoomed the chart then annotation is not following my chart zoom and actually moves away from series where i plotted it. Same this works well with Trendline tool without any problem for zoom.
I used following code for zooming

Code: Select all

tChartMain.Zoom.Active = true;
tChartMain.Zoom.Allow = true;
tChartMain.Zoom.Pen.Visible = true;
tChartMain.Zoom.Brush.Visible = true;
tChartMain.Zoom.MouseButton = MouseButtons.Left;
tChartMain.Zoom.Direction = ZoomDirections.Both;
tChartMain.Zoom.FullRepaint = true;
tChartMain.Zoom.Pen.Color = Color.White;
tChartMain.Zoom.Brush.Color = Color.White;
tChartMain.Zoom.Brush.Transparency = 100;
Kindly help me to get to the appropriate solution for this.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: While zooming chart annotation misplaced

Post by Christopher » Tue Mar 10, 2015 9:21 am

Quant,

You can achieve this by fixing the annotation position to the position of one of the series points, e.g.

Code: Select all

    Points series = new Points();
    Steema.TeeChart.Tools.Annotation tAnnotation = new Steema.TeeChart.Tools.Annotation();

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;
      tChart1.Series.Add(series);
      series.FillSampleValues();

      tChart1.BeforeDrawSeries += tChart1_BeforeDrawSeries;
      
      tAnnotation.Shape.Font.Color = Color.White;
      tAnnotation.Shape.Font.Size = 10;
      tAnnotation.Shape.Color = Color.Black;
      tAnnotation.Text = "Annotation String";
      tAnnotation.Shape.CustomPosition = true;
      tAnnotation.Shape.Shadow.Visible = false;
      tAnnotation.Shape.Transparent = false;
      tChart1.Tools.Add(tAnnotation);
    }

    void tChart1_BeforeDrawSeries(object sender, Graphics3D g)
    {
      tAnnotation.Shape.Left = series.CalcXPos(5); //fix position to fifth point
      tAnnotation.Shape.Top = series.CalcYPos(5);
    }
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply