我想要一個簡單的腳本/庫,通過它我可以繪製像線,列,餅圖等簡單的圖形 沒有ajax,json,flash pls ... 我已經試過pChart ,amCharts但面對每...使用谷歌可視化一些或其他問題api..found它不錯,但無法養活數據從我的MySQL數據庫圖表 我的代碼去如下:在PHP中使用谷歌圖表API實現圖形
<?php
include('dbconnect.php');
$sql_data = mysql_query("SELECT date , value FROM table1 WHERE
value ='xyz' ORDER BY date DESC");
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<?php echo "<script type=text/javascript>";
echo "google.load(\"visualization\", \"1\", {packages:[\"corechart\"]});";
echo "google.setOnLoadCallback(drawChart);";
echo "function drawChart() { ";
echo "var data = google.visualization.arrayToDataTable([
['Date', 'Score'],";
while($result = mysql_fetch_array($sql_data))
{
echo "[".$result['date'] .",".$result['value']."]";
}
echo " ]);";
echo "var options = {
title: 'Score Analysis'
};";
echo "var chart = new google.visualization.LineChart(document.getElementById('chart_div'));";
echo "chart.draw(data, options);";
echo "}
</script>";
?>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
它究竟在哪裏失敗?你是否得到js錯誤? PHP錯誤? MySQL錯誤?發佈客戶端源也會有所幫助。 – AllInOne