You have two problems:
1. Your draw function is a subfunction of the main drawing function. take
it out.
2. You're not adding new data in the draw function. You only drawing the
datatable.
3. You might need to clean the div containing the chart before drawing it.

I believe that if you'll follow this, your script will work :-)



On Fri, Dec 2, 2011 at 11:53 AM, andyciup <[email protected]> wrote:

> Hi. I want to make a low imitation of an animation, by first drawing a
> tree, then adding a note to it, and redrawing the tree, and so on,
> with a 2 second delay, so that what is seen from the browser is a tree
> expanding into bigger hierchahies. I use setTimer, but for some reason
> it is not putting the new updated tree on the page after 2 seconds, as
> required. Below is my code. I used the google template for this one:
>
> <script type='text/javascript' src='https://www.google.com/jsapi'></
> script>
> <script type='text/javascript'>
>  google.load('visualization', '1', {packages:['orgchart']});
>  google.setOnLoadCallback(drawChart);
>  var data;
>  function drawChart() {
>    data = new google.visualization.DataTable();
>    data.addColumn('string', 'Name');
>    data.addColumn('string', 'Manager');
>    data.addColumn('string', 'ToolTip');
>    data.addRows([
>      [{v:'Mike', f:'Mike<div style="color:red; font-
> style:italic">President</div>'}, '', 'The President'],
>      [{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice
> President</div>'}, 'Mike', 'VP'],
>      ['Alice', 'Mike', ''],
>      ['Bob', 'Jim', 'Bob Sponge'],
>      ['Carol', 'Bob', '']
>    ]);
>
>    var chart = new
> google.visualization.OrgChart(document.getElementById('chart_div'));
>    chart.draw(data, {allowHtml:true});
>
>    data.addRows(1);
>    data.setCell(5, 0, "Test");
>    function draw()
>    {
>    //   chart = new
> google.visualization.OrgChart(document.getElementById('chart_div'));
>        chart.draw(data, {allowHtml:true});
>    }
>
>    setTimeout("draw()", 2000);
>
>
>  }
> </script>
>
> Note that if I simply call the draw function, it will indeed display
> the new, updated tree. I feel like there should be a easy way out of
> this.
>
> I would really appreciate any help!
>
> Thank you!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Visualization API" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-visualization-api?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to