Generally what you need to do is use something like JavaScript's setTimeout
(repeatedly) or setInterval (one time) to call the draw() method on the
same chart giving it new data or options each time. In your chart options,
specify the animation duration, and use the same duration in your
setInterval call, something like this:
var options = {
animation: { duration: 1000 }
...
}
var chart = new
google.visualization.LineChart(document.getElementById('myChart'));
// Draw the first time
chart.draw(data, options);
// Draw again every second.
setInteval(function() {
chart.draw(newData, options);
}, 1000);
So basically, you could use the same function that you would give to the
click handler, but it would be called on a timed basis instead.
Hope that helps.
On Tue, Mar 17, 2015 at 3:24 PM, <[email protected]> wrote:
> I am a bit new to programming, and even newer to google charts. I am
> pretty blown away with what is possible, and I think the instructions are
> great, however, the section in google charts for animation (
> https://developers.google.com/chart/interactive/docs/animation), is
> missing what I was trying to do.
>
> I wanted to create a few charts on my homepage that are constantly
> animating, *without the user clicking a button*, just like the chart at
> the very top of the animation page (
> https://developers.google.com/chart/interactive/docs/animation). But the
> instructions on this page only show me how to animate a chart once the user
> clicks a button, for example. Is there a way to just go ahead and animate
> the chart once the page loads, and then *just keep looping back and forth
> (adding data points, removing data points, etc.) *until the user leaves
> the page? It looks like I can do that, but there aren't any examples,
> which makes it a bit more difficult for me.
>
> Similarly, I am having trouble understanding where the code is supposed to
> go for the animate features. I can make a basic graph, but the examples on
> the animate page don't necessarily start from scratch. It says "*Start
> with an already rendered chart*", which I did, but then I don't
> understand where to place the new code?
>
> Thank you in advance to whomever can offer some insight into my issue.
>
> --
> 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 [email protected].
> To post to this group, send email to
> [email protected].
> Visit this group at
> http://groups.google.com/group/google-visualization-api.
> For more options, visit https://groups.google.com/d/optout.
>
--
Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2> -
978-394-1058
[email protected] <[email protected]> 5CC, Cambridge MA
[email protected] <[email protected]> 9 Juniper Ridge
Road, Acton MA
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.