Changeset 43 for trunk/Application/View


Ignore:
Timestamp:
Nov 24, 2009, 2:03:29 PM (15 years ago)
Author:
george
Message:
  • Upraveno: Skripty pro načítání hodnot byly pročištěny a přepsány na třídy. Pro definici místně měřených veličin nyní použita tabulky MeasureClient odkazující se na tabulku MeasureMethod obsahující globální registr měřících metod.
  • Opraveno: Různé chyby vzniklé při přepisu třídy Measure a použité pro zobrazení obrázku grafu.
Location:
trunk/Application/View
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/View/Graph.php

    r40 r43  
    11<?php
     2
     3include_once(dirname(__FILE__).'/../../Base/View.php');
     4include_once(dirname(__FILE__).'/../Model/Measure.php');
    25
    36class GraphView extends View
     
    58  function Render()
    69  {
    7 if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
    8   else $Debug = 0;
    9  
    10 if(!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku');
    11 $StartTime = addslashes($_GET['From']);
    12 if(!array_key_exists('To',$_GET)) die('Musíte zadat čas konce');
    13 $EndTime = addslashes($_GET['To']);
    14 if($EndTime < $StartTime) $EndTime = $StartTime + 60;
    15 $TimeDifference = $EndTime - $StartTime;
    16 if(!array_key_exists('Measure',$_GET)) die('Musíte zadat měřenou veličinu');
    17 $MeasureId = addslashes($_GET['Measure']);
    18 if(!array_key_exists('Width', $_GET)) $Width = $DefaultWidth;
    19 else $Width = addslashes($_GET['Width']);
    20 if(!array_key_exists('Height', $_GET)) $Height = $DefaultHeight;
    21 else $Height = addslashes($_GET['Height']);
    22 if(!array_key_exists('Differential', $_GET)) $Differential = $Config['DefaultVariables']['Differential'];
    23 else $Differential = addslashes($_GET['Differential']);
    24 $VerticalLinesCount = round($Height / ($FontSize + 4));
    25 
    26 $StopWatchStart = GetMicrotime();
    27 
    28 $Measure = GetMeasureById($MeasureId);
    29 
    30 $Level = floor(log(($EndTime - $StartTime) / $DivisionCount / 60) / log($LevelReducing)) - 1;
    31 if($Level < 0) $Level = 0;
    32 if($Level > $MaxLevel) $Level = $MaxLevel;
    33 //$Level = 0;
    34 
    35 
    36 $Points = GetValues($Measure, $StartTime, $EndTime, $Level);
    37 
    38 if($Debug) echo('Points count: '.count($Points).'<br>');
    39 //if($Debug) foreach($Points as $Index => $Item)
    40 //  echo($Index.': '.$Item['min'].'<br>');
    41 
    42 // Calculate total max, avg, min value
    43 $MaxValue = -1000000000000000000;
    44 $AvgValue = 0;
    45 $MinValue = 1000000000000000000;
    46 foreach($Points as $Index => $Item)
    47 {
    48   //$Points[$Index]['min'] =  $Points[$Index]['min'] / $Measure['Divider'];
    49   //$Points[$Index]['avg'] =  $Points[$Index]['avg'] / $Measure['Divider'];
    50   //$Points[$Index]['max'] =  $Points[$Index]['max'] / $Measure['Divider'];
    51   if($Points[$Index]['avg'] > $MaxValue) $MaxValue = $Points[$Index]['avg'];
    52   if($Points[$Index]['avg'] < $MinValue) $MinValue = $Points[$Index]['avg'];
    53   if($Points[$Index]['max'] > $MaxValue) $MaxValue = $Points[$Index]['max'];
    54   if($Points[$Index]['min'] < $MinValue) $MinValue = $Points[$Index]['min'];
    55   $AvgValue = $AvgValue + $Points[$Index]['avg'];
    56 }
    57 //$MinValue = round($MinValue * $Measure['Divider']) / $Measure['Divider'];
    58 //$MaxValue = round($MaxValue * $Measure['Divider']) / $Measure['Divider'];
    59 $AvgValue = $AvgValue / count($Points); //round( * $Measure['Divider']) / $Measure['Divider'];
    60 
    61 // Generate polygon and recalculate y values to fit graph height
    62 $PointsMin = array(0, $Height-1);
    63 $PointsAvg = array(0, $Height-1);
    64 $PointsMax = array(0, $Height-1);
    65 if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
    66 {
    67   foreach($Points as $Index => $Item)
    68   {
    69     $PointsMin[] = $Index*$Width/$DivisionCount;
    70     $PointsMin[] = $Height - 1 - ($Points[$Index]['min'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $K;
    71     $PointsAvg[] = $Index*$Width/$DivisionCount;
    72     $PointsAvg[] = $Height - 1 - ($Points[$Index]['avg'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $K;
    73     $PointsMax[] = $Index*$Width/$DivisionCount;
    74     $PointsMax[] = $Height - 1 - ($Points[$Index]['max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $K;
    75     //echo($Index.' - '.$Item.' '.$Points[$Index].'<br>');
     10    if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
     11      else $Debug = 0;
     12 
     13    if(!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku');
     14    $StartTime = addslashes($_GET['From']);
     15    if(!array_key_exists('To', $_GET)) die('Musíte zadat čas konce');
     16    $EndTime = addslashes($_GET['To']);
     17    if($EndTime < $StartTime) $EndTime = $StartTime + 60;
     18    $TimeDifference = $EndTime - $StartTime;
     19    if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
     20    $MeasureId = addslashes($_GET['Measure']);   
     21    if(!array_key_exists('Width', $_GET)) $Width = $DefaultWidth;
     22      else $Width = addslashes($_GET['Width']);
     23    if(!array_key_exists('Height', $_GET)) $Height = $DefaultHeight;
     24      else $Height = addslashes($_GET['Height']);
     25    if(!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];
     26      else $Differential = addslashes($_GET['Differential']);
     27    $VerticalLinesCount = round($Height / ($this->Config['Application']['FontSize'] + 4));
     28
     29    $StopWatchStart = $this->System->GetMicrotime();
     30
     31    $Measure = new Measure($this->System);
     32    $Measure->Load($MeasureId);
     33    $Measure->LevelReducing = $this->Config['Application']['LevelReducing'];
     34    $Measure->ReferenceTime = $this->Config['Application']['ReferenceTime'];
     35    $Measure->MaxLevel = $this->Config['Application']['MaxLevel'];
     36    $Measure->DivisionCount = $this->Config['Application']['DivisionCount'];
     37    $Measure->Differential = $this->Config['Application']['DefaultVariables']['Differential'];
     38    $Measure->Debug = $Debug;
     39
     40    $FontSize = $this->Config['Application']['FontSize'];
     41    $FontFile = dirname(__FILE__).'/../Style/'.$this->Config['System']['Style'].'/'.$this->Config['Application']['FontFileName'];
     42
     43    $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1;
     44    if($Level < 0) $Level = 0;
     45    if($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;
     46    //$Level = 0;
     47
     48    $Points = $Measure->GetValues($StartTime, $EndTime, $Level);
     49
     50    if($Debug) echo('Points count: '.count($Points).'<br/>');
     51    //if($Debug) foreach($Points as $Index => $Item)
     52    // echo($Index.': '.$Item['min'].'<br>');
     53
     54    // Calculate total max, avg, min value
     55    $MaxValue = -1000000000000000000;
     56    $AvgValue = 0;
     57    $MinValue = 1000000000000000000;
     58    foreach($Points as $Index => $Item)
     59    {
     60      //$Points[$Index]['min'] =  $Points[$Index]['min'] / $Measure['Divider'];
     61      //$Points[$Index]['avg'] =  $Points[$Index]['avg'] / $Measure['Divider'];
     62      //$Points[$Index]['max'] =  $Points[$Index]['max'] / $Measure['Divider'];
     63      if($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];
     64      if($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];
     65      if($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];
     66      if($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];
     67      $AvgValue = $AvgValue + $Points[$Index]['Avg'];
     68    }
     69    //$MinValue = round($MinValue * $Measure['Divider']) / $Measure['Divider'];
     70    //$MaxValue = round($MaxValue * $Measure['Divider']) / $Measure['Divider'];
     71    $AvgValue = $AvgValue / count($Points); //round( * $Measure['Divider']) / $Measure['Divider'];
     72
     73    // Generate polygon and recalculate y values to fit graph height
     74    $PointsMin = array(0, $Height - 1);
     75    $PointsAvg = array(0, $Height - 1);
     76    $PointsMax = array(0, $Height - 1);
     77    if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
     78    {
     79      foreach($Points as $Index => $Item)
     80      {
     81        $PointsMin[] = $Index * $Width / $Measure->DivisionCount;
     82        $PointsMin[] = $Height - 1 - ($Points[$Index]['Min'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     83        $PointsAvg[] = $Index * $Width / $Measure->DivisionCount;
     84        $PointsAvg[] = $Height - 1 - ($Points[$Index]['Avg'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     85        $PointsMax[] = $Index * $Width / $Measure->DivisionCount;
     86        $PointsMax[] = $Height - 1 - ($Points[$Index]['Max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $this->Config['Application']['ValueToImageHeigthCoefficient'];
     87        //echo($Index.' - '.$Item.' '.$Points[$Index].'<br>');
     88      }
     89    }
     90    $PointsMin[] = $Width - 1;
     91    $PointsMin[] = $Height - 1;
     92    $PointsAvg[] = $Width - 1;
     93    $PointsAvg[] = $Height - 1;
     94    $PointsMax[] = $Width - 1;
     95    $PointsMax[] = $Height - 1;
     96    $PointsMin[] = $Width - 1;
     97    $PointsMin[] = $Height - 1;
     98    $PointsAvg[] = $Width - 1;
     99    $PointsAvg[] = $Height - 1;
     100    $PointsMax[] = $Width - 1;
     101    $PointsMax[] = $Height - 1;
     102
     103
     104    //array_unshift($Points, $Height - 1);
     105    //array_unshift($Points, 0);
     106    //$Points[] = $Width - 1;
     107    //$Points[] = $Height - 1;
     108
     109    //print_r($PointsMax);
     110 
     111    // Generate image
     112    if(!$Debug)
     113    {
     114      Header('Content-type: image/png');
     115      Header('Cache-Control: no-cache');  // Dynamic graph - no cache
     116      $Image = @imagecreate($Width, $Height);
     117      $BackgroundColor = imagecolorallocate($Image, 255, 255, 255);
     118      $Black = imagecolorallocate($Image, 0, 0, 0);
     119      $White = imagecolorallocate($Image, 255, 255, 255);
     120      $Gray = imagecolorallocate($Image, 200, 200, 200);
     121      $DarkGray = imagecolorallocate($Image, 100, 100, 100);
     122      $LightBlue = imagecolorallocate($Image, 150, 150, 255);
     123      $Blue = imagecolorallocate($Image, 0, 0, 255);
     124      $LightRed = imagecolorallocate($Image, 255, 150, 150);
     125      $Red = imagecolorallocate($Image, 255, 0, 0);
     126      $Green = imagecolorallocate($Image, 0, 200, 0);
     127      $LightGreen = imagecolorallocate($Image, 150, 255, 150);
     128
     129      imagefilledpolygon($Image, $PointsMax, count($PointsMax) / 2, $LightRed);
     130      imagefilledpolygon($Image, $PointsAvg, count($PointsAvg) / 2, $LightGreen);
     131      imagefilledpolygon($Image, $PointsMin, count($PointsMin) / 2, $LightBlue);
     132 
     133      $TimeMarks = array(1, 60, 60*60, 60*60*24, 60*60*24*7, 60*60*24*30, 60*60*24*365, 60*60*24*365*10);
     134 
     135      $TimeRange = $EndTime - $StartTime;
     136      $TimeMarksIndex = 0;
     137      while(($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1;
     138      if($TimeMarksIndex < 2) $TimeMarksIndex = 2;
     139      $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1];
     140      $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 
     141   
     142      $TimeShift = $Measure->AlignTime($StartTime, $MajorTimeMarks) - $StartTime;
     143      //imagestring($Image, 10, 40, 50, $TimeShift, $Black);
     144 
     145      // Zobraz měřítko Y
     146      $VerticalLinesDistance = $Height / $VerticalLinesCount;
     147      for($I = 1; $I <= $VerticalLinesCount; $I++)
     148      {
     149        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
     150        for($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
     151        //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
     152      }
     153
     154      $TimeShift = $Measure->AlignTime($StartTime, $MinorTimeMarks) - $StartTime;
     155 
     156      // Zobraz měřítko X
     157      $LastTextEnd = 0;
     158      for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
     159      {
     160        $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
     161        //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
     162        if(($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift);
     163          else $Text = date('j.n.Y G:i', $Time + $TimeShift);
     164        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
     165        if($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
     166        {
     167          for($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
     168          imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,  $Height - 2, $Black, $FontFile, $Text);
     169          $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2;
     170        }
     171        else for($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
     172      }
     173 
     174      // Popisky osy Y
     175      for($I = 1; $I <= $VerticalLinesCount; $I++)
     176      {
     177        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
     178        //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $this->Config['Application']['ValueToImageHeigthCoefficient'] * $Height);
     179        $Text = $this->System->AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $this->Config['Application']['ValueToImageHeigthCoefficient'] * ($MaxValue - $MinValue) + $MinValue)), $Measure->Data['Unit'], 3);
     180        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
     181        if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     182          imagettftext($Image, $FontSize, 0, 2,  $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text);
     183      }
     184      $GenerationTime = floor(($this->System->GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
     185
     186      $Left = $Width - 10;
     187      $Text = '    Max. '.$this->System->AddPrefixMultipliers($MaxValue, $Measure->Data['Unit']);
     188      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
     189      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
     190      imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text);
     191
     192      $Text = '    Avg.  '.$this->System->AddPrefixMultipliers($AvgValue, $Measure->Data['Unit']);
     193      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
     194      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
     195      imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text);
     196
     197      $Text = '    Min.  '.$this->System->AddPrefixMultipliers($MinValue, $Measure->Data['Unit']);
     198      $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
     199      $Left -= ($BoundingBox[2] - $BoundingBox[0]);
     200      imagettftext($Image, $FontSize, 0, $Left, 14, $Blue, $FontFile, $Text);
     201      //imagestring($Image, 2, 70, 20, 'Vygenerováno za '.$GenerationTime.' sekund', $Black);
     202      //imagestring($Image, 2, 50, 30, 'Level: '.$Level, $Black);
     203
     204      imagettftext($Image, $FontSize, 0, 70, 14, $Black, $FontFile, $Measure->Data['Description']);
     205      imagerectangle($Image, 0, 0, $Width - 1, $Height - 1, $Black);   // Frame border
     206      imagepng($Image);
     207      imagedestroy($Image);
     208    }   
    76209  }
    77210}
    78 $PointsMin[] = $Width-1;
    79 $PointsMin[] = $Height-1;
    80 $PointsAvg[] = $Width-1;
    81 $PointsAvg[] = $Height-1;
    82 $PointsMax[] = $Width-1;
    83 $PointsMax[] = $Height-1;
    84 $PointsMin[] = $Width-1;
    85 $PointsMin[] = $Height-1;
    86 $PointsAvg[] = $Width-1;
    87 $PointsAvg[] = $Height-1;
    88 $PointsMax[] = $Width-1;
    89 $PointsMax[] = $Height-1;
    90 
    91 
    92 //array_unshift($Points, $Height - 1);
    93 //array_unshift($Points, 0);
    94 //$Points[] = $Width - 1;
    95 //$Points[] = $Height - 1;
    96 
    97 //print_r($PointsMax);
    98 
    99 // Generate image
    100 if(!$Debug)
    101 {
    102   header("Content-type: image/png");
    103   header("Cache-Control: no-cache");  // Dynamic graph - no cache
    104   $Image = @imagecreate($Width, $Height);
    105   $BackgroundColor = imagecolorallocate($Image, 255, 255, 255);
    106   $Black = imagecolorallocate($Image, 0, 0, 0);
    107   $White = imagecolorallocate($Image, 255, 255, 255);
    108   $Gray = imagecolorallocate($Image, 200, 200, 200);
    109   $DarkGray = imagecolorallocate($Image, 100, 100, 100);
    110   $LightBlue = imagecolorallocate($Image, 150, 150, 255);
    111   $Blue = imagecolorallocate($Image, 0, 0, 255);
    112   $LightRed = imagecolorallocate($Image, 255, 150, 150);
    113   $Red = imagecolorallocate($Image, 255, 0, 0);
    114   $Green = imagecolorallocate($Image, 0, 200, 0);
    115   $LightGreen = imagecolorallocate($Image, 150, 255, 150);
    116 
    117   imagefilledpolygon($Image, $PointsMax, count($PointsMax) / 2, $LightRed);
    118   imagefilledpolygon($Image, $PointsAvg, count($PointsAvg) / 2, $LightGreen);
    119   imagefilledpolygon($Image, $PointsMin, count($PointsMin) / 2, $LightBlue);
    120  
    121   $TimeMarks = array(1, 60, 60*60, 60*60*24, 60*60*24*7, 60*60*24*30, 60*60*24*365, 60*60*24*365*10);
    122  
    123   $TimeRange = $EndTime - $StartTime;
    124   $TimeMarksIndex = 0;
    125   while(($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1;
    126   if($TimeMarksIndex < 2) $TimeMarksIndex = 2;
    127   $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1];
    128   $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 
    129    
    130   $TimeShift = AlignTime($StartTime, $MajorTimeMarks) - $StartTime;
    131   //imagestring($Image, 10, 40, 50, $TimeShift, $Black);
    132  
    133   // Zobraz měřítko Y
    134   $VerticalLinesDistance = $Height / $VerticalLinesCount;
    135   for($I=1; $I<=$VerticalLinesCount; $I++)
    136   {
    137     $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    138     for($X=1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
    139     //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    140   }
    141 
    142   $TimeShift = AlignTime($StartTime, $MinorTimeMarks) - $StartTime;
    143  
    144   // Zobraz měřítko X
    145   $LastTextEnd = 0;
    146   for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
    147   {
    148     $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
    149     //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    150     if(($MajorTimeMarks > 60*60*24)) $Text = date('j.n.Y', $Time + $TimeShift);
    151       else $Text = date('j.n.Y G:i', $Time + $TimeShift);
    152     $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    153     if($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
    154     {
    155       for($Y=0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
    156       imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,  $Height - 2, $Black, $FontFile, $Text);
    157       $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2;
    158     }
    159     else for($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
    160   }
    161  
    162   // Popisky osy Y
    163   for($I=1; $I<=$VerticalLinesCount; $I++)
    164   {
    165     $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    166     //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $K * $Height);
    167     $Text = AddPrefixMultipliers(round(($I * $VerticalLinesDistance / $Height / $K * ($MaxValue - $MinValue) + $MinValue)), $Measure['Unit'], 3);
    168     $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    169     if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
    170       imagettftext($Image, $FontSize, 0, 2,  $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text);
    171   }
    172   $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    173 
    174   $Left = $Width - 10;
    175   $Text = "    Max. ".AddPrefixMultipliers($MaxValue, $Measure['Unit']);
    176   $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    177   $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    178   imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text);
    179 
    180   $Text = "    Avg.  ".AddPrefixMultipliers($AvgValue, $Measure['Unit']);
    181   $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    182   $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    183   imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text);
    184 
    185   $Text = "    Min.  ".AddPrefixMultipliers($MinValue, $Measure['Unit']);
    186   $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    187   $Left -= ($BoundingBox[2] - $BoundingBox[0]);
    188   imagettftext($Image, $FontSize, 0, $Left, 14, $Blue, $FontFile, $Text);
    189   //imagestring($Image, 2, 70, 20, 'Vygenerováno za '.$GenerationTime.' sekund', $Black);
    190   //imagestring($Image, 2, 50, 30, 'Level: '.$Level, $Black);
    191 
    192   imagettftext($Image, $FontSize, 0, 70, 14, $Black, $FontFile, $Measure['Description']);
    193   imagerectangle($Image, 0, 0, $Width - 1, $Height - 1, $Black);   // Frame border
    194   imagepng($Image);
    195   imagedestroy($Image);
    196 }
    197    
    198   }
    199 }
    200211
    201212?>
  • trunk/Application/View/Main.php

    r42 r43  
    100100    $Debug = 0;
    101101
    102     foreach($this->Config['DefaultVariables'] as $Index => $Variable)
     102    foreach($this->Config['Application']['DefaultVariables'] as $Index => $Variable)
    103103    {
    104104      if(!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
     
    147147    {
    148148      $Output .= 'Délka úseku: ';
    149       foreach($GrafTimeRanges as $Index => $Item)
     149      foreach($this->GraphTimeRanges as $Index => $Item)
    150150        $Output .= '<a href="?Period='.$Index.'">'.$Item['caption'].'</a>&nbsp;';
    151151      $Output .= '<br/>';
     
    167167  {
    168168    $Output = '<strong>Graf:</strong><br/>';
    169     $Output .= '<img alt="Graf" src="?Module=Graph&amp;Measure='.$_SESSION['Measure'].'&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width=750&amp;Height=200&amp;Differential='.$_SESSION['Differential'].'" width="750" height="200"><br>';
     169    $Output .= '<img alt="Graf" src="?M=Graph&amp;Measure='.$_SESSION['Measure'].'&amp;From='.$_SESSION['TimeStart'].'&amp;To='.$_SESSION['TimeEnd'].'&amp;Width='.$this->Config['Application']['GraphSize']['Width'].'&amp;Height='.$this->Config['Application']['GraphSize']['Height'].'&amp;Differential='.$_SESSION['Differential'].'" width="'.$this->Config['Application']['GraphSize']['Width'].'" height="'.$this->Config['Application']['GraphSize']['Height'].'"><br>';
    170170    $Output .= '<a href="?Measure='.$_SESSION['Measure'].'&amp;TimeStart='.$_SESSION['TimeStart'].'&amp;TimeEnd='.$_SESSION['TimeEnd'].'&amp;TimeSpecify=1&amp;Differential='.$_SESSION['Differential'].'">Odkaz na vybraný graf</a><br>';
    171171//print_r(GetValues($Measure, $TimeStart, $TimeEnd));
     
    191191        $RowCount = $RowCount[0];
    192192      }
    193       $Result2 = $this->Database->select($Measure['DataTable'], 'Time, Average', 'Measure='.$Measure['Id'].' AND Level=0 ORDER BY Time DESC LIMIT 1');
     193      $Result2 = $this->Database->select($Measure['DataTable'], 'Time, Avg', 'Measure='.$Measure['Id'].' AND Level=0 ORDER BY Time DESC LIMIT 1');
    194194      if($Result2->num_rows > 0)
    195195      {
    196196        $Row = $Result2->fetch_array();
    197         $LastMeasureTime = date('j.n.Y G:i:s', MysqlDateTimeToTime($Row['Time']));
    198         $LastMeasureValue = AddPrefixMultipliers($Row['Average'], $Measure['Unit']);
     197        $LastMeasureTime = date('j.n.Y G:i:s', $this->Database->MysqlDateTimeToTime($Row['Time']));
     198        $LastMeasureValue = $this->System->AddPrefixMultipliers($Row['Avg'], $Measure['Unit']);
    199199      } else
    200200      {
     
    202202        $LastMeasureValue = '&nbsp;';
    203203      }
    204       if($Measure['Continuity'] == 1) $Interpolate = 'Ano'; else $Interpolate = 'Ne';
     204      if($Measure['Continuity'] == 1) $Interpolate = 'Ano';
     205        else $Interpolate = 'Ne';
    205206      if($Measure['Info'] == '') $Measure['Info'] = '&nbsp;';
    206207      $GenerationTime = floor(($this->System->GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
Note: See TracChangeset for help on using the changeset viewer.