Changeset 51 for branches/old/graph.php
- Timestamp:
- Feb 20, 2015, 9:21:01 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/old/graph.php
r28 r51 1 1 <?php 2 2 3 include('global.php'); 3 4 4 5 if(array_key_exists('Debug', $_GET)) $Debug = $_GET['Debug']; 5 6 else $Debug = 0; 6 7 7 8 if(!array_key_exists('From',$_GET)) die('Musíte zadat čas počátku'); 8 9 $StartTime = addslashes($_GET['From']); … … 28 29 if($Level < 0) $Level = 0; 29 30 if($Level > $MaxLevel) $Level = $MaxLevel; 30 //$Level = 0;31 32 31 33 32 $Points = GetValues($Measure, $StartTime, $EndTime, $Level); … … 54 53 //$MinValue = round($MinValue * $Measure['Divider']) / $Measure['Divider']; 55 54 //$MaxValue = round($MaxValue * $Measure['Divider']) / $Measure['Divider']; 56 $AvgValue = $AvgValue / count($Points); //round( 55 $AvgValue = $AvgValue / count($Points); //round(* $Measure['Divider']) / $Measure['Divider']; 57 56 58 57 // Generate polygon and recalculate y values to fit graph height … … 61 60 $PointsMax = array(0, $Height-1); 62 61 if(($MaxValue - $MinValue) == 0) $MaxValue = $MinValue + 1; 63 { 62 { 64 63 foreach($Points as $Index => $Item) 65 64 { … … 73 72 } 74 73 } 75 $PointsMin[] = $Width -1;76 $PointsMin[] = $Height -1;77 $PointsAvg[] = $Width -1;78 $PointsAvg[] = $Height -1;79 $PointsMax[] = $Width -1;80 $PointsMax[] = $Height -1;81 $PointsMin[] = $Width -1;82 $PointsMin[] = $Height -1;83 $PointsAvg[] = $Width -1;84 $PointsAvg[] = $Height -1;85 $PointsMax[] = $Width -1;86 $PointsMax[] = $Height -1;74 $PointsMin[] = $Width - 1; 75 $PointsMin[] = $Height - 1; 76 $PointsAvg[] = $Width - 1; 77 $PointsAvg[] = $Height - 1; 78 $PointsMax[] = $Width - 1; 79 $PointsMax[] = $Height - 1; 80 $PointsMin[] = $Width - 1; 81 $PointsMin[] = $Height - 1; 82 $PointsAvg[] = $Width - 1; 83 $PointsAvg[] = $Height - 1; 84 $PointsMax[] = $Width - 1; 85 $PointsMax[] = $Height - 1; 87 86 88 87 … … 95 94 96 95 // Generate image 97 if(!$Debug) 96 if(!$Debug) 98 97 { 99 98 header("Content-type: image/png"); … … 115 114 imagefilledpolygon($Image, $PointsAvg, count($PointsAvg) / 2, $LightGreen); 116 115 imagefilledpolygon($Image, $PointsMin, count($PointsMin) / 2, $LightBlue); 117 116 118 117 $TimeMarks = array(1, 60, 60*60, 60*60*24, 60*60*24*7, 60*60*24*30, 60*60*24*365, 60*60*24*365*10); 119 118 120 119 $TimeRange = $EndTime - $StartTime; 121 120 $TimeMarksIndex = 0; … … 124 123 $MajorTimeMarks = $TimeMarks[$TimeMarksIndex - 1]; 125 124 $MinorTimeMarks = $TimeMarks[$TimeMarksIndex - 2]; 126 125 127 126 $TimeShift = AlignTime($StartTime, $MajorTimeMarks) - $StartTime; 128 127 //imagestring($Image, 10, 40, 50, $TimeShift, $Black); 129 128 130 129 // Zobraz měřítko Y 131 130 $VerticalLinesDistance = $Height / $VerticalLinesCount; … … 138 137 139 138 $TimeShift = AlignTime($StartTime, $MinorTimeMarks) - $StartTime; 140 139 141 140 // Zobraz měřítko X 142 141 $LastTextEnd = 0; … … 155 154 } 156 155 else for($Y=0; $Y < $Height; $Y = $Y + 3) imagesetpixel($Image, $X, $Y, $Gray); 157 } 158 156 } 157 159 158 // Popisky osy Y 160 for($I =1; $I<=$VerticalLinesCount; $I++)159 for($I = 1; $I <= $VerticalLinesCount; $I++) 161 160 { 162 161 $Y = $Height - 1 - ($VerticalLinesDistance * $I); … … 166 165 if(($Y - ($BoundBox[5] - $BoundBox[1]) / 2) > 10) 167 166 imagettftext($Image, $FontSize, 0, 2, $Y - ($BoundBox[5] - $BoundBox[1]) / 2, $Black, $FontFile, $Text); 168 } 167 } 169 168 $GenerationTime = floor((GetMicrotime() - $StopWatchStart) * 1000 ) / 1000; 170 169 … … 175 174 imagettftext($Image, $FontSize, 0, $Left, 14, $Red, $FontFile, $Text); 176 175 177 $Text = " Avg. ".AddPrefixMultipliers($AvgValue, $Measure['Unit'] );176 $Text = " Avg. ".AddPrefixMultipliers($AvgValue, $Measure['Unit'], 4); 178 177 $BoundingBox = imagettfbbox($FontSize, 0, $FontFile, $Text); 179 178 $Left -= ($BoundingBox[2] - $BoundingBox[0]); … … 192 191 imagedestroy($Image); 193 192 } 194 195 ?>
Note:
See TracChangeset
for help on using the changeset viewer.