LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Chart Axis Scaling

Is there a way of automatically scaling a chart axis so that it is either has a set range or if the data is outside of that range it starts 'autoscaling'.

 

For example, I want my Y axis to be 0..100 all the time, unless the data is larger than 100, then I would want the y axis to be 0..<max value>. 

 

Similarly, if the data fell below 0 I want the range to be ,<min value>..100.

 

This is being applied to charts with multiple Y axis with multiple plots on each y axis which the user can turn on/off.

 

I have had a stab at coding something but it has turned into a monster because it has to handle:

- The fact that the chart is effectively a buffer of elements so I have to create and manage my own buffer for each plot to extract min/max values (I could get it from the history data property node I suppose but that is a cluster for each X axis position so also doesn't quite work)

- The user making plots visible/invisible so that it only scales to visible plots

 

I am just hoping that there is a property that does this automatically which I have missed. If not I will have to have another stab at coding something myself.

 

(I haven't posted the code because I have realised that it is no way near fit for purpose and would just muddy the waters) I may refactor it so that I am using a graph and managing the myself, may be easier.

0 Kudos
Message 1 of 4
(1,078 Views)

The Graph and Chart are really nice features in LabVIEW, but they are not always as "flexible" as we'd ideally like them to be.  On the other hand, with a little (or a lot) of work, we can "massage" them in various ways ...

 

I picked up on your mention of going to a Graph.  A fellow named Steve Bird (whose Web site I've misplaced) described (a decade ago?) something he called the "Monster Graph", which was a way of "having your Chart and Seeing it, too" (that is, flexibly changing the X Axis).  I coded it up for myself and called it the "Flexi-Graph" (sounds more "friendly" than "Monster") and in the several cases that I used it, was quite satisfied.  

 

The basic idea for this "Graph substitute" is if the data come in at a slow-enough rate, you can keep a record of the "last N points" (a circular buffer, or a lossy Queue) and use it to manage your Y scaling.  [It gets complicated if you have multiple traces with multiple gains, but that's why good programmers are well-paid ...].  You need to do computation for each point that comes in, but the number of points remains fixed to your Chart/Graph width.

 

Bob Schor

 

 

0 Kudos
Message 2 of 4
(1,049 Views)

I also needed to do something like this in the past (unusual, because I usually have XY graphs and not charts), and in that case, I simply ignored the history and tracked only a very limited history under the assumption that all that really matters is the "current" state.

 

To do this, I ran the VI to control this every time I updated the chart and gave it only the updated value. The history part was simply managed inside the VI on a binary level (if are you stable inside or outside the range for X seconds then set the scale to the range or to autoscale). You can use the Elapsed Time express VI to check if the condition is stable (use the reset input) or code a version which will suit your needs.

 

Note that if you have multiple charts, you will need to make your VI preallocated reentrant, as each instance should have its own memory.

 

If you do need to track the entire history, then you have been given other options. Personally, this is usually my preference anyway, as I prefer using XY graphs, which require having all of the data.


___________________
Try to take over the world!
0 Kudos
Message 3 of 4
(997 Views)

Option 1: You want it to scale "larger" immediately, but not scale "smaller" at all?

I have used the property "Set Autoscale Delay" for precisely this function in the past.

 

https://www.ni.com/docs/en-US/bundle/labview/page/lvprop/graphchart_autoscale_delay.html

 

Just set it to a value like 3 years and you should be good.

 

Option 2: If you want it to autoscale, but have a "minimum" scale, then add some data to the graph associated to each axis, and pass values "0,100" to it. Then set the line draw properties to make both the line and points invisible. Now your graph will not autoscale below this., Minimum will always be 0 or lower, maximum will be 100 or larger. You will need some kind of "parser" when actually writing your data of the graph where you add the "0,100" data at the appropriate indices (preferably at the end of the array of data).

0 Kudos
Message 4 of 4
(964 Views)