此代码在独立页面中运行良好。我通过 jquery ajax 将这段代码拉到另一个页面,它不显示图表。我已经搜索和搜索并没有找到答案。
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours per Day'],
['Data Entry', 2],
['Filing', 1],
['Social Media', 2],
['Email Responses', 1],
['Customer Care', 2]
]);
var options = {
chartArea:{left:20,top:0,width:"80%",height:"70%"},
legend: {position: 'left', textStyle: {fontSize: 14}},
is3D: 'true'
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<div id="chart_div" style="position: relative; z-index: 100; width: 580px; height: 400px; margin: 0px 0px 0px 50px; border: overflow: hidden;">
</div>
感谢任何人可以提供的任何帮助,谢谢。