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); }
<?php $relPath = "./../../pinc/"; include_once $relPath . 'base.inc'; include_once 'common.inc'; // Initialize the graph before anything else. // This makes use of the jpgraph cache if enabled. // Last argument to init_pie_graph is the cache timeout in minutes. $graph = init_pie_graph(640, 400, 58); $res = mysql_query("SELECT IFNULL(LEFT(u_intlang,2),'') AS intlang,COUNT(*) AS num FROM users GROUP BY intlang ORDER BY num DESC"); $x = array(); $y = array(); while ($r = mysql_fetch_assoc($res)) { array_push($x, ($r['intlang'] ? dgettext("iso_639", eng_name($r['intlang'])) : _("Browser default")) . " (%d)"); array_push($y, $r['num']); } $title = _("Number of users per user interface language"); draw_pie_graph($graph, $x, $y, $title); // vim: sw=4 ts=4 expandtab