4

I would like to store freely formatted (JSON, XML, CSV) d3 data sets back to a database, preferably using (for the sake of consistency) native d3 methods.

Is this already catered for in d3, and if not, can existing d3.js methods be coaxed into handling this?

Examples would be welcome.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1019696
  • 453
  • 1
  • 5
  • 15

1 Answers1

2

This isn't something that you can do with Javascript -- there's no direct access to things like databases. This is not a restriction of d3, but Javascript itself. What you can do is post data to a server which will then add it to a database. There's no support in d3 for that though, only for retrieving data.

There are plenty of other Javascript libraries though that allow you to post data to a server, for example jquery.

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
  • Ok, granted, perhaps I overshot the mark by referring to databases. Let's make it simpler. If this is code to read from a local file: d3.json( "http://localhost:8000/data.json" callback_function )  ...how would I **write** to the same file. :-) – user1019696 Nov 10 '12 at 13:46
  • Same thing. You can't really. See [this question](http://stackoverflow.com/questions/585234/how-to-read-and-write-into-file-using-javascript) for some more information. – Lars Kotthoff Nov 10 '12 at 15:03