refact chart into class