From 09a806bdfadebe76cf578f5231dc714d59317492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Wed, 23 May 2007 01:35:34 +0000 Subject: [PATCH] nice little graph: per month accout creation stats, using Image_Graph --- .gitattributes | 1 + bureau/admin/adm_panel.php | 1 + bureau/admin/stats_members.php | 93 ++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 bureau/admin/stats_members.php diff --git a/.gitattributes b/.gitattributes index 45d12196..161350b2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -201,6 +201,7 @@ bureau/admin/sta2_doadd_raw.php -text bureau/admin/sta2_doedit_raw.php -text bureau/admin/sta2_edit_raw.php -text bureau/admin/sta2_list.php -text +bureau/admin/stats_members.php -text bureau/admin/styles/style.css -text bureau/admin/template.php -text bureau/admin/web_list.php -text diff --git a/bureau/admin/adm_panel.php b/bureau/admin/adm_panel.php index d562c70a..05808b97 100644 --- a/bureau/admin/adm_panel.php +++ b/bureau/admin/adm_panel.php @@ -54,6 +54,7 @@ include("head.php"); + ". _("Image_Graph not installed. pear install Image_Graph-devel to see the graph.")."

"; + exit(0); +} + +$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"); + +$Graph =& Image_Graph::factory('graph', array(800, 600)); +$Graph->add( + Image_Graph::vertical( + Image_Graph::factory('title', array(_('Account creation per month'), 12)), + Image_Graph::vertical( + $Plotarea = Image_Graph::factory('plotarea'), + $Legend = Image_Graph::factory('legend'), + 90 + ), + 5 + ) +); + +$Legend->setPlotarea($Plotarea); + +$total =& Image_Graph::factory('Image_Graph_Dataset_Trivial'); +$total->setName(_('before the month')); +$units =& Image_Graph::factory('Image_Graph_Dataset_Trivial'); +$units->setName(_('during the month')); + +$i = 0; +while ($db->next_record()) { + $units->addPoint($db->f('month'), $db->f('count')); + $total->addPoint($db->f('month'), $i); + $i += $db->f('count'); +} +$Datasets[]= $total; +$Datasets[]= $units; +$Plot =& $Plotarea->addNew('bar', array($Datasets, 'stacked')); + +$AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); +$AxisX->setLabelOption('showoffset', 1); +$AxisX->setLabelInterval(2); + +// set a line color +$Plot->setLineColor('gray'); + +// create a fill array +$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array'); +$FillArray->addColor('blue@0.2'); +$FillArray->addColor('yellow@0.2'); +$FillArray->addColor('green@0.2'); + +// set a standard fill style +$Plot->setFillStyle($FillArray); + +// create a Y data value marker +$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y); +// and use the marker on the 1st plot +$Plot->setMarker($Marker); + +$Plot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros')); + +$Graph->Done(); + +?>