我正在使用谷歌圖表,我需要從PHP文件(或HTML文件內的php?)中獲取數據以將數據提供給圖表。那麼,我將如何做到這一點,並確保在繪製圖表之前獲取數據。 我已經去了,雖然搞清楚如何從MySQL數據庫和PHP抓取數據最簡單的方法使用HTML中的PHP的變量
這是我需要把瓦爾在
<html>
<head>
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Color');
data.addColumn('number', 'Votees ');
data.addRows([
['Value from Mysql', 3000],
['Value2 from Mysql', 13000],
]);
// Set chart options
var options = {'title':'Table Name From MySql',
'width':600,
'height':450};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<div id="chart_div"></div>
</body>
</html>
自己先試一下 – 2012-07-22 19:30:23
如果你能給我們提供一些關於你如何實現這些圖表的更多信息,我相信我們可以給你一個更具體的答案。幫助我們來幫助你;) – Lix 2012-07-22 19:39:45