1. 鼠标移动上去触发tooltip
extraCssText 自定义tooltip的样式(包括:大小,颜色,背景 等等)
tooltip: {
trigger: 'item',
extraCssText:'width:220px;height:106px;display: flex;align-items: center;border-radius:10px !important;padding:0', // tooltip外框的样式
formatter:function(v){ // 鼠标移动上去就会触发,打印的v是 这条数据的所有信息
console.log(v,'故障分析')
var perName; // 故障的上上一个名字
if(v.treeAncestors.length==3){
perName = v.treeAncestors[1].name +"-";
}
if(v.treeAncestors.length==4){
perName = v.treeAncestors[2].name +"-";
}
if(v.data.codeName === "正常"){
return "";
}
let tpoolStatus = ""
if(v.data.codeName === "短路"){
tpoolStatus = "<div class='tpool-status tpool-status-danger'><img width='32' src='"+dangerImage+"' alt=''>"+ v.data.codeName +"</div>"
}
if(v.data.codeName === "停电"){
tpoolStatus = "<div class='tpool-status tpool-status-warning'><img width='32' src='"+warningImage+"' alt=''>"+ v.data.codeName +"</div>"
}
if (v.data.epuType == "M0001"){
perName = "";
}
return "<div class='tpool-tips'>" +
tpoolStatus +
"<div class='tpool-hr'></div>" +
"<div class='tpool-name'><span>"+(perName+v.data.name || '表箱')+"</span>"+"</div>" +
"</div>"
},
backgroundColor:"#fff"
},
tooltip中使用图片:
2. 鼠标点击触发tooltip