สอบถามเรื่อง JpGraph อัพโหลดแล้ว Error ครับ คือตอนที่ ทำในเครื่อง แสดงผลได้ปกติครับ
code ครับ
Code (PHP)
<?php
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_line.php");
$graphname = 'Report/';
$xlinename = 'date';
$ylinename ='Piece';
//ใส่ชื่อเส้น
$lg1 = "max1";
$lg2 = "max2";
$lg3 = "max3";
$lg4 = "min";
$ydatamax1 = array(25,40,60,21,33,25,14,88,99,52,14,12);
$ydatamax2= array(15,55,80,15,66,20,11,30,60,60,90,20);
$ydatamax3 = array(10,75,89,15,22,20,11,90,60,10,11,60);
$ydatamin1 = array(1,3,2,5,4,8,1,2,4,5,1,9);
$xmouth = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$xdate1 = array("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31");
$xdate2 = array("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30");
$xdate3 = array("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29");
$selectx = 1;
switch ($selectx) {
case 1:
$xdata = $xmouth;
$xlinename = 'Month';
$graphname = 'Month';
break;
case 2:
$xdata = $xdate1;
$graphname = 'Date';
break;
case 3:
$xdata = $xdate2;
$graphname = 'Date';
break;
case 4:
$xdata = $xdate3;
$graphname = 'Date';
break;
}
$mygraph = new Graph(800,500,"auto");
$mygraph->SetScale("textlin");
$mygraph->SetMargin(40,140,30,50);
$mygraph->title->Set($graphname);
$mygraph->xaxis->title->set($xlinename);
$mygraph->yaxis->title->set($ylinename);
$mygraph->xgrid->Show();
$mygraph->ygrid->SetFill(true,'[email protected] ','lavender');
$mygraph->SetShadow();
$mygraph->title->SetFont(FF_FONT1,FS_BOLD,15);
$mygraph->title->SetColor("black");
$mygraph->xaxis->SetTitlemargin(18);
$mygraph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$mygraph->xaxis->title->SetColor("black");
$mygraph->xaxis->title->SetFont(FF_TIMES,FS_BOLD,12);
$mygraph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,10);
$mygraph->xaxis->SetLabelAngle(45);
//$mygraph->xaxis->SetTextLabelInterval(2);
$mygraph->xaxis->SetWeight(3);
$mygraph->yaxis->SetTitlemargin(18);
$mygraph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$mygraph->yaxis->title->SetColor("black");
$mygraph->yaxis->title->SetFont(FF_TIMES,FS_BOLD,12);
$mygraph->yaxis->SetWeight(3);
$mygraph->img->SetAntiAliasing();
$mygraph->xaxis->SetTickLabels($xdata);
$linemax1 = new LinePlot($ydatamax1);
$linemax1 -> SetColor("red");
$linemax1 ->SetWeight(2);
$linemax1 ->value->Show();
$linemax1 ->value->SetColor("red");
$linemax1 ->value->SetFont(FF_FONT1);
$linemax1->SetLegend($lg1);
$linemax2 = new LinePlot($ydatamax2);
$linemax2 -> SetColor("blue");
$linemax2 ->SetWeight(2);
$linemax2 ->value->Show();
$linemax2 ->value->SetColor("blue");
$linemax2 ->value->SetFont(FF_FONT1);
$linemax2->SetLegend($lg2);
$linemax3 = new LinePlot($ydatamax3);
$linemax3 -> SetColor("green");
$linemax3 ->SetWeight(2);
$linemax3 ->value->Show();
$linemax3 ->value->SetColor("green");
$linemax3 ->value->SetFont(FF_FONT1);
$linemax3->SetLegend($lg3);
$linemin1 = new LinePlot($ydatamin1);
$linemin1 -> SetColor("black");
$linemin1 ->SetWeight(2);
$linemin1 ->value->Show();
$linemin1 ->value->SetColor("black");
$linemin1 ->value->SetFont(FF_FONT1);
$linemin1->SetLegend($lg4);
$mygraph->Add($linemax1);
$mygraph->Add($linemax2);
$mygraph->Add($linemax3);
$mygraph->Add($linemin1);
$mygraph->Stroke();
?>
Date :
2010-05-10 19:49:57
By :
sagon
งะมะมีท่านใดตอบ T-T
Date :
2010-05-11 21:06:53
By :
sagon
ผมไม่เคยใช้หรอก จาก อ่านดูแล้ว ผมว่าลอง อัพฟอนต์ขึ้นไปเอง สิครับ แล้วเซตฟอนต์ ด้วยนะครับ
Date :
2010-05-11 21:30:52
By :
เอี่ยว ^^
ประกาศ folder ที่เก็บ font
defined('TTF_DIR',dirname(__FILE__).'/fonts/');
test.php
<?php
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_line.php");
defined('TTF_DIR',dirname(__FILE__).'/fonts/');
$graphname = 'Report/';
$xlinename = 'date';
$ylinename ='Piece';
//ใส่ชื่อเส้น
$lg1 = "max1";
$lg2 = "max2";
$lg3 = "max3";
$lg4 = "min";
$ydatamax1 = array(25,40,60,21,33,25,14,88,99,52,14,12);
$ydatamax2= array(15,55,80,15,66,20,11,30,60,60,90,20);
$ydatamax3 = array(10,75,89,15,22,20,11,90,60,10,11,60);
$ydatamin1 = array(1,3,2,5,4,8,1,2,4,5,1,9);
$xmouth = array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
$xdate1 = array("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31");
$xdate2 = array("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30");
$xdate3 = array("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29");
$selectx = 1;
switch ($selectx) {
case 1:
$xdata = $xmouth;
$xlinename = 'Month';
$graphname = 'Month';
break;
case 2:
$xdata = $xdate1;
$graphname = 'Date';
break;
case 3:
$xdata = $xdate2;
$graphname = 'Date';
break;
case 4:
$xdata = $xdate3;
$graphname = 'Date';
break;
}
$mygraph = new Graph(800,500,"auto");
$mygraph->SetScale("textlin");
$mygraph->SetMargin(40,140,30,50);
$mygraph->title->Set($graphname);
$mygraph->xaxis->title->set($xlinename);
$mygraph->yaxis->title->set($ylinename);
$mygraph->xgrid->Show();
$mygraph->ygrid->SetFill(true,'[email protected] ','lavender');
$mygraph->SetShadow();
$mygraph->title->SetFont(FF_FONT1,FS_BOLD,15);
$mygraph->title->SetColor("black");
$mygraph->xaxis->SetTitlemargin(18);
$mygraph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$mygraph->xaxis->title->SetColor("black");
$mygraph->xaxis->title->SetFont(FF_TIMES,FS_BOLD,12);
$mygraph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,10);
$mygraph->xaxis->SetLabelAngle(45);
//$mygraph->xaxis->SetTextLabelInterval(2);
$mygraph->xaxis->SetWeight(3);
$mygraph->yaxis->SetTitlemargin(18);
$mygraph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$mygraph->yaxis->title->SetColor("black");
$mygraph->yaxis->title->SetFont(FF_TIMES,FS_BOLD,12);
$mygraph->yaxis->SetWeight(3);
$mygraph->img->SetAntiAliasing();
$mygraph->xaxis->SetTickLabels($xdata);
$linemax1 = new LinePlot($ydatamax1);
$linemax1 -> SetColor("red");
$linemax1 ->SetWeight(2);
$linemax1 ->value->Show();
$linemax1 ->value->SetColor("red");
$linemax1 ->value->SetFont(FF_FONT1);
$linemax1->SetLegend($lg1);
$linemax2 = new LinePlot($ydatamax2);
$linemax2 -> SetColor("blue");
$linemax2 ->SetWeight(2);
$linemax2 ->value->Show();
$linemax2 ->value->SetColor("blue");
$linemax2 ->value->SetFont(FF_FONT1);
$linemax2->SetLegend($lg2);
$linemax3 = new LinePlot($ydatamax3);
$linemax3 -> SetColor("green");
$linemax3 ->SetWeight(2);
$linemax3 ->value->Show();
$linemax3 ->value->SetColor("green");
$linemax3 ->value->SetFont(FF_FONT1);
$linemax3->SetLegend($lg3);
$linemin1 = new LinePlot($ydatamin1);
$linemin1 -> SetColor("black");
$linemin1 ->SetWeight(2);
$linemin1 ->value->Show();
$linemin1 ->value->SetColor("black");
$linemin1 ->value->SetFont(FF_FONT1);
$linemin1->SetLegend($lg4);
$mygraph->Add($linemax1);
$mygraph->Add($linemax2);
$mygraph->Add($linemax3);
$mygraph->Add($linemin1);
$mygraph->Stroke();
?>
แล้วเอา font arial.ttf ไปใส่ไว้ใน folder /fonts (folder ที่อยู่ระดับเดียวกับ test.php)
อ่านวิธี copy .ttf มาไช้ได้ที่ https://www.thaicreate.com/php/forum/041909.html ครับ
Date :
2010-05-11 22:02:06
By :
num
ขอบคุณคุณ num กับ Guestครับ
ผมก็อป font ลง folder fonts แล้วครับ เก็บในfolder เดียวกับ test.php (เปลี่ยนเป็นgrahpgen.php)ก็อป code จาก คุณ num
มันขึ้นแบบนี้ครับ ผม พลาดตรงไหนครับ
Date :
2010-05-12 14:59:54
By :
sagon
ผมเขียนชื่อ function ผิดครับโทษที defined() --> define()
Date :
2010-05-12 17:12:11
By :
num
กลับไปเป็น เหมือนเดิม ในเครื่องแสดงปกติ พออัพขึ้นhost ขึ้นerror
Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/usr/share/fonts/truetype/arial.ttf) is not within the allowed path(s): (/home/testgraph/:/tmp:/usr/local/lib/php/) in /home/test/domains/testgraph.com/public_html/func/jpgraph/jpgraph_ttf.inc.php on line 497
JpGraph Error: 25049 Font file "/usr/share/fonts/truetype/arial.ttf" is not readable or does not exist.
เหมือนเดิมครับ พอเปลี่ยน font ก็แค่เปลี่ยนชื่อfont แต่error เหมือนเดิม T-T
Date :
2010-05-12 20:05:47
By :
sagon
เอาไว้ก่อน include จะได้เป่าครับ
define('TTF_DIR',dirname(__FILE__).'/fonts/');
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_line.php");
Date :
2010-05-12 21:04:12
By :
num
สำเร็จแล้วครับ!!!!!!!!!
ขอบคุณ มากๆเลยครับ!!!!!!!!!!
Date :
2010-05-12 23:35:24
By :
sagon
ผมมีปัญหาเดียวกัน แต่ก็แก้วแล้วครับแต่ยังไม่ได้
Date :
2010-10-30 17:43:41
By :
chansaad
หน้าสนใจ
ประวัติการแก้ไข 2010-11-05 15:38:49
Date :
2010-11-05 15:38:15
By :
deedee2338
Load balance : Server 01