Saving graph to and reinstating from localStorage