javascript - mouse out event handler not working when mouse over event handler is a there in Google chart script -
javascript - mouse out event handler not working when mouse over event handler is a there in Google chart script -
for below code mouse out handler not working, when removed mouse on relevant code works fine. (due chart.draw() not working properly). guys can u give me hand problem.
google.setonloadcallback(drawchart); function drawchart() { var info = google.visualization.arraytodatatable([ ['task', 'hours per day'], ['work', 11], ['eat', 2], ['commute', 2], ['watch tv', 2], ['sleep', 7] ]); var options = { title: 'my daily activities', legend: 'none', pieslicetext: 'percentage', slices: { } }; var chart = new google.visualization.piechart(document.getelementbyid('piechart')); chart.draw(data, options); google.visualization.events.addlistener(chart, 'onmouseout', function(e) { var slices = options.slices ; slices[e.row] = {}; options['slices'] = slices; chart.draw(data,options); } ); // mouse out end google.visualization.events.addlistener(chart, 'onmouseover', function(e) { var sliceid= e.row; console.log("mouse over"+sliceid); var slices = options.slices ; slices[e.row] = {offset:0.2}; options['slices'] = slices; chart.draw(data,options); } ); // mouse on end }
seems problem mouseover fires repeteadly chart redraws time, not giving plenty time mouseover event fire. should create work:
google.visualization.events.addlistener(chart, 'onmouseover', function(e) { var sliceid= e.row; var slices = options.slices ; if(slices.hasownproperty(e.row)){ if(slices[e.row].hasownproperty('offset')) homecoming false // if still mouseover, skip }
working fiddle: http://jsfiddle.net/qm7f86ez/
javascript google-visualization google-chartwrapper pygooglechart
Comments
Post a Comment