Alternc  3.2
Alternc logiel libre pour l'h├ębergement
 All Data Structures Namespaces Files Functions Variables Pages
stats_members.php
Go to the documentation of this file.
1 <?php
2 /*
3  $Id: stats_show_per_month.php,v 1.6 2005/08/02 14:56:51 anarcat Exp $
4  ----------------------------------------------------------------------
5  AlternC - Web Hosting System
6  Copyright (C) 2002 by the AlternC Development Team.
7  http://alternc.org/
8  ----------------------------------------------------------------------
9  Based on:
10  Valentin Lacambre's web hosting softwares: http://altern.org/
11  ----------------------------------------------------------------------
12  LICENSE
13 
14  This program is free software; you can redistribute it and/or
15  modify it under the terms of the GNU General Public License (GPL)
16  as published by the Free Software Foundation; either version 2
17  of the License, or (at your option) any later version.
18 
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  To read the license please visit http://www.gnu.org/copyleft/gpl.html
25  ----------------------------------------------------------------------
26  Original Author of file:
27  Purpose of file:
28  ----------------------------------------------------------------------
29 */
30 @require_once("../class/config.php");
31 if ((@include_once 'Image/Graph.php') === FALSE) {
32  echo "<p class=\"alert alert-warning\">". _("Image_Graph not installed. use 'aptitude install php-pear' then 'pear install --alldeps Image_Graph-devel' to see the graph.")."</p>";
33  exit(0);
34 }
35 
36 $db->query("SELECT COUNT(login) AS count,date_format(created, '%Y-%m') as month FROM `membres` where created is NOT null GROUP BY month ORDER BY month ASC");
37 
38 $Graph =& Image_Graph::factory('graph', array(800, 600));
39 $Graph->add(
40  Image_Graph::vertical(
41  Image_Graph::factory('title', array(_('Account creation per month'), 12)),
42  Image_Graph::vertical(
43  $Plotarea = Image_Graph::factory('plotarea'),
44  $Legend = Image_Graph::factory('legend'),
45  90
46  ),
47  5
48  )
49 );
50 
51 $Legend->setPlotarea($Plotarea);
52 
53 $total =& Image_Graph::factory('Image_Graph_Dataset_Trivial');
54 $total->setName(_('before the month'));
55 $units =& Image_Graph::factory('Image_Graph_Dataset_Trivial');
56 $units->setName(_('during the month'));
57 
58 $i = 0;
59 while ($db->next_record()) {
60  $units->addPoint($db->f('month'), $db->f('count'));
61  $total->addPoint($db->f('month'), $i);
62  $i += $db->f('count');
63 }
65 $Datasets[]= $units;
66 $Plot =& $Plotarea->addNew('bar', array($Datasets, 'stacked'));
67 
68 $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
69 $AxisX->setLabelOption('showoffset', 1);
70 $AxisX->setLabelInterval(2);
71 
72 // set a line color
73 $Plot->setLineColor('gray');
74 
75 // create a fill array
76 $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
77 $FillArray->addColor('blue@0.2');
78 $FillArray->addColor('yellow@0.2');
79 $FillArray->addColor('green@0.2');
80 
81 // set a standard fill style
82 $Plot->setFillStyle($FillArray);
83 
84 // create a Y data value marker
85 $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
86 // and use the marker on the 1st plot
87 $Plot->setMarker($Marker);
88 
89 $Plot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
90 
91 $Graph->Done();
92 
93 ?>