score:0

I would recommend you to not use JSON at all since it is not streamable. Indeed, charts are often representing a big amount of datas and it is recommended to load their content progressively with the help of the XHR progress event.

Since most of the charts are tabular datas, i assume CSV is the better format for that purpose. If you still want be able to manage trees like with JSON, take a look at VarStream https://github.com/nfroidure/VarStream.

Here is an example of loading charts with a streamable format versus with JSON : http://server.elitwork.com/experiments/chartstream/index.html

The badest is your connection, the more you see how usefull is XHR Streaming.

score:3

You'll need to wrangle the data a little bit to get in a format that d3 likes, but there are built in functions to do all the work for you:

var companies = d3.layout.stack()(d3.values(json.series))

will give you a data structure similar to causes in the stacked bar chart example.

Basically, d3.values is taking your object with several arrays and turning in into an array of arrays. d3.layout.stack takes that two dimensional array, re structures it a a little bit and adds convenience functions that make it much simpler create a stacked bar chart.


Related Query

More Query from same tag