监听事件示例
作者:互联网
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>监听事件</title> </head> <body> <div id="main" style="width:600px;height:300px;"></div> <script src="js/echarts.js"></script> <script> var myChart = echarts.init(document.getElementById('main')); option = { title:{ text:'监听事件' }, tooltip:{}, legend:{ data:['销量'] }, xAxis:{ data:["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"] }, yAxis:{}, series:[{ name:'销量', type:'bar', data:[5,10,25,20,6,8] }] }; myChart.setOption(option); myChart.on('legendselectchanged',function(params){ //获取点击图例的点击状态 var isSelected = params.selected[params.name]; //打印 console.log((isSelected ? '选中了':'取消选中了')+ '图例' + params.name); //打印所有图例的状态 console.log(params.isSelected); }); </script> </body> </html>
标签:name,示例,myChart,isSelected,图例,params,事件,data,监听 来源: https://www.cnblogs.com/dzwj/p/15881103.html