Community
InfraWorks Forum
Welcome to Autodesk’s InfraWorks Forums. Share your knowledge, ask questions, and explore popular InfraWorks topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tooltip HTML rounding decimals

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
John_DeLeeuw
456 Views, 4 Replies

Tooltip HTML rounding decimals

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

Tags (1)
Labels (1)
4 REPLIES 4
Message 2 of 5

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
Message 3 of 5

@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

Message 4 of 5
ronnie.xue
in reply to: John_DeLeeuw

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
in reply to: John_DeLeeuw

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

John de Leeuw
Senior Consultant

Community Ambassador - Twitter - LinkedIn

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report