<?php // content="text/plain; charset=utf-8"
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
// die Daten, Temperatur und Feuchte (y-Achse) sowie Uhrzeit (x-Achse)
$temperaturA = [11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13];
$feuchteA = [70, 70, 75, 75, 80, 80, 85, 85, 90, 90, 85, 85];
$uhrzeitA = ["10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00"];
$graph = new Graph(600, 500);
$graph->SetMargin(40, 150, 40, 30);
$graph->SetMarginColor('white');
// Hier wird der Min- und Max-Wert fuer die Feuchte festgelegt
$graph->SetScale('intlin', 0, 100);
$graph->yscale->ticks->Set(10);
$graph->title->Set('Using multiple Y-axis');
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 14);
$graph->xgrid->Show();
$graph->ygrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xgrid->SetColor('#E3E3E3');
$graph->xaxis->SetTickLabels($uhrzeitA);
$graph->img->SetAntiAliasing(false);
// Hier wird der Min- und Max-Wert fuer die Temperatur festgelegt
$graph->SetYScale(0, 'lin', -20, 30);
$graph->yaxis->SetColor('blue');
$p1 = new LinePlot($feuchteA);
$graph->Add($p1);
$p1->SetFastStroke(false);
$p1->SetStyle('solid');
$p1->SetLineWeight('10');
$p1->SetColor('blue');
$p1->SetLegend('Luftfeuchtigkeit');
$p2 = new LinePlot($temperaturA);
$graph->AddY(0, $p2);
$p1->SetFastStroke(false);
$p1->SetStyle('solid');
$p1->SetLineWeight('10');
$p2->SetColor('red');
$p2->SetLegend('Temperatur');
$graph->ynscale[0]->ticks->Set(5);
$graph->ynaxis[0]->SetColor('red');
// Output line
$graph->Stroke();