使用php、mysql和jQueryAjax的谷歌饼图
我正在创建google piecharts,但这里我必须使用iframe来显示此图表, 但是我想通过ajax展示它,而不使用iframe。。。。使用php、mysql和jQueryAjax的谷歌饼图,php,jquery,google-pie-chart,Php,Jquery,Google Pie Chart,我正在创建google piecharts,但这里我必须使用iframe来显示此图表, 但是我想通过ajax展示它,而不使用iframe。。。。 有没有办法在没有iframe的情况下显示google piechart???您可以使用google chart api使用纯javascript显示piechart .您可以使用google图表api用纯javascript显示piechart .由@Grrbrr404提供的链接不再工作,因此,您可以像这样尝试 脚本 <script type="
有没有办法在没有iframe的情况下显示google piechart???您可以使用google chart api使用纯javascript显示piechart
.您可以使用google图表api用纯javascript显示piechart
.由@Grrbrr404提供的链接不再工作,因此,您可以像这样尝试 脚本
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "getData.php",
dataType:"json",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240});
}
</script>
显示此由@Grrbrr404提供的链接不再工作,因此,您可以像这样尝试 脚本
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "getData.php",
dataType:"json",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240});
}
</script>
显示此