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.

Example Code

Customizing the Gauge Control in LabVIEW

Code and Documents

Attachment

Description

 

 

image002.jpg

 

Introduction

Customizing controls in LabVIEW only takes minutes and can make a big impact in the usability and visual appeal of your LabVIEW application.  Common reasons for wanting to use custom controls include:

 

  • Desire to make the front panel resemble real world objects
    • i.e. make a gauge look like a car speedometer
  • Setting your application apart from other LabVIEW applications
    • perhaps you are selling or distributing the application and want it to mirror your company’s style or color scheme
  • Developing professional, end-use software for distribution
  • Creating intuitive, easy-to-use interfaces to maximize user efficiency

 

This tutorial will demonstrate how to customize the gauge control in LabVIEW.  Other controls follow similar steps and the principals learned here will easily translate.

Customizing the Gauge Indicator

This tutorial will use the gauge from the modern palette to demonstrate how to customize a standard LabVIEW control.

 

glossy.png

 

Changing Background Images

  1. Start by adding a gauge to your front panel, then select it and copy it to the clipboard. We will come back to it after creating a new background image to replace the plain white background the gauge currently has.

2. There are numerous elements of the gauge control which we can edit. The needle is the notable exception (although you can change its color). There is an advantage to leaving the default frame as it is a vector graphic which scales very nicely. Scaling effects are most visible around the edge of your control so leaving the default frame while customizing the background image and the center piece is a good compromise between scalability and customizability. In this example we will replace the background and center piece.

 

3.       Now you have your background image created it’s time to switch back to LabVIEW. Right click on your gauge and select Advanced»Customize to bring up the control editor.

 

image046.jpg

 

 

4.       Change to Customize Mode by clicking on the wrench icon on the toolbar

 

image048.jpg

 

5.       Customize mode allows you to move, rescale or replace any of the stock components of a control.  In order to use your new background image, right click on the current dial and select Import from File at Same Size….

 

image050.jpg

 

6.       Browse to select your new background image.

 

image052.jpg

 

 

7.       You background will take the place of the original plain background.

 

image054.jpg

 

 

8.       The center piece of the gauge is also replaceable using the same technique.  For this example right click and select Import from File at Same Size… and use the same background image.  You will end up with something like this:

 

image056.jpg

 

9.     Save your new control by selecting File»Save.

 

 

10.   Now when you close the control editor LabVIEW will prompt you if you want to replace the original control.  Click “Yes”.

 

image060.jpg

 

 

11.   Congratulations you have created a nice looking, reusable gauge.  As we created a large background image and kept the original frame your gauge will rescale nicely up to, and probably a little beyond, the size of the original background image size.

 

image062.jpg

 

12.   This is a quick and easy example of what is possible.  Using the control editor you can create almost any style of gauge you’d like, here are few of my favorites:

 

image002.jpg

 

 

13.   In addition to using custom created graphics, using real-life images such as photographs can lend provide a familiar interface to users who are not familiar with virtual instruments.  In this last sample you can see how a photo can be used as the basis of a custom control:

 

image065.jpg

image067.jpg

 

 

 

Other Customizable Elements

The Needle

Properties - Needle.png

 

You can add additional needles to your gauge or change the color of existing needles by right clicking on the gauge and selecting Properties and then the “Appearance” tab.

The Ramp

Customized Ramp.png

 

The ramp has a number of customizable factors.  First of all is whether or not it is displayed at all – you can enable it from the “Scale” tab of the Properties dialog.  The other visual option you have here is “Interpolate Color”.  This option gives you a constant gradient between colors as opposed to blocks of solid color

 

Changing the color of your ramp is done with the same color tool you can use for just about any front panel element in LabVIEW.  You can bring up the tools palette by holding Shift and right clicking on the front panel.  This works in both interpolated and non-interpolated mode.  Even if you intend for your finished product to be interpolated it may be easier to turn it off while you pick colors and then let LabVIEW interpolate once you are done.

 

 

 

 

You can also adjust the radius and thickness of the ramp by clicking and dragging the handles located at the 12:00 position.

 

 

Scale Ramp.png

 

Finally you can adjust the starting point for your gauge by hovering over a tick mark until your cursor changes (as shown below) and then rotating the entire scale around.

 

Customized Ramp - StartPospng.png

 

 

The More We Share the Easier It Will Get

I strongly encourage anyone who is creating custom controls to share them with the community if your situation allows.  Any customizations can be saved and distributed very easily by simply saving your custom control and uploading the .ctl file to this community group.  As the group grows and more controls are posted you might be able to just download the design you want rather than creating it from scratch as shown here.  You can find all the controls I showed in this tutorial in the attached zip file.

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Evan R.
NI Employee (retired)
on

Who's got the Canadian vehicle??

Elijah_K
Active Participant
Active Participant
on

Well, Simon is a Brit.  Makes for a good excuse if you get caught speeding... "I don't know what 30 mph is!"

Great job Simon, by the way.

Elijah Kerry
NI Director, Software Community
SimonH
NI Employee (retired)
on

Actually Britain still uses mph.  It would be too expensive to change all the road signs to km.

Esley
Member
Member
on

First of all, I want to say thank you very much. I am now looking for a guideline to make my front panel resemble real automobile dashboard. And your help is available. I just a temporary labVIEW learner, so I really like to see your example file, but I only have LabVIEW 8.5. Do you mind saving as file for 8.5 or older verson. If you wouldn't upload on this site, just send to my e-mail address: Esley.Ng@gmail.com.

And I want let you know that your name will be appear in my project (gratitude page) like a contributor. Your tutorial is the key I need to finish my work.

FabiolaDelaCueva
Active Participant Active Participant
Active Participant
on

The document clearly says:

" There are numerous elements of the gauge control which we can edit.  The needle is the notable exception (although you can change its color)."

But what if I need to have a thicker needle. Is this possible?

Thanks

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
Christina_R
Active Participant
Active Participant
on

The needle can be replaced with any of the "line" decorations and maintain its rotational functionality. Perhaps "Thick line with arrow" would work for you?

Unfortunately, you cannot replace the needle with arbitrary graphics or modify its shape directly.


Christina Rogers
Principal Product Owner, LabVIEW R&D
FabiolaDelaCueva
Active Participant Active Participant
Active Participant
on

Hi Christina,

Thanks for the prompt response.

Unfortunately the "Thick line with arrow" is thinner than the default needle in the gauge.

Thanks,

Fab

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
Christina_R
Active Participant
Active Participant
on

I thought maybe you just needed the tip more visible. Is it that you still want the triangular shape but you want the base (at the center of the gauge) thicker?


Christina Rogers
Principal Product Owner, LabVIEW R&D
FabiolaDelaCueva
Active Participant Active Participant
Active Participant
on

We want to keep the triangular shape and just make it thicker.

The operators sit far from the monitor, they want to have a way to tell from a distance where the needles are at. At this point they don't need to see the exact number where the needles are pointing at, but more the relative position of the needles.  There is a digital display to tell them the exact number.

Since there is no way to edit the thickness of the needle, I will suggest adding the ramp to the dial to see if that would help them.

Thanks again,

Fab

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
FabiolaDelaCueva
Active Participant Active Participant
Active Participant
on

And just in case someone else sees this post and is trying to do the same thing, there is an idea that needs your vote:

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Custom-Meter-Gauge-Needles/idi-p/1006643

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
beaugauge
Member
Member
on

good gauge control

www.beaugauge.com

BeauGauge Controls.jpg

FabiolaDelaCueva
Active Participant Active Participant
Active Participant
on

Beaugauge,

Those look great, can they be used in LabVIEW?

Fab

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
FabiolaDelaCueva
Active Participant Active Participant
Active Participant
on

Answering my own question:

1) The beaugauge can be used in LabVIEW, because they are Activex controls.

2) The beaugauge controls cost money (start at $995)

...

I would prefer for LabVIEW to offer more customization capabilities:

Related ideas:

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Update-Front-Panel/idc-p/1020365#M3177

http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Custom-Meter-Gauge-Needles/idi-p/1006643

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
beaugauge
Member
Member
on

"How to use BeauGauge ActiveX control in your LabVIEW project"

http://www.beaugauge.com/en/edu034.html

219-labview-gauge-iocomp-dundas-activex%20gauge-Industrial%20Control-Dashboard-Widget-beaugauge.jpg

TroyK
Active Participant
Active Participant
on

They're definitly impressive looking guages.

If nothing else, they cetainly show the cost of the LabVIEW development system to be quite reasonable.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
RC-Freak
Member
Member
on
RC-Freak
Member
Member
on

Hi Folks,

just to show you the progress ... altitude gauge, turn bank indicator including the inclinometer as well as the other gauges are fully working now !

have Fun

All_Instruments_VIII.JPG

barddya
Member
Member
on

Great Job.

Thanx

Nayrf
Member
Member
on

Very Nice Gauges!

I just want to ask if we can change the length of a needle without affecting the length of other needles on the gauge. Appreciate your help. Thanks.

RC-Freak
Member
Member
on

Hi Folks,

now, the cat is out of the bag

http://forums.ni.com/t5/LabVIEW/Airplane-Instruments-quot-Six-Pack-quot/td-p/3232032

Merry Christmas ... Ho..Hoo..Hoo

Carsten

W.Nijs
Member
Member
on

Whow, verry nice. And... yes, ho.. ho.. ho... try it at the hollidays. Does someone worked on controls as a joystick?

Merry Christmas and a Happy New Year.

Wijnand

yukeyang
Member
Member
on

nice work,i just anolog the second gauge,but the scale is outside the number in my control,while yours scale is inside the number,cant figure it out,could u tell me how to move the scale inside the number?捕获.PNG捕获1.PNG

Christina_R
Active Participant
Active Participant
on

I believe what you want is the "Reverse Ticks" command that's in the context (right-click) menu on a scale in the Control Editor.

2016-03-09_1513.png2016-03-09_1514.png


Christina Rogers
Principal Product Owner, LabVIEW R&D
yukeyang
Member
Member
on

fantastic,great thx.Kudos to U!

Julien_V.
Active Participant
Active Participant
on

Hello,

Nice tuto, thanks.

And my results :

Sans titre.png

Cordialement,

Julien V.

[FIRST]

[LabVIEW Programming]


[FIRST]

nickexists
Member
Member
on

Awesome work! are you willing to share the files?

Julien_V.
Active Participant
Active Participant
on

Thanks.

Yes I can share it.

But the controls are not resizable.

Cordialement,

Julien V.

[FIRST]

[LabVIEW Programming]


[FIRST]

nickexists
Member
Member
on

Cool. Thanks!

dreamheart
Member
Member
on

I have a question, I have a gauge and I want to set it so I have on the ramp two red sections, two yellow and a green one. Is that possible? I'll try to show two examples, 1 is how I have it now. 2 is my goal. any help pls? (I know the photo looks awful, but a physical representation explain more than just words 🙂

gauge.jpggauge fixed.jpg

gilgamesch
Member
Member
on

If you didn`t find the answer and for anybody else.

 

You can insert more colours to your colour ramp if you check custom scale devision.

instrument.png

 

 Then you have to click on the place of the scale where you want to have it and insert a new subdivision. Now it is necessary to check that automatic mouse mode on this way you can move your subdivision on the rim or you can change the division by using the text mouse mode. With every new subdivision comes a new placeholder for colouring the colour ramp. You can see this easily if you uncheck the colour transitions option.

Contributors