Updated code and added generate chart

Updated code and added generate chart