Page 1 of 1

Is there a problem using coloreach property?

Posted: Tue Apr 18, 2006 7:01 pm
by 9086062
I have a chart with several series on it. I use the coloreach property to specify a color for each point on a few of these series to highlight the data. Occasionally, the lines with the coloreach property set seem to go bad (random colors and spikey data). Then all of a sudden it starts working again like nothing happened. The lines without the coloreach property set are not affected. I was curious if this is a known problem and if there is a fix for it.

Thanks.

Posted: Wed Apr 19, 2006 8:52 am
by narcis
Hi cw,

Can you please send us an example we can run "as-is" or the steps we should follow to reproduce the problem here?

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Thanks in advance.

Posted: Wed Apr 19, 2006 1:25 pm
by 8129060
Here is a snippet of code showing how I add the data and color to the series. This works for very long periods of time with now problems, but will occasionally go strange for a little while and then start working again.

There is scrolling code at the bottom of this logic. This is real time data display and I only keep around a fixed amount of data in the series. I was worried about eating up memory if this was left running for long periods of time. I also have an up/down control where the user can select how many of seconds to display on the plot. That is the series may contain a minute of data, but the user may zoom in and only display 20 seconds across the bottom axis.

This code is called each time new samples are received.

Code: Select all

for (i = 0; i < mNumSamples; i++)
{
  DataChart.Series[0].Add(SampleNum, mSamplesData1[i], 
                                       DataChart.Series[0].Color);
  DataChart.Series[1].Add(SampleNum++, 
	                        mSamplesData2[i],
                                        DataChart.Series[1].Color);
}
if ((mFlags & 1) != 0)
{
   DataChart.Series[0].Color = Color.Red;
}
else
{
   DataChart.Series[0].Color = Color.Blue;
}
if ((mFlags & 2) != 0)
{
   DataChart.Series[1].Color = Color.Red;
}
else
{
   DataChart.Series[1].Color = Color.Green;
}

// now scroll the data by removing old data
int SamplesOnChart = (int)numUDChartSeconds.Value * 10;
int MaxSamplesOnChart = (int)numUDChartSeconds.Maximum * 10;
DataChart.Axes.Bottom.SetMinMax(mSampleNumber - SamplesOnChart, 
					mSampleNumber);
while (DataChart.Series[0].XValues[0] < 
                                            (mSampleNumber - MaxSamplesOnChart))
{
   DataChart.Series[0].Delete(0);
}
while (DataChart.Series[1].XValues[0] < 
	                   (mSampleNumber - MaxSamplesOnChart))
{
   DataChart.Series[1].Delete(0);
}

Posted: Thu Apr 20, 2006 10:34 am
by narcis
Hi cw,

Thanks for the code but it is very difficult to see which the problem is without being able to reproduce the problem here. Could you please arrange an example we can run "as-is" to reproduce the problem here?

Thanks in advance.