// Actual name of the TTF file used together with FF_CHINESE aka FF_BIG5
// This is the TTF file being used when the font family is specified as
// either FF_CHINESE or FF_BIG5
define('CHINESE_TTF_FONT','bkai00mp.ttf');
<?php // content="text/plain; charset=utf-8"
require_once ('../jpgraph/src/jpgraph.php');
require_once ('../jpgraph/src/jpgraph_bar.php');
include"../connect.php";
$sql="SELECT * FROM evaluation WHERE project_id='8' ";
$query=mysql_query($sql);
$datay = array(); //ตัวแปร Aray
while($row = mysql_fetch_array($query)){
$datay[] = $row[score];
}
//$datay=array(12,8,38,3,10,5);
// Create the graph. These two calls are always required
$graph = new Graph(300,200);
$graph->SetScale('textlin');
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(40,30,40,40);
// Create a bar pot
$bplot = new BarPlot($datay);
$graph->Add($bplot);
// Create and add a new text
$txt=new Text('ทดสอบ');
$txt->SetPos(10,20);
$txt->SetColor('darkred');
$txt->SetFont(FF_ANGSA,FS_BOLD,15);
$txt->SetBox('yellow','navy','[email protected]');
$graph->AddText($txt);
// Setup the titles
$graph->title->Set('ทดสอบ');
$graph->xaxis->title->Set('แกน-X');
$graph->yaxis->title->Set('แกน-Y');
$graph->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->yaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->xaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
// Display the graph
$graph->Stroke();
?>
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".