Refactor the way charts are being drawn