Changeset 64 for trunk/Graph.php


Ignore:
Timestamp:
Jan 1, 2016, 2:05:17 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Basic application related code moved from Global.php to separate file Application.php.
  • Modified: Main index page converted to PHP class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Graph.php

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