changes to make chart totally dynamic, and cleared a problem with $apply