update function that create graph chart