making chart function