Provkör på
http://ellak.dyn.ee/vp.php för 25h.
För att ange datum tex.
http://ellak.dyn.ee/vp.php?Day=2005-12-13<?php
include ("jpgraph.php");
include ("jpgraph_line.php");
mysql_connect("192.168.0.32", "root", "") or die("Kan ej ansluta: " . mysql_error());
mysql_select_db("alp") or die("Kan ej öppna databas alp");
if (isset($_GET['From'])) {
$fran = $_GET['From'];
$till = $_GET['To'];
} elseif (isset($_GET['Day'])) {
$fran = Date("Y-m-d H:i",strtotime($_GET['Day']));
$till = Date("Y-m-d H:i",strtotime($fran) +(1 * 24 * 60 * 60));
}
else {
$till = Date("Y-m-d H:i", time());
$fran = Date("Y-m-d H:i",strtotime($till) - (1 * 24 * 60 * 60));
}
$query = "SELECT `KB-f`, `KB-r`, `Freon`, `Ute`, `VB-r`, `VB-f` FROM VPData WHERE DatumTid >= '$fran' and DatumTid < '$till'";
$result = mysql_query($query) or die("SQL fråga felaktig: " . mysql_error());
for ($i=strtotime($fran); $myrow=mysql_fetch_row($result); $i = $i + 60) {
$ydataa[] = $myrow[5];
$ydatab[] = $myrow[4];
$ydatac[] = $myrow[3];
$ydatad[] = $myrow[2];
$ydatae[] = $myrow[1];
$ydataf[] = $myrow[0];
$xdata[] = Date("H:i", $i);
}
// Create the graph. These two calls are always required
// $graph = new Graph(800,350,"auto");
$graph = new Graph(1024,600,"auto");
$graph->SetScale("textlin",-20,55);
$graph->title->Set("Värmepumpdata: ".Date("Y-m-d H:i",strtotime($fran))." -> ".Date("Y-m-d H:i",strtotime($till)));
$graph ->img->SetMargin(40,20,30,70);
$graph ->xgrid->Show(true,false);
$graph ->xaxis->SetTextTickInterval(60);
$graph ->xaxis->SetTextLabelInterval(1);
$graph ->xaxis->SetTickLabels($xdata);
//$graph ->xaxis->SetFont(FF_ARIAL,FS_NORMAL,7);
$graph ->xaxis->SetFont(FF_FONT0);
//$graph ->xaxis->SetLabelAngle(30);
// $graph ->xaxis->HideFirstTicklabel();
$graph ->xaxis->SetLabelMargin(41);
$graph ->xaxis->SetLabelMargin(140);
$graph ->yaxis->title->Set("Grader");
$graph ->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph ->SetShadow();
$graph ->legend->SetLayout(LEGEND_HOR);
$graph ->legend->Pos(.5,.90,"center","center");
$graph ->legend->Pos(.5,.94,"center","center");
$graph ->ygrid->Show(true,true);
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5');
// Create the linear plot
$lineplot1=new LinePlot($ydataa);
$lineplot1->SetColor("blue");
$lineplot1 ->SetLegend("VB-f");
$lineplot1 ->setfaststroke();
// Create the linear plot
$lineplot2=new LinePlot($ydatab);
$lineplot2->SetColor("red");
$lineplot2 ->SetLegend("VB-r");
$lineplot2 ->setfaststroke();
// Create the linear plot
$lineplot3=new LinePlot($ydatac);
$lineplot3->SetColor("orange");
$lineplot3 ->SetLegend("Ute");
$lineplot3 ->setfaststroke();
// Create the linear plot
$lineplot4=new LinePlot($ydatad);
$lineplot4->SetColor("gold");
$lineplot4 ->SetLegend("Luft-B");
$lineplot4 ->setfaststroke();
// Create the linear plot
$lineplot5=new LinePlot($ydatae);
$lineplot5->SetColor("black");
$lineplot5 ->SetLegend("KB-r");
$lineplot5 ->setfaststroke();
// Create the linear plot
$lineplot6=new LinePlot($ydataf);
$lineplot6->SetColor("olivedrab");
$lineplot6 ->SetLegend("KB-f");
$lineplot6 ->setfaststroke();
// Add the plot to the graph
$graph->Add($lineplot1);
$graph->Add($lineplot2);
$graph->Add($lineplot4);
$graph->Add($lineplot5);
$graph->Add($lineplot6);
$graph->Add($lineplot3);
// Display the graph
$graph->Stroke();
?>