7

I'm using d3.js to create a chart which I want to some how export in vector format to edit in illustrator. Is this possible? This is a snippet of the code that's generated:

enter image description here

mheavers
  • 29,530
  • 58
  • 194
  • 315

2 Answers2

9

There are more complicated methods involving node.js and server-side rendering but a quick, easy way is to just copy the svg element from the DOM, paste it into a file and save it with the extension .svg

After that you can open it in a vector editor.

Tyson Anderson
  • 413
  • 3
  • 9
  • 1
    Quick update: Since the method described above will not take an external css file into account I've found that a better method is to use this command line tool for writing html content to a pdf: http://plessl.github.com/wkpdf/ – Tyson Anderson Feb 06 '13 at 22:14
  • 7
    Update #2: SVG Crowbar is a super handy tool made just for this purpose http://nytimes.github.io/svg-crowbar/ – Tyson Anderson Apr 10 '13 at 08:41
  • This method works exceptionally good with svg layers on a leaflet.js map. Thanks! – waeltken Dec 03 '15 at 15:21
0

You can try this: saveSvgAsPng

sidian
  • 31
  • 1
  • 1
    The OP asked for an export in vector format and your suggested library do the opposite. – smwhr Jul 13 '20 at 12:38