echart点击导航条触发的方法
作者:互联网
myChart.on(“legendselectchanged”, function(obj) {
})
例子:
myChart.on("legendselectchanged", function(obj) {
let selectArr = obj.selected
let mm = current_data
let select_arr_true = []
let total_count = []
$.each(selectArr,function(index,item){
if (item) {
for (let i = 0; i < current_num; i++) {
let aa = current_data[i]
if (current_data.legend[i].name == index) {
select_arr_true.push(current_data.legend[i].data)
}
}
}
})
for (let i = 0; i < select_arr_true[0].length;i++) {
let total = 0
for(let j = 0; j < select_arr_true.length; j++) {
total += select_arr_true[j][i]
}
total_count.push(total)
}
current_data.legend[current_num-1].data = total_count
myChart.setOption(option);
})
标签:arr,echart,current,点击,let,导航条,total,data,select 来源: https://blog.51cto.com/u_14846736/2742818