Changeset 92 for trunk/Graph.php
- Timestamp:
- Apr 7, 2020, 11:53:58 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Graph.php
r85 r92 26 26 global $Config; 27 27 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'); 29 29 $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'); 31 31 $EndTime = addslashes($_GET['To']); 32 if ($EndTime < $StartTime) $EndTime = $StartTime + 60;32 if ($EndTime < $StartTime) $EndTime = $StartTime + 60; 33 33 $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'); 35 35 $MeasureId = addslashes($_GET['Measure']); 36 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;36 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth; 37 37 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; 39 39 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']; 41 41 else $Differential = addslashes($_GET['Differential']); 42 42 $VerticalLinesCount = round($Height / ($this->FontSize + 4)); … … 54 54 55 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;56 if ($Level < 0) $Level = 0; 57 if ($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel; 58 58 59 59 $Points = $Measure->GetValues($StartTime, $EndTime, $Level); … … 63 63 $AvgValue = 0; 64 64 $MinValue = 1000000000000000000; 65 foreach ($Points as $Index => $Item)65 foreach ($Points as $Index => $Item) 66 66 { 67 67 //$Points[$Index]['Min'] = $Points[$Index]['Min'] / $Measure['Divider']; 68 68 //$Points[$Index]['Avg'] = $Points[$Index]['Avg'] / $Measure['Divider']; 69 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'];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 74 $AvgValue = $AvgValue + $Points[$Index]['Avg']; 75 75 } … … 82 82 $PointsAvg = array(0, $Height - 1); 83 83 $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) 87 87 { 88 88 $PointsMin[] = $Index * $Width / $Measure->DivisionCount; … … 138 138 $TimeRange = $EndTime - $StartTime; 139 139 $TimeMarksIndex = 0; 140 while ((($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) and ($TimeMarksIndex < (count($TimeMarks) - 1)))140 while ((($TimeRange / $TimeMarks[$TimeMarksIndex]) > 1) and ($TimeMarksIndex < (count($TimeMarks) - 1))) 141 141 $TimeMarksIndex += 1; 142 if ($TimeMarksIndex < 2) $TimeMarksIndex = 2;142 if ($TimeMarksIndex < 2) $TimeMarksIndex = 2; 143 143 $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1]; 144 144 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; … … 149 149 // Zobraz měřítko Y 150 150 $VerticalLinesDistance = $Height / $VerticalLinesCount; 151 for ($I = 1; $I <= $VerticalLinesCount; $I++)151 for ($I = 1; $I <= $VerticalLinesCount; $I++) 152 152 { 153 153 $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); 155 155 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 156 156 } … … 160 160 // Zobraz měřítko X 161 161 $LastTextEnd = 0; 162 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)162 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks) 163 163 { 164 164 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 165 165 //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); 167 167 else $Text = date('j.n.Y G:i', $Time + $TimeShift); 168 168 $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)) 170 170 { 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); 172 172 imagettftext($Image, $this->FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2, $Height - 2, $Black, $this->FontFileName, $Text); 173 173 $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2; 174 174 } 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); 176 176 } 177 177 178 178 // Popisky osy Y 179 for ($I = 1; $I <= $VerticalLinesCount; $I++)179 for ($I = 1; $I <= $VerticalLinesCount; $I++) 180 180 { 181 181 $Y = $Height - 1 - ($VerticalLinesDistance * $I); … … 185 185 $Measure->Data['Unit'], 3); 186 186 $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) 188 188 imagettftext($Image, $this->FontSize, 0, 2, $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $this->FontFileName, $Text); 189 189 }
Note:
See TracChangeset
for help on using the changeset viewer.