![]() | Steema Issues DatabaseNote: 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. |
| Summary: | The line pen color isn’t drawn smoothed although Chart is smoothed. | ||
|---|---|---|---|
| Product: | .NET TeeChart | Reporter: | sandra pazos <sandra> |
| Component: | Series | Assignee: | Steema Issue Manager <issuemanager> |
| Status: | RESOLVED NOTABUG | ||
| Severity: | normal | CC: | chris |
| Priority: | Normal | ||
| Version: | TeeChart for .Net 4.1.2016.05125 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows | ||
| URL: | http://www.teechart.net/support/viewtopic.php?f=4&t=16196&sid=22ea6746611dd12e8e509141483eba65 | ||
| Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
| Attachments: |
FastLine Smoothed
usercontrol screenshot |
||
Created attachment 631 [details]
usercontrol screenshot
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".
|
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