Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1591 - The line pen color isn’t drawn smoothed although Chart is smoothed.
Summary: The line pen color isn’t drawn smoothed although Chart is smoothed.
Status: RESOLVED NOTABUG
Alias: None
Product: .NET TeeChart
Classification: Unclassified
Component: Series (show other bugs)
Version: TeeChart for .Net 4.1.2016.05125
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Steema Issue Manager
URL: http://www.teechart.net/support/viewt...
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-03 06:19 EDT by sandra pazos
Modified: 2016-08-16 09:32 EDT (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments
FastLine Smoothed (81.84 KB, image/jpeg)
2016-08-03 06:19 EDT, sandra pazos
Details
usercontrol screenshot (4.67 KB, image/png)
2016-08-16 09:30 EDT, christopher ireland
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sandra pazos 2016-08-03 06:19:41 EDT
Created attachment 625 [details]
FastLine Smoothed

The problem is produced when you do zoom in the Chart or customize the Axes scale with SetMinMax. 
The problem is evident, if you set the pen color red or green. 
The code below shows the problem:
  Steema.TeeChart.Styles.FastLine fastLine1; 
        private void Form1_Load(object sender, EventArgs e)
        {
            fastLine1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            double[] xValues = new double[11];
            for (int i = 0; i < 11; i++)
                xValues[i] = 36951 + i * 360;
            double[] yValues = new double[] { 873, 871, 869, 867, 865, 863, 861, 859, 857, 853, 851 };

            fastLine1.Add(xValues, yValues);
            fastLine1.XValues.DateTime = true;
            fastLine1.Color = Color.Red;
            fastLine1.LinePen.Width = 2; 
            tChart1.Axes.Left.SetMinMax(400, 900);

        }
Also I have attached an image that shows the problem
Comment 1 christopher ireland 2016-08-16 09:30:24 EDT
Created attachment 631 [details]
usercontrol screenshot
Comment 2 christopher ireland 2016-08-16 09:32:33 EDT
This appears to be an issue with WinForms GDI+, and is not specific to TeeChart. To see this issue in action independently of TeeChart, please use the code for the usercontrol below:

  public partial class UserControl1 : UserControl
  {
    public UserControl1()
    {
      InitializeComponent();

      XValues = new List<int>();
      YValues = new List<int>();
      MarginBottom = 0;
    }
    public List<int> XValues { get; set; }
    public List<int> YValues { get; set; }
    public int MarginBottom { get; set; }
    private int CalcXPos(int xValue)
    {
      double range = XValues.Max() - XValues.Min();
      double ratio = rect.Width / range;
      return(int)Math.Round(ratio * (xValue - XValues.Min()));
    }
    private int CalcYPos(int yValue)
    {
      double range = YValues.Max() - YValues.Min();
      int height = rect.Height - MarginBottom;
      double ratio = height / range;
      return height - (int)Math.Round(ratio * (yValue - YValues.Min()));
    }

    private Rectangle rect;
    protected override void OnPaint(PaintEventArgs e)
    {
      rect = e.ClipRectangle;
      Graphics g = e.Graphics;
      g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

      g.FillRectangle(Brushes.Yellow, rect);

      for (int i = 0; i < XValues.Count; i++)
      {
        Point p0 = Point.Empty;
        Point p1 = new Point(CalcXPos(XValues[i]), CalcYPos(YValues[i]));
        if(i > 0)
        {
          p0 = new Point(CalcXPos(XValues[i - 1]), CalcYPos(YValues[i - 1]));

          Pen pen = new Pen(Color.Red, 2.0f);
          g.DrawLine(pen, p0, p1);
        }
      }
    }
  }

this usercontrol can be hosted in a WinForm like this:

    public Form2()
    {
      InitializeComponent();

      this.Width = 750;
      this.Height = 550;

      UserControl1 control1 = new UserControl1();
      control1.Dock = DockStyle.Fill;
      this.Controls.Add(control1);

      int[] xValues = new int[11];
      for (int i = 0; i < 11; i++)
        xValues[i] = 36951 + i * 360;
      int[] yValues = new int[] { 873, 871, 869, 867, 865, 863, 861, 859, 857, 853, 851 };

      control1.XValues.AddRange(xValues);
      control1.YValues.AddRange(yValues);
      control1.MarginBottom = this.Height - 75;
    }

the result can be seen in the image attached, "usercontrol screenshot".