Changeset 28 for graph.php


Ignore:
Timestamp:
Feb 13, 2008, 1:59:20 PM (17 years ago)
Author:
george
Message:

Upraveno: Změna kódování stránek na UTF-8.
Přidáno: Verze 3.1 v sekci vývoje.
Přidáno: Odkaz pod grafem na vybraný časový úsek.
Opraveno: Zobrazování desetinných míst u čísel bez jednotek.
Opraveno: Zobrazování textů Min, Avg, Max v grafu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graph.php

    r23 r28  
    55  else $Debug = 0;
    66 
    7 if(!array_key_exists('From',$_GET)) die('Musíte zadat èas poèátku');
     7if(!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku');
    88$StartTime = addslashes($_GET['From']);
    9 if(!array_key_exists('To',$_GET)) die('Musíte zadat èas konce');
     9if(!array_key_exists('To',$_GET)) die('Musíte zadat čas konce');
    1010$EndTime = addslashes($_GET['To']);
    1111if($EndTime < $StartTime) $EndTime = $StartTime + 60;
    1212$TimeDifference = $EndTime - $StartTime;
    13 if(!array_key_exists('Measure',$_GET)) die('Musíte zadat mìøenou velièinu');
     13if(!array_key_exists('Measure',$_GET)) die('Musíte zadat měřenou veličinu');
    1414$MeasureId = addslashes($_GET['Measure']);
    1515if(!array_key_exists('Width', $_GET)) $Width = $DefaultWidth;
     
    1717if(!array_key_exists('Height', $_GET)) $Height = $DefaultHeight;
    1818else $Height = addslashes($_GET['Height']);
     19if(!array_key_exists('Differential', $_GET)) $Differential = $Config['DefaultVariables']['Differential'];
     20else $Differential = addslashes($_GET['Differential']);
    1921$VerticalLinesCount = round($Height / ($FontSize + 4));
    2022
     
    4143foreach($Points as $Index => $Item)
    4244{
    43   $Points[$Index]['min'] =  $Points[$Index]['min'] / $Measure['Divider'];
    44   $Points[$Index]['avg'] =  $Points[$Index]['avg'] / $Measure['Divider'];
    45   $Points[$Index]['max'] =  $Points[$Index]['max'] / $Measure['Divider'];
     45  //$Points[$Index]['min'] =  $Points[$Index]['min'] / $Measure['Divider'];
     46  //$Points[$Index]['avg'] =  $Points[$Index]['avg'] / $Measure['Divider'];
     47  //$Points[$Index]['max'] =  $Points[$Index]['max'] / $Measure['Divider'];
    4648  if($Points[$Index]['avg'] > $MaxValue) $MaxValue = $Points[$Index]['avg'];
    4749  if($Points[$Index]['avg'] < $MinValue) $MinValue = $Points[$Index]['avg'];
     
    5052  $AvgValue = $AvgValue + $Points[$Index]['avg'];
    5153}
    52 $MinValue = round($MinValue * $Measure['Divider']) / $Measure['Divider'];
    53 $MaxValue = round($MaxValue * $Measure['Divider']) / $Measure['Divider'];
    54 $AvgValue = round($AvgValue / count($Points) * $Measure['Divider']) / $Measure['Divider'];
     54//$MinValue = round($MinValue * $Measure['Divider']) / $Measure['Divider'];
     55//$MaxValue = round($MaxValue * $Measure['Divider']) / $Measure['Divider'];
     56$AvgValue = $AvgValue / count($Points); //round( * $Measure['Divider']) / $Measure['Divider'];
    5557
    5658// Generate polygon and recalculate y values to fit graph height
     
    126128  //imagestring($Image, 10, 40, 50, $TimeShift, $Black);
    127129 
    128   // Zobraz mìøítko Y
     130  // Zobraz měřítko Y
    129131  $VerticalLinesDistance = $Height / $VerticalLinesCount;
    130132  for($I=1; $I<=$VerticalLinesCount; $I++)
     
    136138
    137139  $TimeShift = AlignTime($StartTime, $MinorTimeMarks) - $StartTime;
    138 
    139   /*
    140   if(($MinorTimeMarks / $TimeRange * $Width) > 3)
    141   for($Time = $StartTime; $Time < $EndTime; $Time += $MinorTimeMarks)
    142   {
    143     $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
    144     for($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
    145     //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    146     //imagestring($Image, 2, 2, $Y - 6, round(($I * $VerticalLinesDistance + $MinValue)*$Measure['divider']) / $Measure['divider'], $Black);
    147   }
    148   */
    149  
    150   // Zobraz mìøítko X
     140 
     141  // Zobraz měřítko X
    151142  $LastTextEnd = 0;
    152143  for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
     
    178169  $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000  ) / 1000;
    179170
    180   imagettftext($Image, $FontSize, 0, $Width-94, 14, $Red, $FontFile, "Max. ".AddPrefixMultipliers($MaxValue, $Measure['Unit']));
    181   imagettftext($Image, $FontSize, 0, $Width-194, 14, $Green, $FontFile, "Avg.  ".AddPrefixMultipliers($AvgValue, $Measure['Unit']));
    182   imagettftext($Image, $FontSize, 0, $Width-294, 14, $Blue, $FontFile, "Min.  ".AddPrefixMultipliers($MinValue, $Measure['Unit']));
     171  $Left = $Width - 10;
     172  $Text = "    Max. ".AddPrefixMultipliers($MaxValue, $Measure['Unit']);
     173  $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
     174  $Left -= ($BoundingBox[2] - $BoundingBox[0]);
     175  imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text);
     176
     177  $Text = "    Avg.  ".AddPrefixMultipliers($AvgValue, $Measure['Unit']);
     178  $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
     179  $Left -= ($BoundingBox[2] - $BoundingBox[0]);
     180  imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text);
     181
     182  $Text = "    Min.  ".AddPrefixMultipliers($MinValue, $Measure['Unit']);
     183  $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
     184  $Left -= ($BoundingBox[2] - $BoundingBox[0]);
     185  imagettftext($Image, $FontSize, 0, $Left, 14, $Blue, $FontFile, $Text);
    183186  //imagestring($Image, 2, 70, 20, 'Vygenerováno za '.$GenerationTime.' sekund', $Black);
    184187  //imagestring($Image, 2, 50, 30, 'Level: '.$Level, $Black);
    185188
    186   imagettftext($Image, $FontSize, 0, 70, 14, $Black, $FontFile, to_utf8($Measure['Description']));
     189  imagettftext($Image, $FontSize, 0, 70, 14, $Black, $FontFile, $Measure['Description']);
    187190  imagerectangle($Image, 0, 0, $Width - 1, $Height - 1, $Black);   // Frame border
    188191  imagepng($Image);
Note: See TracChangeset for help on using the changeset viewer.