1

I have created a simple Area chart from D3js Example. Now i want to export complete code of area chart into xml so that any end user can manually change xml data and then save it and use it. Is there a way to achieve in it.

Mayur
  • 1,053
  • 3
  • 21
  • 37

2 Answers2

2

If you are generating SVG via D3.js, it is naturally XML - which is handy for you.

You could grab the SVG from the HTML DOM and use the FileSaver API to generate a file to save.

Here is a FileSaver polyfil which also has a nice introduction.

Alternatively you could send the SVG (from the DOM) via Ajax and do it server-side.

UPDATE:

Here is an example of grabbing the svg element on the client side, however it generates the download vis the server-side. Mixed with FileSaver you could do the lot client side. http://d3export.housegordon.org/

Alex KeySmith
  • 16,047
  • 8
  • 65
  • 149
0

See this question I don't think you can export the chart but you can try exporting the chart data.

Community
  • 1
  • 1
artm
  • 8,456
  • 3
  • 22
  • 40