2

I'm currently trying to create charts loading data by jQuery/Ajax. I have a simple function:

function loadMorePosts(url){
$.ajax({
  url: url
}).done(function( html ) {
  $("#postDataTable").append(html);
});
}

In the <head> section I have:

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
google.load("visualization", "1", {packages:["corechart"]});    
</script>

Normally chart is draw with this code:

var dataPostChart1 = google.visualization.arrayToDataTable([
['Name:','x1:','x2:','x3:'],
['Count: ',61360,0,1873]
]);

var postOptions1 = {
legend: {'position':'none'},
chartArea: {left:40, width:150, height: 150},
colors: ['#6666ff','#33cc00','#cc00cc'],
vAxis: {'textStyle': {'fontSize': 10}},
hAxis: {'textPosition':'none', 'gridlines':{'count':0}}
};

var postChart1 = new google.visualization.ColumnChart(document.getElementById('graph10151496349581102_1'));
postChart1.draw(dataPostChart1, postOptions1);

After loading via Ajax, I get the same data and no chart. What am I doing wrong?

4

0 回答 0