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
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to