0
A
回答
1
這是我的代碼。 db.php用於定義數據庫連接 `
require_once("db.php"); //include database connection
require_once("constant.php"); //include database connection
require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_line.php');
$default=true;
$filter="";
if(isset($_GET["timelapse"])) $timelapse=$_GET["timelapse"];
else $timelapse=TODAY;
$strQueryString="SELECT Date_Time, DissolvedOxygen as DissolvedOxygen FROM datareading";
//echo $strQueryString;
$strQueryString.= " ORDER BY Date_Time ASC";
$query = mysql_query($strQueryString);
$xdata=array();
$ydata=array();
while($row=mysql_fetch_array($query)){
$date = date_create($row["Date_Time"]);
$xdata[]=date_format($date," h:i a");
$ydata[]=$row["DissolvedOxygen"];
}
//print_r($xdata);
$graph = new Graph(920,500); // Initialize Graph
$graph->SetScale("intlin");
$graph->SetMargin(80,30,40,50);
$graph->SetMarginColor('white');
$graph->SetFrame(false,'blue',3);
//Set Title Attributes
$graph->title->Set("Dissolved Oxygen Level");
$graph->yaxis->SetTitleMargin(50);
$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
//Set Subtitle Attributes
$graph->subtitle->Set("Last 24 Hours");
$graph->subtitle->SetFont(FF_ARIAL,FS_BOLD,10);
$graph->subtitle->SetColor('black');
//$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetTickLabels($xdata);
$graph->xaxis->SetTextLabelInterval(2);
// Use Arial font
$graph->xaxis->SetFont(FF_ARIAL,FS_BOLD,9);
$graph->SetAxisLabelBackground(LABELBKG_XAXIS,'orange','red','lightblue','red');
$graph->yaxis->SetFont(FF_ARIAL,FS_BOLD,9);
$graph->xgrid->Show();
// Create the plot line
$p1 = new LinePlot($ydata);
$p1->value->SetFont(FF_FONT1, FS_BOLD);
$p1->value->SetAlign('center');
//Set y-axis title
$graph->yaxis->title->Set("Dissolved Oxygen (mg/L or ppm)");
$graph->yaxis->SetLabelAlign('right','bottom');
$graph->Add($p1);
//print_r($xdata);
$graph->Stroke();`
相關問題
- 1. 來自mysql數據的多線圖c3
- 2. 來自MySQL數據的線圖
- 3. JPGraph:不使用xy數據繪製線
- 4. 圖片來自MYSQL數據庫(PHP,MySql)
- 5. 如何使用來自mysql的數據創建折線圖
- 6. matplotlib來自數據幀的線圖
- 7. jpgraph:折線圖中的顯示範圍
- 8. 來自MySQL的XML數據
- 9. 來自JSON的數據MYSQL
- 10. Highcharts來自mysql數據庫的數據
- 11. JPGraph - PHP的 - MySQL的 - 0值
- 12. 用於實線的JpGraph setWeight
- 13. 數據網格視圖不顯示來自mysql表的數據
- 14. JPGraph PHP圖表
- 15. Highchart線型圖MySQL數據
- 16. 如何在mysql數據庫中添加JPGraph的標題
- 17. 來自MySql數據庫的Google圖表列圖形
- 18. 將mysql結果導入Jpgraph
- 19. JpGraph圖例順序
- 20. 高斯圖與jpgraph
- 21. PHP的JPGRAPH - 省略單個數據點
- 22. 顯示來自mysql的新數據
- 23. 顯示來自mysql的數據
- 24. 來自現有數據的MySQL外鍵
- 25. 來自MySQL數據庫陣列的ListAdapter
- 26. 使用來自mysql的大量數據
- 27. 來自MS Access的PHP MySQL數據庫
- 28. Android - 顯示來自MySQL的數據
- 29. 來自mysql數據庫的JavaScript變量
- 30. 來自mysql數據庫的Echo Datetime
請提供更多詳細信息。你已經有了什麼代碼,你試過了什麼? – Andrew 2013-05-13 12:25:34