コード例 #1
0
ファイル: statistics.php プロジェクト: vmei/MIT-Mobile-Web
<?php

/**
 * Copyright (c) 2008 Massachusetts Institute of Technology
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */
$all_data = PageViews::past_days(7);
// find the largest number of views in the days
$max_views = 0;
foreach ($all_data as $day) {
    if ($day['total'] > $max_views) {
        $max_views = $day['total'];
    }
}
// determine the maximum to use for the bar graph
$limits = array(1, 2, 4, 5);
$found = False;
$scale = 10;
while (!$found) {
    foreach ($limits as $limit) {
        if ($limit * $scale > $max_views) {
            $max_scale = $limit * $scale;
            $found = True;
            break;
        }
    }
    $scale *= 10;
}