FreeSol-Bild.php

Aus FreeSol-Wiki
<?php // content="text/plain; charset=utf-8"

require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_line.php');

$datum=$_GET["datum"];
$graphzahl=$_GET["graphzahl"];
$praefix=$_GET["praefix"];
$host=$_GET["url"];

$temp2=$datum.'minutesv.js';
$files= array($temp2);
$daten = file_get_contents($host.$files[0]);

$teile = preg_split('/\r\n/', $daten );
$datumsteile =preg_split('/\./', $teile[0] );
$solar = array();
$temp='leer';

for ($i = 1; $i <= 48; $i++)  {
    $solar[] ='0';
}

if (count ($datumsteile ) ==3) {
for ($i = 1; $i <= 18; $i++) {
   $zeilenteile =preg_split('/:/', $teile[$i] );
   $minutenzeilenwerte =preg_split('/  /', $zeilenteile[1] );
   unset($minutenzeilenwerte[12]);
   foreach ($minutenzeilenwerte as $minutenwert) {
      $solar[] = $minutenwert;
   }
}
}

for ($i = 1; $i <= 24; $i++)  {
    $solar[] ='0';
}


$host = "http://freesol.lima-city.de/Daten/Files/fs/";
$temp2=$datum.$praefix.'_bv.js';
$files= array($temp2);
$daten = file_get_contents($host.$files[0]);

$teile = preg_split('/\r\n/', $daten );
$datumsteile =preg_split('/\./', $teile[0] );
$bezug = array();
$temp='leer';

if (count ($datumsteile ) ==3) {
for ($i = 1; $i <= 18; $i++) {
   $zeilenteile =preg_split('/:/', $teile[$i] );
   $minutenzeilenwerte =preg_split('/  /', $zeilenteile[1] );
   unset($minutenzeilenwerte[12]);
   foreach ($minutenzeilenwerte as $minutenwert) {
      $bezug[] = $minutenwert;
   }
}
}

$host = "http://freesol.lima-city.de/Daten/Files/fs/";
$temp2=$datum.$praefix.'_ev.js';
$files= array($temp2);
$daten = file_get_contents($host.$files[0]);

$teile = preg_split('/\r\n/', $daten );
$datumsteile =preg_split('/\./', $teile[0] );
$einspeis = array();
$temp='leer';

if (count ($datumsteile ) ==3) {
for ($i = 1; $i <= 18; $i++) {
   $zeilenteile =preg_split('/:/', $teile[$i] );
   $minutenzeilenwerte =preg_split('/  /', $zeilenteile[1] );
   unset($minutenzeilenwerte[12]);
   foreach ($minutenzeilenwerte as $minutenwert) {
      $einspeis [] = $minutenwert;
   }
}
}

// Setup the graph

$graph = new Graph(400,300);
$graph->SetScale("textlin");

$graph->title->Set('Solarerzeugung '.$datum);
$graph->SetBox(false);

$graph->xgrid->Show(False);
//$graph->xgrid->SetLineStyle("solid");
//$graph->xgrid->SetColor('black'); //das ist der Hintergrund


// Erg㭺ungen
$graph->yaxis->SetColor("black");
$graph->yaxis->SetWeight(1);
$graph->ygrid->Show(true);                         //Gitterlinien (Hauptlinien, Nebenlinien)
$graph->ygrid->setcolor("black@0.8", "black@0.9");
$graph->ygrid->SetWeight(1,1);
$graph->yaxis->scale->ticks->Set(10,5);                  //Werte an Y-Achse

$graph->xgrid->Show(true);                         //Gitterlinien (Hauptlinien, Nebenlinien)
$graph->xgrid->setcolor("black@0.8", "black@0.9");
$graph->xgrid->SetWeight(1,1);


$tickPositions = array();
$tickLabels = array();
$tickPositions = array(35,71,107,143,179,215,251);
$tickLabels = array('03:00','06:00','09:00','12:00','15:00','18:00','21:00');
$graph->xaxis->SetMajTickPositions($tickPositions,$tickLabels);


// Create the first line
$p1 = new LinePlot($solar,$time4);
$graph->Add($p1);
$p1->SetColor("yellow");
$p1->SetLegend('Solar');

if ($graphzahl >1) {
// Create the second line
$p2 = new LinePlot($bezug,$time4);
$graph->Add($p2);
$p2->SetColor("blue");
$p2->SetLegend('Bezug');

// Create the third line
$p3 = new LinePlot($einspeis,$time4);
$graph->Add($p3);
$p3->SetColor("lime");
$p3->SetLegend('Einspeisung');
}

$graph->xaxis->title->Set("Uhrzeit");
$graph->yaxis->title->Set("Leistung in W");
$graph->xaxis->SetTitlemargin(30);
$graph->yaxis->SetTitlemargin(30);

$graph->legend->SetFrameWeight(1);

// Output line
$graph->Stroke();


?>