fixed padding calculations, cleaned up chart function