Opened 10 years ago

Closed 9 years ago

#9476 closed defect (fixed)

dojox.charting.plot2d.Pie._getLabel() makes use of Number.toFixed() which is broken in IE

Reported by: Jared Jurkiewicz Owned by: Eugene Lazutkin
Priority: high Milestone: 1.5
Component: Charting Version: 1.2.3
Keywords: Cc: deanw
Blocked By: Blocking:

Description

Reported from a co-worker of mine:

The function dojox.charting.plot2d.Pie._getLabel() uses Number.toFixed() to round and stringify the number that is displayed as label next to the pie element.

Number.toFixed() is broken in Internet Explorer for numbers between 0.5 and 0.95 - in this case it returns 0 instead of 1.

Therefore the following alert would show 0:

var a = 0.921;

var b = 0;

alert(a.toFixed(b));

A workaround is to round the number using Math.round(). This would return 1:

alert((Math.round(Math.pow(10, b) * a) / Math.pow(10, b)).toFixed(b));

Change History (7)

comment:1 Changed 10 years ago by Adam Peller

or use dojo.number.round (though you'd have to check back in 1.2 to see if this quirk was fixed back then) iirc, the IE bug is more extensive than this and comes up anytime the most significant digit is 5-9 in a number < 1.

comment:2 Changed 10 years ago by Adam Peller

probably a good idea to use dojo.number format also for i18n (proper decimal point, etc.)

comment:3 Changed 10 years ago by Eugene Lazutkin

Status: newassigned

dojo.number sounds right to me: l10n + one place to fix quirks..

comment:4 Changed 10 years ago by Eugene Lazutkin

Milestone: tbd1.4

comment:5 Changed 10 years ago by Adam Peller

Cc: deanw added

comment:6 Changed 10 years ago by Eugene Lazutkin

Milestone: 1.41.5

bumping tickets that didn't make the 1.4 cut, but most likely to go in the next point release.

comment:7 Changed 9 years ago by Eugene Lazutkin

Resolution: fixed
Status: assignedclosed

(In [21713]) Switching to dojo.number, thx jaredj and peller!, !strict, fixes #9476.

Note: See TracTickets for help on using tickets.