public function index2Action()
 {
     $this->_helper->layout->disableLayout();
     include 'open-flash-chart.php';
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('report', array('left(create_date,10) as date', 'count(*)'))->where('report.campaign_id = 3')->where("report.state = 'APPROVED'")->group('date')->order('date')->limit(0);
     $results = $db->fetchAll($select);
     $array_data = array();
     $array_create_date = array();
     foreach ($results as $result) {
         array_push($array_data, (int) $result["count(*)"]);
         array_push($array_create_date, $result["date"]);
     }
     $title = new title("BugsLock Reports By Day");
     $y = new y_axis();
     $y->set_range(0, 100, 10);
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($array_create_date);
     $x_labels->set_steps(2);
     $x_labels->rotate(40);
     $x->set_labels($x_labels);
     //There is a bug on the tooltip of bar: can not show #x_label#. So use bar_stack instead of bar here.
     //		$bar = new bar_filled( '#E2D66A', '#577261' );
     //		$bar->set_values($array_data);
     //		$bar->set_tooltip('#x_label#: #val#');
     $bar = new bar_stack();
     $bar->set_colours(array('#E2D66A', '#577261'));
     foreach ($array_data as $date) {
         $bar->append_stack(array((int) $date));
     }
     $bar->set_tooltip('#x_label#: #val#');
     $this->view->chart3 = new open_flash_chart();
     $this->view->chart3->set_title($title);
     $this->view->chart3->add_element($bar);
     $this->view->chart3->set_bg_colour('#FFFFFF');
     $this->view->chart3->set_x_axis($x);
     $this->view->chart3->set_y_axis($y);
     //		echo $this->view->chart3->toPrettyString();
 }
Exemple #2
0
 /**
  * Alias for FlashChart::chart('bar_stack');
  *
  * @param array $options
  * @param string $datasetName The name to be used to associate charts with data
  * @param string $chartId Name of chart. Use for seperate charts.
  * @return string
  */
 public function barStack($options = array(), $datasetName = 'default', $chartId = 'default')
 {
     if (empty($this->data[$datasetName])) {
         return false;
     }
     $bar_stack = new bar_stack();
     $bar_stack->set_colours($this->stackColours);
     foreach ($this->data[$datasetName] as $values) {
         $bar_stack->append_stack($values);
     }
     if (!empty($this->tooltip)) {
         $bar_stack->set_tooltip($this->tooltip);
     }
     foreach ($options as $key => $setting) {
         $set_method = 'set_' . $key;
         if (is_array($setting)) {
             $bar_stack->{$set_method}($setting[0], $setting[1]);
         } else {
             $bar_stack->{$set_method}($setting);
         }
     }
     $this->Chart->set_bg_colour($this->bg_colour);
     $this->Chart->add_element($bar_stack);
     return $this->renderData($chartId);
 }
Exemple #3
0
 /**
  * Alias for FlashChart::chart('bar_stack');
  *
  * @param array $options
  * @param string $datasetName The name to be used to associate charts with data
  * @param string $chartId Name of chart. Use for seperate charts.
  * @return string
  */
 public function barStack($options = array(), $datasetName = 'default', $chartId = null)
 {
     if (!is_null($chartId)) {
         $this->chartId = $chartId;
     }
     if (empty($this->data[$datasetName])) {
         return false;
     }
     $bar_stack = new bar_stack();
     $numbers = $this->getNumbers($datasetName);
     foreach ($numbers as $values) {
         $tmp = array();
         if (sizeof($this->stackColours) == sizeof($values)) {
             foreach ($values as $key => $value) {
                 $tmp[] = new bar_stack_value($value, $this->stackColours[$key]);
             }
         } else {
             $tmp = $values;
         }
         $bar_stack->append_stack($tmp);
     }
     if (!empty($this->tooltip)) {
         $bar_stack->set_tooltip($this->tooltip);
     }
     foreach ($options as $key => $setting) {
         $set_method = 'set_' . $key;
         if (is_array($setting)) {
             $bar_stack->{$set_method}($setting[0], $setting[1]);
         } else {
             $bar_stack->{$set_method}($setting);
         }
     }
     $this->Chart->set_bg_colour($this->bg_colour);
     $this->Chart->add_element($bar_stack);
     return $this->data($this->chartId);
 }
    protected function renderHTML()
    {
        global $g_BizSystem;
        $sql = "SELECT username, cflags, methods, user_agent, contact from location order by username";
        $db = $g_BizSystem->GetDBConnection("Serdb");
        $resultSet = $db->query($sql);
        if ($resultSet === false) {
            $err = $db->ErrorMsg();
            echo $err;
            exit;
        }
        $chart_colors = array();
        $chart_colors[0] = '#FF0000';
        $chart_colors[1] = '#00FF00';
        $chart_colors[2] = '#0000FF';
        $chart_colors[3] = '#408080';
        $chart_colors[4] = '#330000';
        $chart_colors[5] = '#FDD017';
        $chart_colors[6] = '#52D017';
        $chart_colors[7] = '#6698FF';
        $chart_colors[8] = '#00FFFF';
        $chart_colors[9] = '#FF00FF';
        $chart_colors[10] = '#2554C7';
        $chart_colors[11] = '#806D7E';
        $chart_colors[12] = '#FF8040';
        $chart_colors[13] = '#C0C0C0';
        $chart_colors[14] = '#808000';
        $chart_colors[15] = '#800000';
        $chart_colors_size = 16;
        $ul_contacts = array();
        for ($i = 0; $i <= 5; $i++) {
            $ul_contacts[$i] = 0;
        }
        $prevuser = "******";
        $prevcnt = 1;
        $ul_uas = array();
        $ul_uas['asterisk'] = 0;
        $ul_uas['freeswitch'] = 0;
        $ul_uas['x-lite'] = 0;
        $ul_uas['eyebeam'] = 0;
        $ul_uas['bria'] = 0;
        $ul_uas['ekiga'] = 0;
        $ul_uas['twinkle'] = 0;
        $ul_uas['snom'] = 0;
        $ul_uas['cisco'] = 0;
        $ul_uas['linksys'] = 0;
        $ul_uas['nokia'] = 0;
        $ul_uas['grandstream'] = 0;
        $ul_uas['polycom'] = 0;
        $ul_uas['draytek'] = 0;
        $ul_uas['avm'] = 0;
        $ul_uas['sipura'] = 0;
        $ul_uas['mitel'] = 0;
        $ul_uas['others'] = 0;
        $ul_methods = array();
        $ul_methods['INVITE'] = 0;
        $ul_methods['CANCEL'] = 0;
        $ul_methods['ACK'] = 0;
        $ul_methods['BYE'] = 0;
        $ul_methods['REGISTER'] = 0;
        $ul_methods['OPTIONS'] = 0;
        $ul_methods['UPDATE'] = 0;
        $ul_methods['PRACK'] = 0;
        $ul_methods['SUBSCRIBE'] = 0;
        $ul_methods['NOTIFY'] = 0;
        $ul_methods['PUBLISH'] = 0;
        $ul_methods['MESSAGE'] = 0;
        $ul_methods['INFO'] = 0;
        $ul_methods['REFER'] = 0;
        $ul_methods['OTHERS'] = 0;
        $ul_methods['NONE'] = 0;
        $ul_nat = array();
        $ul_nat['NATTED'] = 0;
        $ul_nat['SIPPING'] = 0;
        $ul_proto = array();
        $ul_proto['UDP'] = 0;
        $ul_proto['TCP'] = 0;
        $ul_proto['TLS'] = 0;
        $ul_proto['SCTP'] = 0;
        $yidx = 0;
        $ousr = 0;
        while ($row = $resultSet->fetch()) {
            $r_username = $row[0];
            $r_cflags = $row[1];
            $r_methods = $row[2];
            $r_user_agent = $row[3];
            $r_contact = $row[4];
            /* statistics for contacts per user */
            if ($yidx == 0) {
                $prevuser = $r_username;
                $prevcnt = 1;
            } else {
                if ($r_username == $prevuser) {
                    $prevcnt = $prevcnt + 1;
                } else {
                    $ousr++;
                    if ($prevcnt < 5) {
                        $ul_contacts[$prevcnt] = $ul_contacts[$prevcnt] + 1;
                    } else {
                        $ul_contacts[5] = $ul_contacts[5] + 1;
                    }
                    $prevuser = $r_username;
                    $prevcnt = 1;
                }
            }
            /* known UA stats */
            if (isset($r_user_agent)) {
                if (preg_match('/asterisk/i', $r_user_agent)) {
                    $ul_uas['asterisk'] = $ul_uas['asterisk'] + 1;
                } else {
                    if (preg_match("/freeswitch/i", $r_user_agent)) {
                        $ul_uas['freeswitch'] = $ul_uas['freeswitch'] + 1;
                    } else {
                        if (preg_match("/x-lite/i", $r_user_agent)) {
                            $ul_uas['x-lite'] = $ul_uas['x-lite'] + 1;
                        } else {
                            if (preg_match("/bria/i", $r_user_agent)) {
                                $ul_uas['bria'] = $ul_uas['bria'] + 1;
                            } else {
                                if (preg_match("/ekiga/i", $r_user_agent)) {
                                    $ul_uas['ekiga'] = $ul_uas['ekiga'] + 1;
                                } else {
                                    if (preg_match("/twinkle/i", $r_user_agent)) {
                                        $ul_uas['twinkle'] = $ul_uas['twinkle'] + 1;
                                    } else {
                                        if (preg_match("/snom/i", $r_user_agent)) {
                                            $ul_uas['snom'] = $ul_uas['snom'] + 1;
                                        } else {
                                            if (preg_match("/cisco/i", $r_user_agent)) {
                                                $ul_uas['cisco'] = $ul_uas['cisco'] + 1;
                                            } else {
                                                if (preg_match("/linksys/i", $r_user_agent)) {
                                                    $ul_uas['linksys'] = $ul_uas['linksys'] + 1;
                                                } else {
                                                    if (preg_match("/nokia/i", $r_user_agent)) {
                                                        $ul_uas['nokia'] = $ul_uas['nokia'] + 1;
                                                    } else {
                                                        if (preg_match("/grandstream/i", $r_user_agent)) {
                                                            $ul_uas['grandstream'] = $ul_uas['grandstream'] + 1;
                                                        } else {
                                                            if (preg_match("/polycom/i", $r_user_agent)) {
                                                                $ul_uas['polycom'] = $ul_uas['polycom'] + 1;
                                                            } else {
                                                                if (preg_match("/draytek/i", $r_user_agent)) {
                                                                    $ul_uas['draytek'] = $ul_uas['draytek'] + 1;
                                                                } else {
                                                                    if (preg_match("/avm/i", $r_user_agent)) {
                                                                        $ul_uas['avm'] = $ul_uas['avm'] + 1;
                                                                    } else {
                                                                        if (preg_match("/sipura/i", $r_user_agent)) {
                                                                            $ul_uas['sipura'] = $ul_uas['sipura'] + 1;
                                                                        } else {
                                                                            if (preg_match("/mitel/i", $r_user_agent)) {
                                                                                $ul_uas['mitel'] = $ul_uas['mitel'] + 1;
                                                                            } else {
                                                                                $ul_uas['others'] = $ul_uas['others'] + 1;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            /* transports */
            if (isset($r_contact)) {
                if (preg_match('/;transport=tcp/i', $r_contact)) {
                    $ul_proto['TCP'] = $ul_proto['TCP'] + 1;
                } else {
                    if (preg_match("/;transport=tls/i", $r_contact)) {
                        $ul_proto['TLS'] = $ul_proto['TLS'] + 1;
                    } else {
                        if (preg_match("/;transport=sctp/i", $r_contact)) {
                            $ul_proto['SCTP'] = $ul_proto['SCTP'] + 1;
                        } else {
                            $ul_proto['UDP'] = $ul_proto['UDP'] + 1;
                        }
                    }
                }
            }
            /* supported SIP methods stats */
            if (isset($r_methods) && $r_methods != 0) {
                /* 1 - 2^0 INVITE */
                if ($r_methods & 1) {
                    $ul_methods['INVITE'] = $ul_methods['INVITE'] + 1;
                }
                /* 2 - 2^1 CANCEL */
                if ($r_methods & 2) {
                    $ul_methods['CANCEL'] = $ul_methods['CANCEL'] + 1;
                }
                /* 3 - 2^2 ACK */
                if ($r_methods & 4) {
                    $ul_methods['ACK'] = $ul_methods['ACK'] + 1;
                }
                /* 4 - 2^3 BYE */
                if ($r_methods & 8) {
                    $ul_methods['BYE'] = $ul_methods['BYE'] + 1;
                }
                /* 5 - 2^4 INFO */
                if ($r_methods & 16) {
                    $ul_methods['INFO'] = $ul_methods['INFO'] + 1;
                }
                /* 6 - 2^5 REGISTER */
                if ($r_methods & 32) {
                    $ul_methods['REGISTER'] = $ul_methods['REGISTER'] + 1;
                }
                /* 7 - 2^6 SUBSCRIBE */
                if ($r_methods & 64) {
                    $ul_methods['SUBSCRIBE'] = $ul_methods['SUBSCRIBE'] + 1;
                }
                /* 8 - 2^7 NOTIFY */
                if ($r_methods & 128) {
                    $ul_methods['NOTIFY'] = $ul_methods['NOTIFY'] + 1;
                }
                /* 9 - 2^8 MESSAGE */
                if ($r_methods & 256) {
                    $ul_methods['MESSAGE'] = $ul_methods['MESSAGE'] + 1;
                }
                /* 10 - 2^9 OPTIONS */
                if ($r_methods & 512) {
                    $ul_methods['OPTIONS'] = $ul_methods['OPTIONS'] + 1;
                }
                /* 11 - 2^10 PRACK */
                if ($r_methods & 1024) {
                    $ul_methods['PRACK'] = $ul_methods['PRACK'] + 1;
                }
                /* 12 - 2^11 UPDATE */
                if ($r_methods & 2048) {
                    $ul_methods['UPDATE'] = $ul_methods['UPDATE'] + 1;
                }
                /* 13 - 2^12 REFER */
                if ($r_methods & 4096) {
                    $ul_methods['REFER'] = $ul_methods['REFER'] + 1;
                }
                /* 14 - 2^13 PUBLISH */
                if ($r_methods & 8192) {
                    $ul_methods['PUBLISH'] = $ul_methods['PUBLISH'] + 1;
                }
                /* 15 - 2^14 OTHER */
                if ($r_methods & 16384) {
                    $ul_methods['OTHERS'] = $ul_methods['OTHERS'] + 1;
                }
            } else {
                $ul_methods['NONE'] = $ul_methods['NONE'] + 1;
            }
            /* supported NAT stats */
            if (isset($r_cflags) && $r_cflags != 0) {
                if ($r_cflags & 1 << 6) {
                    $ul_nat['NATTED'] = $ul_nat['NATTED'] + 1;
                }
                if ($r_cflags & 1 << 7) {
                    $ul_nat['SIPPING'] = $ul_nat['SIPPING'] + 1;
                }
            }
            $yidx = $yidx + 1;
        }
        if ($yidx > 0) {
            $ousr++;
            if ($prevcnt < 5) {
                $ul_contacts[$prevcnt] = $ul_contacts[$prevcnt] + 1;
            } else {
                $ul_contacts[5] = $ul_contacts[5] + 1;
            }
        }
        /* user agents chart */
        $ua_title = new title('User Agents');
        $ua_x_labels = new x_axis_labels();
        $ua_x_labels->rotate(20);
        $ua_bar = new bar_glass();
        $chart_vals = array();
        $chart_lbls = array();
        $i = 0;
        $ymax = 10;
        foreach ($ul_uas as $key => $val) {
            if ($val > 0) {
                $chart_vals[$i] = new bar_value($val);
                $chart_vals[$i]->set_colour($chart_colors[$i % $chart_colors_size]);
                $chart_vals[$i]->set_tooltip($key . '<br>#val#');
                $chart_lbls[$i] = $key;
                if ($ymax < $val) {
                    $ymax = $val;
                }
                $i = $i + 1;
            }
        }
        $ua_bar->set_values($chart_vals);
        $ua_x_labels->set_labels($chart_lbls);
        $x = new x_axis();
        $x->set_labels($ua_x_labels);
        $y = new y_axis();
        $y->set_range(0, $ymax, $ymax / 10);
        $ul_uas_chart = new open_flash_chart();
        $ul_uas_chart->set_title($ua_title);
        $ul_uas_chart->add_element($ua_bar);
        $ul_uas_chart->set_x_axis($x);
        $ul_uas_chart->add_y_axis($y);
        /* supported SIP Methods chart */
        $mt_title = new title('Supported SIP Methods');
        $mt_x_labels = new x_axis_labels();
        $mt_x_labels->rotate(20);
        $mt_bar = new bar_glass();
        $chart_vals = array();
        $chart_lbls = array();
        $i = 0;
        $ymax = 10;
        foreach ($ul_methods as $key => $val) {
            if ($val > 0) {
                $chart_vals[$i] = new bar_value($val);
                $chart_vals[$i]->set_colour($chart_colors[$i % $chart_colors_size]);
                $chart_vals[$i]->set_tooltip($key . '<br>#val#');
                $chart_lbls[$i] = $key;
                if ($ymax < $val) {
                    $ymax = $val;
                }
                $i = $i + 1;
            }
        }
        $mt_bar->set_values($chart_vals);
        $mt_x_labels->set_labels($chart_lbls);
        $x = new x_axis();
        $x->set_labels($mt_x_labels);
        $y = new y_axis();
        $y->set_range(0, $ymax, $ymax / 10);
        $mt_chart = new open_flash_chart();
        $mt_chart->set_title($mt_title);
        $mt_chart->add_element($mt_bar);
        $mt_chart->set_x_axis($x);
        $mt_chart->add_y_axis($y);
        /* bar stacks - contacts/user, nat stats, ... */
        $cn_title = new title('Contacts and NAT Stats');
        $cn_x_labels = new x_axis_labels();
        $cn_x_labels->rotate(20);
        $bar_stack = new bar_stack();
        $bar_stack->set_colours($chart_colors);
        $chart_lbls = array();
        $c = 0;
        $lidx = 0;
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($yidx, $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('Records<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'All Records';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ousr, $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('Online<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'Online Users';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[1], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('1 contact<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[2], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('2 contacts<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[3], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('3 contacts<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[4], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('4 contacts<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_contacts[5], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('&gt;=5 contacts <br>#val#');
        $i = $i + 1;
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'Contacts per AoR';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ul_nat['NATTED'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('Natted<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($yidx - $ul_nat['NATTED'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('Not-Natted<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'Natted';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ul_nat['SIPPING'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('SIP Ping<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($yidx - $ul_nat['SIPPING'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('No SIP Ping<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'SIP Ping';
        $chart_vals = array();
        $i = 0;
        $chart_vals[$i] = new bar_stack_value($ul_proto['UDP'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('UDP<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_proto['TCP'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('TCP<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_proto['TLS'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('TLS<br>#val#');
        $i = $i + 1;
        $chart_vals[$i] = new bar_stack_value($ul_proto['SCTP'], $chart_colors[$c++ % $chart_colors_size]);
        $chart_vals[$i]->set_tooltip('SCTP<br>#val#');
        $bar_stack->append_stack($chart_vals);
        $chart_lbls[$lidx++] = 'Transports';
        $cn_x_labels->set_labels($chart_lbls);
        $x = new x_axis();
        $x->set_labels($cn_x_labels);
        $y = new y_axis();
        $y->set_range(0, $yidx, $yidx / 10);
        $cn_chart = new open_flash_chart();
        $cn_chart->set_title($cn_title);
        $cn_chart->add_element($bar_stack);
        $cn_chart->set_x_axis($x);
        $cn_chart->add_y_axis($y);
        $sHTML = '';
        $sHTML .= '
			<div align="center">
				<p><b>Processed ' . $yidx . ' records.</b></p>
			</div>
			';
        if ($yidx > 0) {
            $sHTML .= '
			<script type="text/javascript" src="' . APP_URL . '/js/swfobject.js"></script>
			<script type="text/javascript">
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_ul_uas",
					"600", "300", "9.0.0", "expressInstall.swf",
					{"get-data":"get_data_ul_uas"} );
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_ul_met",
					"600", "300", "9.0.0", "expressInstall.swf",
					{"get-data":"get_data_ul_met"} );
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_ul_cns",
					"600", "300", "9.0.0", "expressInstall.swf",
				{"get-data":"get_data_ul_cns"} );
			</script> 
			';
            $sHTML .= '
			<br />
			<div align="center">
				<div id="div_chart_ul_uas">
				</div>
				<br />
				<br />
				<div id="div_chart_ul_met">
				</div>
				<br />
				<br />
				<div id="div_chart_ul_cns">
				</div>
				<br />
				<br />
			</div>
			';
            $sHTML .= '
			<script type="text/javascript">
				function get_data_ul_uas()
				{
					data = \'' . $ul_uas_chart->toString() . '\';
					return data;
				}

				function get_data_ul_met()
				{
					data = \'' . $mt_chart->toString() . '\';
					return data;
				}

				function get_data_ul_cns()
				{
					data = \'' . $cn_chart->toString() . '\';
					return data;
				}

			</script>
			';
        }
        /* if $yidx */
        return $sHTML;
    }
Exemple #5
0
        $tipoDoc = $rs->fields["SGD_TPR_DESCRIP"];
        $rads = $rs->fields["RADS"];
        $infoXtipoRojo[$tipoDoc] = $infoXtipoRojo[$tipoDoc] + 0;
        $infoXtipoAmarillo[$tipoDoc] = $infoXtipoAmarillo[$tipoDoc] + 0;
        $infoXtipoVerde[$tipoDoc] = $rads;
        //echo "<hr> $tipoDoc  ".$infoXtipo[$tipoDoc][0];    // 5
        $rs->MoveNext();
    }
}
$ofc_path = "../../include/ofc-2-Kvasir/php-ofc-library";
include "{$ofc_path}/open-flash-chart.php";
$title = new title('Radicados Discriminados por Tipo Documental ');
$title->set_style("{font-size: 9px; color: #F24062; text-align: center;}");
$noTotalRadsTMP = 0;
$i = 1;
$bar_stack = new bar_stack();
$bar_stack->set_colours(array('#ff0000', '#50284A', '#77CC6D'));
foreach ($infoXtipoRojo as $key => $value) {
    $bar_stack->append_stack(array($infoXtipoRojo[$key] + 0, $infoXtipoAmarillo[$key] + 0, $infoXtipoVerde[$key] + 0));
    $arrayTipos[] = $key;
    // Suma el total de Radicados
    $noTotalRadsTMP = $noTotalRadsTMP + $infoXtipoRojo[$key] + $infoXtipoAmarillo[$key] + $infoXtipoVerde[$key];
    if ($noTotalRadsTMP > $noTotalRads) {
        $noTotalRads = $noTotalRadsTMP;
    }
    $noTotalRadsTMP = 0;
}
// set a cycle of 3 colours:
// add 3 bars:
// add 4 bars, the fourth will be the same colour as the first:
//$bar_stack->append_stack( array( 2.5, 5, 1.25, 1.25 ) );
    $data_soll[$row->d] = round((double) $row->SollETotal, 3);
    $MaxETotal = max(round((double) $row->MaxETotal, 3), $MaxETotal);
    $MinETotal = min(round((double) $row->MinETotal, 3), $MinETotal);
    $i++;
}
if (defined($_REQUEST['debug'])) {
    print_r($data_curr);
    print_r($data_soll);
}
if ($i == 0) {
    echo 0;
    exit;
}
$title = new title(date('F Y', $time) . " (" . round($MaxETotal - $MinETotal, 2) . " kWh)");
$title->set_style('{font-size: 20px; color: #778877}');
$bars_curr = new bar_stack();
//$bars_curr->set_key( 'Ist Tagesleistung (kWh)', 10 );
$bars_curr->set_colours(array('#EFC01D', '#000000'));
$bars_curr->set_alpha(0.8);
$bars_curr->set_tooltip('#val# kWh');
for ($i = 0; $i < count($data_curr); $i++) {
    $bval = new bar_stack_value(min($data_curr[$i], $data_soll[$i]), '#EFC01D');
    $bval->{"on-click"} = "load_chart('day',{$ttime_axis[$i]})";
    if ($data_curr[$i] < $data_soll[$i]) {
        $bval_plus = null;
        $bval_minus = new bar_stack_value($data_soll[$i] - $data_curr[$i], '#FFC0C0');
    } elseif ($data_curr[$i] > $data_soll[$i]) {
        $bval_minus = null;
        $bval_plus = new bar_stack_value($data_curr[$i] - $data_soll[$i], '#1DFF1D');
    }
    $bars_curr->append_stack(array($bval, $bval_minus, $bval_plus));
Exemple #7
0
function stacked_bar_chart($host_instance_list)
{
    $title = new title('所有instance实际内存使用');
    $title->set_style("{color: #567300; font-size: 16px; font-weight:bold;}");
    $bar_stack = new bar_stack();
    $bar_stack->set_colours(array('#C4D318', '#7D7B6A'));
    $max = 64;
    foreach ($host_instance_list as $i => $instance) {
        $jvmmem = isset($instance['jvmmem']) ? explode('/', $instance['jvmmem']) : array();
        if ($jvmmem) {
            foreach ($jvmmem as &$j) {
                $j = intval($j);
            }
            $max = $max < $jvmmem[1] ? $jvmmem[1] : $max;
            $jvmmem[1] = $jvmmem[1] - $jvmmem[0];
        }
        $bar_stack->append_stack($jvmmem);
        $lables[] = $instance['port_num'];
        $services[$i] = $instance['service_name'];
    }
    $bar_stack->set_keys(array(new bar_stack_key('#C4D318', 'used', 13), new bar_stack_key('#7D7B6A', 'total', 13)));
    $bar_stack->set_on_click('(function(x){var services=' . json_encode($services) . ';alert(services[x]);})');
    //js
    $bar_stack->set_tooltip('#val#M,共#total#M');
    $y = new y_axis();
    $y->set_range(0, $max + 32, 256);
    $x = new x_axis();
    $x->set_labels_from_array($lables);
    $tooltip = new tooltip();
    $tooltip->set_hover();
    $chart = new open_flash_chart();
    $chart->set_title($title);
    $chart->add_element($bar_stack);
    $chart->set_x_axis($x);
    $chart->add_y_axis($y);
    $chart->set_tooltip($tooltip);
    return $chart->toPrettyString();
}
 function gsitedata()
 {
     $this->autoRender = false;
     $solid = $this->Session->read('sol');
     $host_id = $this->Session->read('host_id');
     $tinterval = 3600;
     $host_srch = "";
     if (!empty($host_id) && $host_id != 0) {
         $host_srch = " AND source_id = " . $host_id;
     }
     $this->DnsMessage->recursive = -1;
     $site_count = $this->DnsMessage->query('SELECT hostname, COUNT(*) FROM dns_messages WHERE sol_id = ' . $solid . $host_srch . ' GROUP BY hostname ORDER BY COUNT(*) DESC LIMIT 50');
     //sort($site_count);
     $data = array();
     $x = array();
     $max_resp = 0;
     foreach ($site_count as $site) {
         $data[] = array((int) $site[0]['COUNT(*)'], 0);
         if ($max_resp < (int) $site[0]['COUNT(*)']) {
             $max_resp = (int) $site[0]['COUNT(*)'];
         }
         if (empty($site[0]['hostname'])) {
             $x[] = (string) $site['dns_messages']['hostname'];
         } else {
             $x[] = (string) $site[0]['hostname'];
         }
     }
     // joson data format
     $title = new title(__("Host Popularity", true));
     $title->set_style("{font-size: 14px; color: #990000; text-align: center; font-weight:bold;}");
     $bar = new bar_stack();
     $bar->set_colours(array('#e77919', '#577261'));
     $bar->set_on_show(new bar_on_show('grow-up', 0, 0.5));
     $bar->set_values($data);
     $bar->set_tooltip('Host: #x_label#<br>Response #val#<br>');
     $tooltip = new tooltip();
     $tooltip->set_hover();
     $tooltip->set_shadow(false);
     $tooltip->set_stroke(5);
     $tooltip->set_colour("#6E604F");
     $tooltip->set_background_colour("#BDB396");
     $data_labels = new x_axis_labels();
     $data_labels->rotate(90);
     $data_labels->set_labels($x);
     $x_axis = new x_axis();
     $x_axis->set_labels($data_labels);
     $y = new y_axis();
     $y->set_range(0, $max_resp * 1.1, (int) ($max_resp / 10));
     $chart = new open_flash_chart();
     $chart->set_bg_colour('#F9F9F9');
     $chart->set_title($title);
     $chart->add_element($bar);
     $chart->set_x_axis($x_axis);
     $chart->set_y_axis($y);
     $chart->set_tooltip($tooltip);
     // menu'
     $m = new ofc_menu("#f0E0ff", "#878787");
     $m->values(array(new ofc_menu_item(__('DNS Response', true), 'go_gpage')));
     $chart->set_menu($m);
     header("Content-Type: text/plain");
     echo $chart->toPrettyString();
     die;
 }
Exemple #9
0
function generateStats($params)
{
    global $reportCacheLocation;
    // Computer Statistics Generation
    $dbTrackHandler = connectDb();
    $resultBag = generateStatsBag($params, $dbTrackHandler);
    // ----------------------------------------------------
    // Generate charts
    $animation_1 = isset($params['animation_1']) ? $params['animation_1'] : 'pop';
    $delay_1 = isset($params['delay_1']) ? $params['delay_1'] : 0.5;
    $cascade_1 = isset($params['cascade_1']) ? $params['cascade_1'] : 1;
    $title = new title("Genie Report: " . $params['reportName'] . " - Generated on " . date('Y/m/d h:i:s A'));
    $title->set_style("{font-size: 12px; color: #000000; text-align: center;}");
    $bar_stack = new bar_stack();
    if ($params['reportType'] == 'computerStats') {
        foreach ($resultBag as $elm) {
            $tmpTotal = $elm[AVAIBILITY_TYPE_OFFLINE] + $elm[AVAIBILITY_TYPE_AVAILABLE] + $elm[AVAIBILITY_TYPE_BUSY];
            if ($tmpTotal == 0) {
                $tmpTotal = 1;
            }
            // Only Chuck Norris can divide by Zero.
            $bar_stack->append_stack(array($elm[AVAIBILITY_TYPE_OFFLINE] / $tmpTotal * 100, $elm[AVAIBILITY_TYPE_AVAILABLE] / $tmpTotal * 100, $elm[AVAIBILITY_TYPE_BUSY] / $tmpTotal * 100));
        }
        $bar_stack->set_colours(array('#FF0000', '#00FF00', '#A25B00'));
        $bar_stack->set_keys(array(new bar_stack_key('#FF0000', 'OFFLINE', 13), new bar_stack_key('#00FF00', 'FREE', 13), new bar_stack_key('#A25B00', 'BUSY', 13)));
    } else {
        $allProgNames = array();
        foreach ($resultBag as $elm) {
            $progNames = array_keys($elm);
            foreach ($progNames as $progName) {
                if (validProgram($progName)) {
                    if (!array_key_exists($progName, $allProgNames)) {
                        $allProgNames[$progName] = "#" . dechex(rand(0, 10000000));
                    }
                }
            }
        }
        $progsArray = array();
        foreach ($resultBag as $elm) {
            $tmpTotal = 0;
            $progNames = array_keys($elm);
            foreach ($elm as $programName => $programWeight) {
                if (validProgram($programName)) {
                    $tmpTotal += $programWeight;
                }
            }
            //echo "<h1>$tmpTotal</h1>";
            if ($tmpTotal == 0) {
                $tmpTotal = 1;
            }
            // Only Chuck Norris can divide by Zero.
            $progs = array();
            foreach ($elm as $programName => $programWeight) {
                if (validProgram($programName)) {
                    $percentVal = $programWeight / $tmpTotal * 100;
                    $progs[] = new bar_stack_value($percentVal, $allProgNames[$programName]);
                    $progsArray[$percentVal * 1000000] = $programName;
                }
            }
            $bar_stack->append_stack($progs);
        }
        $legends = array();
        //$strAllProgNames = array_keys($allProgNames);
        foreach ($allProgNames as $programName => $programColor) {
            $legends[] = new bar_stack_key($programColor, $programName, 13);
        }
        $bar_stack->set_keys($legends);
        ksort($progsArray);
        echo "<pre>";
        while (list($key, $value) = each($progsArray)) {
            $kw = $key / 1000000;
            echo "{$kw}: {$value}<br />\n";
        }
        echo "</pre>";
    }
    //$bar_stack->set_tooltip( 'In #x_label# you get #total# days holiday a year.<br>Number of days: #val#' );
    $bar_stack->set_on_show(new bar_on_show($animation_1, $cascade_1, $delay_1));
    $y = new y_axis();
    $y->set_range(0, 100, 10);
    //$y->set_range( 0, $tmpMax, $tmpMax/10 );
    $x_labels = new x_axis_labels();
    $x_labels->rotate(45);
    $x_labels->set_labels(array_keys($resultBag));
    $x = new x_axis();
    $x->set_labels($x_labels);
    $tooltip = new tooltip();
    $tooltip->set_hover();
    $chart = new open_flash_chart();
    $chart->set_title($title);
    $chart->add_element($bar_stack);
    $chart->set_x_axis($x);
    $chart->add_y_axis($y);
    $chart->set_tooltip($tooltip);
    // ----------------------------------------------------
    $cacheid = time();
    $filename = $cacheid . '.cache.json';
    $myFile = "{$reportCacheLocation}/reports-cache/" . $filename;
    $fh = fopen($myFile, 'w') or die("can't open file");
    fwrite($fh, $chart->toPrettyString());
    fclose($fh);
    return $cacheid;
}