Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/TimeMeasure/Graph.php

    r738 r873  
    2020  {
    2121    $this->ClearPage = true;
    22     return($this->Render());
     22    return ($this->Render());
    2323  }
    2424
     
    2727    $PrefixMultiplier = new PrefixMultiplier();
    2828
    29     if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
     29    if (array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];
    3030      else $Debug = 0;
    3131
    32     if(!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku');
     32    if (!array_key_exists('From', $_GET)) die('Musíte zadat čas počátku');
    3333    $StartTime = addslashes($_GET['From']);
    34     if(!array_key_exists('To', $_GET)) die('Musíte zadat čas konce');
     34    if (!array_key_exists('To', $_GET)) die('Musíte zadat čas konce');
    3535    $EndTime = addslashes($_GET['To']);
    36     if($EndTime < $StartTime) $EndTime = $StartTime + 60;
     36    if ($EndTime < $StartTime) $EndTime = $StartTime + 60;
    3737    $TimeDifference = $EndTime - $StartTime;
    38     if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
     38    if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
    3939    $MeasureId = addslashes($_GET['Measure']);
    40     if(!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
     40    if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
    4141      else $Width = addslashes($_GET['Width']);
    42     if(!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
     42    if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
    4343      else $Height = addslashes($_GET['Height']);
    44     if(!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];
     44    if (!array_key_exists('Differential', $_GET)) $Differential = $this->Config['Application']['DefaultVariables']['Differential'];
    4545      else $Differential = addslashes($_GET['Differential']);
    4646    $VerticalLinesCount = round($Height / ($this->FontSize + 4));
     
    6363
    6464    $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1;
    65     if($Level < 0) $Level = 0;
    66     if($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;
     65    if ($Level < 0) $Level = 0;
     66    if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;
    6767    //$Level = 0;
    6868
    6969    $Points = $Measure->GetValues($StartTime, $EndTime, $Level);
    7070
    71     if($Debug) echo('Points count: '.count($Points).'<br/>');
    72     //if($Debug) foreach($Points as $Index => $Item)
     71    if ($Debug) echo('Points count: '.count($Points).'<br/>');
     72    //if ($Debug) foreach ($Points as $Index => $Item)
    7373    // echo($Index.': '.$Item['min'].'<br>');
    7474
     
    7777    $AvgValue = 0;
    7878    $MinValue = 1000000000000000000;
    79     foreach($Points as $Index => $Item)
     79    foreach ($Points as $Index => $Item)
    8080    {
    8181      //$Points[$Index]['min'] =  $Points[$Index]['min'] / $Measure['Divider'];
    8282      //$Points[$Index]['avg'] =  $Points[$Index]['avg'] / $Measure['Divider'];
    8383      //$Points[$Index]['max'] =  $Points[$Index]['max'] / $Measure['Divider'];
    84       if($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];
    85       if($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];
    86       if($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];
    87       if($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];
     84      if ($Points[$Index]['Avg'] > $MaxValue) $MaxValue = $Points[$Index]['Avg'];
     85      if ($Points[$Index]['Avg'] < $MinValue) $MinValue = $Points[$Index]['Avg'];
     86      if ($Points[$Index]['Max'] > $MaxValue) $MaxValue = $Points[$Index]['Max'];
     87      if ($Points[$Index]['Min'] < $MinValue) $MinValue = $Points[$Index]['Min'];
    8888      $AvgValue = $AvgValue + $Points[$Index]['Avg'];
    8989    }
     
    9696    $PointsAvg = array(0, $Height - 1);
    9797    $PointsMax = array(0, $Height - 1);
    98     if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
     98    if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
    9999    {
    100       foreach($Points as $Index => $Item)
     100      foreach ($Points as $Index => $Item)
    101101      {
    102102        $PointsMin[] = $Index * $Width / $Measure->DivisionCount;
     
    128128
    129129    // Generate image
    130     if(!$Debug)
     130    if (!$Debug)
    131131    {
    132132      Header('Content-type: image/png');
     
    153153      $TimeRange = $EndTime - $StartTime;
    154154      $TimeMarksIndex = 0;
    155       while(($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1;
    156       if($TimeMarksIndex < 2) $TimeMarksIndex = 2;
     155      while (($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) $TimeMarksIndex += 1;
     156      if ($TimeMarksIndex < 2) $TimeMarksIndex = 2;
    157157      $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1];
    158158      $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2];
     
    163163      // Zobraz měřítko Y
    164164      $VerticalLinesDistance = $Height / $VerticalLinesCount;
    165       for($I = 1; $I <= $VerticalLinesCount; $I++)
     165      for ($I = 1; $I <= $VerticalLinesCount; $I++)
    166166      {
    167167        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    168         for($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
     168        for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
    169169        //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    170170      }
     
    174174      // Zobraz měřítko X
    175175      $LastTextEnd = 0;
    176       for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
     176      for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
    177177      {
    178178        $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
    179179        //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    180         if(($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift);
     180        if (($MajorTimeMarks > 60 * 60 * 24)) $Text = date('j.n.Y', $Time + $TimeShift);
    181181          else $Text = date('j.n.Y G:i', $Time + $TimeShift);
    182182        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    183         if($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
     183        if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
    184184        {
    185           for($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
     185          for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
    186186          imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,  $Height - 2, $Black, $FontFile, $Text);
    187187          $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2;
    188188        }
    189         else for($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
     189        else for ($Y = 0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
    190190      }
    191191
    192192      // Popisky osy Y
    193       for($I = 1; $I <= $VerticalLinesCount; $I++)
     193      for ($I = 1; $I <= $VerticalLinesCount; $I++)
    194194      {
    195195        $Y = $Height - 1 - ($VerticalLinesDistance * $I);
     
    199199          $this->ValueToImageHeigthCoefficient * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3);
    200200        $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text);
    201         if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     201        if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
    202202          imagettftext($Image, $FontSize, 0, 2,  $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text);
    203203      }
Note: See TracChangeset for help on using the changeset viewer.