Tooltip HTML rounding decimals

Tooltip HTML rounding decimals

John_DeLeeuw
Advisor Advisor
685 Views
4 Replies
Message 1 of 5

Tooltip HTML rounding decimals

John_DeLeeuw
Advisor
Advisor

I tried several Javascript functions to get my Tooltip numbers rounded to the nearest integer but none work in Tooltips.

 

Anybody have a suggestion that really works?

 

JohnDeLeeuw_0-1643023031476.png

 

John de Leeuw
Senior Consultant

Community Ambassador - Twitter - LinkedIn

0 Likes
Accepted solutions (1)
686 Views
4 Replies
Replies (4)
Message 2 of 5

Karsten.Saenger
Autodesk Support
Autodesk Support

Hi @John_DeLeeuw ,

 

this is a known behavior in InfraWorks with customized tooltips, it's always displaying 15 digits.

The only workaround, for now, is to convert the numbers to strings in the script.

 

Regards,

Karsten.



Karsten Saenger
0 Likes
Message 3 of 5

John_DeLeeuw
Advisor
Advisor

@Karsten.Saenger , can you provide an example script because normal javascript isn't fully working inside tooltips. I tried looking at the QT Developer Network site, mentioned here in the online help but could not find any working example.

 

My code now:

<script>
var num = %USER_HOOGSTE_GOOT%;
var text = num.toString();
var result = text.slice(0, 4);
</script>

And then try using the result in the HTML code write but that also seems difficult. 

John de Leeuw
Senior Consultant

Community Ambassador - Twitter - LinkedIn

0 Likes
Message 4 of 5

ronnie.xue
Autodesk
Autodesk
Accepted solution

Hi @John_DeLeeuw ,

 

By default, the tooltip only supports simple HTML tags that outlined here - Supported HTML Subset | Qt GUI 5.15.8 so javascript is not working there.

To use javascript, you'll need to either include a <img> or <iframe> tag in the script so that full HTML support is activated. For instance, here's a trick to display area with 2 decimal places.

ronniexue_2-1643421728174.png

 

If only simple text is needed and the assets are imported, the conversion of tooltip can actually being done in import script in Data Source Configuration as well, for instance, here's how to set the tooltip of roads to the max speed with 2 decimal places

 

ronniexue_1-1643421598796.png

 

Message 5 of 5

John_DeLeeuw
Advisor
Advisor

@ronnie.xue thanks Ronnie, that works like a charm! 👏

John de Leeuw
Senior Consultant

Community Ambassador - Twitter - LinkedIn

0 Likes