The structure:
A thread collects data from a external device and add them into a DataTable. Cycle: < 1 Second.
For each column (except 1st column containing a TimeStamp) a "line" series is created. The DataSource of the series is set to the DataTable.
Code: Select all
foreach (DataColumn col in dataTable.Columns)
{
if (col == dataTable.Columns[0]) continue;
Steema.TeeChart.Styles.Line lineSeries = new Steema.TeeChart.Styles.Line();
ChartControl.Series.Add(lineSeries);
lineSeries.DataSource = dataTable; //set DataTable as DataSource
lineSeries.YValues.DataMember = col.ToString();
lineSeries.XValues.DataMember = timeCol.ToString();
lineSeries.XValues.DateTime = true;
lineSeries.Title = col.ToString();
lineSeries.Active = false;
...
}
The EventHandler for updating the Teechart look like this:
Code: Select all
for (int i = 0; i < ChartControl.Series.Count; i++)
{
if (ChartControl[i].Active && Drawing == false)
ChartControl[i].CheckDataSource();
}
ChartControl.Invalidate();
Drawing = false if ChartControl.AfterDraw is fired.
Before I introduce the "Drawing" property, I always get troubles with displaying the Series and at the end there was the "red cross".
Now it is working fine, but there are many open questions.
Do I understand right, that I only have to ensure, that the CheckUpdateSource is not called during TeeChart is drawing.
Is there a more elegant way to avoid "red cross" in my situation?
What do Series.BeginUpdate() and Series.EndUpdate() doing? Could you explain what "Recalculates the function just one time, when finished adding points." means!
I attached the "stress test" project, I used to find a solution for my DataTable problem.
Thank you for your comments...