LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variable time formats

Solved!
Go to solution

I have a slider control representing a timespan:

 

Untitled.png

 

Most of my tests involve time spans under a few minutes, but they can be as long as hours.  Is there a way to specify the display format to output short relative time if hours or minutes are zero?  For example:

 

20 seconds displayed as just 20

62 seconds displayed as 1:02

42 minutes 42 seconds displayed as 42:42

1 hour, 49 minutes, and 42 seconds displayed as 1:49:42

 

Etc..

 

Thanks,

 

XL600

0 Kudos
Message 1 of 10
(3,643 Views)

It's possible to set the 'Marker Values' or to use text labels as markers. I'm not sure which would serve you better, but programmatically setting the values you want to display and changing the format appropriately should work out.

 

I attach a VI Snippet to demonstrate doing this with minutes and seconds.

 

markerValues.png

 

 


GCentral
0 Kudos
Message 2 of 10
(3,605 Views)

The marker values have to be numeric with a format string, which seems to prevent truncating leading zeros when time is selected %<...>t.  Is there a way to supply custom text in place of marker values?

0 Kudos
Message 3 of 10
(3,590 Views)
Solution
Accepted by topic author xl600

My suggestion was that given you presumably know the length of the data, you can determine which you want (eg from a choice of "%<%H:%M:%S>t", "%<%M:%S>t" and "%<%S>t") and then call the property node with the format specifier. I don't know if you'll also need to change the limits of the scale or the numeric values via an array (like in my example).

 

To call it automatically, you could place this code with some checks on the maximum time of the data (assuming it starts at 0 - if not, the width of the data perhaps) and then call it each time you update the graph/chart/table, or once per minute, or similar. The less often you call it, the less impact it will have on your speed, but whether that matters to you depends on what else you're doing and your computer, I suppose. If you're already changing the limits based on the values in the graph/chart/table, then you should have the information readily available.


GCentral
0 Kudos
Message 4 of 10
(3,584 Views)

In the spirit of more accurately answering your second question though - yes. I just don't think it's likely to be the simplest way.

 

See the example below. I enabled text labels (right click on your slide) and then removed the 'Text Display' from visible items.

 

textLabels.png


GCentral
0 Kudos
Message 5 of 10
(3,583 Views)

I tried your suggestion as follows (This is my span select initializer called whenever my underlying run information changes):

 

Untitled3.png

Works pretty well and produces a pretty good display.  I also tried the text label approach, but it was a bit more convoluted so I think I'll stick with the FormatString approach.

 

This did get me thinking... When dragging the slider, the small pop-up value display shows DBL.  I wasn't able to find any format string property for that to get it to display in time mode.  So, the value indicated while moving the sliders is disconnected from the slider labels when a time label is used.

 

Untitled1.png

 

Thanks for the tips!

 

0 Kudos
Message 6 of 10
(3,566 Views)

@xl600 wrote:

This did get me thinking... When dragging the slider, the small pop-up value display shows DBL.  I wasn't able to find any format string property for that to get it to display in time mode.  So, the value indicated while moving the sliders is disconnected from the slider labels when a time label is used.

 

Untitled1.png

  


Ah. That's a little frustrating, but I suppose it's just a reflection of the actual value stored. If you don't like it, you can remove it, but I can't find a way to change what it reads.

 

If you want to hide it, you need to either right click, go to properties, and untick 'Show value tip strip', or use a property node to set the same property to false. You won't need to do it each time you refresh though - just when you create it (so the right click should be simpler).


GCentral
0 Kudos
Message 7 of 10
(3,531 Views)

Thanks again!  After hiding the tip strip, I realized the digital displays can be separately formatted.  You can't change the basic recessed look of the 'modern' control, but this is a pretty good way to display:

 

Untitled.png

 

All I had to do is tie the format strings together...

 

Untitled1.png

Message 8 of 10
(3,521 Views)

@xl600 wrote:

Thanks again!  After hiding the tip strip, I realized the digital displays can be separately formatted.  You can't change the basic recessed look of the 'modern' control, but this is a pretty good way to display:

 

Untitled.png

 

All I had to do is tie the format strings together...

 

Untitled1.png


Did you try to customize the control?

 

Advanced >>> Customize

 

Click the wrench and change it to blow torch

 

Right click the control and choose "replace" then navigate to the classic simple numeric.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 10
(3,508 Views)

Always some way to do it Smiley Tongue

 

  • Customize the control
  • Replace the digital displays with 'classic' numeric
  • Set the background and border to transparent
  • Save the control

 

Untitled.png

 

Looks great now!

 

Thanks!

0 Kudos
Message 10 of 10
(3,505 Views)