Page 1 of 1

Сustom drawings overlaps the canvas

Posted: Fri Sep 01, 2017 6:32 pm
by 15679954
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.

Re: Сustom drawings overlaps the canvas

Posted: Mon Sep 04, 2017 9:47 am
by Christopher
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();
    }