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

// Die Werte der 2 Linien in ein Array speichern
//$ydata = array(11,3,8);
//$xdata = array("11:16","12:15","12:16");
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$ydata = array();
$xdata = array(); 
if (($handle = fopen("temperaturgraph.txt", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 2000, ";")) !== FALSE) {
        $num = count($data);
    if ($num < 1)
        continue;
        $ydata[] = floatval($data[0]);
        $xdata[] = $data[1]; 
    
            }
    fclose($handle);
}
//print_r ($ydata1); 
//echo "<br />";
//print_r ($ydata2);


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



//  Linien generieren

$lineplot =new LinePlot($ydata);

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


// Grafik Formatieren
// Schatten hinzufügen
//$graph->SetShadow();
$graph->img->SetMargin(50,20,40,50);
//$graph->SetMarginColor("hellgrau");

$graph->title->Set("Temperatur");
$graph->xaxis->title->Set("");
$graph->yaxis->title->Set("°C");

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

$graph->xaxis->SetLabelAngle(90);
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

$graph->xaxis->SetTextLabelInterval(2);
$graph->xgrid->Show();
$graph->xaxis->SetPos('min');
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);


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

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