From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Multi Plot Chart with TIME in the X-axis

Solved!
Go to solution

I have been wrestling with charts in LabVIEW for over a decade. For the first five years or so of LabVIEW programming I even though it was impossible to plot a chart. The examples are useless as they realy do not explain how or why they work. They are made to polt a pretty graph but they can not be used for any other purpose

 

All I want is a simple chart I can wire measurments into with each one drawn on a seperate plot and the current time in the X-axis.

 

All plots and the X-Axis is updated at regulat intervals.

 

Why is this so freakin' difficult?

 

I have tried the "wire current time to X-axis offset trick" (why do we still have to do stupid tricks like this?) but the axis does not update 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 1 of 20
(5,288 Views)
Where's your code?

I don't see where providing the start time to the offset property is stupid or a trick. The time has to come from somewhere and this is the way you have to do it if you don't provide a waveform data type that has the start time included
0 Kudos
Message 2 of 20
(5,284 Views)

@RTSLVU wrote:

I have tried the "wire current time to X-axis offset trick" (why do we still have to do stupid tricks like this?) but the axis does not update 


If you want a absolute time formatted x-axis and the updates occur at regular itnervals, all you need is set x0 (x-scale offset) to the current time once at the start of the program. All later times are calculated from the dt (x-scale multipler), even after the history size is exceeded.

 

There are no tricks (stupid or otherwise) involved.

 

Please show us your code, maybe you are doing things wrong (e.g. update x0 with each iteration or similar).

 

If you think that the examples are not good, provide constructive feedback to NI. I am sure they would appreciate it. Thanks!

0 Kudos
Message 3 of 20
(5,273 Views)

Here is my code, or at least the top level VI.

 

I set x-scale offset to the current time at the start of the program in the "start" case.

 

My graph shows the time the program started at both ends of the X-axis and it does not update even as teh chart starts to scroll to the left it always shows the same time.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 20
(5,259 Views)

The scale will start moving once you have exceeded the history buffer size. Before that, only the right side will move, of course, because your x scale is set to autoscale and it will do that until 3600 points have been added.

0 Kudos
Message 5 of 20
(5,235 Views)

@altenbach wrote:

The scale will start moving once you have exceeded the history buffer size. Before that, only the right side will move, of course, because your x scale is set to autoscale and it will do that until 3600 points have been added.


Hmmm... Okay maybe I was not waiting long enough?

 

Anyway how do I make a chart that will start out with the current time on the left end of the X-axis and current time plus one hour on the right.

 

Then once the data reaches the right end the chart should scroll to the left  always showing the last hour of data on the chart?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 20
(5,193 Views)
  • turn off  autoscaling
  • Set the xmin to t0  and xmax to t0+1hour at the beginning of the run. After 1 hour, the markers will start scrolling.
  • Set the chart history lenght to exactly 1 hour of data based on dt (this can only happen in edit mode and cannot be changed during run).
  • Actually it is probably sufficient to set the chart history to >1 hour as long as the visible  range is 1 hour. the extra data would simply scroll of and could be retrieved by showing the x scrollbar.
  • Another possibility would be to set t0 to "current - 1 hour" and set the chart history to an array of NaN data equivalent to one hour. (I have not tried this).
  • ...
0 Kudos
Message 7 of 20
(5,185 Views)

@altenbach wrote:
  • turn off  autoscaling
  • Set the xmin to t0  and xmax to t0+1hour at the beginning of the run. After 1 hour, the markers will start scrolling.
  • Set the chart history lenght to exactly 1 hour of data based on dt (this can only happen in edit mode and cannot be changed during run).
  • Actually it is probably sufficient to set the chart history to >1 hour as long as the visible  range is 1 hour. the extra data would simply scroll of and could be retrieved by showing the x scrollbar.
  • Another possibility would be to set t0 to "current - 1 hour" and set the chart history to an array of NaN data equivalent to one hour. (I have not tried this).
  • ...

Should I still set Xscale.Offset to the current time at the beginning of my program?

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 20
(5,171 Views)

Yes, if you want to have the markers in absolute time.

0 Kudos
Message 9 of 20
(5,153 Views)

That does not seem to work for me.

 

minh.PNG

Here I set the X-scale min to the current timh and X-scale max to the current time + 3600 (1hr)

 

But my chart X axis only shows a couple minutes AND the X-axis is not keeping up with the data.

I took this screen shot at 9:03 the chart is holding about 15 minutes of data but the X axis does not match up with the data.

 

X-axis.png

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 20
(5,147 Views)