ช่วยที่ค่ะ jpgraphไม่ขึ้น แบบนี้กราฟทำงานได้ปกติถึงจะยังไม่มีข้อมูลการฟขึ้นมาแบบไม่มีข้อมูล ปกติ
แบบนี้กราฟทำงานได้ปกติถึงจะยังไม่มีข้อมูลการฟขึ้นมาแบบไม่มีข้อมูล ปกติ (PHP)
include("../JpGraph/src/jpgraph.php");
include("../JpGraph/src/jpgraph_bar.php");
$g = new Graph(500, 300);
$g->SetScale("textlin");
$title = iconv("tis-620", "utf-8", "รายงาน");
$g->title->Set($title);
$g->title->SetFont(FF_JASMINE, FS_BOLD, 16);
$labels = array("m", "sd", "sd", "SDF" ,"df", "fs");
for($i = 0; $i < count($labels); $i++) {
$labels[$i] = iconv("tis-620", "utf-8", $labels[$i]);
}
$g->xaxis->SetTickLabels($labels);
$g->xaxis->SetFont(FF_CORDIA, FS_NORMAL, 14);
$g->xaxis->SetLabelAngle(0);
$data1 = array($mon1 , $mon2 , $mon3 , $mon4 , $mon5 , $mon6 ,$mon7 ,$mon8 ,$mon9 ,$mon10 ,$mon11 ,$mon12 );
$bar1 = new BarPlot($data1);
$data2 = array($mont1 , $mont2 , $mont3 , $mont4 , $mont5 , $mont6 ,$mont7 ,$mont8 ,$mont9 ,$mont10 ,$mont11 ,$mont12);
$bar2 = new BarPlot($data2);
$bar1->value->Show();
$bar1->value->SetAngle(90);
$bar1->SetFillColor("blue");
$bar1->SetLegend("Product 1");
$bar2->value->Show();
$bar2->value->SetAngle(90);
$bar2->SetFillColor("lightgray");
$bar2->SetLegend("Product 2");
$bars = array($bar1, $bar2);
$gb = new GroupBarPlot($bars);
$g->Add($gb);
$g->Stroke();
---------------------------------------------------------------------------------------------------------------------------------------------------
แต่เมื่อลงเพิ่มโค๊ดเค้าไปมันเออเลอฺร์ (PHP)
///////สว่นที่เพิ่ม//////////////////////////////////////////////////////
<?
include("../JpGraph/src/jpgraph.php");
include("../JpGraph/src/jpgraph_bar.php");
include("../connect.php");
$year1 = $_GET['year1'];
$year2 = $_GET['year2'];
$sql1 = "select * from rent WHERE year = $year1";
$result1 = mysql_query($sql1);
while($row1 = mysql_fetch_array($result1)){
//$mon1 += $row1['month1'];
$mon2 += $row1['month2'];
$mon3 += $row1['month3'];
$mon4 += $row1['month4'];
$mon5 += $row1['month5'];
$mon6 += $row1['month6'];
$mon7 += $row1['month7'];
$mon8 += $row1['month8'];
$mon9 += $row1['month9'];
$mon10 += $row1['month10'];
$mon11 += $row1['month11'];
$mon12 += $row1['month12'];
}
$totlemon1 = $mon1 +$mon2 +$mon3 +$mon4 +$mon5 +$mon6 +$mon7 +$mon8 +$mon9 +$mon10 +$mon11 +$mon12;
$sql2 = "select * from rent WHERE year = $year2";
$result2 = mysql_query($sql2);
while($row2 = mysql_fetch_array($result2)){
$mont1 += $row2['month1'];
$mont2 += $row2['month2'];
$mont3 += $row2['month3'];
$mont4 += $row2['month4'];
$mont5 += $row2['month5'];
$mont6 += $row2['month6'];
$mont7 += $row2['month7'];
$mont8 += $row2['month8'];
$mont9 += $row2['month9'];
$mont10 += $row2['month10'];
$mont11 += $row2['month11'];
$mont12 += $row2['month12'];
}
$totlemon2 = $mont1 +$mont2 +$mont3 +$mont4 +$mont5 +$mont6 +$mont7 +$mont8 +$mont9 +$mont10 +$mont11 +$mont12;
/////////////////////สว่นที่เพิ่ม//////////////
$g = new Graph(500, 300);
$g->SetScale("textlin");
$title = iconv("tis-620", "utf-8", "รายงาน");
$g->title->Set($title);
$g->title->SetFont(FF_JASMINE, FS_BOLD, 16);
$labels = array("m", "sd", "sd", "SDF" ,"df", "fs");
for($i = 0; $i < count($labels); $i++) {
$labels[$i] = iconv("tis-620", "utf-8", $labels[$i]);
}
$g->xaxis->SetTickLabels($labels);
$g->xaxis->SetFont(FF_CORDIA, FS_NORMAL, 14);
$g->xaxis->SetLabelAngle(0);
$data1 = array($mon1 , $mon2 , $mon3 , $mon4 , $mon5 , $mon6 ,$mon7 ,$mon8 ,$mon9 ,$mon10 ,$mon11 ,$mon12 );
$bar1 = new BarPlot($data1);
$data2 = array($mont1 , $mont2 , $mont3 , $mont4 , $mont5 , $mont6 ,$mont7 ,$mont8 ,$mont9 ,$mont10 ,$mont11 ,$mont12);
$bar2 = new BarPlot($data2);
$bar1->value->Show();
$bar1->value->SetAngle(90);
$bar1->SetFillColor("blue");
$bar1->SetLegend("Product 1");
$bar2->value->Show();
$bar2->value->SetAngle(90);
$bar2->SetFillColor("lightgray");
$bar2->SetLegend("Product 2");
$bars = array($bar1, $bar2);
$gb = new GroupBarPlot($bars);
$g->Add($gb);
$g->Stroke();
?>
มันขึ้นว่า
Code
JpGraph Error: HTTP headers have already been sent.
Caused by output from file jp.php at line 10.
Explanation:
HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it's image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).
Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser.
For example it is a common mistake to leave a blank line before the opening "<?php".
ไม่ทราบว่าแก้ยังไงดีค่ะTag : PHP
ประวัติการแก้ไข 2012-12-18 19:17:55 2012-12-18 19:18:34 2012-12-18 19:19:31 2012-12-18 19:20:59 2012-12-18 19:37:05 2012-12-18 21:16:58
Date :
2012-12-18 19:16:37
By :
mameaw4569
View :
1248
Reply :
4
ถ้าแบบนี้สงสัยจะต้องนั่ง remove ทีล่ะบรรทัด แล้วค่อย ๆ ไล่หาครับ
Date :
2012-12-19 14:38:28
By :
mr.win
กราฟเละแบบนี้จะปรับยังไงค่ะ เลขข้างน้ามันหายไปอะค่ะ จะปรับขอบในยังไง
ส่วนเรื่องภาษาไวค่อยแก้ที่หลัง
แล้วคือกราฟมันไปติดอยู่มุมซ้ายบน แล้วจะให้แสดงตรงกลางยังไง
Code (PHP)
<?
include("../JpGraph/src/jpgraph.php");
include("../JpGraph/src/jpgraph_bar.php");
include("../connect.php");
$totlemon1 = $mon1 +$mon2 +$mon3 +$mon4 +$mon5 +$mon6 +$mon7 +$mon8 +$mon9 +$mon10 +$mon11 +$mon12;
$totlemon2 = $mont1 +$mont2 +$mont3 +$mont4 +$mont5 +$mont6 +$mont7 +$mont8 +$mont9 +$mont10 +$mont11 +$mont12;
$title = "รายได้(บาท)";
$g = new Graph(1000, 500);
$g->SetScale("textlin");
$title = iconv("tis-620", "utf-8", "รายงาน");
$g->title->Set($title);
$g->title->SetFont(FF_JASMINE, FS_BOLD, 16);
$labels = array("ม.ค.", "ก.พ.", "มี.ค", "เม.ย." ,"พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.","รวม","55");
for($i = 0; $i < count($labels); $i++) {
$labels[$i] = iconv("tis-620", "utf-8", $labels[$i]);
}
$g->xaxis->SetTickLabels($labels);
$g->xaxis->SetFont(FF_CORDIA, FS_NORMAL, 14);
$g->xaxis->SetLabelAngle(0);
$data1 = array($mon1 , $mon2 , $mon3 , $mon4 , $mon5 , $mon6 ,$mon7 ,$mon8 ,$mon9 ,$mon10 ,$mon11 ,$mon12, "" ,"");
$bar1 = new BarPlot($data1);
$data2 = array($mont1 , $mont2 , $mont3 , $mont4 , $mont5 , $mont6 ,$mont7 ,$mont8 ,$mont9 ,$mont10 ,$mont11 ,"" ,"");
$bar2 = new BarPlot($data2);
$data3 = array("" , "", "" , "" , "", "" ,"" ,"","" ,"" ,"" ,"", "",$totlemon1);
$bar3 = new BarPlot($data3);
$bar1->value->Show();
$bar1->value->SetAngle(0);
$bar1->SetFillColor("blue");
$bar1->SetLegend($year1);
$bar2->value->Show();
$bar2->value->SetAngle(0);
$bar2->SetFillColor("lightgray");
$bar2->SetLegend($year2);
$bar3->value->Show();
$bar3->value->SetAngle(0);
$bar3->SetFillColor("red");
$bar3->SetLegend("รวม");
$bars = array($bar1, $bar2,$bar3);
$gb = new GroupBarPlot($bars);
$g->Add($gb);
$g->Stroke();
?>
<?
$year1 = $_POST['year1'];
$year2 = $_POST['year2'];
$mon1 = $_POST['mon1'];
$mon2 = $_POST['mon1'];
$mon3 = $_POST['mon1'];
$mon4 = $_POST['mon1'];
$mon5 = $_POST['mon1'];
$mon6 = $_POST['mon1'];
$mon7 = $_POST['mon1'];
$mon8 = $_POST['mon1'];
$mon9 = $_POST['mon1'];
$mon10 = $_POST['mon1'];
$mon11 = $_POST['mon1'];
$mon12 = $_POST['mon1'];
$mont1 = $_POST['mont1'];
$mont2 = $_POST['mont2'];
$mont3 = $_POST['mont3'];
$mont4 = $_POST['mont4'];
$mont5 = $_POST['mont5'];
$mont6 = $_POST['mont6'];
$mont7 = $_POST['mont7'];
$mont8 = $_POST['mont8'];
$mont9 = $_POST['mont9'];
$mont10 = $_POST['mont10'];
$mont11 = $_POST['mont11'];
$mont12 = $_POST['mont12'];
?>
<? header("location: rent.php"); ?>
ประวัติการแก้ไข 2012-12-19 18:54:43 2012-12-19 18:55:42
Date :
2012-12-19 18:54:13
By :
mameaw4569
ทำได้แล้ว
Date :
2012-12-19 23:24:03
By :
mameaw4569
ตกลงเป็นเพราะอะไรครับ ?
Date :
2012-12-20 06:23:57
By :
mr.win
Load balance : Server 01