<?php
include ("tmp/jpgraph.php");
include ("tmp/jpgraph_line.php");

// Die Werte der 2 Linien in ein Array speichern
//$ydata = array(11,3,8,12,5,1,9,13,5,7);
//$ydata2= array(80,129,45,78,09,12,56,120,111,200);
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$ydata = array();
$ydata2 = array();
$xdata = array(); 
if (($handle = fopen("tempcfgraph.txt","r")) !== FALSE) {
    while (($data = fgetcsv($handle, 2000, ";")) !== FALSE) {
        $num = count($data);
    if ($num < 1)
        continue;
        $ydata[] = floatval($data[0]);
        $ydata2[] = floatval($data[1]); 
	$xdata[] = $data[2];
    
            }
    fclose($handle);
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

// Grafik generieren und Grafiktyp festlegen
$graph = new Graph(1200,600,"auto");    
$graph->SetScale("textlin");
$graph->SetY2Scale("lin"); 

// Die Zwei Linien generieren
$lineplot=new LinePlot($ydata);
$lineplot2=new LinePlot($ydata2);

// Die Linien zu der Grafik hinzufügen
$graph->Add($lineplot);
//$graph->Add($lineplot2);
$graph->AddY2($lineplot2); 

// Grafik Formatieren
$graph->img->SetMargin(50,50,20,40);
$graph->title->Set("Temperatur / Luftfeuchte");
$graph->xaxis->title->Set("/15min");
$graph->yaxis->title->Set("Temperatur °C");

$graph->xaxis->SetTickLabels($xdata);

$graph->y2axis->SetColor("orange");
$graph->y2axis->title->Set("Luftfeuchte %");
$graph->y2axis->SetWeight(2);

$graph->title->SetFont(FF_FONT2,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT2,FS_BOLD);
$graph->y2axis->title->SetFont(FF_FONT2,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

$graph->xaxis->SetTextLabelInterval(2);
$graph->xaxis->SetLabelAngle(90);
$graph->xgrid->Show();
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);

$lineplot2->SetColor("orange");
$lineplot2->SetWeight(2);

$graph->yaxis->SetColor("blue");
$graph->yaxis->SetWeight(2);
$graph->SetShadow();

// Grafik anzeigen
$graph->Stroke();
?>