jpgraph problem

Krebskasper

Grünschnabel
moin,
ich habe folgendes problem:
ich erstelle mithilfe meines scripts einen array mit dem ich per jpgraph einen linie im graphen zeichnen lassen will. in dem script gibt es eine textausgabe(die fehlerfrei funktioniert) und eine graphische ausgabe, die es eben nicht tut.

mit hilfe eines vorangegangen scripts wird ein parameter und der zeitraum angegeben.

hier nun das script:
PHP:
<?php
	include("../header.php");
    include ("jpgraph.php");
    include ("jpgraph_line.php");

// Configure this script:
//	$debug = true;
	$thisFile = "view/query." .$phpExt;

// Create a database connection
	$con = NewADOConnection("$db_type");
	$con->Connect("$db_host", "$db_user", "$db_pwd", "$db_name");


/*********************************************************
	aquire and format the variables
*********************************************************/

// Add 00:00:00 as time, for it requires less ressources
// than substr()-ing in the query
	$from_date = $HTTP_POST_VARS["from_year"] ."-"
				.$HTTP_POST_VARS["from_mon"] ."-"
				.$HTTP_POST_VARS["from_day"]." 00:00:00";
// Add 23:59:59 as time, for it requires less ressources
// than substr()-ing in the query
	$to_date   = $HTTP_POST_VARS["to_year"] ."-"
				.$HTTP_POST_VARS["to_mon"] ."-"
				.$HTTP_POST_VARS["to_day"]." 23:59:59";

	if (isset($HTTP_POST_VARS["pcatch"]) && $HTTP_POST_VARS["pcatch"] != "NULL")
		$catchment = $HTTP_POST_VARS["pcatch"];
	if (isset($HTTP_POST_VARS["pupd"]) && $HTTP_POST_VARS["pupd"] != "")
		$pupd = $HTTP_POST_VARS["pupd"];
	if (isset($HTTP_POST_VARS["parameter_code"]) && $HTTP_POST_VARS["parameter_code"] != "NULL")
		$pcode = $HTTP_POST_VARS["parameter_code"];
	if (isset($HTTP_POST_VARS["sensorid"]) && $HTTP_POST_VARS["sensorid"] != "")
		$sensorid = $HTTP_POST_VARS["sensorid"];
	if (isset($HTTP_POST_VARS["x"]) && $HTTP_POST_VARS["x"] != "")
		$koordx = $HTTP_POST_VARS["x"];
	if (isset($HTTP_POST_VARS["y"]) && $HTTP_POST_VARS["y"] != "")
		$koordy = $HTTP_POST_VARS["y"];
	if (isset($HTTP_POST_VARS["wovalue"]) && $HTTP_POST_VARS["wovalue"] != "")
		$wovalue = $HTTP_POST_VARS["wovalue"];
	if (isset($HTTP_POST_VARS["designator"]) && $HTTP_POST_VARS["designator"] != "")
		$designator = $HTTP_POST_VARS["designator"];
	if (isset($HTTP_POST_VARS["createchart"]) && $HTTP_POST_VARS["createchart"] != "")
		$createchart = $HTTP_POST_VARS["createchart"];

/*********************************************************
	create the SQL-statement
*********************************************************/
	$sql  = "SELECT val.t, val.val, sens.pparam, param.descr, sens.desig, param.unit";
/*	if (isset($koordx))		$sql .= ", sens.x";
	if (isset($koordy))		$sql .= ", sens.y";
	$sql .= ", val.id";
*/
	$sql .= ", catch.name cname";
	$sql .= ", param.name pname";

	$sql .= " FROM " .SENS_TABLE ." AS sens";
	$sql .= ", " .SENSVAL_TABLE  ." AS val ";
	$sql .= ", " .CATCHMENT_TABLE ." AS catch ";
	$sql .= ", " .PARAMETER_TABLE ." AS param ";

	$sql .=  "WHERE val.psens = sens.uid_ ";
	$sql .= " AND val.t > '".$from_date."' ";
	$sql .= " AND val.t < '".$to_date."' ";
	if (isset($catchment))		$sql .= " AND catch.id = '".$catchment."' ";
	if (isset($pcode)) 		$sql .= " AND sens.pparam = '".$pcode."'";
	if (isset($pupd))		$sql .= " AND val.pupd = '".$pupd."'";
	if (isset($sensorid)) 		$sql .= " AND sens.uid_ = '".$sensorid."'";
	if (isset($designator)) 	$sql .= " AND sens.desig = '".$designator."'";
	$sql .= " AND param.code = sens.pparam ";
	$sql .= " AND catch.id = sens.pcatch";
	if (isset($pcode))		$sql .=" GROUP BY sens.pparam";
	$sql .= " ORDER BY val.psens, val.t ASC";
	//echo ($sql) ."<br>\n";
	createDebugMessage( "SQL: " .$sql .$messageExt, $thisFile, $debug);


/*********************************************************
	fetch and print the result set
*********************************************************/
	$rs = &$con->Execute($sql);
	$con->SetFetchMode(ADODB_FETCH_ASSOC); // Return associative array
	//echo "<p>\n";
	$tsconsistency=1;

	if (isset($createchart))
	{
		$line_graph = new Graph(800,600,"auto");
		$line_graph->SetScale("textlin");
		$xdata = array();
		$ydata = array();
	}
	
	while ($row = $rs->FetchNextObject())
	{
		if (!isset($createchart))
		{
			if ($row->PPARAM != $oldp)
			{
				if (isset($oldt))
				{
					echo "end date : " .makeNice($oldt)."<br>";
		        }
				
				if ($row->CNAME   != $oldc)
				{
					echo "</p><p>\n<big><strong>" .$row->CNAME ."</strong></big><br><b>Designator: </b>"
					.$row->DESIG."&nbsp;&nbsp;&nbsp;<b>Parameter: </b>".$row->PNAME." (" .$row->PPARAM .") <br>"
					.$row->DESCR."  <b>Unit:</b>".$row->UNIT." : <br>\n";
				}
				
				else 
				{
					echo "</p><p>\n<b>Designator: </b>".$row->DESIG." (" .$row->PPARAM .") <b>Parameter: </b>"
					.$row->PNAME."<br>".$row->DESCR."  <b>Unit:</b>".$row->UNIT." : <br>\n";			
				}
				
				
				
				echo "start date : ".makeNice($row->T)."<br>";

	
			}
			if (!$wovalue)
			{
				echo makeNice($row->T) ." : " .$row->VAL ."<br>\n";
			}
				
			$oldp = $row->PPARAM;
			$oldt = $row->T;
			$oldc = $row->CNAME;
			$oldd = $row->DESIG;
			$isdata = 1;
		}
			
		else
		{			
			if (isset($pcode))
			{
				if ($row->PPARAM != $oldp)
				{
					/*if (isset($oldt))
					{
						echo "end date : ".$oldt;
					}
					
					echo "</p><p>\n<big><strong>" .$row->CNAME ."</strong></big><br><b>Designator: </b>"
					.$row->DESIG."&nbsp;&nbsp;&nbsp;<b>Parameter: </b>".$row->PNAME." (" .$row->PPARAM .") <br>"
					.$row->DESCR."  <b>Unit:</b>".$row->UNIT." : <br>\n";
					
					echo "start date : ".makeNice($row->T)."<br>";*/
					if (isset($oldp))
					{
						$lineplot = new LinePlot($ydata);
						$line_graph->Add($lineplot);
						format_graph($line_graph);
						$line_graph->Stroke();
						unset($lineplot);
						unset($line_graph);
						unset($xdata);
						unset($ydata);
						$line_graph = new Graph(800,600,"auto");
						$line_graph->SetScale("textlin");
						$xdata=array();
						$ydata=array();
					}
				}
				array_push($xdata, makeNice($row->T));
				array_push($ydata, $row->VAL);
			
				/*if ($tsconsistency && !$firstts)
				{
					$timestep=($row->T - $oldt)/1000/24;
			
//				echo "T, oldt : ".$row->T." , ".$oldt."<br>";
//				echo "timestep : ".$timestep."<br>";
	    		    if ($tsconsistency)
	   	  		 	{
						if ($timestep != $oldtimestep)
						{
						$tsconsistency=0;
						}
					}				
					$timestep = $oldtimestep;
				}*/
				$oldp = $row->PPARAM;
				$oldt = $row->T;
				$oldc = $row->CNAME;
				$oldd = $row->DESIG;
				$firstts= 0;
				$isdata=1;
			}
		}
	}
				
	if (isset($isdata))
	{
		echo "end date : ".makeNice($oldt)."</p>\n";
	}
		
	else
	{
		echo "<br><br><strong>No data found for your specifications</strong>";
	}
	
	if (isset($createchart))
	{
		$lineplot = new LinePlot($ydata);
		$line_graph->Add($lineplot);
		format_graph($line_graph);
		$line_graph->Stroke();
	}
	
	$con->close();

//Funktionen

function format_graph($graph)
 {
 	// Grafik Formatieren
 	$graph->img->SetMargin(40,20,20,40);
 	$graph->title->Set("tQs-View Output");
 	$graph->xaxis->title->Set("time");
 	$graph->yaxis->title->Set($row->DESCR);//?
 	
 	$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);
 	
  //	$lineplot2->SetColor("orange");
  //	$lineplot2->SetWeight(2);
 	
 	$graph->yaxis->SetColor("red");
 	$graph->yaxis->SetWeight(2);
 	$graph->SetShadow();
	return $graph;
 }

?>

was auskommentiert ist braucht selbstvereständlich nicht beachtet zu werden. die fehlermeldung die von jpgraph ausgeben wird ist folgende:

JpGraph Error: A plot has an illegal scale. This could for example be that you are trying to use text autoscaling to draw a line plot with only one point or that the plot area is too small. Try increasing the graph size or correct the lineplot.

schoneinmal danke im voraus, und bei fragen einfach posten email pm oder sonstwas :)

greetz,
der kasper
 
Steht doch da, was er will. In Deutsch übersetzt (google) heißt das ca.
Störung JpGraph: Ein Plot hat eine ungültige Skala. Dieses könnte zum Beispiel sein, daß Sie versuchen, Textselbständige Maßstabsfestlegung zu verwenden, um einen Linienplot mit nur einem Punkt zu zeichnen, oder daß der Plotbereich zu klein ist. Versuchen Sie, die Diagrammgröße zu erhöhen oder beheben Sie das lineplot.
 

Neue Beiträge

Zurück