$(function(){
var xlm = {
arr : [],
init : function(){
//ajax 调用
$.ajax({
type:"GET",
url:'1.json',
dataType:"json",
success:function(datas){
$.each(datas.data,function(i,n){
console.log(datas.data[i].title)
})
}
});
}
};
xlm.init();
//图形
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
option = null;
option = {
title: {
text: '某站点用户访问来源',
subtext: '纯属虚构',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
left: 'left',
data: []
},
series: [{
name: '访问来源',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [],
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
}
}
}]
};
if(option && typeof option === "object") {
myChart.setOption(option, true);
}
})
1.json值
{
"code": 0,
"msg": "OK",
"data": [
{
"title": "a",
"value": "72"
},
{
"title": "b",
"value": "11"
},
{
"title": "c",
"value": "1"
},
{
"title": "d",
"value": "4"
},
{
"title": "e",
"value": "6"
},
{
"title": "f",
"value": "0"
},
{
"title": "g",
"value": "3"
},
{
"title": "h",
"value": "3"
}
]
}