我在JSON中获取数据
{"Excellent":"5","NeedsImprovement":"14","Average":"9"}
如何使用AmCharts饼图/圆环图和angular-js绘制JSON。
答案 0 :(得分:2)
var data = JSON.parse(JSON_TEXT);
var dataProvider = [];
for(var key in data) {
dataProvider.push({
value: data[key],
title: key,
});
}
var chart = AmCharts.makeChart("chartdiv", {
"type": "pie",
"theme": "none",
"dataProvider": dataProvider,
"titleField": "title",
"valueField": "value",
"labelRadius": 5,
"radius": "42%",
"innerRadius": "60%",
"labelText": "[[title]]"
});
并且您应该更新数据
chart.dataProvider = newSetOfDataArray;
chart.validateData();