|
 |
|
สอบถามเรื่อง jpgraph ครับ มัน error ไม่รู้ผิดตรงไหนครับ |
|
 |
|
|
 |
 |
|
โค้ตด้านเชื่อมฐานข้อมูลนำของท่าน A-mac ครับ
จากกระทู้นี้ครับ https://www.thaicreate.com/php/forum/029208.html
ผมก็เลยคิดอยากเป็นเปลื่ยนเป็นอย่างอื่นบ้าง แต่
ไม่รู้ผิดตรงไหนครับ ผมเอาโค้ตมาผสมกันมั่วด้วยครับ
อยากได้ กราฟแท่งเท่านั้นเองครับ แล้วดึงมาจากฐานข้อมูลอ่ะครับ
ผิดตรงไหน หรือ เป็นยังไง ช่วยให้ความกระจ่างด้วยนะครับ
Code (PHP)
<?php
<?php
include ("jpgraph/src/jpgraph.php");
include ("jpgraph/src/jpgraph_bar.php");
include ("jpgraph/src/jpgraph_line.php");
// ติดต่อ ฐานข้อมูล เลือกข้อมูลขึ้นมาเพื่อแสดงกราฟ
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("book1");
$strSQL = "SELECT * FROM faculty";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
// เตรียมข้อมุลที่จะแสดง เพื่อสร้างกราฟ
$datay=array();
while($objResult = mysql_fetch_array($objQuery))
{
$datay[] = $objResult["quantity"];
}
// Create the graph.
$mygraph = new Graph(480,360);
$mygraph->SetScale("textlin");
$mygraph->title->Set("Script 13-1");
//กำหนดประเภทของฟ้อนต์ให้กับไตเติ้้ลของกราฟ
$mygraph->title->SetFont(FF_FONT2,FS_BOLD);
//กำหนดสีให้กับไตเติ้ลของกราฟ
$mygraph->title->SetColor("maroon1");
//ปรับระยะห่างของไตเติ้ลของกราฟกับขอบภาพ
$mygraph->title->SetMargin(10);
$subtitle=iconv('TIS-620', 'UTF-8', "แสดงตัวอย่างการสร้างกราฟเส้นจากฐานข้อมูล");
$mygraph->subtitle->Set($subtitle);
$mygraph->subtitle->SetFont(FF_TAHOMA,FS_NORMAL,10);
//กำหนดให้รูปให้มีเงาอยู่ด้านหลัง
$mygraph->SetShadow();
//ปรับระยะห่างระหว่างขอบกราฟกับขอบรูปภาพ
$mygraph->SetMargin(50, 50, 40 , 50);
//กำหนดสีให้กับระยะห่างของขอบกราฟกับขอบรูปภาพ
$mygraph->SetMarginColor("greenyellow");
$mygraph->legend->SetPos(0.03,0.2, "right", "top");
$mygraph->img->SetAntiAliasing();
$mygraph->xaxis->title->Set("Month");
$mygraph->yaxis->title->Set("Hundred Baht");
$mygraph->xaxis->SetTickLabels($xdata);
//กำหนดสีของแกน
$mygraph->xaxis->SetColor('blue');
$mygraph->yaxis->SetColor('blue','black');
//กำหนดประเภทของฟ้อนต์ให้กับตัวหนังสือที่ใช้กับแกน Y
$mygraph->yaxis->title->SetFont(FF_FONT2,FS_BOLD);
//กำหนดประเภทของฟ้อนต์ให้กับตัวหนังสือที่ใช้กับแกน X
$mygraph->xaxis->title->SetFont(FF_FONT2, FS_BOLD);
//ปรับระยะห่างระหว่างตัวหนังสือที่บอกค่าของแกน X กับแกน X
$mygraph->xaxis->SetLabelMargin(2);
//สร้างเส้นกราฟโดยสร้างตามจุดของแกนY ที่รับมา แต่ยังไม่ทำการวาด
$line1=new LinePlot($ydata);
$line1->SetColor("blue");
$line1->SetWeight(2);
$line1->value->Show();
$line1->value->SetColor("blue");
$line1->value->SetFont( FF_FONT1);
$line1->mark->SetType(MARK_IMG_MBALL,'blue', 0.5);
$line1->SetLegend("2548");
// เริ่มต้นการวาดเส้นกราฟ
$mygraph->Add($line1);
//แสดงผลกราฟที่วาดได้
$mygraph->Stroke();
?>
?>
ผิดตรงไหนยังไง มาช่วยด้วยนะครับผม ผมงงไปหมดแล้วอ่ะ
กราฟทำเส้นเดียว ไม่ใช่ทำเส้นคู่ครับผม พอดีผมไปเอาโค้ตกราฟที่แสดงเปรียบเทียบมาครับ
ลบไป แก้ไข ไปบ้างแต่ก็ error ครับ ช่วยด้วยครับผม
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-09-03 17:32:40 |
By :
nuttapont |
View :
1047 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2009-09-03 17:39:30 |
By :
nuttapont |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอบก่อนออกไปผจญภัย
$xdata อยู่ไหน
$ydata อยู่ไหน
มันบอกว่า ไม่มีจุดที่จะ plot เพราะ array ที่ให้ไปไม่มีอะไรเลย
|
 |
 |
 |
 |
Date :
2009-09-03 17:45:04 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แท่งไม่มีแกน
|
 |
 |
 |
 |
Date :
2009-09-03 18:39:24 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|