Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Truncating Text help?

I wonder if someone can help, I have converted my meters into miles for my distance which works. On the console log it keeps saying truncating text as the conversion produces an equation with a few digits after the decimal point. The watch works fine as the truncating text is forcing a round up of the numbers due to my text length. Is there any code I could add to automatically force round up to as many digits as I want to display so I don't get the truncating message in the console log? (it just annoys me)

Thank in advance

Best Answer
0 Votes
3 REPLIES 3

It sounds like you're not setting text-length in your SVG.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

I've tried this. When the equation is worked out to miles(in the function) I end up with a number with about 6 digits (1.2435) for example. This is when using a text string of only 4, if I increase the text string number I get an even longer number. The only way to get the number down to 1.2 miles is to set the text length as 2, then I get the truncating message.

I would assume that when I do the equation in the function I need to add something which rounds it 2 digits, its this bit of code that i'm not sure about.

i've included the function code so I get a miles conversion,

 

function updateDistance() {
myDistance.text=(today.local.distance || 0)* 0.00062137;
console.log(today.adjusted.distance);

 

Please note: there are no actual issues with the miles distance shown on the watch, it works fine even with the truncating message on the console.

 

Best Answer
0 Votes

Have a look at toFixed()

Peter McLennan
Gondwana Software
Best Answer
0 Votes