Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

overflow when using PlotYAppend multiple times with a Double.NaN array in C#

Hey all,
 
I am new to using this Measurements Studio, so I have a question that I just can't seem to figure out:
 
 
I want to make a plot of multiple colors, but I can not do this, so I have to basically make two different plots of different colors and pass NaN values to a certain plot when I don't want to see it.  For example:
 
I have a binary string:     00011110101010001110101101010110110001010110101
or it may look like this:    10100100101101010110011001010110101010101
 
The possiblities are endless.
 
 
I want to plot this binary string.  I want Plot1 to be black and plot the black binary numbers and Plot2 to be red and plot the red binary numbers. 
 
I plot just 1 binary number at a time, and I traverse the binary string in a for loop.  So, as you can see, I will have to pass a Double.NaN to Plot2's PlotYAppend method 12 times in a row to start since I traverse the binary string one at a time.
 
 
However, if I do PlotYAppend(nanArray) more than 1 time (where nanArray is an array consisting only of Double.NaN), I get an overflow exception.  How do I fix this?
 
 
Thanks so much!
0 Kudos
Message 1 of 3
(2,855 Views)
You need to set the ProcessSpecialValues property to true on both Plot1 and Plot2 (and any other plot on which you plan to plot NaN and infinity values) for the graph to handle NaN values correctly.
Abhishek Ghuwalewala | Measurement Studio | National Instruments
0 Kudos
Message 2 of 3
(2,847 Views)
Another way to go about this would be to use some custom drawing to draw the plot lines yourself. This will save you from having to have two plots. See the example called Extensibility that is installed with MStudio at [installdir]\DotNET\Examples\UI\WindowsForms\Graph\Extensibility. Look at the OnBeforeDrawPlot method of the example. In a nutshell, it is comparing the current point to the next point to see if it is increasing or decreasing and then using different colors. It also cancels the drawing of the plot by the graph ( e.Cancel = true) because the OnBeforeDrawPlot method is drawing the plot itself. This gives you a lot of control, however, it does require some knowledge of GDI+.
 
Brock
0 Kudos
Message 3 of 3
(2,845 Views)