Save functionality for d3js graphs