Refactor bar graph draw code