tengo un problema con el JPGRAPH y me produce este error
"JpGraph Error 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)."
El error es por un dato que efectivamente es erroneo.
Mi pregunta es ¿como puedo controlar ese error para que continue con el siguiente grafico?
No se el nº de graficos a generar ya que los selecciona el usuario por checkbox.
Utilizo un for para cada checkbox activado me genere un grafico en fichero que luego añado al web.
Si se produce un error de un grafico ya no crea el resto de graficos y aparece en el web el mensaje arriba indicado.
Esta es la función que me crea cada grafico.
la llamada a la función está dentro de un FOR
Código PHP:
<?Php
include ("../jpgraph/jpgraph.php");
//include ("../jpgraph/jpgraph_log.php");
include ("../jpgraph/jpgraph_line.php");
////////////////////////////////////////////////////////
//// Crea Grafico de lineas a partir de los arrays ///////////////////
function grafico($ydata,$datax,$titulo,$num_fich,$elfi,$n_rnc){
// Create the graph. These two calls are always required
$graph = new Graph(900,300,"auto"); // ancho,alto
$graph->SetScale("textlin");
//$graph->SetYScale(0,"lin",$min,$max);
//$graph->yaxis->scale->ticks->Set(1);
$graph -> img -> SetImgFormat('jpeg');
$graph->img->SetMargin(50,110,40,80); // izq,der,arriba,abajo
$graph->SetShadow();
$graph->ygrid->Show(true,true);//
$graph->xgrid->Show(true,false);
// Specify the tick labels
//$a = $gDateLocale->GetShortMonth();
//$graph->yaxis->SetTickLabels($ydata);
$graph->xaxis->SetTickLabels($datax); // texto datos en X1
$graph->xaxis->SetLabelAngle(90); // girar texto
//$graph->yaxis->SetTickLabels($ydata);
// Create the linear plot
$lineplot=new LinePlot($ydata);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->title->Set("Gráfica ".$n_rnc. " - " .$titulo);
/*$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");*/
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$graph->yaxis->SetColor("blue");
$lineplot->SetLegend($titulo);
$graph->legend->Pos(0.01,0.01,"right","top");
$ruta="img/".$elfi ."_graf_".$num_fich .".jpg";
// Display the graph $elfi ."_graf_".$num_fich .".jpg"
$graph->Stroke($ruta);
$elgra=$elfi ."_graf_".$num_fich .".jpg";
return $elgra;
}
?>
Código PHP:
for (..........){
// llamada a la funcion
$elgra=grafico($datos[$n_check],$datos[1],$miarray[0][$n_check],$n_check,$mirnc,$larnc);
//$datos[$n_check],$datos[1] $dat,$
$elgra1="img/".$elgra;
// echo $elgra;
if (file_exists($elgra1)) {
// print_r($graficos);
echo "<IMG src='./img/".$elgra ."' alt='' border='0'>";
$fich_gra[]=$elgra;
$nom_camp[]=$miarray[0][$n_check];
} else {
echo "<b>El Gráfico ". $miarray[0][$n_check]." no se ha podido crear</b>";
}
echo "</td>";
echo "</tr>";
}
Ayuda please.
Saludos