LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incorrect XY Graph Scale Properties

Solved!
Go to solution

Hello,

I have come across a problem with retrieving the scaling properties for XY Graphs. I have developed a LabVIEW top level VI for the purposes of plotting our acquired data sets. Typically, these data sets have fixed number of parameters (10) and depending on the duration of our test, the number of samples per parameter varies. So far so good…I am able to retrieve the data from the tab delimited files in which they exist and plot them on XY graphs in LabVIEW without problem.

The second part of the application is where I have been running into problems. I have created code that utilizes ActiveX mechanisms to transfer the “raw” data from LabVIEW into Excel spreadsheets and then plot the data on Chartsheets within Excel – all using ActiveX functionality. This is all working just fine and allows us to quickly get the results of our testing into a format for presentation to our customers in PowerPoint (copying of plots from Excel).

The problem I am having is that I wanted to use the scaling parameters for my LabVIEW XY graphs to format my Excel plots. To do this I tried using the XY Graph properties. I have been attempting to use the values returned for the YScale.Range & XScale.Range (clusters) properties to set my scales in Excel and have found that these properties rarely return the correct value. In addition I have tried retrieving scaling values using individual elements (XScale.Maximum, XScale.Minimum, XScale.Increment, and  XScale.MinorInc, for the X-Axis & YScale.Maximum, YScale.Minimum, YScale.Increment, and  YScale.MinorInc, for the Y-Axis and run into the same issue.

Initially I figured the problem was on my end due to my inexperience with ActiveX and the limited documentation/example available for using it. After tracing it back, I was surprised to find that the problem was in LabVIEW. The retrieval of the correct scaling parameters is erratic – sometimes they are correct however most of the time they are incorrect and do not reflect the ranges associated with the current data set.

Rather than submitting my larger LabVIEW application I developed a small test VI to do some testing on my end and illustrate my situation via my submitted VI Test_Property_Fetch.VI. For this VI I have created 5 XY graphs which I populate with random data each time the Generate Data button is depressed. For each new generated data set, I plot the data then retrieve the X & Y scaling parameters. The scaling settings before & after the new data sets are plotted are presented in the arrays of clusters on the Front Panel to demonstrate that the scaling values do not properly reflect what the XY Graphs show. Sometimes they do and sometimes they don’t update as expected – primarily the settings for one plot are accurately updated while the other four don’t. And the array element that updates correctly changes randomly.

I’ve tried plotting the data using XY Graph references and directly – same problem.

I’m running LabVIEW 2017 (Version 17.0.1f3 (64-bit)) on Windows 10 64-bit laptop (i5-63000U CPU @ 2.40GHz, 8.00 GB).

I can provide more info as needed. Two screen shots of my block diagram (too large for 1 snip!)

Test_Property_Fetch1.JPGTest_Property_Fetch2.JPG

Any help is greatly appreciated!

0 Kudos
Message 1 of 8
(4,054 Views)

Please use the default font when composing a post. Your tiny font makes it very difficult to read on small, high resolution monitors.

0 Kudos
Message 2 of 8
(4,025 Views)

Obviously, only the graph on the currently visible tab updates.

 

Not sure why you are writing all these properties that are invariant across runs. Once set and the VI saved, they no longer need to be set.

0 Kudos
Message 3 of 8
(4,016 Views)

In any case, just add a "force redraw" method to update the graphs on other tabs. Works just fine now.

(I would probably add it to the next FOR loop before reading the properties to keep it simpler)

 

ForceRedraw.png

 

 

0 Kudos
Message 4 of 8
(4,014 Views)
Solution
Accepted by CaveDweller

Here's a simplified version showing only the gist of my above suggestion.

 

ForceRedraw2.png

Message 5 of 8
(3,999 Views)

Hello Altenbach,

 

Thank you very much for your help! The ForceRedraw Method has resolved my issues with obtaining the correct scaling settings for my XY Graphs. The fact that scaling values associated with the active tab were being updated correctly was completely missed by me (DUH! on my part!). Since I don't have a good algorithm for setting the scales for our data sets dynamically the ability to leverage the good job LabVIEW does in this area for generating plots in Excel is very nice.

 

In my search to figure out what my problem with getting the correct scaling information from run to run I was updating the properties thinking that with each new data set the XY Graph was being reset that is why it was used. As you pointed out doing this is not necessary since the properties are maintained - thank you for clarity on this.

 

Apologies for using the smaller font. As my post was quite wordy I was trying to fit everything into a small space. I will try to remember to use the default font in the future.

 

Thank you for the help you have provided to me as well as others! Much appreciated!

Message 6 of 8
(3,938 Views)

To be fair, I was initially not aware of the ForceRedraw method, but I was aware that graphs on hidden tabs don't properly update, most likely for performance reasons. While I do often have graphs on many tabs, my code architecture ensures that things redraw once a tab gets into view (example).

 

Once I studied your code, I was wondering if there is a method to force a graph update, and there it was! So thanks for making me indirectly aware of it by posting. 😄

 

Of course forcing hidden redraws might cause performance issues if there are many graphs with lots of data each, so it is probably worth thinking about when and when not to use it. In your case it seems fine.

 

Good luck!

Message 7 of 8
(3,915 Views)

Hello Mr. Altenbach,

 

Could be possible to downdate your file to LabVIEW 16.0f5 (64-bit)?

 

Many thanks in advance for your time.

0 Kudos
Message 8 of 8
(2,458 Views)