HOME > PHP > PHP Forum > JpGraph Error กราฟแท่งครับ JpGraph Error: 25070 Either X or Y data arrays contains non-numeric values. Check that the data is really specified as numeric data and not as strings.
JpGraph Error กราฟแท่งครับ JpGraph Error: 25070 Either X or Y data arrays contains non-numeric values. Check that the data is really specified as numeric data and not as strings.
<?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='4' ";
$query=mysql_query($sql);
while($datay=mysql_fetch_array($query)){
//$datay=array(12,8,38,3,10,5);
echo"$datay[score]<br>";
// 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[score]');
$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();
}
?>
JpGraph Error: 25070 Either X or Y data arrays contains non-numeric values. Check that the data is really specified as numeric data and not as strings. It is an error to specify data for example as '-2345.2' (using quotes).
<?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='4' ";
$query=mysql_query($sql);
$datay = array();
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();
?>