//绘制图表.
echarts.init(document.getElementById('main')).setOption({
tooltip : {
trigger: 'item', //触发类型,默认数据触发 (可选为:'item' | 'axis')
formatter: "{a} {b} : {c} ({d}%)", //这里可以使用默认;
axisPointer: {
type: 'cross'
},
backgroundColor: 'rgba(107, 107, 107, 0.5)',
borderWidth: 1,
borderColor: '#ccc',
padding: 8,
textStyle: {
color: 'white'
},
position: function (pos, params, el, elRect, size) {
var obj = {top: 10};
obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 30;
return obj;
},
extraCssText: 'width: 300px'
},
legend: {
orient: 'vertical',
left: 'left',
data: desc_percent_arr,
formatter: function(name) {
if(name === '相似度70%以上') {
return name + ":"+max_percent;
}else if(name === '相似度40%-70%'){
return name + ":"+min_percent;
}else{
return name + ":"+normal_percent;
}
},
tooltip:{
show:true,
},
},
series : [
{
name: '访问来源',
type: 'pie',
radius: '50%',
data: echatrs_data
}
]
});