pulled out the drawchart function out into a utility.