Alternc  latest
Alternc logiel libre pour l'hébergement
stats_members.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * Show the statistics of all members.
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 @require_once("../class/config.php");
27 if ((@include_once 'Image/Graph.php') === FALSE) {
28  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>";
29  exit(0);
30 }
31 
32 $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");
33 
34 $Graph =& Image_Graph::factory('graph', array(800, 600));
35 $Graph->add(
36  Image_Graph::vertical(
37  Image_Graph::factory('title', array(_('Account creation per month'), 12)),
38  Image_Graph::vertical(
39  $Plotarea = Image_Graph::factory('plotarea'),
40  $Legend = Image_Graph::factory('legend'),
41  90
42  ),
43  5
44  )
45 );
46 
47 $Legend->setPlotarea($Plotarea);
48 
49 $total =& Image_Graph::factory('Image_Graph_Dataset_Trivial');
50 $total->setName(_('before the month'));
51 $units =& Image_Graph::factory('Image_Graph_Dataset_Trivial');
52 $units->setName(_('during the month'));
53 
54 $i = 0;
55 while ($db->next_record()) {
56  $units->addPoint($db->f('month'), $db->f('count'));
57  $total->addPoint($db->f('month'), $i);
58  $i += $db->f('count');
59 }
61 $Datasets[]= $units;
62 $Plot =& $Plotarea->addNew('bar', array($Datasets, 'stacked'));
63 
64 $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
65 $AxisX->setLabelOption('showoffset', 1);
66 $AxisX->setLabelInterval(2);
67 
68 // set a line color
69 $Plot->setLineColor('gray');
70 
71 // create a fill array
72 $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
73 $FillArray->addColor('blue@0.2');
74 $FillArray->addColor('yellow@0.2');
75 $FillArray->addColor('green@0.2');
76 
77 // set a standard fill style
78 $Plot->setFillStyle($FillArray);
79 
80 // create a Y data value marker
81 $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
82 // and use the marker on the 1st plot
83 $Plot->setMarker($Marker);
84 
85 $Plot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
86 
87 $Graph->Done();
88 
89 ?>
exit
Definition: adm_doadd.php:70
global $db
Definition: bootstrap.php:26
$total
while($db->next_record()) $Datasets[]
$Plot
$AxisX
$Graph
$FillArray
$Marker
$units