You are calling google.setOnLoadCallback inside your success handler, but
that is too late.  You would need to call google.setOnLoadCallback only
while the code is still loading.
So you should probably turn this inside out.


google.setOnLoadCallback(function () {
    $.ajax({
        url : "Serv",
        dataType: 'json',
         contentType: 'application/json',
        success : function(result) {
          drawBasic(JSON.stringify(result));
        },
        complete: function(){
           // whatever..
        }
    })
});

On Mon, May 11, 2015 at 8:57 AM, Gaurav Mohla <[email protected]> wrote:

> I have a chart compliant json
> {"cols":[{"label":"name","type":"string"},{"label":"count","type":"number"}],"rows":[{"c":[{"v":"Name"},{"v":1}]},{"c":[{"v":"Name1"},{"v":2}]},{"c":[{"v":"Name2"},{"v":3}]},{"c":[{"v":"Name4"},{"v":1}]}]}
> which I want to display as Google Chart on my sceen. using ajax call I am
> able to form the foll code:
>
> <script>
> $(document).ready(function(){
>     google.load('visualization', '1', {
>         packages: ['corechart']
>     });
>
>
>     function drawBasic(d) {
>       var data = new google.visualization.DataTable(d);
>       var options = {
>          title: 'Sample Data',
>          hAxis: {
>             title: 'Name'
>          },
>          vAxis: {
>             title: 'Count'
>          },
>          width: 400,
>          height: 240
>       };
>
>
>       var chart = new google.visualization.ColumnChart(document.
> getElementById('chart_div'));
>       chart.draw(data, options);
>     }
>
>
>     $.ajax({
>         url : "Serv",
>         dataType: 'json',
>          contentType: 'application/json',
>         success : function(result) {
>           google.setOnLoadCallback(drawBasic(JSON.stringify(result)));
>         },
>         complete: function(){
>            // whatever..
>         }
>     });
>
>
>  });
> </script>
> but still I am unable to display the data.
>
> jsbin link: http://jsbin.com/hofaqidape/2/watch?html,js,output
> <http://jsbin.com/hofaqidape/2/watch?html,js,output> . This is what I am
> trying to do dynamically. could somebody help me.
>
> Thanks :)
>
> --
> 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.

Reply via email to