dojo / dojox蜘蛛图的JSON格式

时间:2012-01-20 11:55:57

标签: json dojox.grid dojox.charting dojo

我正在拼命尝试使用json数据来填充我的dojo蜘蛛图表。

首先:我是否需要首先将我的商店(从ItemFileReadStore检索)传递到dojox.charting.DataSeries,然后才能将它用于我的蜘蛛图表?

然后,json需要怎么样?

这就是我尝试过的方式:

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();

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

好吧,我不能通过dojo itemFileReadStore做到这一点......不知道它为什么不起作用。

我通过执行dojo xhr.get请求并通过data [i]引用接收到的数据解决了这个问题:

chart.addSeries("<name>", data[0], { fill: "<color>" });