Added calcApproxTextWidth util function. Fixed overlapping legend, as noted in issue #107.