我目前正在尝试通过jQuery / Ajax创建加载数据的图表。我有一个简单的功能:
function loadMorePosts(url){
$.ajax({
url: url
}).done(function( html ) {
$("#postDataTable").append(html);
});
}
在<head>
部分,我有:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
google.load("visualization", "1", {packages:["corechart"]});
</script>
通常使用此代码绘制图表:
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);
通过Ajax加载后,我得到相同的数据,没有图表。我做错了什么?