<?php

$relPath = "./../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'page_tally.inc';
include_once 'common.inc';
// 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(640, 400, 900);
///////////////////////////////////////////////////
// For each month in which someone joined,
// get the number who joined,
// and the number of those who have proofread at least one page.
//
$result = mysql_query("\n    SELECT\n        FROM_UNIXTIME(date_created, '%Y-%m')\n          AS month,\n        COUNT(*)\n          AS num_who_joined,\n        SUM({$user_ELR_page_tally_column} > 0)\n          AS num_who_proofed\n    FROM users {$joined_with_user_ELR_page_tallies}\n    GROUP BY month\n    ORDER BY month\n");
// If there was a month when nobody joined,
// then the results will not include a row for that month.
// This may lead to a misleading graph,
// depending on its style.
while ($row = mysql_fetch_object($result)) {
    $datax[] = $row->month;
    $data1y[] = 100 * $row->num_who_proofed / $row->num_who_joined;
}
$x_text_tick_interval = calculate_text_tick_interval('monthly', count($datax));
draw_simple_bar_graph($graph, $datax, $data1y, $x_text_tick_interval, _('Percentage of New Users Who Went on to Proofread By Month'), _('% of newly Joined Users who Proofread'));
// vim: sw=4 ts=4 expandtab
Esempio n. 2
0
<?php

// Graph the number of user registered per day.
$relPath = "./../../pinc/";
include_once $relPath . 'base.inc';
include_once $relPath . 'dpsql.inc';
include_once 'common.inc';
$time_interval_options = array('day' => array('format' => '%Y-%b-%d', 'title' => _("Number of users registered per day")), 'week' => array('format' => '%Y-%U', 'title' => _("Number of users registered per week")), 'month' => array('format' => '%Y-%M', 'title' => _("Number of users registered per month")), 'year' => array('format' => '%Y', 'title' => _("Number of users registered per year")));
$time_interval = get_enumerated_param($_GET, 'time_interval', 'day', array_keys($time_interval_options));
$date_format = $time_interval_options[$time_interval]['format'];
$title = $time_interval_options[$time_interval]['title'];
$graph = init_simple_bar_graph(640, 400, 60);
$res = mysql_query("\n    SELECT FROM_UNIXTIME(date_created,'{$date_format}'), COUNT(*)\n    FROM users\n    GROUP BY 1\n    ORDER BY date_created\n") or die(mysql_error());
list($datax, $datay) = dpsql_fetch_columns($res);
$tick = calculate_text_tick_interval('daily', count($datay));
draw_simple_bar_graph($graph, $datax, $datay, $tick, $title, _('# users'));
// vim: sw=4 ts=4 expandtab
    if (count($datay) > $max_num_data) {
        $max_num_data = count($datay);
    }
    //Create the line plot
    $lplot = new LinePlot($datay);
    $lplot->SetColor($psd->color);
    $lplot->SetLegend($psd->cumulative_title);
    $lplot->SetWeight(1);
    $lplot->SetFillColor($psd->color);
    $graph->Add($lplot);
}
//set X axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->title->Set("");
$x_text_tick_interval = calculate_text_tick_interval('daily', $max_num_data);
$graph->xaxis->SetTextTickInterval($x_text_tick_interval);
//Set Y axis
//$graph->yaxis->title->Set(_('Projects'));
$graph->yaxis->SetPos("max");
$graph->yaxis->SetLabelSide(SIDE_RIGHT);
$graph->yaxis->SetTitleMargin(45);
$graph->title->Set(_("Total Projects Created, Proofread, Post-Processed and Posted"));
$graph->title->SetFont($jpgraph_FF, $jpgraph_FS);
$graph->yaxis->title->SetFont($jpgraph_FF, $jpgraph_FS);
$graph->xaxis->title->SetFont($jpgraph_FF, $jpgraph_FS);
$graph->legend->SetFont($jpgraph_FF, $jpgraph_FS, 9);
$graph->legend->SetPos(0.07000000000000001, 0.1, "left", "top");
//Align the legend
$graph->legend->SetColumns(1);
$graph->legend->SetShadow();
        $column_name = 'L_hour';
        $cache_timeout = 58;
        break;
    case 'day':
        $title = _('Number of users newly logged in over 24 hours');
        $column_name = 'L_day';
        $cache_timeout = 58;
        break;
    case 'week':
        $title = _("Number of users newly logged in over 7 days");
        $column_name = 'L_week';
        $cache_timeout = 300;
        break;
    case 'fourweek':
        $title = _("Number of users newly logged in over 28 days");
        $column_name = 'L_4wks';
        $cache_timeout = 900;
        break;
    default:
        die("bad value for 'preceding'");
}
// Initialize the graph before making database call.
// This makes use of the jpgraph cache if enabled.
$graph = init_simple_bar_graph(640, 400, $cache_timeout);
///////////////////////////////////////////////////
//query db and put results into arrays
$result = mysql_query("\n    SELECT DATE_FORMAT(FROM_UNIXTIME(time_stamp),'{$date_format}'), {$column_name}\n    FROM user_active_log \n    WHERE time_stamp >= {$min_timestamp}\n    ORDER BY time_stamp\n");
list($datax, $datay) = dpsql_fetch_columns($result);
$x_text_tick_interval = calculate_text_tick_interval('hourly', count($datay));
draw_simple_bar_graph($graph, $datax, $datay, $x_text_tick_interval, $title, _('Fresh Logons'));
// vim: sw=4 ts=4 expandtab