LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problem changing trace attributes with strip chart

Hello,
 
I have a set of measured data points that I plot it a strip chart. I want some of these points to be red others white.
 
In CVI 8.2 I simply changed the trace attribute for every point and used plotStripChart for each point. Not a very efficient way
to do this but it works.
 
for (i=0;i<Pp_numNewWeightPt;i++){
      stripData[0]= Pp_weightData[i];
      stripData[1]= Pp_linWeightData[i];
     
      if (Pp_weightSampleIsValid[i]==1){
       SetTraceAttribute (Pump_TabPanelHandle, PUMPPANEL_Pump_ResinWeightSC,
              1, ATTR_TRACE_COLOR, VAL_WHITE);
       }
      else{
       SetTraceAttribute (Pump_TabPanelHandle, PUMPPANEL_Pump_ResinWeightSC,
              1, ATTR_TRACE_COLOR, VAL_RED);
       }
      
      PlotStripChart (Pump_TabPanelHandle, PUMPPANEL_Pump_ResinWeightSC, stripData, 2,
          0, 0, VAL_DOUBLE);
      } 
 
The same code in 8.5 does not produce the same results. When new point are writen all the points are red or white. The existing points on the SC also chagne color to either all red or white.
 
What can I do?
 
 
 
Thanks
EP
 
 
 
0 Kudos
Message 1 of 7
(4,453 Views)
Hello EP,

There is no function in CVI 8.5 that allows you to change the color of parts of a Trace.  It was also not available in earlier versions of CVI.  I tried your code in earlier versions and it also changed the entire Trace.  Are you sure you were using a stripchart in the past and not a graph? 

There is a link to a product feedback page here: http://sine.ni.com/apps/utf8/nicc.call_me
You can suggest that the CVI developers look into adding the functionality to change certain points in the future.
Kristen
National Instruments
0 Kudos
Message 2 of 7
(4,413 Views)

KristenC,

I have the same problem, so I have thougth the following algorithm:

- I define two traces in the stripchart (one in green color, the other in red color).

- The two traces have the SAME values to be displayed, and are displayed one point at time.

- IF the trace has to be displayed in green color, I draw FIRST the RED COLOR trace, THEN the GREEN color trace;

- OTHERWISE  I draw FIRST the GREEN COLOR trace, THEN the RED color trace;

The second drawn trace should overwrite the first drawn trace.....

Do you think that this algorithm could work?

THANKS!

0 Kudos
Message 3 of 7
(4,373 Views)
Thanks for the suggestion. It sounds like it could work. I will try it and let you know.

Is there a way to delay displaying of traces? By this I mean sending individual value to the plot using plotStripChart and then displaying all the point in one refresh of the stripchart.


0 Kudos
Message 4 of 7
(4,369 Views)
Hey MaxtheMax
 
Had more time to think of this problem. I dont think you sugestion will work. The reson is because you have to plot all the traces at the same time. There are no function that let you selectivelly plot traces.
 
Kristen to awnser your question, yes i'm sure I was using a strip chart and not a graph. The previous version I was running was labWindows 8.0 I would like to show you but i've uninstalled it.
 
 
0 Kudos
Message 5 of 7
(4,289 Views)
Hello EP000,

After further investigation I was able to reproduce the behavior you are describing.  Using the same code I am seeing different behavior setting attributes on the stripchart control between CVI 8.0 and 8.5.

This was reported to R&D (# 116813) for further investigation.  I do not have a possible workaround at this time, if one is found we will post it to this forum.  Thank you for your feedback and we are sorry you are encountering this problem.
Kristen
National Instruments
0 Kudos
Message 6 of 7
(4,272 Views)

EP000 and MaxtheMax,

Unfortunately the behavior you were seeing prior to CVI 8.5 was technically a bug. Trace attributes such as ATTR_TRACE_COLOR were supposed to apply to the entire strip chart and not just individual points or ranges of points. When CVI 8.5 was released we made several changes and improvements to the strip chart code to allow things such as Autoscaling Y-Axis, History Buffers, etc.. Because of these changes when you make a change to either the axis or trace attributes the entire strip chart must be refreshed which causes all traces to be essentially replotted with the active trace settings, such as the current color. The new strip chart code forced us to close this loophole and there isn't really a way to re-enable what you were seeing. Unfortunately some users such as yourselves were exploiting the incorrect behavior to achieve desired effects on the strip chart that never would have been possible otherwise.

There are two possible workarounds, but neither is perfect. Probably the best way to replicate the behavior you were seeing would be to replace the strip chart with a graph control. You could then use a single call to PlotY to handle each contiguously colored block of points. You would have to handle scrolling the X-axis yourself though. Also you'd need to either buffer the points until you wanted the color to change, or you could create a lot of 2 point plots which just go from yData[i-1] to yData[i] so that you get what appears to be one continuous plot. If memory issues became a concern you could delete plots once they are no longer visible on the graph.

If you must use a strip chart you could change the plot mode to scatter, and add two traces, one white and one red. Then when you determine which color you want for the next point, you could plot the "true" value to the proper trace and plot a value that would be outside the visible y-axis range to the other trace. Autoscaling would need to be disabled for the Y-Axis for this to work. This is probably the simplest solution, but because it involves scatter plots the individual points would not be connected, which might not be desirable depending on your application.

I'm sorry that we don't have a "better" solution for you.

Kevin
NI

Kevin B.
0 Kudos
Message 7 of 7
(4,217 Views)