HOME > PHP > PHP Forum > การสร้างกราฟ จากโค้ดจะเป็นรูปกราฟแท่งแล้วข้างล่างจะเขียนชื่อเดือนเอาไว้ แต่จะเปลี่ยนจารชื่อเดือนให้เป็นชื่อวิชาที่เก็บอยู่ในฐานข้อมูล
<?php
include ("../jpgraph.php");
include ("../jpgraph_bar.php");
require_once("http://127.0.0.1/training/include.php");
require_once("http://127.0.0.1/training/function.php");
// Some data
$st_male=array(140,110,50,250);
$st_female=array(35,90,190,190);
//$datay3=array(20,60,70,140);
// Create the basic graph
$graph = new Graph(450,250,'auto');
$graph->SetScale("textlin");
$graph->img->SetMargin(40,80,30,40);
// Adjust the position of the legend box
$graph->legend->Pos(0.02,0.15);
// Adjust the color for theshadow of the legend
$graph->legend->SetShadow('[email protected]');
$graph->legend->SetFillColor('[email protected]');
// Get localised version of the month names
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
// Set a nice summer (in Stockholm) image
$graph->SetBackgroundImage('stship.jpg',BGIMG_COPY);
// Set axis titles and fonts
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetColor('white');
// Setup graph title
$graph->title->Set ('TRAINING');
// Some extra margin (from the top)
$graph->title->SetMargin(3);
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,12);
// Create the three var series we will combine
$bplot1 = new BarPlot($st_male);
$bplot2 = new BarPlot($st_female);
//$bplot3 = new BarPlot($datay3);
// Get localised version of the month names
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());
แก้เป็น
$graph->xaxis->SetTickLabels($xxxxx);
โดยให้ $xxxxx = array(วิชา1,วิชา2,....) ;
Date :
19 พ.ย. 2550 15:38:33
By :
sinchai9
No. 2
Guest
มัน Error อย่างงี้
Warning: include(../jpgraph.php) [function.include]: failed to open stream: No such file or directory in D:\MyWebSite\04-01.php on line 2
Warning: include() [function.include]: Failed opening '../jpgraph.php' for inclusion (include_path='.;C:\php5\pear') in D:\MyWebSite\04-01.php on line 2
Warning: include(../jpgraph_bar.php) [function.include]: failed to open stream: No such file or directory in D:\MyWebSite\04-01.php on line 3
Warning: include() [function.include]: Failed opening '../jpgraph_bar.php' for inclusion (include_path='.;C:\php5\pear') in D:\MyWebSite\04-01.php on line 3
Warning: require_once() [function.require-once]: URL file-access is disabled in the server configuration in D:\MyWebSite\04-01.php on line 4
Warning: require_once(http://127.0.0.1/training/include.php) [function.require-once]: failed to open stream: no suitable wrapper could be found in D:\MyWebSite\04-01.php on line 4
Fatal error: require_once() [function.require]: Failed opening required 'http://127.0.0.1/training/include.php' (include_path='.;C:\php5\pear') in D:\MyWebSite\04-01.php on line 4
Warning: main(../jpgraph.php): failed to open stream: No such file or directory in c:\appserv\www\test\chart.php on line 10
Warning: main(): Failed opening '../jpgraph.php' for inclusion (include_path='.;c:\php4\pear') in c:\appserv\www\test\chart.php on line 10
Warning: main(../jpgraph_bar.php): failed to open stream: No such file or directory in c:\appserv\www\test\chart.php on line 11
Warning: main(): Failed opening '../jpgraph_bar.php' for inclusion (include_path='.;c:\php4\pear') in c:\appserv\www\test\chart.php on line 11
Warning: main(http://127.0.0.1/training/include.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in c:\appserv\www\test\chart.php on line 12
Fatal error: main(): Failed opening required 'http://127.0.0.1/training/include.php' (include_path='.;c:\php4\pear') in c:\appserv\www\test\chart.php on line 12