Annotation tool drawing order

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Petr
Newbie
Newbie
Posts: 39
Joined: Wed Jul 24, 2013 12:00 am

Annotation tool drawing order

Post by Petr » Thu Jul 03, 2014 9:57 am

Hi, i'm using Cursor tool and annotation tool and color line tool in my programm. I use AfterDrawEvent to annotation and some extra objects on the chart. Here's the the functions that acts on AfterDraw

Code: Select all

private void OnAfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      foreach (TickMark tckMark in m_TickMarksList )
      {
        if (tckMark.Value > TimeAxis.Minimum && tckMark.Value < TimeAxis.Maximum)
        {
          g.Font.Color = Color.Black;
          tckMark.GeniuneTickMark.Active = true;
          DrawtickMarkLabel(g, tckMark.GeniuneTickMark);
          PointTickMarkIntersections(g, tckMark.GeniuneTickMark);
        }
        else
          tckMark.GeniuneTickMark.Active = false;
      }

      if (m_LevelHelper != null)
      {
        DrawLevelLabel(g, m_LevelHelper);
      }

      if( m_TChart.Tools.IndexOf( m_CursorTool ) != -1 )
      {
        DrawCursorToolMarks( g );
        MakeAnnotationForCursorTool();
      }

      if (m_ChartZoomed)
      {
        Helper.RecaclulateAxisIncrement(5, TimeAxis);
      }
    }
Here tckMark.GeniuneTickMark is color line tool, DrawtickMarkLabel(g, tckMark.GeniuneTickMark), PointTickMarkIntersections(g, tckMark.GeniuneTickMark), DrawCursorToolMarks( g ) - draws text and circles on the chart, and MakeAnnotationForCursorTool() is used to fill annotation with text. So in my opinion the order of drawing is such, that anootation tool must be drawn the last one, and be the "top most" one the image, but i can see, that circles and text are drawn later than annotation tool. so i get the picture attached. What should i do to make annotation tool to be drawn the last one?
annotation problem pic.JPG
annotation problem pic.JPG (199.64 KiB) Viewed 5520 times

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

Re: Annotation tool drawing order

Post by Christopher » Fri Jul 04, 2014 8:19 am

Petr,

My suggestion is that you do your custom drawing in an event that occurs before the AfterDraw event. There are several options, e.g.

Code: Select all

    private void InitializeChart()
    {
      Bar bar = new Bar(tChart1.Chart);
      bar.FillSampleValues();

      Annotation anno = new Annotation(tChart1.Chart);
      anno.Shape.CustomPosition = true;
      anno.Shape.Left = 200;
      anno.Shape.Top = 100;
      anno.Text = "Annotation" + Utils.NewLine + "New" + Utils.NewLine + "Text";

      tChart1.AfterDraw += tChart1_AfterDraw;

      tChart1.BeforeDrawSeries += tChart1_BeforeDrawSeries;

      bar.AfterDrawValues += bar_AfterDrawValues;
    }

    void bar_AfterDrawValues(object sender, Graphics3D g)
    {
      g.Font.Color = Color.White;
      g.TextOut(205, 105, "AfterDrawValues");
    }

    void tChart1_BeforeDrawSeries(object sender, Graphics3D g)
    {
      g.Font.Color = Color.Red;
      g.TextOut(205, 115, "BeforeDrawSeries");
    }

    void tChart1_AfterDraw(object sender, Graphics3D g)
    {
      g.Font.Color = Color.Pink;
      g.TextOut(205, 125, "AfterDraw");
    }
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