Пример #1
0
 function _render_statistic($x = array(), $yout = array(), $yin = array(), $type = 'bar', $points)
 {
     $this->load->helper('date');
     $this->load->library('OpenFlashChartLib', NULL, 'OFCL');
     $data_1 = array();
     $data_2 = array();
     $data_3 = array();
     switch ($type) {
         case 'bar':
             for ($i = 0; $i <= $points; $i++) {
                 $data_1[$i] = $x[$i];
                 $data_2[$i] = (int) $yout[$i];
                 // force to integer
                 $data_3[$i] = (int) $yin[$i];
                 // force to integer
             }
             $data_1 = array_reverse($data_1);
             $data_2 = array_reverse($data_2);
             $data_3 = array_reverse($data_3);
             $bar_1 = new bar();
             $bar_1->set_values($data_3);
             $bar_1->set_colour('#639F45');
             $bar_1->key(lang('kalkun_incoming_sms'), 10);
             $bar_1->set_tooltip('#x_label#<br>#val# SMS');
             //$bar_1->set_key("SMS used in last 7 days", 10);
             $bar_2 = new bar();
             $bar_2->set_values($data_2);
             $bar_2->set_colour('#21759B');
             $bar_2->key(lang('kalkun_outgoing_sms'), 10);
             $bar_2->set_tooltip('#x_label#<br>#val# SMS');
             $x = new x_axis();
             $labels = new x_axis_labels();
             $labels->set_labels($data_1);
             $labels->set_steps(1);
             $x->set_labels($labels);
             $y = new y_axis();
             $max = max(max($data_2), max($data_3));
             if ($max < 10) {
                 $max = 10;
             }
             $max = ceil($max / 5) * 5;
             $range = ceil($max / 5);
             $range = ceil($range / 10) * 10;
             $y->set_range(0, $max, $range);
             $element1 = $bar_1;
             $element2 = $bar_2;
             break;
         case 'line':
             for ($i = 0; $i <= 7; $i++) {
                 $data_1[$i] = new scatter_value($x[$i], $yin[$i]);
                 $data_2[$i] = new scatter_value($x[$i], $yout[$i]);
                 $data_3[$i] = (int) $yin[$i];
                 $data_4[$i] = (int) $yout[$i];
             }
             $def = new solid_dot();
             $def->size(4)->halo_size(0)->colour('#21759B')->tooltip('#date:d M y#<br>#val# SMS');
             $line_1 = new scatter_line('#639F45', 3);
             $line_1->set_values($data_1);
             $line_1->set_default_dot_style($def);
             $line_1->set_key("Incoming SMS", 10);
             $line_2 = new scatter_line('#21759B', 3);
             $line_2->set_values($data_2);
             $line_2->set_default_dot_style($def);
             $line_2->set_key("Outgoing SMS", 10);
             $x = new x_axis();
             // grid line and tick every 10
             $x->set_range(mktime(0, 0, 0, date("m"), date("d") - 7, date('Y')), mktime(0, 0, 0, date("m"), date("d"), date('Y')));
             // show ticks and grid lines for every day:
             $x->set_steps(86400);
             $labels = new x_axis_labels();
             // tell the labels to render the number as a date:
             $labels->text('#date:M-d#');
             // generate labels for every day
             $labels->set_steps(86400);
             // only display every other label (every other day)
             $labels->visible_steps(1);
             $labels->rotate(45);
             // finally attach the label definition to the x axis
             $x->set_labels($labels);
             $y = new y_axis();
             $max = max(max($data_3), max($data_4));
             if ($max < 1) {
                 $max = 10;
             }
             $y->set_range(0, $max, round($max / 100) * 10);
             $element1 = $line_1;
             $element2 = $line_2;
             break;
     }
     $chart = new open_flash_chart();
     $chart->add_element($element1);
     $chart->add_element($element2);
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     echo $chart->toPrettyString();
 }
Пример #2
0
 function lists()
 {
     acymailing::setTitle(JText::_('CHARTS'), 'stats', 'diagram&task=lists');
     $listsClass = acymailing::get('class.list');
     $lists = $listsClass->getLists('listid');
     $db =& JFactory::getDBO();
     $db->setQuery('SELECT listid, count(subid) as total FROM ' . acymailing::table('listsub') . ' WHERE `status` = 1 group by listid');
     $subscribers = $db->loadObjectList('listid');
     $db->setQuery('SELECT listid, count(subid) as total FROM ' . acymailing::table('listsub') . ' WHERE `status` = -1 group by listid');
     $unsubscribers = $db->loadObjectList('listid');
     $db->setQuery('SELECT listid, count(subid) as total FROM ' . acymailing::table('listsub') . ' WHERE `status` = 2 group by listid');
     $waitsub = $db->loadObjectList('listid');
     $title = new title(JText::_('NB_SUB_UNSUB'));
     $title->set_style('font-size:20px; color: #FF8040');
     $xLabels = array();
     $subColumn = array();
     $unsubColumn = array();
     $waitColumn = array();
     foreach ($lists as $listid => $oneList) {
         $xLabels[] = $oneList->name;
         $subColumn[] = empty($subscribers[$listid]->total) ? 0 : (int) $subscribers[$listid]->total;
         $unsubColumn[] = empty($unsubscribers[$listid]->total) ? 0 : (int) $unsubscribers[$listid]->total;
         $waitColumn[] = empty($waitsub[$listid]->total) ? 0 : (int) $waitsub[$listid]->total;
     }
     $barSub = new bar();
     $barSub->set_values($subColumn);
     $barSub->set_colour('#00FF00');
     $barSub->set_tooltip(JText::_('SUBSCRIBERS') . ' : #val#');
     $barUnsub = new bar();
     $barUnsub->set_values($unsubColumn);
     $barUnsub->set_colour('#CC0000');
     $barUnsub->set_tooltip(JText::_('UNSUBSCRIBERS') . ' : #val#');
     if (!empty($waitsub)) {
         $barWait = new bar();
         $barWait->set_values($waitColumn);
         $barWait->set_tooltip(JText::_('PENDING_SUBSCRIPTION') . ' : #val#');
         $barWait->set_colour('#FF9900');
     }
     $maxSub = max($subColumn);
     $maxUnsub = max($unsubColumn);
     $maxWait = max($waitColumn);
     $yLabels[] = JText::_('SUBSCRIBERS');
     $yLabels[] = JText::_('UNSUBSCRIBERS');
     $x_axis = new x_axis();
     $xlabelobject = new x_axis_labels();
     $xlabelobject->rotate(-20);
     $xlabelobject->set_labels($xLabels);
     $x_axis->set_labels($xlabelobject);
     $y_axis = new y_axis();
     $maxYValue = max(array($maxSub, $maxUnsub, $maxWait));
     $y_axis->range(0, $maxYValue, intval($maxYValue / 10));
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->set_x_axis($x_axis);
     $chart->set_y_axis($y_axis);
     if (!empty($waitsub)) {
         $chart->add_element($barWait);
     }
     $chart->add_element($barSub);
     $chart->add_element($barUnsub);
     $this->assignRef('chart', $chart);
 }