//使用之前先在main.js中引入echats
//然后 Vue.use(echats)
var mycharts = this.echarts,init(document.getElementById("myChart"))
myChats.setOption({
echats官网找实例
//设置高亮色和平常色
itemStyle:{
normal:{
color:'#b22125'
},
emphasis:{
borderColor:'black',
color:'black'
}
}
})
//按照节点来控制父容器大小
let conation = document.getElementById("myChart");
let allNodes = 0;
let nodes = myCharts._chartsViews[0]._data._graphicEls
for(var i =0;i<nodes.length;i++){
let node = nodes[i]
if(node == undefined){
continue
}else{
allNodes++
}
}
conation.style.width=50*allNodes +'px' //自行调节
conation.style.height=50*allNodes +'px' //自行调节
myCharts.resize()
//节点高亮
mycharts.on('click',function(params){
if(this.index == null || this.index ==''){
myCharts.dispatchAction({
type:'highlight',
dataIndex:param.dataIndex
})
}else if(this.index[this.index.length-1] != param.dataIndex){
myCharts.dispatchAction({
type:'highlight',
dataIndex:param.dataIndex
})
myCharts.dispatchAction({
type:'downplay',
dataIndex:this.index[this.index.length-1]
})
}else{
myCharts.dispatchAction({
type:'highlight',
dataIndex:param.dataIndex
})
}
let ind =[]
ind.push(param.dataIndex)
this.index = ind // index是return里定义的一个数组
})
echars的api不好找 写在内网的项目 这个笔记纯手扣,会有错误。