echart2.x 添加legend 绑定事件
echart2.x legend 绑定事件
var ecConfig = echarts.config;
(有些情况:var ecConfig = require('echarts/config'))
myChart.on(ecConfig.EVENT.LEGEND_SELECTED, function(params) { // legendselected legendselectchanged console.log('obj', params) var selected = obj.selected; var legend = obj.name; // 使用 legendToggleSelect Action 会重新触发 legendselectchanged Event,导致本函数重复运行 // 使得 无 selected 对象 if (selected != undefined) { if (isFirstUnSelect(selected)) { triggerAction('legendToggleSelect', selected); } else if (isAllUnSelected(selected)) { triggerAction('legendSelect', selected); } } });