File: users_graph.php

package info (click to toggle)
gforge 4.5.14-22etch13
  • links: PTS
  • area: main
  • in suites: etch
  • size: 13,004 kB
  • ctags: 11,918
  • sloc: php: 36,047; sql: 29,050; sh: 10,538; perl: 6,496; xml: 3,810; makefile: 341; python: 263; ansic: 256
file content (78 lines) | stat: -rw-r--r-- 1,914 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
  *
  * SourceForge Sitewide Statistics
  *
  * SourceForge: Breaking Down the Barriers to Open Source Development
  * Copyright 1999-2001 (c) VA Linux Systems
  * http://sourceforge.net
  *
  * @version   $Id: users_graph.php 1667 2003-02-06 21:50:24Z rspisser $
  *
  */


require_once('pre.php');
require_once('graph_lib.php');

   // require you to be a member of the sfstats group (group_id = 11084)
session_require( array('group'=>$sys_stats_group) );

if ( ! $group_id ) {
	$group_id = 0;
}

if ( ! $year ) {
	$year = gmstrftime("%Y", time() );
}

$sql = "SELECT month,day,new_users,new_projects FROM stats_site ORDER BY month ASC, day ASC";
$res = db_query( $sql );

$i = 0;
while ( $row = db_fetch_array($res) ) {
        $xdata[$i]          = $i;
	$xlabel[$i]         = (substr($row['month'],4) + 1 - 1) . "/" . $row['day'];
        $ydata1[$i]         = $row["new_users"];
        $ydata2[$i]         = $row["new_projects"];
        ++$i;
}
//
// Need at least 2 data points
//
if ($i == 0) {
    $xdata[0] = 0;
    $xlabel[0] = "";
    $ydata1[0] = 0;
    $ydata2[0] = 0;

    $xdata[1] = 1;
    $xlabel[1] = "";
    $ydata1[1] = 0;
    $ydata2[1] = 0;
}
if ($i == 1) {
    $xdata[1] = 1;
    $xlabel[1] = $xlabel[0];
    $ydata1[1] = $ydata1[0];
    $ydata2[1] = $ydata2[0];
}


$graph = new Graph( 750, 550 );

$data1 = $graph->AddData( $xdata, $ydata1, $xlabel );
$data2 = $graph->AddData( $xdata, $ydata2, $xlabel );

$graph->DrawGrid('gray');
$graph->LineGraph($data1,'red');
$graph->LineGraph($data2,'blue');
$graph->SetTitle($Language->getText('stats_user_graph','new_additions_by_day') );
$graph->SetSubTitle($Language->getText('stats_user_graph','new_user_projects'));
$graph->SetxTitle($Language->getText('stats_user_graph','date'));
$graph->SetyTitle($Language->getText('stats_user_graph','user_projects'));
$graph->DrawAxis();
//$graph->showDebug();
$graph->ShowGraph('png');

?>