ChartWrapper select events with animation

210 views
Skip to first unread message

thespanner

unread,
Feb 9, 2012, 6:28:12 AM2/9/12
to Google Visualization API
Hi,

I'm having big trouble with this at the moment. The animation stuff is
great but I get a null reference exception after I've attached a
select handler to my ChartWrapper.

So,

(1) I create a graph (using Chartwrapper)
(2) Bind to the ready event which in turn binds to the select event on
the chart

In my selectHandler I change the parameters for my graph
I call mychartwrapper.draw

After a few clicks on my graph I get a null exception in the google
code. I've tried all kinds of work arounds including:

Removing all my select event bindings as soon as my selectHandler is
triggered, then only readding after I receive the next 'ready' from
the ChartWrapper.

...also....

Removing all my select event bindings as soon as my selectHandler is
triggered, then only readding after I receive the next
'animationfinish' from the chart instance.

All I have to do to make this fail is to click 2 or 3 times in quickly
on one of my data points. Or on the graph while it is animating.

Any ideas?

asgallant

unread,
Feb 9, 2012, 10:45:08 AM2/9/12
to google-visua...@googlegroups.com
I suspect that the problem is that every time you call the draw method, the API adds another copy of the 'select' event handler to the chart.  Removing the 'ready' event handler after it is first called will fix the problem if this is indeed the cause. Try this:

var ready = google.visualization.events.addListener(chart, 'ready', function () {
    google.visualization.events.addListener(chart, 'select', function () {....});
    google.visualization.events.removeListener(ready);
});


gokster

unread,
Feb 12, 2012, 8:13:48 AM2/12/12
to google-visua...@googlegroups.com
Thanks for your reply,
 
I'll retest this but i think i've already tried this one out. The ready event does get fired each time the graph is drawn. What i've been doing is removing all event bindings to the chart when the user selects something. Then reconnecting them after the chart has fired the 'animationfinish' event. 
 
Doesn't seem to make any difference. I still get a null error. Turning off animations makes everything just fine. Even though i remove the select event handler I still get an error.
 


 


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/ix0X0Hhyc24J.

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Reply all
Reply to author
Forward
0 new messages