LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to determine plot type

Solved!
Go to solution

Hi,

 

I am using a xy graph with a varying number of plots: a few line plots and several xy plots.

 

After plotting I would like to inspect the data: For this purpose I thought to cycle through the plots using ATTR_FIRST_PLOT and ATTR_NEXT_PLOT.

 

Then using GetPlotAttribute ( ATTR_PLOT_YDATA ) I thought to obtain the data sets for analysis - provided that the plot is a xy plot and not a line plot... Unfortunately I did not find a suitable attribute that I could read to distinguish between a line plot and a xy plot - using GetPlotAttribute ( ATTR_PLOT_YDATA ) on a line plot is invalid and will return an error. (There is no plot attribute plot type)

 

The only trick I could think of is using different line types for plotting - but in this case the xy plots are scatter plots ...

 

Hints are welcome...

0 Kudos
Message 1 of 6
(4,563 Views)

Well, it seems you are right: there seems to be no attribute to retrieve the plot type!

 

What I can think of as a workaround is either of the following options:

  1. Save all valid plot handles in an array and iterate on array elements to retrieve plot data
  2. Trap error -123 (invalid attribute) while getting plot data and skip traces. You will need to disable "Break on library errors" before doing so: you can either do it in the IDE (valid for the whole application) or set it programmatically with SetBreakOnLibraryErrors only around that section of code


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 6
(4,556 Views)

[EDITED NOTE: Roberto beat me to it again.  I didn't see his response before I posted mine, but here's my response anyway.]

 

Wolfgang:

 

I'm surprised that there is no attribute for plot type, but I couldn't find one either in GetCtrlAttribute or GetPlotAttribute.  The plot type seems like a pretty basic and important thing to know.  You can GetPlotAttribute on the ATTR_PLOT_STYLE, but the style is not the same as the type.

 

If you want to just try reading the YDATA for all plots and skip any plots that generate errors, you can use SetBreakOnLibraryErrors (0);

 

I generally don't like disabling all library error dialogs, so I'll use SetBreakOnLibraryErrors just for the code I know I'll handle the errors on.  And to be the most flexible, I'll save the current break state when disabling it, so I can restore the previous state later.

 

For example:

 

int prevBreak;

 

//....

 

// disable library error dialogs, saving the previous break state

prevBreak =SetBreakOnLibraryErrors (0);

 

// code for which I want to handle or ignore library errors

// ...

// restore the previous break state

SetBreakOnLibraryErrors (prevBreak);

0 Kudos
Message 3 of 6
(4,551 Views)
Solution
Accepted by topic author Wolfgang

There is an undocumented plot type attribute, which you can use. You can't set it, but you can get it.

 

You can find it in this list of undocumented attributes. In this case, you don't have to worry about the disclaimers I made in that post. After having made that list public, we're certainly not going to deprecate any of them in a future version, and this particular attribute is as straightforward as they come, so you also don't have to worry about it being buggy.

 

Sorry for the trouble.

 

Luis

Message 4 of 6
(4,538 Views)

Hi Luis,

 

thanks a lot, that's great news! What about making this attribute public in the next release?

 

Roberto, Al, thanks for your toughts and suggestions!

0 Kudos
Message 5 of 6
(4,521 Views)

Okay, we'll add it in a future release, although it probably won't be in the very next one.

 

Luis

0 Kudos
Message 6 of 6
(4,505 Views)