From: Pascal Corpet Date: Sun, 16 Jan 2005 13:38:40 +0000 (+0000) Subject: graphe des stats par promo a la volee avec gnuplot X-Git-Tag: xorg/old~405 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=97a3e612c78c734424db000976bfbbad7519b19e;p=platal.git graphe des stats par promo a la volee avec gnuplot git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-352 --- diff --git a/htdocs/stats/graph_by_promo.php b/htdocs/stats/graph_by_promo.php new file mode 100644 index 0000000..0595b7b --- /dev/null +++ b/htdocs/stats/graph_by_promo.php @@ -0,0 +1,82 @@ +xdb->iterRow( + "SELECT IF (promo < $depart, ".($depart-1).", promo) AS annee,COUNT(user_id) + FROM auth_user_md5 + WHERE promo >= $depart AND perms IN ('admin','user') + GROUP BY annee"); + +//genere des donnees compatibles avec GNUPLOT +$inscrits=''; + +// la première ligne contient le total des inscrits avant la date de départ +list(,$init_nb) = $res->next(); +$total = $init_nb; + +list($annee, $nb) = $res->next(); + +for ($i=$depart;$i<=date("Y");$i++) { + if ($annee<$i) { + if(!list($annee, $nb) = $res->next()) { + $annee = 0; + $nb = 0; + } + } + if ($nb > $total) $total = $nb; + if ($nb > 0 || $i < date("Y")) + $inscrits .= $i." ".$nb."\n"; +} + +//Genere le graphique à la volée avec GNUPLOT +header( "Content-type: image/png"); + +$ymin = round($init_nb*0.95,0); +$ymax = round($total *1.05,0); + +$gnuplot = << diff --git a/templates/stats/nb_by_promo.tpl b/templates/stats/nb_by_promo.tpl index 14cfa4d..bdf0145 100644 --- a/templates/stats/nb_by_promo.tpl +++ b/templates/stats/nb_by_promo.tpl @@ -68,7 +68,7 @@ Voici le nombre d'inscrits par promo :

Inscrits par promo en (%)

- [graphe du nombre d'inscrits par promo] + [graphe du nombre d'inscrits par promo]
{/if}