Changeset 62 for trunk/graph.php
- Timestamp:
- Jan 1, 2016, 12:13:34 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/graph.php
r61 r62 12 12 if($EndTime < $StartTime) $EndTime = $StartTime + 60; 13 13 $TimeDifference = $EndTime - $StartTime; 14 if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu');14 if(!array_key_exists('Measure', $_GET)) die('Musíte zadat měřenou veličinu'); 15 15 $MeasureId = addslashes($_GET['Measure']); 16 16 if(!array_key_exists('Width', $_GET)) $Width = $DefaultWidth; … … 24 24 $StopWatchStart = GetMicrotime(); 25 25 26 $Measure = GetMeasureById($MeasureId); 26 $Measure = new Measure($Database); 27 $Measure->Load($MeasureId); 28 $Measure->DivisionCount = $Config['DivisionCount']; 29 $Measure->LevelReducing = $Config['LevelReducing']; 30 $Measure->MaxLevel = $Config['MaxLevel']; 31 $Measure->ReferenceTime = $Config['ReferenceTime']; 32 $Measure->Differential = $Differential; 27 33 28 $Level = floor(log(($EndTime - $StartTime) / $ DivisionCount / 60) / log($LevelReducing)) - 1;34 $Level = floor(log(($EndTime - $StartTime) / $Measure->DivisionCount / 60) / log($Measure->LevelReducing)) - 1; 29 35 if($Level < 0) $Level = 0; 30 if($Level > $M axLevel) $Level = $MaxLevel;36 if($Level > $Measure->MaxLevel) $Level = $Measure->MaxLevel; 31 37 32 $Points = GetValues($Measure,$StartTime, $EndTime, $Level);38 $Points = $Measure->GetValues($StartTime, $EndTime, $Level); 33 39 34 40 if($Debug) echo('Points count: '.count($Points).'<br>'); … … 56 62 57 63 // Generate polygon and recalculate y values to fit graph height 58 $PointsMin = array(0, $Height -1);59 $PointsAvg = array(0, $Height -1);60 $PointsMax = array(0, $Height -1);64 $PointsMin = array(0, $Height - 1); 65 $PointsAvg = array(0, $Height - 1); 66 $PointsMax = array(0, $Height - 1); 61 67 if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1; 62 68 { 63 69 foreach($Points as $Index => $Item) 64 70 { 65 $PointsMin[] = $Index *$Width/$DivisionCount;71 $PointsMin[] = $Index * $Width / $Measure->DivisionCount; 66 72 $PointsMin[] = $Height - 1 - ($Points[$Index]['min'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $K; 67 $PointsAvg[] = $Index *$Width/$DivisionCount;73 $PointsAvg[] = $Index * $Width / $Measure->DivisionCount; 68 74 $PointsAvg[] = $Height - 1 - ($Points[$Index]['avg'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $K; 69 $PointsMax[] = $Index *$Width/$DivisionCount;75 $PointsMax[] = $Index * $Width / $Measure->DivisionCount; 70 76 $PointsMax[] = $Height - 1 - ($Points[$Index]['max'] - $MinValue) / ($MaxValue - $MinValue) * $Height * $K; 71 77 //echo($Index.' - '.$Item.' '.$Points[$Index].'<br>'); … … 90 96 //$Points[] = $Width - 1; 91 97 //$Points[] = $Height - 1; 92 93 //print_r($PointsMax);94 98 95 99 // Generate image … … 124 128 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 125 129 126 $TimeShift = AlignTime($StartTime, $MajorTimeMarks) - $StartTime;130 $TimeShift = $Measure->AlignTime($StartTime, $MajorTimeMarks) - $StartTime; 127 131 //imagestring($Image, 10, 40, 50, $TimeShift, $Black); 128 132 … … 136 140 } 137 141 138 $TimeShift = AlignTime($StartTime, $MinorTimeMarks) - $StartTime;142 $TimeShift = $Measure->AlignTime($StartTime, $MinorTimeMarks) - $StartTime; 139 143 140 144 // Zobraz měřítko X … … 161 165 $Y = $Height - 1 - ($VerticalLinesDistance * $I); 162 166 //$Y = $Height - 1 - ($VerticalLinesDistance * $I / ($MaxValue - $MinValue) * $K * $Height); 163 $Text = $PrefixMultiplier->Add(round(($I * $VerticalLinesDistance / $Height / $K * ($MaxValue - $MinValue) + $MinValue)), $Measure['Unit'], 3); 167 $Text = $PrefixMultiplier->Add(round(($I * $VerticalLinesDistance / $Height / 168 $K * ($MaxValue - $MinValue) + $MinValue)), $Measure->Data['Unit'], 3); 164 169 $BoundBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 165 170 if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) … … 169 174 170 175 $Left = $Width - 10; 171 $Text = " Max. ".$PrefixMultiplier->Add($MaxValue, $Measure ['Unit']);176 $Text = " Max. ".$PrefixMultiplier->Add($MaxValue, $Measure->Data['Unit']); 172 177 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 173 178 $Left -= ($BoundingBox[2] - $BoundingBox[0]); 174 179 imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text); 175 180 176 $Text = " Avg. ".$PrefixMultiplier->Add($AvgValue, $Measure ['Unit'], 4);181 $Text = " Avg. ".$PrefixMultiplier->Add($AvgValue, $Measure->Data['Unit'], 4); 177 182 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 178 183 $Left -= ($BoundingBox[2] - $BoundingBox[0]); 179 184 imagettftext($Image, $FontSize, 0, $Left, 14, $Green, $FontFile, $Text); 180 185 181 $Text = " Min. ".$PrefixMultiplier->Add($MinValue, $Measure ['Unit']);186 $Text = " Min. ".$PrefixMultiplier->Add($MinValue, $Measure->Data['Unit']); 182 187 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 183 188 $Left -= ($BoundingBox[2] - $BoundingBox[0]); … … 186 191 //imagestring($Image, 2, 50, 30, 'Level: '.$Level, $Black); 187 192 188 imagettftext($Image, $FontSize, 0, 70, 14, $Black, $FontFile, $Measure ['Description']);193 imagettftext($Image, $FontSize, 0, 70, 14, $Black, $FontFile, $Measure->Data['Description']); 189 194 imagerectangle($Image, 0, 0, $Width - 1, $Height - 1, $Black); // Frame border 190 195 imagepng($Image);
Note:
See TracChangeset
for help on using the changeset viewer.