Skip to content

Instantly share code, notes, and snippets.

@norrs
Created June 19, 2013 09:10
Show Gist options
  • Save norrs/5812879 to your computer and use it in GitHub Desktop.
Save norrs/5812879 to your computer and use it in GitHub Desktop.
var XMLS = new XMLSerializer();
var html = d3.select("svg")
.attr("title", "sdfsdfsdf")
.attr("version", 1.1)
.attr("xmlns", "http://www.w3.org/2000/svg")
.node();
html.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" )
d3.select("body").append("div")
.attr("id", "download")
.html("Right-click on this preview and choose Save as<br />Left-Click to dismiss<br />")
.append("img")
.attr("src", "data:image/svg+xml;base64,"+ btoa(XMLS.serializeToString(html)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment