コード例 #1
0
function display_graph($d)
{
    $total_pages = 0;
    if ($d == 0) {
        $graph = init_pie_graph(660, 400, 5);
        $title = _("Net pages saved so far today");
        for ($rn = 1; $rn <= MAX_NUM_PAGE_EDITING_ROUNDS; $rn++) {
            $round = get_Round_for_round_number($rn);
            $site_stats = get_site_page_tally_summary($round->id);
            $data[] = $pages = $site_stats->curr_day_actual;
            $labels[] = "{$round->id} ({$pages})";
            $total_pages += $pages;
        }
    } else {
        $graph = init_pie_graph(660, 400, 60);
        $title = sprintf(_("Net pages saved in preceding %s days"), $d);
        $now = time();
        for ($rn = 1; $rn <= MAX_NUM_PAGE_EDITING_ROUNDS; $rn++) {
            $round = get_Round_for_round_number($rn);
            $tallyboard = new TallyBoard($round->id, 'S');
            $data[] = $pages = $tallyboard->get_delta_sum(1, $now - 60 * 60 * 24 * $d, $now);
            $labels[] = "{$round->id} ({$pages})";
            $total_pages += $pages;
        }
    }
    if ($total_pages == 0) {
        dpgraph_error(_("No pages saved in specified range"));
    }
    draw_pie_graph($graph, $labels, $data, $title);
}
コード例 #2
0
// where possisble
$width = 300;
$height = 200;
$cache_timeout = 59;
# in minutes
$graph = new Graph($width, $height, get_image_cache_filename(), $cache_timeout);
// Pull all interested phases, primarily all the rounds and PP
$interested_phases = array_keys($Round_for_round_id_);
$interested_phases[] = "PP";
// Pull the stats data out of the database
$stats = get_round_backlog_stats($interested_phases);
// get the total of all phases
$stats_total = array_sum($stats);
// If this is a new system there won't be any stats so don't divide by zero
if ($stats_total == 0) {
    dpgraph_error(_("No pages found."));
}
// calculate the goal percent as 100 / number_of_phases
$goal_percent = ceil(100 / count($stats));
// colors
$barColors = array();
$barColorDefault = "#EEEEEE";
$barColorAboveGoal = "#FF484F";
$goalColor = "#0000FF";
// calculate the percentage of work remaining in each round
// and the color for each bar
foreach ($stats as $phase => $num_pages) {
    $stats_percentage[$phase] = ceil($num_pages / $stats_total * 100);
    if ($stats_percentage[$phase] > $goal_percent) {
        $barColors[] = $barColorAboveGoal;
    } else {
コード例 #3
0
$relPath = "./../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'misc.inc';
include_once $relPath . 'page_tally.inc';
// $page_tally_names get_pages_per_day_for_past_n_days
include_once 'common.inc';
$valid_tally_names = array_keys($page_tally_names);
$tally_name = get_enumerated_param($_GET, 'tally_name', null, $valid_tally_names);
$holder_type = get_enumerated_param($_GET, 'holder_type', null, array('U', 'T'));
$holder_id = get_integer_param($_GET, 'holder_id', null, 0, null);
if (@$_GET['days_back'] == 'all') {
    $days_back = 'all';
} else {
    $days_back = get_integer_param($_GET, 'days_back', 30, 1, null);
}
// Initialize the graph before anything else.
// This makes use of the jpgraph cache if enabled.
// Last argument to init_simple_bar_graph is the cache timeout in minutes.
$graph = init_simple_bar_graph(600, 300, 60);
$pages_per_day = get_pages_per_day_for_past_n_days($tally_name, $holder_type, $holder_id, $days_back);
$datax = array_keys($pages_per_day);
$datay = array_values($pages_per_day);
$x_text_tick_interval = calculate_text_tick_interval('daily', count($datax));
if (empty($datax) || empty($datay)) {
    $specimen = $holder_type == 'U' ? 'user' : 'team';
    dpgraph_error("This {$specimen} has not completed any pages in this round.", 600, 300);
    die;
}
draw_simple_bar_graph($graph, $datax, $datay, $x_text_tick_interval, _('Pages Completed per Day'), _('Pages'));
// vim: sw=4 ts=4 expandtab