From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Clear XY graph

Hello 

I'm working on project data is loged and displyed on XY graph.

 

I just want to place a button when ever user want Clear The Graph and also need to clear During Cod Running (for example for initial or end of Test).

 

I saw here people sugest using "build express XY "  and simply use Reset Input.

but i have to reset in deferent place in code and as far as i know it's imposible .

here is my XY Graph:

 Capture.PNG

and because of using shift register i can't move constant array to bufer array . 

 

 

Best Regards

0 Kudos
Message 1 of 14
(4,860 Views)

Hello,

 

All depends on the framework, there are many possibilities. You can also clear the Graph by the menu you get via right mouse click. You can wire a cluster with empty arrays to the XYGraph, it will delete it also. For this you can use a CASE structure. You can also clear the Graph in similar way via property node value or local variable, but the wire is the recommended and usually possible approach.

 

You have another problem with the example you show: there is indefinitely growing arrays stored in shift registers, after a while this will flood your RAM and crash the application.

Why you connect a Boolean False to the stop condition in the while loop? Never use the red Abort button to stop your VI! Connect a Boolean control.

 

I would really recommend you to go through some learning material:

 

Learn NI Training Resource Videos

3 Hour LabVIEW Introduction

6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training

Message 2 of 14
(4,838 Views)

hello Blokk

 

" You can wire a cluster with empty arrays to the XYGraph, it will delete it also."

 

Yes but after start again it will be displayed again! becasue The array that feed graph didn't change.

 

"there is indefinitely growing arrays stored in shift registers, after a while this will flood your RAM and crash the application."

 

what is your suggestion ?

 

 

"Why you connect a Boolean False to the stop condition in the while loop? Never use the red Abort button to stop your VI! Connect a Boolean control."

 

you are right this not my original code here i just examine how to clear and so on .

 

 

0 Kudos
Message 3 of 14
(4,817 Views)

@mori64 wrote:

hello Blokk

 

" You can wire a cluster with empty arrays to the XYGraph, it will delete it also."

 

Yes but afer start again it will be displayed again! becasue The array that feed graph didn't change.

Use a CASE structure as I said.

 

"there is indefinitely growing arrays stored in shift registers, after a while this will flood your RAM and crash the application."

what is your suggestion ?

 Usually I program a Functional Global Variable which acts as a buffer for data. Inside the FGV I limit the size of the stored data, when the buffer is full, I continuously delete the old data points and add the new data points. There are other options to create such functionality, even built-in ones (for example the "Data Queue PtByPt.vi").

In this way you do not create a memory leak. You could also consider using Chart instead of a Graph, but it depends on your requirements... A Chart has a limited history, by default only stores 1024 points.

As I wrote before, part of these things are totally basic, if you start to learn and go through the teaching material, it will help you a lot! 🙂 I recommend you the Core 1-2 online course!

 


 

Message 4 of 14
(4,812 Views)
  • The data is not stored in the "cluster", it is stored in the shift registers. In order to clear the graph, simply feed an empty array to the shift registers.
  • What is the "cluster" (indicator and local variable) used for? Seems pretty pointless.
  • The cluster local variable is not needed because the values don't matter, all you need is a diagram constant to define the names. No local variable needed. This is one of those occasions where using a plain "bundle" (instead of "bundle by name") would be entirely sufficient.
  • What is the point of "Array 3" and "Array 4" controls? do they even have any interesting data?
  • If you would use a complex 1D array for your graph data, you would only need one shift register, simplifying the code and data structures.
Message 5 of 14
(4,769 Views)

Hello altenbach 

 

"The data is not stored in the "cluster", it is stored in the shift registers. In order to clear the graph, simply feed an empty array to the shift registers"

 

You are right.

 

"

  • What is the "cluster" (indicator and local variable) used for? Seems pretty pointless.
  • The cluster local variable is not needed because the values don't matter, all you need is a diagram constant to define the names. No local variable needed. This is one of those occasions where using a plain "bundle" (instead of "bundle by name") would be entirely sufficient."

I got the point .

 

What is the point of "Array 3" and "Array 4" controls? do they even have any interesting data?"

 

I thought by this way i can feed the arry inside of  while loop .

 

"If you would use a complex 1D array for your graph data, you would only need one shift register, simplifying the code and data structures."

 

 as i know i need 2D array for XY Graph

 

 

here is my try 

 

0 Kudos
Message 6 of 14
(4,736 Views)

mori64 wrote:

What is the point of "Array 3" and "Array 4" controls? do they even have any interesting data?"

I thought by this way i can feed the arry inside of  while loop .


No, they are outside the loop and are only read once at the start of the program. there is no point having those or writing to them once the loop has started. Why would you need to feed them? Are they hungry?


mori64 wrote:

as i know i need 2D array for XY Graph 


Your code does not have any 2D arrays, so what are you trying to say? Obviously you are wrong!

 

In your code, the X-values are spaced evenly in time, so a plain waveform graph would suffice. Why do you even use an xy graph?

 

It is possible that all you need is a chart. No reset needed because the history size is fixed.

 

Learn the difference between xy-graphs, plain graphs and charts and how to use them.

 

Looking at your code, I really recommend that you start with a few simple tutorials, because it is obvious that you lack basic understanding of dataflow. What's the point of the inner while loop? Since it never iterates more than once you can delete it and nothing would change, What is the purpose of the event structure? Since you are polling anyway, an event structure has no purpose. What is the point of the case structure? All you do is spend a nanosecond doing nothing in case zero then go to case 1 forever. (Since you are incrementing by one in all cases, you would get the same value by just tapping into the iteration terminal if you would really need all that, but you don't!).

 

Let's assume that your x-values are actually not spaced evenly and you actually need an xy graph, here's how your old code would look like. Arguably simpler! There is typically no need for hidden controls/indicators and local variables. the data is in the wire!

 

 

 

Now try to rewrite it using a plain graph or even a chart. It would be much simpler!

 

 

 

Download All
Message 7 of 14
(4,677 Views)
Thanks for your replay I need to display Force as X and distance as Y . is it possible using Graph ?
0 Kudos
Message 8 of 14
(4,653 Views)

If your graph is going to use a constant distance between points, you can call the X axis whatever you'd like.  If you want to have different spacing between points, you'll need to remain with the XY Graph.

Message 9 of 14
(4,648 Views)

@mori64 wrote:
Thanks for your replay I need to display Force as X and distance as Y . is it possible using Graph ?

Only if your points (force) are spaced equally in X as in the example. I already said that.

Message 10 of 14
(4,633 Views)