Created a new method update() that will redraw the graph if the data array has been modified