cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to set the number of decimals in the Slider widget?

tsmith-4
1-Visitor

How to set the number of decimals in the Slider widget?

How to set the number of decimals for the Value that is displaying in the Slider Widget?

What is the best practice regarding "rounding" of numbers when it is going to be displayed?

2 REPLIES 2
Aanjan
12-Amethyst
(To:tsmith-4)

Tommy, you can control the slider step however lower you want, as it works based on the value given to the Step property (which by default is 1). If you have a NUMBER property bound to the slider, it would display whatever the value is, regardless of what decimal point it has.

alexe1
12-Amethyst
(To:tsmith-4)

You can pass the value through an expression widget first to round it just for the UI.

For example, if you create an input "myInput" for an expression widget, you can use the expression myInput.toFixed(2) to round it to 2 decimal places, then just assign the output of the expression to the slider. Of course you'll need an expression widget for each slider you have.

Its a little clunky, but can be useful in some situations, especially for something like the slider which does not give you the option to render the number how you want.

Announcements


Top Tags