Fixing infinite loop caused by pie chart having only null or zero values

Fixes #2131.
Adding a default label position when none may be defined. Added comments, an extra check for valid values, and pulled apart some complicated statements in order to provide better readability / comprehension. 

PR from @simplymeasured