Old embedded Motion Charts keep refreshing

29 views
Skip to first unread message

Christi

unread,
Dec 10, 2015, 2:26:01 PM12/10/15
to Google Visualization API, Christi Electris
My embedded motion charts keep refreshing after approximately 10 seconds, making it impossible to use them. 

I created a series of many motion charts to display my data back for a global scenario project in 2009. I updated the code at one time between then and now when something in the Google Charts stopped working, however this strange behavior has just begun. 

Take a look here:

Now you can see that they do not display properly on our website. However if you click on the advanced features, and look at the underlying data link, you will see that the Google Sheets have a motion chart that works without any problems. For example: 

Please help! We need to fix this bug so that our data can be easily accessed.

Thanks,
Christi

Sergey Grabkovsky

unread,
Dec 10, 2015, 2:38:47 PM12/10/15
to google-visua...@googlegroups.com, Christi Electris
Hi Christi,

I believe your issue stems from the fact that you create a new instance of MotionChart every time your data refreshes ("query.send(draw);"). I would advise that you restructure your code as follows:

google.load('visualization', '1', {'packages':['motionchart']});

google.setOnLoadCallback(initialize);

function initialize() {

 var query = new google.visualization.Query(

     'http://spreadsheets.google.com/pub?key=pbD-qQOd8BSUVbHnvf7AGUQ');

 query.setRefreshInterval(10);

 

 // Create only one instance of the chart and pass it to a draw function,

 // which will return a function that we will use for the query response.

 var chart = new google.visualization.MotionChart(document.getElementById('chart_div'));

 query.send(draw(chart));

}


function draw(chart) {

 // Note that this returns a function.

 return function(response) {

   if (response.isError()) {

      alert('Error in query')

   }

   var myData = response.getDataTable();

   chart.draw(myData, {width: 516, height:410, state: '{"dimensions":{"iconDimensions":["dim0"]},"nonSelectedAlpha":0.4,"orderedByX":false,"xZoomedDataMax":4102444800000,"iconType":"BUBBLE","showTrails":true,"uniColorForNonSelected":false,"yLambda":1,"duration":{"timeUnit":"Y","multiplier":1},"yZoomedDataMax":2667,"time":"2005","sizeOption":"_UNISIZE","xLambda":1,"xZoomedDataMin":1104537600000,"yZoomedDataMin":906,"stateVersion":3,"xAxisOption":"_TIME","playDuration":15,"iconKeySettings":[],"yAxisOption":"3","yZoomedIn":false,"xZoomedIn":false,"orderedByY":false,"colorOption":"4"}', showXMetricPicker:false, showXScalePicker:false, showYScalePicker:false,showSelectListComponent:false, showSidePanel:false });

 };

}



--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/3a03caa8-a01d-4e01-a4d2-aaded06a139a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

unnamed.gif

Sergey Grabkovsky

Software Engineer

Google, Inc

gra...@google.com

Christi

unread,
Dec 21, 2015, 12:18:55 PM12/21/15
to Google Visualization API, cele...@tellus.org
Sergey, 

Thanks for your help. It didn't seem to fix my particular problem, however. It turns out that what fixed it was lengthening the refresh interval. I simply lengthened it to 80. It hadn't caused a problem in the past, and perhaps I don't even need to set an interval since the data is not changing, however I left it in for now.

 query.setRefreshInterval(80);

Thanks again,
Christi

Reply all
Reply to author
Forward
0 new messages