Question

I'm desperately trying to use json data to fill my dojo spider chart.

First of all: Do I need to pass my store (retrieved from ItemFileReadStore) first to a dojox.charting.DataSeries before I can use it for my spider chart?

Then, how the json needs to look like?

This is the way I just tried it:

var data = {"identifier":"id","items":[
                     {"id": "1", "data": {"GDP": 2,"area": 6,"population": 2000,"inflation": 15,"growth": 12}},
                     {"id": "2", "data": {"GDP": 6,"area": 15,"population": 500,"inflation": 5,"growth": 6}},
                     {"id": "3", "data": {"GDP": 10,"area": 10,"population": 800,"inflation": 2,"growth": 18}}
                     ]
            };
var fileStore = new dojo.data.ItemFileWriteStore({data: data});
var store1 = new dojox.charting.DataSeries(fileStore, {query: {id:"1"}}, "data");
var store2 = new dojox.charting.DataSeries(fileStore, {query: {id:"2"}}, "data");
var store3 = new dojox.charting.DataSeries(fileStore, {query: {id:"3"}}, "data");
chart1.addSeries("USA", store1, { fill: "green" });
chart1.addSeries("Japan", store2, { fill: "yellow" });
chart1.addSeries("Korean", store3, { fill: "orange" });
chart1.render();

Any ideas?

Was it helpful?

Solution

ok, I couldn't do it by dojo itemFileReadStore...no idea why it was not working.

I solved the issue by doing a dojo xhr.get request and referencing the received data by data[i]:

chart.addSeries("<name>", data[0], { fill: "<color>" });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top