<?php

require_once ('../../../graph/jpgraph/src/Examples/jpgraph/jpgraph.php');
require_once ('../../../graph/jpgraph/src/Examples/jpgraph/jpgraph_scatter.php');
require_once( "../../../graph/jpgraph/src/Examples/jpgraph/jpgraph_date.php" );
require_once ('../../../graph/jpgraph/src/Examples/jpgraph/jpgraph_line.php');
require_once ('../../../graph/jpgraph/src/Examples/jpgraph/jpgraph_utils.inc.php');


//$survey_id5599=$survey_id55;
  //  $map_me=$map_id;
// $sq112ac199="SELECT * FROM $table_name79 WHERE survey_id='$survey_id5599'"; //    points.
//  $sq112ac199="SELECT * FROM $table_name80 WHERE survey_id='$survey_id5599'"; //    map_test.

 // $sq112ac199="SELECT * FROM $table_name79 WHERE map_id='$map_me'";
//  $sq112ac199="SELECT COUNT(NULLIF(van1,''))+ COUNT(NULLIF(van2,''))+COUNT(NULLIF(van3,''))+COUNT(NULLIF(van4,''))+COUNT(NULLIF(van5,''))+COUNT(NULLIF(van6,''))+COUNT(NULLIF(van7,''))+COUNT(NULLIF(van8,''))+COUNT(NULLIF(van9,''))+COUNT(NULLIF(van10,''))+COUNT(NULLIF(van11,''))     as county4 FROM $table_name80 WHERE map_id='$map_me'";
 //  $result3399 = @mysql_query($sq112ac199,$connection) or die(mysql_error());
 //    $row3399 = mysql_fetch_assoc($result3399);
            // $field_cnt = mysql_num_fields($result3399);
//       $field_cnt=$row3399['county4'];

 //                $field_cnt="M=$map_me F=$field_cnt ---   $graphyme[4],$graphymA[5], $graphymP[5]";

//echo "field_cnt =$field_cnt";

//echo "hi $xmainbob";
//$datax = array(3.5,3.7,3,4);
//$datay = array(20,22,12,13);
//   $datax=array($xmainbob);
//  $datay=array($ymainbob);

//echo "$bobdatev1[$j] <br/>$bobv1[$j])<br/>";

$datay1=explode(',', $bobv1[$j]);
//$datax1=explode(',', $bobdatev1[$j]);
$datax1=explode(',', $bobdatev11[$g]);
         $min1=min($datax1);
         $man1=max($datax1);
//echo " 2-$min1-$man1= $datay1[2] <br/>";

if ($datax[0]==$blink){
$datax = array(0,0,0,0);
$datay = array(0,0,0,0);
}


//$datay = array();
//$datax = array();
//$ts = time();
//$n=count($bobdatev1[$j]); // Number of data points
  $n=  $answer1a[$j]; // Number of data points
 // echo "num33A1 =$n-$datay1[1]-<br/>";


  $dateUtils = new DateScaleUtils();

// Setup a basic graph
$width=500; $height=300;
$graph = new Graph($width, $height);

// We set the x-scale min/max values to avoid empty space
// on the side of the plot
$graph->SetScale('intlin',0,0,$min1,$man1);
$graph->SetMargin(60,20,40,60);

// Setup the titles
//$graph->title->SetFont(FF_ARIAL,FS_BOLD,12);
$graph->title->Set('Records Collected For Selected Time Period');
//$graph->subtitle->SetFont(FF_ARIAL,FS_ITALIC,10);
//$graph->subtitle->Set('(Example using DateScaleUtils class)');

// Setup the labels to be correctly format on the X-axis
//$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,8);
$graph->xaxis->SetLabelAngle(30);

// The second paramter set to 'true' will make the library interpret the
// format string as a date format. We use a Month + Year format
$graph->xaxis->SetLabelFormatString('M, Y',true);

// Get manual tick every second year
list($tickPos,$minTickPos) = $dateUtils->getTicks($xdata,DSUTILS_DAY1);
$graph->xaxis->SetTickPositions($tickPos,$minTickPos);

// First add an area plot
$lp1 = new LinePlot($datay1,$datax1);
$lp1->SetWeight(0);
$lp1->SetFillColor('orange@0.85');
$graph->Add($lp1);

$sp12 = new ScatterPlot($datay1,$datax1);
$sp12->mark->SetType(MARK_FILLEDCIRCLE);
$sp12->mark->SetFillColor("blue");
$sp12->link->SetColor('green@0.7');
$graph->Add($sp12);

// And then add line. We use two plots in order to get a
// more distinct border on the graph
$lp2 = new LinePlot($datay1,$datax1);
$lp2->SetColor('orange');
$graph->Add($lp2);

$Rtoday2a=date("Y-m-d h:i:s");
$Rtoday1=date("h_i_s");

// Get the handler to prevent the library from sending the
// image to the browser
$gdImgHandler = $graph->Stroke(_IMG_HANDLER);
$fileNamer = "data/$map_id$Rtoday1$g.png";
$graph->img->Stream($fileNamer);

?>
