SVN: toys/stbr/stats/daily.php

2010-01-03 Thread shadzik
Author: shadzik
Date: Sun Jan  3 14:21:49 2010
New Revision: 11089

Modified:
   toys/stbr/stats/daily.php
Log:
- we don't always have a full dataset, don't assume data we don't have yet is 
0, rather don't display it at all


Modified: toys/stbr/stats/daily.php
==
--- toys/stbr/stats/daily.php   (original)
+++ toys/stbr/stats/daily.php   Sun Jan  3 14:21:49 2010
@@ -25,10 +25,21 @@
 foreach ($pld_lines as $line) {
foreach($days as $day) {
$q = @$DBhandle-query('select count(*) from application where 
line=' . $line . ' and date ='.$year.'-' . (string)$month . '-'.$day.' 
00:00:00 and date  '.$year.'-'. (string)$month .'-'.$day.' 23:59:59');
-   if ($line == th)
-   $thm[] = (int)$q-fetchSingle();
-   else
-   $tim[] = (int)$q-fetchSingle();
+   $data = (int)$q-fetchSingle();
+   switch($line) {
+   case th:
+   if ($data == 0)
+   $thm[] = null;
+   else
+   $thm[] = $data;
+   break;
+   case ti:
+   if ($data == 0)
+   $tim[] = null;
+   else
+   $tim[] = $data;
+   break;
+   }
}
 }
 
___
pld-cvs-commit mailing list
pld-cvs-commit@lists.pld-linux.org
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit


SVN: toys/stbr/stats/daily.php

2010-01-02 Thread shadzik
Author: shadzik
Date: Sat Jan  2 14:07:21 2010
New Revision: 11082

Modified:
   toys/stbr/stats/daily.php
Log:
- fix month format (no need to put extra zero before the month)


Modified: toys/stbr/stats/daily.php
==
--- toys/stbr/stats/daily.php   (original)
+++ toys/stbr/stats/daily.php   Sat Jan  2 14:07:21 2010
@@ -8,8 +8,8 @@
 $year = date(Y);
 $month = date(m);
 $max_days = date(t);
-if ($month  10)
-   $month = 0.$month;
+//if ($month  10)
+// $month = 0.$month;
 $days = array();
 for ($i=1; $i=$max_days; $i++) {
if ($i  10)
@@ -40,7 +40,7 @@
$scale = $ti_max;
 
 $month_name = date(F);
-$title = new title(Daily Requests in $month_name);
+$title = new title(Daily Requests in $month_name $year);
 
 $th_bar-set_values($thm);
 $th_bar-set_colour('#FF6633');
___
pld-cvs-commit mailing list
pld-cvs-commit@lists.pld-linux.org
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit


SVN: toys/stbr/stats/daily.php

2009-12-28 Thread shadzik
Author: shadzik
Date: Tue Dec 29 00:41:20 2009
New Revision: 11076

Added:
   toys/stbr/stats/daily.php
Log:
- daily line chart


Added: toys/stbr/stats/daily.php
==
--- (empty file)
+++ toys/stbr/stats/daily.php   Tue Dec 29 00:41:20 2009
@@ -0,0 +1,71 @@
+?
+
+require_once(php-ofc-library/open-flash-chart.php);
+require_once(db.dat);
+
+$pld_lines = array(th,ti);
+
+$year = date(Y);
+$month = date(m);
+$max_days = date(t);
+if ($month  10)
+   $month = 0.$month;
+$days = array();
+for ($i=1; $i=$max_days; $i++) {
+   if ($i  10)
+   $i = 0.$i;
+   $days[] = (string)$i;
+}
+
+$th_bar = new line();
+$ti_bar = new line();
+
+$thm = array();
+$tim = array();
+foreach ($pld_lines as $line) {
+   foreach($days as $day) {
+   $q = @$DBhandle-query('select count(*) from application where 
line=' . $line . ' and date ='.$year.'-' . (string)$month . '-'.$day.' 
00:00:00 and date  '.$year.'-'. (string)$month .'-'.$day.' 23:59:59');
+   if ($line == th)
+   $thm[] = (int)$q-fetchSingle();
+   else
+   $tim[] = (int)$q-fetchSingle();
+   }
+}
+
+$th_max = max($thm);
+$ti_max = max($tim);
+if ($th_max = $ti_max)
+   $scale = $th_max;
+else
+   $scale = $ti_max;
+
+$month_name = date(F);
+$title = new title(Daily Requests in $month_name);
+
+$th_bar-set_values($thm);
+$th_bar-set_colour('#FF6633');
+$th_bar-set_key('Th', 12);
+$ti_bar-set_values($tim);
+$ti_bar-set_colour('#3366FF');
+$ti_bar-set_key('Titanium', 12);
+
+$chart = new open_flash_chart();
+$chart-set_title($title);
+$chart-add_element($th_bar);
+$chart-add_element($ti_bar);
+
+$y = new y_axis();
+$y-set_range(0, $scale, 1);
+
+$xlabels = new x_axis_labels();
+$xlabels-set_labels($days);
+
+$x = new x_axis();
+$x-set_labels($xlabels);
+
+$chart-set_x_axis($x);
+$chart-set_y_axis($y);
+
+echo $chart-toPrettyString();
+
+?
___
pld-cvs-commit mailing list
pld-cvs-commit@lists.pld-linux.org
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit