|
 |
|
ปัญหา การสร้างกราฟเส้น คือผมต้องการที่จะเอาข้อมูลจาก ฐานข้อมูล (Oracle) มาขึ้นกราฟเส้นหนะครับ |
|
 |
|
|
 |
 |
|
คุณ SAM มา Oracle เลย เอาใจช่วยได้อย่างเดียวครับ เพราะ อย่างอื่นช่วยไม่ได้ สู้ๆ
|
 |
 |
 |
 |
Date :
2009-07-13 12:07:57 |
By :
teez1232002 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
งะ....อย่างน้อยก็ขอบใจที่เข้ามาตอบครับ ผมกำลังงงๆ อยู่กับวิธีที่โชว์ออกมาเป็นกราฟเส้น
|
 |
 |
 |
 |
Date :
2009-07-13 13:44:05 |
By :
Devilbesideyou |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดูในตัวอย่างของ JpGraph อะครับ ข้อมูลแต่ละเส้นจะเป็น array ผมก็ไม่ได้จับ JpGraph มานาน ถ้าไงเอาโค๊ดมาโพสต์หน่อยก็ดี
|
 |
 |
 |
 |
Date :
2009-07-13 14:06:48 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดู Code ให้หน่อยนะครับ
Code (PHP)
<?php
include ("../connect.php");
include ("../jpgraph.php");
include ("../jpgraph_line.php");
$sql = "select a_service.a_enddate-a_service.a_startdate
from a_service, a_channel
where a_service.a_id=a_channel.a_id and a_channel='3333'
and a_service.a_status='C'
order by a_service.a_enddate";
$statement = ociparse($conn,$sql);
ociexecute($statement, OCI_DEFAULT);
ocifetch($statement);
$v_3333 = ociresult($statement,1);
$sql = "select a_service.a_enddate-a_service.a_startdate
from a_service, a_channel
where a_service.a_id=a_channel.a_id and a_channel='9999'
and a_service.a_status='C'
order by a_service.a_enddate";
$statement = ociparse($conn,$sql);
ociexecute($statement, OCI_DEFAULT);
ocifetch($statement);
$v_9999 = ociresult($statement,1);
$sql = "select a_service.a_enddate-a_service.a_startdate
from a_service, a_channel
where a_service.a_id=a_channel.a_id and a_channel='2222'
and a_service.a_status='C'
order by a_service.a_enddate";
$statement = ociparse($conn,$sql);
ociexecute($statement, OCI_DEFAULT);
ocifetch($statement);
$v_2222 = ociresult($statement,1);
$sql = "select a_service.a_enddate-a_service.a_startdate
from a_service, a_channel
where a_service.a_id=a_channel.a_id and a_channel='1111'
and a_service.a_status='C'
order by a_service.a_enddate";
$statement = ociparse($conn,$sql);
ociexecute($statement, OCI_DEFAULT);
ocifetch($statement);
$v_1111 = ociresult($statement,1);
$sql = "select a_service.a_enddate-a_service.a_startdate
from a_service, a_channel
where a_service.a_id=a_channel.a_id and a_channel='4444'
and a_service.a_status='C'
order by a_service.a_enddate";
$statement = ociparse($conn,$sql);
ociexecute($statement, OCI_DEFAULT);
ocifetch($statement);
$v_4444 = ociresult($statement,1);
$a_3333 = $v_3333*24*60;
$a_9999 = $v_9999*24*60;
$a_2222 = $v_2222*24*60;
$a_1111 = $v_1111*24*60;
$a_4444 = $v_4444*24*60;
$ydata1 [0] = "$a_3333";
$ydata2 [1] = "$a_9999";
$ydata3 [2] = "$a_2222";
$ydata4 [3] = "$a_1111";
$ydata5 [4] = "$a_4444";
$graph = new Graph(600,350,"auto");
$graph->SetScale("textlin");
$graph->yaxis->scale->SetGrace(50);
$graph->title->Set("Line graph Compare");
$graph->img->SetMargin(50,20,20,40);
$graph->xaxis->SetTitle("Date","center");
$graph->yaxis->SetTitleMargin(30);
$graph->yaxis->title->Set("Time (Minute)");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$lineplot1=new LinePlot($ydata1);
$lineplot1->SetColor("blue");
$lineplot1->SetLegend('3333');
$graph->Add($lineplot1);
$lineplot2=new LinePlot($ydata2);
$lineplot2->SetColor("red");
$lineplot2->SetLegend('9999');
$graph->Add($lineplot2);
$lineplot3=new LinePlot($ydata3);
$lineplot3->SetColor("yellow");
$lineplot3->SetLegend('2222');
$graph->Add($lineplot3);
$lineplot4=new LinePlot($ydata4);
$lineplot4->SetColor("green");
$lineplot4->SetLegend('1111');
$graph->Add($lineplot4);
$lineplot5=new LinePlot($ydata5);
$lineplot5->SetColor("black");
$lineplot5->SetLegend('4444');
$graph->Add($lineplot5);
$graph->Stroke();
?>
|
 |
 |
 |
 |
Date :
2009-07-13 14:29:32 |
By :
Devilbesideyou |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมต้องการดึงข้อมูลจากฐานข้อมูลมาทำกราฟครับ ไม่ได้ใส่ตัวเลขเข้าไปแบบนี้ แบบที่คุณบอกผมทำได้แล้วครับ
|
 |
 |
 |
 |
Date :
2009-07-13 15:38:23 |
By :
Devilbesideyou |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รอคุณ PlaKriM ละกันครับ ผมเหนื่อย
|
 |
 |
 |
 |
Date :
2009-07-13 18:28:40 |
By :
lozomac |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เหมือนคุณ a-mac บอกครับ
$ydata1 คือ เส้นที่ 1
$ydata2 คือ เส้นที่ 2
$ydata3 คือ เส้นที่ 3
$ydata4 คือ เส้นที่ 4
$ydata5 คือ เส้นที่ 5
ตัวแปรเปล่านี้ต้องเป็น array ที่จะบอกจุกในการ plot
จากโค๊ดของน้อง แต่จะเส้นน่าจะมีจุดเดียว ดังนั้น มันจึงไม่เป็นเส้น เหมือนคุณ a-mac บอกอีกนั้นแหละ
|
 |
 |
 |
 |
Date :
2009-07-13 21:17:35 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ เดี๋ยวจะลองทำดูอีกรอบ
|
 |
 |
 |
 |
Date :
2009-07-13 22:48:56 |
By :
Devilbesideyou |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|