I verified this problem with the MStudio 8.0 for VS 2003 Beta (The beta ended yesterday BTW) and the behavior is the same.
We added the ProcessSpecialValue property for this very purpose because
we noticed that GDI+ (the drawing API in the .NET framework) would
report errors when drawing NaNs (or other special values). It seems you
have hit a special case where if we tell GDI+ to draw a series of
points, and if the first point in that series contains NaN, it throws
the Overflow exception. If the NaN is anywhere else, it seems to be
work itself out. You can see this if you drop a picture box on a form
and add the following to its OnPaint method.
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
PointF[] points = new PointF[5];
for(int i =0;i<5;i++)
points[i] = new PointF(i*20,i*20);
points[0] = new PointF(40,float.NaN);
g.DrawLines(Pens.Black,points);
}
If you change the location of the NaN in the array of PointFs, you will still be able to draw this OK without any exceptions.
This might be one peculiarity. There might be other cases that GDI+
does weird things with special values. I could not find this behavior
elaborated in the GDI+ documentation. But in most cases, I would expect
it to throw exceptions.
I also noticed that if you enable one of the PointStyles on the plot,
you will always get an exception, which makes sense since GDI+ does not
know where to draw the NaN on the screen.
ProcessSpecialValues essentially runs through the data and removes any
NaNs or other values from the array before passing it on to GDI+. We
made this a configurable option since filtering the data everytime
would slow things down. This is off by default.
So if you are fairly certain that the only negative value in your data
array is in the very first index, changing it would be the easiest
alternative. It won't make much sense trying to visualize negative data
on a log scale anyway. There really is no good way to modify the data
for the graph once it has been passed to the graph. Plus this will
allow you to use the PointStyles for the plots and the graph will
handle any special cases for you.
I mentioned the performance hit for enabling that property because
things are a little slower with that property enabled since we do some
additional processing. For you application ( and depending on your
system specs) you might not notice the difference. So I would recommend
experimenting with that property and see if you notice anything.
Another thing you could try is custom drawing the plot. We allow users
to custom draw plots by giving them the array of points and providing
BeforeDraw and AfterDraw events. You would get the array and for your
custom plot modify the point array. Then draw the plot yourself with
GDI+. The help topic "Creating a Custom Plot for the Measurement Studio
Scatter and Waveform Graph .NET Controls" mentions how to do this. This
is alot more work though.
I hope this explains things.
Bilal Durrani
NI