Changeset 873 for trunk/Modules/TimeMeasure/Graph.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/TimeMeasure/Graph.php
r738 r873 20 20 { 21 21 $this->ClearPage = true; 22 return ($this->Render());22 return ($this->Render()); 23 23 } 24 24 … … 27 27 $PrefixMultiplier = new PrefixMultiplier(); 28 28 29 if (array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug'];29 if (array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 30 30 else $Debug = 0; 31 31 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'); 33 33 $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'); 35 35 $EndTime = addslashes($_GET['To']); 36 if ($EndTime < $StartTime) $EndTime = $StartTime + 60;36 if ($EndTime < $StartTime) $EndTime = $StartTime + 60; 37 37 $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'); 39 39 $MeasureId = addslashes($_GET['Measure']); 40 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth;40 if (!array_key_exists('Width', $_GET)) $Width = $this->DefaultWidth; 41 41 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; 43 43 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']; 45 45 else $Differential = addslashes($_GET['Differential']); 46 46 $VerticalLinesCount = round($Height / ($this->FontSize + 4)); … … 63 63 64 64 $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; 67 67 //$Level = 0; 68 68 69 69 $Points = $Measure->GetValues($StartTime, $EndTime, $Level); 70 70 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) 73 73 // echo($Index.': '.$Item['min'].'<br>'); 74 74 … … 77 77 $AvgValue = 0; 78 78 $MinValue = 1000000000000000000; 79 foreach ($Points as $Index => $Item)79 foreach ($Points as $Index => $Item) 80 80 { 81 81 //$Points[$Index]['min'] = $Points[$Index]['min'] / $Measure['Divider']; 82 82 //$Points[$Index]['avg'] = $Points[$Index]['avg'] / $Measure['Divider']; 83 83 //$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']; 88 88 $AvgValue = $AvgValue + $Points[$Index]['Avg']; 89 89 } … … 96 96 $PointsAvg = array(0, $Height - 1); 97 97 $PointsMax = array(0, $Height - 1); 98 if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1;98 if (($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1; 99 99 { 100 foreach ($Points as $Index => $Item)100 foreach ($Points as $Index => $Item) 101 101 { 102 102 $PointsMin[] = $Index * $Width / $Measure->DivisionCount; … … 128 128 129 129 // Generate image 130 if (!$Debug)130 if (!$Debug) 131 131 { 132 132 Header('Content-type: image/png'); … … 153 153 $TimeRange = $EndTime - $StartTime; 154 154 $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; 157 157 $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1]; 158 158 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; … … 163 163 // Zobraz měřítko Y 164 164 $VerticalLinesDistance = $Height / $VerticalLinesCount; 165 for ($I = 1; $I <= $VerticalLinesCount; $I++)165 for ($I = 1; $I <= $VerticalLinesCount; $I++) 166 166 { 167 167 $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); 169 169 //imageline($Image, 30, $Y, $Width-1, $Y, IMG_COLOR_STYLED); 170 170 } … … 174 174 // Zobraz měřítko X 175 175 $LastTextEnd = 0; 176 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks)176 for ($Time = $StartTime; $Time < $EndTime; $Time += $MajorTimeMarks) 177 177 { 178 178 $X = round(($Time - $StartTime + $TimeShift) / $TimeRange * $Width) % $Width; 179 179 //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); 181 181 else $Text = date('j.n.Y G:i', $Time + $TimeShift); 182 182 $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)) 184 184 { 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); 186 186 imagettftext($Image, $FontSize, 0, $X - ($BoundBox[2] - $BoundBox[0]) / 2, $Height - 2, $Black, $FontFile, $Text); 187 187 $LastTextEnd = $X + ($BoundBox[2] - $BoundBox[0]) / 2; 188 188 } 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); 190 190 } 191 191 192 192 // Popisky osy Y 193 for ($I = 1; $I <= $VerticalLinesCount; $I++)193 for ($I = 1; $I <= $VerticalLinesCount; $I++) 194 194 { 195 195 $Y = $Height - 1 - ($VerticalLinesDistance * $I); … … 199 199 $this->ValueToImageHeigthCoefficient * ($MaxValue - $MinValue) + $MinValue)), $MeasureMethod['Unit'], 3); 200 200 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 201 if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10)201 if (($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) 202 202 imagettftext($Image, $FontSize, 0, 2, $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text); 203 203 }
Note:
See TracChangeset
for help on using the changeset viewer.