Сustom drawings overlaps the canvas

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
mpsa
Newbie
Newbie
Posts: 1
Joined: Thu Jan 19, 2017 12:00 am

Сustom drawings overlaps the canvas

Post by mpsa » Fri Sep 01, 2017 6:32 pm

Hi Steema Support!

While working on project (TeeChart .NET 4.1.2017.2145), we had to use different line type (e.g. dashed) for certain dots among the whole variety of the dots of the line.
Using AfterDrawValues hits the spot, but there is a problem - while dragging the chart, additionally drawn lines overlap the axises (canvas). Trimming with ClearClipRegions is of no use.

Are we tackling the issue efficiently? And how do we solve the trimming problem?

Find the text project enclosed.
Kind regards.
Attachments
TestTChart.zip
(17.8 KiB) Downloaded 685 times
problem.PNG
problem.PNG (29.4 KiB) Viewed 6129 times

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

Re: Сustom drawings overlaps the canvas

Post by Christopher » Mon Sep 04, 2017 9:47 am

Hello,

Probably the easiest solution here is to do the clipping in the same event, making the call to BeforeDrawValues unnecessary:

Code: Select all

      _chartLine.AfterDrawValues += ChartLine_AfterDrawValues;
      //_chartLine.BeforeDrawValues += ChartLine_BeforeDrawValues;
      _chartLine.FillSampleValues(100);
    }

    private void ChartLine_AfterDrawValues(object sender, Graphics3D g)
    {
      g.ClipRectangle(_chartLine.Chart.ChartRect);

      foreach (int badIndex in _badIndexes)
      {
        if (badIndex < _chartLine.Count)
        {
          Point p2 = new Point(_chartLine.CalcXPos(badIndex), _chartLine.CalcYPos(badIndex));
          if (badIndex - 1 >= 0)
          {
            g.Pen.Style = DashStyle.Solid;
            g.Pen.Width = 2;
            g.Pen.Color = Color.White;
            Point p1 = new Point(_chartLine.CalcXPos(badIndex), _chartLine.CalcYPos(badIndex - 1));
            g.Line(p1, p2);
            g.Pen.Style = DashStyle.Dash;
            g.Pen.Color = Color.Blue;
            g.Line(p1, p2);
          }
          if (badIndex + 1 < _chartLine.Count)
          {
            Point p3 = new Point(_chartLine.CalcXPos(badIndex + 1), _chartLine.CalcYPos(badIndex));
            Point p4 = new Point(_chartLine.CalcXPos(badIndex + 1), _chartLine.CalcYPos(badIndex + 1));
            g.Pen.Style = DashStyle.Solid;
            g.Pen.Width = 2;
            g.Pen.Color = Color.White;
            g.Line(p2, p3);
            g.Line(p3, p4);
            g.Pen.Style = DashStyle.Dash;
            g.Pen.Color = Color.Blue;
            g.Line(p2, p3);
            g.Line(p3, p4);
          }
        }
      }

      g.UnClip();
    }
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