title: How to save d3 graph as image on local machine?
body: <p>HTML Code:</p>
  
  <pre><code>&lt;div id="chart"&gt;&lt;/div&gt;
  
  &lt;div id="canvas-option"&gt;
      &lt;label&gt;File Name : 
          &lt;input type="text" id="canvas-filename" placeholder="image"/&gt;.png&lt;/label&gt;
          &lt;input type="submit" value="Save"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Script Code:</p>
  
  <pre><code> var canvas = d3.select("#chart").append("svg")
       .attr("id","svg_graph")
       .attr("width",width)
       .attr("height",height);
  
  
  
  &gt; canvas_option_form = $("canvas-option"),  canvas1 = $("chart"),
  &gt;   canvas_filename=$("canvas-filename")
  &gt;   canvas_option_form.addEventListener("submit",function(event)    {
  &gt;       event.preventDefault();         canvas1.toBlob(function(blob)       {
  &gt;           saveAs(blob,(canvas_filename.value ||
  &gt;                                 canvas_filename.placeholder)+".png");         },"image/png");     },false);
  </code></pre>
  
  <p>so i want it svg to save as png or any other image formate at local machine.</p>