直接代码吧
工具还是蛮强大的
a 的值就是 鼠标悬浮在的当前柱状图的详情 可根据需要取值
tooltip : {
trigger: 'axis',
axisPointer: {
type: 'shadow'
},
formatter: function(a) {
var greenimg = "<img style='width:10px;height:10px;' src='"+base+"images/green.png"+"'/>";
var blueimg = "<img style='width:10px;height:10px;' src='"+base+"images/blue.png"+"'/>";
if(a.length > 0){
if(a.length < 2){
return blueimg+ 0 + "亩<br />" + greenimg+ a[0].value + "亩";
}else{
return blueimg+ a[0].value + "亩<br />" + greenimg+ a[1].value + "亩"+ "   " +(a[1].value == 0 ? 0: ((a[1].value/a[0].value * 100).toFixed(2))) + "%";
}
}else {
return blueimg+ 0 + "亩<br />" + greenimg+ 0 + "亩";
}
}