我想使用JSON文件与Legend制作Pie DataChart 我的js代码看起来像这样
var store = new dojo.data.ItemFileWriteStore(
{ url:dojo.moduleUrl("dojox.charting", "file.json")
});
makeObjects = function(){
var chart1 = new dojox.charting.DataChart("test11111111", {
type: dojox.charting.plot2d.Pie, // <-- chart type. Can be used Pie
scroll:false,
stretchToFit:true
});
var c = dojo.connect(chart1, "onData", function(){
dojo.disconnect(c);
new dojox.charting.widget.Legend({chart:chart1}, "legendPie");
});
chart1.setStore(store2, {legend:"*"}, "ss_series");
chart1.render();
JSON文件就像这样
{ "items": [
{ "ss_series":[10126, 9803, 15965, 17290, 15667, 17762],
"legend":["Rome", "Paris", "Madrid", "Berlin", "London", "Dublin"]}
]}
问题在于Legend还显示了馅饼的百分比而不是图例值 有人能帮我吗? 感谢
答案 0 :(得分:0)
如何将数据重新格式化为:
"ss_series": [{y: 10126, legend: "Rome"}, {y: 9803, legend: "Paris"} , ... ]
这应该可以解决问题吗?