ECHARTS histogram click event appears repeated multiple times

During the development process, usually after drawing with Echarts, we often encounter such a demand: on the histogram, click on a certain bar, call the corresponding method or jump to the corresponding interface,

When I met this demand, I first thought of the method of binding the click event with on, and then tried it on the code. Sure enough, this function can be achieved. When the click event is to re-acquire data and re-render a chart, it is also easy to achieve ,

But when encountering the original chart with the function of switching data rendering,

I have encountered this situation recently when doing chart development. Here are the charts I made:

 

At this time, if the switching data clicks on the bar again, the clicked data will be repeated many times, as many times as there are switching

Solution:

  Turn off the click before binding the click event:

                dmChart.off('click');
		dmChart.on('click', function (parmas) {
			alert(parmas.name);
	
		});

  Perfect solution, record it!

 

Guess you like

Origin www.cnblogs.com/yuqingya/p/12700030.html