我有一个JSON结果,它返回了我想要显示的数据,但问题是它都显示在一个图表上。我想迭代JSON并为每个项目生成一个图表(按问题分组的JSON对象)
这是JSON结构:
[{"Question":"At which location is your work based?","OptionTitles": ["opt1","opt2"],"OptionCounts":[2,2]},
{"Question":"In which business unit do you work?","OptionTitles":["opt1","opt2","opt3","opt4"],"OptionCounts":[1,1,1,1]}]
所以,对于每个问题对象,我都想显示一个单独的剑道图,你知道我该如何实现吗?
图表代码:
$("#chartBar").kendoChart({
theme: "metro",
dataSource: {
transport: {
read: {
url: '/urlToData',
dataType: 'json'
}
}
},
seriesDefaults: {
type:"bar"
},
series: [{ name: "OptionTitles[0]", field: "OptionCounts[0]" }],
categoryAxis: {
field: "OptionTitles[0]"
},
tooltip: { visible: true },
});
非常感谢
我需要遍历json,为每个图表创建一个新对象以绑定到