FastLine skipping null data points
Posted: Wed Feb 10, 2010 6:20 pm
Using TeeChart.WPF.dll 4.0.2009.35592, we are trending data which occasionally has null points which we want to represent by blanks on the drawn line. We're finding that if we use FastLine (in an attempt to improve rendering performance), these null points are occasionally skipped: the rendered series appears to include data. As it's important that the line displayed be accurate, that's a big problem. If we switch to a Line instead of a FastLine, the problem disappears (all the points are properly rendered) but there's a performance drop at the same time. Is FastLine meant to do that or is this a bug? I realise that FastLine is meant to compact the amount of data rendered, but in this case its rendering is generating line segments which are occasionally quite long (several dozen pixels) and quite clearly going through areas where there should be no data.
The following code demonstrates the problem. Generate a standard WPF app with a single TChart as the only control (named "chart"). The code below generates a sine wave with no interruptions for the first half and regular interruptions on the second. If I maximize the application, all the data renders correctly. If I make it a little smaller (say 1024x768 pixels), the data begins to become inaccurate, particularly around the cusp of the low part of the sine wave. If I change the FastLine to a Line, the rendering is correct at all application sizes.
The following code demonstrates the problem. Generate a standard WPF app with a single TChart as the only control (named "chart"). The code below generates a sine wave with no interruptions for the first half and regular interruptions on the second. If I maximize the application, all the data renders correctly. If I make it a little smaller (say 1024x768 pixels), the data begins to become inaccurate, particularly around the cusp of the low part of the sine wave. If I change the FastLine to a Line, the rendering is correct at all application sizes.
Code: Select all
void GenerateLine(out List<double> xValues, out List<double> yValues)
{
xValues = new List<double>();
yValues = new List<double>();
for (int i = 0; i < 1000; i++)
{
xValues.Add(i);
yValues.Add(System.Math.Sin(3.1415926535 * i / 500) * 100);
}
}
public Window1()
{
InitializeComponent();
chart.Aspect.ApplyZOrder = false;
chart.Aspect.Chart3DPercent = 0;
Axis axis = new Axis(false, false, chart.Chart);
chart.Axes.Custom.Add(axis);
FastLine line = new FastLine();
line.DrawAllPoints = false;
line.Title = "Line";
chart.Series.Add(line);
line.TreatNulls = TreatNullsStyle.DoNotPaint;
List<double> xValues;
List<double> yValues;
GenerateLine(out xValues, out yValues);
line.BeginUpdate();
line.XValues.Clear();
line.XValues.Value = xValues.ToArray();
line.XValues.Count = xValues.Count;
line.YValues.Clear();
line.YValues.Value = yValues.ToArray();
line.YValues.Count = yValues.Count;
for (int i = 500; i < 1000; i += 20)
for (int j = 0; j < 10; j++)
line.SetNull(j + i);
line.Invalidate();
line.EndUpdate();
}