Fix to function for adding data to the graph.