using d3.js to store a svg line chart as an image on the client side -
d3.select("#save").on("click", function(){ var html = d3.select("svg") .attr("version", 1.1) .attr("xmlns", "http://www.w3.org/2000/svg") .node().parentnode.innerhtml; //console.log(html); var imgsrc = 'data:image/svg+xml;base64,'+ btoa(html); var img = '<img src="'+imgsrc+'">'; d3.select("#svgdataurl").html(img); });
this code not showing copied image @ all. problem? code http://techslides.com/save-svg-as-an-image/ . line chart has mouse on , mouse click actions. want convert chart image @ client side without server interaction. link suitable way unable replicate chart.
something amiss in port of it...here fiddle code in question , works.
<div id="svg"></div> <button id="save">save image</button> <div id="svgdataurl"></div>
Comments
Post a Comment