Fix legend texts width computation

Hi,

On IE, Chrome and Firefox, `getComputedTextLength` seems to return 0 when the element is not visible, so I copied the workaround from the catch to this case.