Re: getting iconType from motionchart

42 views
Skip to first unread message

asgallant

unread,
Sep 6, 2012, 10:54:59 AM9/6/12
to google-visua...@googlegroups.com
It works fine for me when I tried in on the Visualization Playground.

google.visualization.events.addListener(motionchart'ready'function ({
    var my_state JSON.parse(motionchart.getState());
    console.debug(my_state.iconType);
}); 

On Thursday, September 6, 2012 10:24:43 AM UTC-4, Gallusz Abaligeti wrote:
Dear All,

I'm working on a motionchart, and i would like to get the "iconType" property from the actual state of the chart if it changed. My code is the following:

google.visualization.events.addListener(motionchart, 'statechange', statechangeHandler);
function statechangeHandler() {
     var my_state=JSON.parse(motionchart.getState());
     console.debug(my_state.iconType);
};

Its not working, however if I ask just for the "my_state" object, then i can see all of the properties on the console.
Please help me, thanks a lot!

regards,
gallusz

Gallusz Abaligeti

unread,
Sep 6, 2012, 2:10:50 PM9/6/12
to google-visua...@googlegroups.com
Thank You, Your code is working!

regards,
gallusz

Gallusz Abaligeti

unread,
Sep 6, 2012, 2:46:02 PM9/6/12
to google-visua...@googlegroups.com
Hm, if i change 'ready' event to 'statechange' in Your code it wont work again :S I'm getting really confused.
Any suggestion?

Thanks,
gallusz

2012. szeptember 6., csütörtök 16:55:00 UTC+2 időpontban asgallant a következőt írta:

asgallant

unread,
Sep 6, 2012, 4:41:46 PM9/6/12
to google-visua...@googlegroups.com
Well this is a truly bizarre phenomenon: attempting to access any of the state properties appears to (retroactively, some how) render the entire object null.  I can't even begin to imagine what might be causing this.  I made a jsfiddle demonstrating the problem: http://jsfiddle.net/asgallant/HV6W3/, but I can't replicate it with any manually made JSON string.  According to JSONLint.com, the JSON returned by #getState is valid.  I'm stumped.  If it weren't for the fact that everything works correctly using a "ready" event handler, I would say it isn't even a problem with the Visualization API.

Searching the bug reports, this has already been filed (here).  I'll add my jsfiddle as supplemental information, but seeing as how that bug report goes back almost a year with no update from the dev team, I wouldn't hold my breath waiting for a fix.

Gallusz Abaligeti

unread,
Sep 7, 2012, 5:12:49 AM9/7/12
to google-visua...@googlegroups.com
Thanks!

gallusz
Reply all
Reply to author
Forward
0 new messages