Changeset 884 for trunk/www/views/plot_rating.php
- Timestamp:
- 01/23/08 17:37:32 (4 years ago)
- File:
-
- 1 edited
-
trunk/www/views/plot_rating.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/views/plot_rating.php
r852 r884 6 6 if (2 <= count($history)) { 7 7 $keys = array_keys($history); 8 $range_start = $history[$keys[0]]['timestamp'] - 30*24*3600; 9 $range_end = $history[$keys[count($history)-1]]['timestamp'] + 30*24*3600; 8 $range_start = $history[$keys[0]]['timestamp']; 9 $range_end = $history[$keys[count($history)-1]]['timestamp']; 10 $rating_start = $history[$keys[0]]['rating']; 11 $rating_end = $rating_start; 12 foreach ($history as $round_id => $round) { 13 $rating_start = min($rating_start, $round['rating']); 14 $rating_end = max($rating_end, $round['rating']); 15 } 16 $rating_start = rating_scale($rating_start)-50; 17 $rating_end = rating_scale($rating_end)+50; 10 18 } 11 19 else { … … 13 21 $range_start = mktime(1, 0, 0, 1, 1, 2004); 14 22 $range_end = time(); 23 $rating_start = 0; $rating_end = 1000; 15 24 } 16 25 // compute months between date range to show as xtics 17 list($dy, $dm, $dd) = split('-', date('Y-m-d', $range_ start));26 list($dy, $dm, $dd) = split('-', date('Y-m-d', $range_end)); 18 27 $i = 0; 19 28 $xtics = array(); 29 $scale = ceil(($range_end-$range_start)/(30*24*3600)/12); 20 30 while (true) { 21 $dx = mktime(1, 0, 0, $dm +$i, $dd, $dy);31 $dx = mktime(1, 0, 0, $dm - $i, $dd, $dy); 22 32 $xtics[] = date('Y-m-d', $dx); 23 if ($dx > $range_end) {33 if ($dx < $range_start) { 24 34 break; 25 35 } 26 $i += 2;36 $i += $scale; 27 37 } 38 $xtics = array_reverse($xtics); 28 39 29 40 // format date ranges for gnuplot 30 $range_start = date('Y-m-d', $range_start );31 $range_end = date('Y-m-d', $range_end );41 $range_start = date('Y-m-d', $range_start - 15*24*3600); 42 $range_end = date('Y-m-d', $range_end + 15*24*3600); 32 43 33 44 // gnuplot script 34 45 $script = " 46 set terminal postscript noenhanced 47 set locale \"ro_RO.UTF-8\" 35 48 set xdata time 36 49 set timefmt \"%Y-%m-%d\" 37 50 set format x \"%b %y\" 38 39 40 51 set grid 41 52 42 set rmargin 253 set rmargin 5 43 54 set lmargin 5 44 55 set tmargin 12 … … 50 61 51 62 set style line 1 lt 1 lw 4 pt 3 ps 0.5 52 set style line 2 lt 3 lw 4 pt 7 ps 1.63 set style line 2 lt 3 lw 3 pt 7 ps 1.0 53 64 set style line 3 lt 11 lw 3 54 65 set xrange [\"{$range_start}\":\"{$range_end}\"] 66 set yrange [{$rating_start}:{$rating_end}] 55 67 56 68 set xtics ('".join("', '", $xtics)."') 57 69 set xtic rotate by -20 58 59 70 60 71 set clip … … 63 74 // display round_id labels 64 75 $i = 1; 76 $scale = ceil(($rating_end-$rating_start)/20); 65 77 foreach ($history as $round_id => $round) { 66 78 $date = date("Y-m-d", $round['timestamp']); 67 $rating = rating_scale($round['rating']) + ($i % 2 ? 100 : -100);79 $rating = rating_scale($round['rating']) + ($i % 2 ? $scale : -$scale); 68 80 $align = ($i % 2 ? "left" : "right"); 69 81 $align = "left"; 70 $script .= "set label {$i} \"{$i}\" at \"{$date}\",{$rating} {$align} font \"Helvetica,1 7\" back tc lt 9\n";82 $script .= "set label {$i} \"{$i}\" at \"{$date}\",{$rating} {$align} font \"Helvetica,19\" back tc lt 9\n"; 71 83 $i++; 72 84 } … … 83 95 plot \\ 84 96 \"%data%\" using 1:2 title \"Rating\" with lines ls 1, \\ 85 \"%data%\" using 1:2 smooth bezier title \"Medie\" with lines ls 3, \\ 86 \"%data%\" using 1:2:3 title \"Deviatie\" with errorbars ls 2 97 \"%data%\" using 1:2 notitle with points ls 2 87 98 "; 88 99 }
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)