Changeset 92 for trunk/Graph.php


Ignore:
Timestamp:
Apr 7, 2020, 11:53:58 AM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Graph.php

    r85 r92  
    2626    global $Config;
    2727
    28     if(!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku');
     28    if (!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku');
    2929    $StartTime = addslashes($_GET['From']);
    30     if(!array_key_exists('To',$_GET)) die('Musíte zadat čas konce');
     30    if (!array_key_exists('To',$_GET)) die('Musíte zadat čas konce');
    3131    $EndTime = addslashes($_GET['To']);
    32     if($EndTime < $StartTime) $EndTime = $StartTime + 60;
     32    if ($EndTime < $StartTime) $EndTime = $StartTime + 60;
    3333    $TimeDifference = $EndTime - $StartTime;
    34     if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
     34    if (!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');
    3535    $MeasureId = addslashes($_GET['Measure']);
    36     if(!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
     36    if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;
    3737    else $Width = addslashes($_GET['Width']);
    38     if(!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
     38    if (!array_key_exists('Height', $_GET)) $Height = $this->DefaultHeight;
    3939    else $Height = addslashes($_GET['Height']);
    40     if(!array_key_exists('Differential', $_GET)) $Differential = $Config['DefaultVariables']['Differential'];
     40    if (!array_key_exists('Differential', $_GET)) $Differential = $Config['DefaultVariables']['Differential'];
    4141    else $Differential = addslashes($_GET['Differential']);
    4242    $VerticalLinesCount = round($Height / ($this->FontSize + 4));
     
    5454
    5555    $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;
     56    if ($Level < 0) $Level = 0;
     57    if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel;
    5858
    5959    $Points = $Measure->GetValues($StartTime, $EndTime, $Level);
     
    6363    $AvgValue = 0;
    6464    $MinValue = 1000000000000000000;
    65     foreach($Points as $Index => $Item)
     65    foreach ($Points as $Index => $Item)
    6666    {
    6767      //$Points[$Index]['Min'] =  $Points[$Index]['Min'] / $Measure['Divider'];
    6868      //$Points[$Index]['Avg'] =  $Points[$Index]['Avg'] / $Measure['Divider'];
    6969      //$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'];
     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'];
    7474      $AvgValue = $AvgValue + $Points[$Index]['Avg'];
    7575    }
     
    8282    $PointsAvg = array(0, $Height - 1);
    8383    $PointsMax = array(0, $Height - 1);
    84     if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
    85     {
    86       foreach($Points as $Index => $Item)
     84    if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;
     85    {
     86      foreach ($Points as $Index => $Item)
    8787      {
    8888        $PointsMin[] = $Index * $Width / $Measure->DivisionCount;
     
    138138    $TimeRange = $EndTime - $StartTime;
    139139    $TimeMarksIndex = 0;
    140     while((($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) and ($TimeMarksIndex < (count($TimeMarks) - 1)))
     140    while ((($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) and ($TimeMarksIndex < (count($TimeMarks) - 1)))
    141141      $TimeMarksIndex += 1;
    142     if($TimeMarksIndex < 2) $TimeMarksIndex = 2;
     142    if ($TimeMarksIndex < 2) $TimeMarksIndex = 2;
    143143    $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1];
    144144    $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2];
     
    149149    // Zobraz měřítko Y
    150150    $VerticalLinesDistance = $Height / $VerticalLinesCount;
    151     for($I = 1; $I <= $VerticalLinesCount; $I++)
     151    for ($I = 1; $I <= $VerticalLinesCount; $I++)
    152152    {
    153153      $Y = $Height - 1 - ($VerticalLinesDistance * $I);
    154       for($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
     154      for ($X = 1; $X < $Width; $X = $X + 3) imagesetpixel($Image, $X, $Y, $Gray);
    155155      //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    156156    }
     
    160160    // Zobraz měřítko X
    161161    $LastTextEnd = 0;
    162     for($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
     162    for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)
    163163    {
    164164      $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width;
    165165      //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED);
    166       if(($MajorTimeMarks > 60*60*24)) $Text = date('j.n.Y', $Time + $TimeShift);
     166      if (($MajorTimeMarks > 60*60*24)) $Text = date('j.n.Y', $Time + $TimeShift);
    167167        else $Text = date('j.n.Y G:i', $Time + $TimeShift);
    168168      $BoundBox = imagettfbbox($this->FontSize, 0, $this->FontFileName, $Text);
    169       if($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
     169      if ($LastTextEnd < ($X - ($BoundBox[2] - $BoundBox[0] + 20) / 2))
    170170      {
    171         for($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
     171        for ($Y = 0; $Y < $Height; $Y = $Y + 1) imagesetpixel($Image, $X, $Y, $Gray);
    172172        imagettftext($Image, $this->FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2,  $Height - 2, $Black, $this->FontFileName, $Text);
    173173        $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2;
    174174      }
    175       else for($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
     175      else for ($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray);
    176176    }
    177177
    178178    // Popisky osy Y
    179     for($I = 1; $I <= $VerticalLinesCount; $I++)
     179    for ($I = 1; $I <= $VerticalLinesCount; $I++)
    180180    {
    181181      $Y = $Height - 1 - ($VerticalLinesDistance * $I);
     
    185185          $Measure->Data['Unit'], 3);
    186186      $BoundBox = imagettfbbox($this->FontSize, 0, $this->FontFileName, $Text);
    187       if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
     187      if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)
    188188        imagettftext($Image, $this->FontSize, 0, 2,  $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $this->FontFileName, $Text);
    189189    }
Note: See TracChangeset for help on using the changeset viewer.