Example #1
0
$user_line->colour('#0099cc');
$user_line->set_key('User', 14);
$grp_line = new line();
$grp_line->set_values($groups_added);
$grp_line->colour('#990000');
$grp_line->set_key('Groups', 14);
$max = $max;
$steps = round($max / 5, 0.49);
$y = new y_axis();
$y->set_range(0, $max, $steps);
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($vid_line);
$chart->add_element($user_line);
$chart->add_element($grp_line);
$x_labels = new x_axis_labels();
$x_labels->set_steps(1);
$x_labels->set_vertical();
$x_labels->set_colour('#A2ACBA');
$x_labels->set_labels($year);
$x = new x_axis();
$x->set_colour('#A2ACBA');
$x->set_grid_colour('#D7E4A3');
$x->set_offset(false);
$x->set_steps(4);
// Add the X Axis Labels to the X Axis
$x->set_labels($x_labels);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
echo $chart->toString();
Example #2
0
<?php

require_once 'php-ofc-library/open-flash-chart.php';
// generate some random data
srand((double) microtime() * 1000000);
$max = 20;
$tmp = array();
for ($i = 0; $i < 13; $i++) {
    $tmp[] = rand(0, $max);
}
$title = new title(date("D M d Y"));
$bar = new bar();
$bar->set_values(array(3, 2, 3, 4, 5, 6, 7, 8, 9, 3, 12, 4));
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$path = "data.json.inc";
$file = fopen($path, "w");
fwrite($file, $chart->toString());
fclose($file);
Example #3
0
 /**
  * assign the chartdata object for open flash chart library
  * @param $config
  * @return unknown_type
  */
 function _setChartdata($config)
 {
     $model = $this->getModel();
     $rounds = $this->get('Rounds');
     $round_labels = array();
     foreach ($rounds as $r) {
         $round_labels[] = $r->name;
     }
     $division = $this->get('division');
     $data = $model->getDataByDivision($division->id);
     //create a line
     $length = count($rounds) - 0.5;
     $linewidth = $config['color_legend_line_width'];
     $lines = array();
     //$title = $division->name;
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->set_bg_colour($config['bg_colour']);
     //colors defined for ranking table lines
     //todo: add support for more than 2 lines
     foreach ($this->colors as $color) {
         foreach ($rounds as $r) {
             for ($n = $color['from']; $n <= $color['to']; $n++) {
                 $lines[$color['color']][$n][] = $n;
             }
         }
     }
     //set lines on the graph
     foreach ($lines as $key => $value) {
         foreach ($value as $line => $key2) {
             $chart->add_element(hline($key, $length, $line, $linewidth));
         }
     }
     //load team1, first team in the dropdown
     $team = $this->team1;
     $d = new $config['dotstyle_1']();
     $d->size((int) $config['line1_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line1']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($team->rankings);
     $line->set_width((int) $config['line1_strength']);
     $line->set_key($team->name, 12);
     $line->set_colour($config['line1']);
     $line->on_show(new line_on_show($config['l_animation_1'], $config['l_cascade_1'], $config['l_delay_1']));
     $chart->add_element($line);
     //load team2, second team in the dropdown
     $team = $this->team2;
     $d = new $config['dotstyle_2']();
     $d->size((int) $config['line2_dot_strength']);
     $d->halo_size(1);
     $d->colour($config['line2']);
     $d->tooltip('Rank: #val#');
     $line = new line();
     $line->set_default_dot_style($d);
     $line->set_values($team->rankings);
     $line->set_width((int) $config['line2_strength']);
     $line->set_key($team->name, 12);
     $line->set_colour($config['line2']);
     $line->on_show(new line_on_show($config['l_animation_2'], $config['l_cascade_2'], $config['l_delay_2']));
     $chart->add_element($line);
     $x = new x_axis();
     if ($config['x_axis_label'] == 1) {
         $xlabels = new x_axis_labels();
         $xlabels->set_labels($round_labels);
         $xlabels->set_vertical();
     }
     $x->set_labels($xlabels);
     $x->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $chart->set_x_axis($x);
     $x_legend = new x_legend(JText::_('COM_JOOMLEAGUE_CURVE_ROUNDS'));
     $x_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_x_legend($x_legend);
     $y = new y_axis();
     $y->set_range(count($data), 1, -1);
     $y->set_colours($config['x_axis_colour'], $config['x_axis_colour_inner']);
     $chart->set_y_axis($y);
     $y_legend = new y_legend(JText::_('COM_JOOMLEAGUE_CURVE_RANK'));
     $y_legend->set_style('{font-size: 15px; color: #778877}');
     $chart->set_y_legend($y_legend);
     ob_clean();
     echo $chart->toString();
 }
Example #4
0
    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;
    }
Example #5
0
/** flowview_viewchart()
 *
 *  This function is taken from Slowlog.  Given
 *  a title, chart type and chart data, it will
 *  echo the required syntax for the Callback
 *  from the chart page to operate corectly.
 */
function flowview_viewchart()
{
    global $colors, $config;
    include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart-object.php";
    include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart.php";
    $title = $_REQUEST["title"];
    $chart_type = "bar";
    $column = $_REQUEST["type"];
    $sessionid = $_REQUEST["session"];
    /* get the chart data from the session */
    if (isset($_SESSION['flowview_flows'][$sessionid]['data'])) {
        $data = $_SESSION['flowview_flows'][$sessionid]['data'];
    } else {
        $filter = createfilter($sessionid);
        $data = $_SESSION['flowview_flows'][$sessionid]['data'];
    }
    switch ($column) {
        case 'flows':
            $unit = ucfirst($column);
            $suffix = "Total Flows";
            $_SESSION['sess_flows_flows'] = 'on';
            break;
        case 'bytes':
            $unit = ucfirst($column);
            $suffix = "Bytes Exchanged";
            $_SESSION['sess_flows_bytes'] = 'on';
            break;
        case 'packets':
            $unit = ucfirst($column);
            $suffix = "Packets Examined";
            $_SESSION['sess_flows_packets'] = 'on';
            break;
    }
    $columns = $_SESSION['flowview_flows'][$sessionid]['columns'];
    foreach ($columns as $key => $cdata) {
        if (strtolower($cdata) == $column) {
            $column = $key;
        }
    }
    if (sizeof($data)) {
        $elements = array();
        $legend = array();
        $maxvalue = 0;
        if (isset($_REQUEST['exclude']) && $_REQUEST['exclude'] > 0) {
            for ($i = 0; $i < $_REQUEST['exclude']; $i++) {
                array_shift($data);
            }
        }
        foreach ($data as $row) {
            if ($maxvalue < $row[$column]) {
                $maxvalue = $row[$column];
                $scaling = flowview_autoscale($row[$column]);
            }
        }
        $maxvalue = flowview_getmax($maxvalue);
        $autorange = flowview_autoscale($maxvalue);
        $maxvalue = $maxvalue / $autorange[0];
        $i = 0;
        foreach ($data as $row) {
            $elements[$i] = new bar_value(round($row[$column] / $autorange[0], 3));
            $elements[$i]->set_colour(flowview_get_color());
            $elements[$i]->set_tooltip($unit . ": #val# " . $autorange[1]);
            if (sizeof($row) == 4) {
                $legend[] = $row[0];
            } else {
                $legend[] = $row[0] . " -\n" . $row[1];
            }
            $i++;
        }
        $bar = new bar_glass();
        $bar->set_values($elements);
        $title = new title($title . " (" . $suffix . ")");
        $title->set_style("{font-size: 18px; color: #444444; text-align: center;}");
        $x_axis_labels = new x_axis_labels();
        $x_axis_labels->set_size(10);
        $x_axis_labels->rotate(45);
        $x_axis_labels->set_labels($legend);
        $x_axis = new x_axis();
        //$x_axis->set_3d( 3 );
        $x_axis->set_colours('#909090', '#909090');
        $x_axis->set_labels($x_axis_labels);
        $y_axis = new y_axis();
        $y_axis->set_offset(true);
        $y_axis->set_colours('#909090', '#909090');
        $y_axis->set_range(0, $maxvalue, $maxvalue / 10);
        $y_axis->set_label_text("#val# " . $autorange[1]);
        $chart = new open_flash_chart();
        $chart->set_title($title);
        $chart->add_element($bar);
        $chart->set_x_axis($x_axis);
        $chart->add_y_axis($y_axis);
        $chart->set_bg_colour('#FEFEFE');
        echo $chart->toString();
    }
}
Example #6
0
 function loadaverage()
 {
     sleep(1);
     $uptime = trim(shell_exec("cat /proc/uptime  |awk '{print \$1}' |cut -d '.' -f 1"));
     $load_average_1min = trim(shell_exec("cat /proc/loadavg |awk '{print \$1}'"));
     $load_average_5min = trim(shell_exec("cat /proc/loadavg |awk '{print \$2}'"));
     $load_average_15min = trim(shell_exec("cat /proc/loadavg |awk '{print \$3}'"));
     if ($load_average_1min <= 1) {
         $stats = '当前系统空闲';
     } elseif ($load_average_1min <= 4) {
         $stats = '当前系统正常';
     } else {
         $stats = '当前系统繁忙';
     }
     $days = floor($uptime / 86400);
     $hours = floor($uptime % 86400 / 3600);
     $minutes = floor($uptime % 3600 / 60);
     $title = new title("系统平均负载\n{$stats}");
     $title->set_style("{font-size: 12px; font-family: Times New Roman; font-weight: bold; color: #A2ACBA; text-align: center;}");
     settype($load_average_1min, "float");
     settype($load_average_5min, "float");
     settype($load_average_15min, "float");
     $load_average = array($load_average_1min, $load_average_5min, $load_average_15min);
     function colour($value)
     {
         if ($value <= 1) {
             $colour = "#339900";
         } elseif ($value <= 4) {
             $colour = "#FFFF00";
         } else {
             $colour = "#FF0033";
         }
         return $colour;
     }
     if (max($load_average) <= 0.5) {
         $y_axis_max = 0.5;
     } elseif (max($load_average) <= 1) {
         $y_axis_max = 1;
     } elseif (max($load_average) <= 5) {
         $y_axis_max = 5;
     } elseif (max($load_average) <= 10) {
         $y_axis_max = 10;
     } elseif (max($load_average) <= 50) {
         $y_axis_max = 50;
     } else {
         $y_axis_max = 100;
     }
     $y_axis_step = $y_axis_max / 5;
     if ($load_average_1min == 0) {
         $data[0] = new bar_value($y_axis_max / 100);
         $data[0]->set_colour(colour($load_average_1min));
         $data[0]->set_tooltip(0);
     } else {
         $data[0] = new bar_value($load_average_1min);
         $data[0]->set_colour(colour($load_average_1min));
         $data[0]->set_tooltip('#val#');
     }
     if ($load_average_5min == 0) {
         $data[1] = new bar_value($y_axis_max / 100);
         $data[1]->set_colour(colour($load_average_5min));
         $data[1]->set_tooltip(0);
     } else {
         $data[1] = new bar_value($load_average_5min);
         $data[1]->set_colour(colour($load_average_5min));
         $data[1]->set_tooltip('#val#');
     }
     if ($load_average_15min == 0) {
         $data[2] = new bar_value($y_axis_max / 100);
         $data[2]->set_colour(colour($load_average_15min));
         $data[2]->set_tooltip(0);
     } else {
         $data[2] = new bar_value($load_average_15min);
         $data[2]->set_colour(colour($load_average_15min));
         $data[2]->set_tooltip('#val#');
     }
     $bar = new bar_glass();
     $bar->set_values($data);
     $x = new x_axis();
     $x->set_labels_from_array(array('1分钟', '5分钟', '15分钟'));
     $y = new y_axis();
     $y->set_range(0, $y_axis_max, $y_axis_step);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->add_element($bar);
     $chart->set_bg_colour('#FFFFFF');
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     $x_legend = new x_legend("系统当前已运行 {$days} 天 {$hours} 小时 {$minutes} 分钟");
     $x_legend->set_style('{font-size: 12px; color: #778877}');
     $chart->set_x_legend($x_legend);
     header("Cache-Control: cache, must-revalidate");
     header("Pragma: public");
     echo $chart->toString();
 }
Example #7
0
function siremis_get_chart_data($groupId, $chartId, $debug = 0)
{
    global $g_BizSystem;
    $cgobj = $g_BizSystem->GetService("ser.service.siremisCharts");
    $cgrp = $cgobj->GetChartGroup($groupId);
    if ($debug == 1) {
        echo "Chart found {$id} :: " . $cgobj->GetChartGroupCount() . " ::: ";
    }
    $chart = $cgrp->GetChart($chartId);
    if (!$chart) {
        echo "Chart not found {$id}\n";
        exit;
    }
    if ($debug == 1) {
        echo "Chart :: " . $cgrp->GetChartCount() . " ::: ";
    }
    $sql = "SELECT * ";
    $xydata = array();
    // XAxis
    $xax = $chart->GetXAxisList();
    foreach ($xax as $it) {
        $sql = "SELECT " . $it->GetXYData();
        $xydata[0] = $it;
    }
    // YAxis
    $yax = $chart->GetYAxisList();
    $yn = 0;
    foreach ($yax as $it) {
        $sql .= "," . $it->GetXYData();
        $yn = $yn + 1;
        $xydata[$yn] = $it;
    }
    if ($debug == 1) {
        echo "::::::: {$yn} ::: " . $chart->GetYAxisCount();
    }
    $sql .= " FROM " . $chart->GetTable();
    if ($chart->GetOrderBy() && $chart->GetOrderBy() != "") {
        $sql .= " " . $chart->GetOrderBy();
    }
    if ($chart->GetLimit() && $chart->GetLimit() != "") {
        $sql .= " " . $chart->GetLimit();
    }
    // " ORDER BY id DESC LIMIT 30";
    $db = $g_BizSystem->GetDBConnection("Serdb");
    $resultSet = $db->query($sql);
    if ($resultSet === false) {
        $err = $db->ErrorMsg();
        echo $err;
        exit;
    }
    $xdata = array();
    $ydata = array();
    for ($i = 0; $i < $yn; $i = $i + 1) {
        $ydata[$i] = array();
    }
    $k = 0;
    $ymin = 0;
    $ymax = 0;
    while ($row = $resultSet->fetch()) {
        $xdata[$k] = $row[0];
        for ($i = 0; $i < $yn; $i = $i + 1) {
            $ydata[$i][$k] = 0 + $row[$i + 1];
            if ($k == 0) {
                $ymin = $ydata[$i][$k];
                $ymax = $ydata[$i][$k];
            } else {
                if ($ydata[$i][$k] < $ymin) {
                    $ymin = $ydata[$i][$k];
                }
                if ($ydata[$i][$k] > $ymax) {
                    $ymax = $ydata[$i][$k];
                }
            }
        }
        $k = $k + 1;
    }
    $ofcobj = new open_flash_chart();
    $ctitle = $chart->GetTitle();
    $rev = 0;
    if ($chart->GetOrder() && $chart->GetOrder() == "reverse") {
        $rev = 1;
    }
    $x = new x_axis();
    $xstep = (int) ($k / 20);
    if ($k % 20 != 0) {
        $xstep = $xstep + 1;
    }
    $x->set_steps($xstep);
    if ($xydata[0]->getXYType() == "timestamp") {
        if ($rev == 1) {
            $time_min = $xdata[$k - 1];
            $time_max = $xdata[0];
        } else {
            $time_min = $xdata[0];
            $time_max = $xdata[$k - 1];
        }
        $ctitle .= " - From " . date('Y-m-d H:i:s', $time_min);
        $ctitle .= " To " . date('Y-m-d H:i:s', $time_max);
        $time_x_labels = new x_axis_labels();
        $time_x_labels->rotate(20);
        $chart_lbls = array();
        for ($i = 0; $i < $k; $i = $i + 1) {
            if ($rev == 0) {
                $chart_lbls[] = date('H:i', $xdata[$i]);
            } else {
                $chart_lbls[] = date('H:i', $xdata[$k - $i - 1]);
            }
        }
        $time_x_labels->visible_steps($xstep);
        $time_x_labels->set_labels($chart_lbls);
        $x->set_labels($time_x_labels);
    } else {
        $time_x_labels->visible_steps($xstep);
        if ($rev == 1) {
            $ctitle .= " - From " . $xdata[$k - 1] . " To " . $xdata[0];
        } else {
            $ctitle .= " - From " . $xdata[0] . " To " . $xdata[$k - 1];
        }
    }
    $ofcobj->set_title(new title($ctitle));
    $dot_style = new dot();
    $dot_style->size(3)->halo_size(1);
    for ($i = 0; $i < $yn; $i++) {
        if ($chart->GetChartType() == "area") {
            $line[$i] = new area();
            $line[$i]->set_fill_alpha(0.3);
            $line[$i]->set_default_dot_style($dot_style);
        } else {
            if ($chart->GetChartType() == "line_dot") {
                $line[$i] = new line_dot();
                $line[$i]->set_default_dot_style($dot_style);
            } else {
                $line[$i] = new line();
                $line[$i]->set_default_dot_style($dot_style);
            }
        }
        if ($xydata[$i + 1]->GetXYColor() && $xydata[$i + 1]->GetXYColor() != "") {
            $line[$i]->set_colour($xydata[$i + 1]->GetXYColor());
        }
        if ($xydata[$i + 1]->GetXYTitle() && $xydata[$i + 1]->GetXYTitle() != "") {
            $line[$i]->set_key($xydata[$i + 1]->GetXYTitle(), 10);
        } else {
            $line[$i]->set_key("Key " . $i, 10);
        }
        if ($rev == 1) {
            $line[$i]->set_values(array_reverse($ydata[$i]));
        } else {
            $line[$i]->set_values($ydata[$i]);
        }
        $ofcobj->add_element($line[$i]);
    }
    if ($ymax > 10) {
        $y = new y_axis();
        if ($ymin > 10) {
            $y->set_range($ymin - 10, $ymax, (int) (($ymax - $ymin + 10) / 10));
        } else {
            $y->set_range(0, $ymax, (int) ($ymax / 10));
        }
        $ofcobj->set_y_axis($y);
    }
    $ofcobj->set_x_axis($x);
    if ($chart->GetBGColor() && $chart->GetBGColor() != "") {
        $ofcobj->set_bg_colour($chart->GetBGColor());
    }
    // return $ofcobj->toPrettyString();
    return $ofcobj->toString();
}
Example #8
0
 private static function make_bandwidth_chart($values, $options = array())
 {
     if (!$values || !count($values)) {
         return false;
     }
     $title = !empty($options['title']) ? $options['title'] : 'Chart';
     //array_check_value($options, 'title', 'BI Chart');
     $step = !empty($options['step']) ? $options['step'] : 0.75;
     //array_check_value($options, 'step', 0.75);
     $max = !empty($options['max']) ? $options['max'] : 0;
     //array_check_value($options, 'max', 0);
     $value_mod = !empty($options['value_modifier']) ? $options['value_modifier'] : 1;
     //array_check_value($options, 'value_modifier', 1);
     $input_title = !empty($options['input_title']) ? $options['input_title'] : 'Downloads for :key: #val#';
     //array_check_value($options, 'input_title', 'Downloads for :key: #val#');
     $output_title = !empty($options['output_title']) ? $options['output_title'] : 'Uploads for :key: #val#';
     //array_check_value($options, 'output_title', 'Uploads for :key: #val#');
     $total_title = !empty($options['total_title']) ? $options['total_title'] : 'Total for :key: #val#';
     //array_check_value($options, 'total_title', 'Total for :key: #val#');
     $on_click = !empty($options['on_click']) ? $options['on_click'] : false;
     //array_check_value($options, 'on_click', false);
     $x_labels = !empty($options['x_labels']) ? $options['x_labels'] : array_keys($values);
     //array_check_value($options, 'x_labels', array_keys($values));
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_title.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/open-flash-chart.php';
     //include(APP_FOLDER . '/libraries/php-ofc-library/ofc_bar_glass_value.php');
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_line_dot.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_line_base.php';
     include_once APP_FOLDER . '/libraries/php-ofc-library/ofc_x_axis.php';
     $title = new title($title);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $input = array();
     $ouput = array();
     $total = array();
     $clicks = array();
     foreach ($values as $key => $value) {
         $this_value = (double) number_format($value['input'] / $value_mod, 2, '.', '');
         $tmp = new bar_glass_value($this_value);
         $tmp->set_tooltip(preg_replace('/:key/', $key, $input_title));
         $input[] = $tmp;
         $this_value = (double) number_format($value['output'] / $value_mod, 2, '.', '');
         $tmp = new bar_glass_value($this_value);
         $tmp->set_tooltip(preg_replace('/:key/', $key, $output_title));
         $output[] = $tmp;
         $this_value = (double) number_format(($value['input'] + $value['output']) / $value_mod, 2, '.', '');
         $tmp = new dot_value($this_value, '#000066');
         $tmp->set_tooltip(preg_replace('/:key/', $key, $total_title));
         $total[] = $tmp;
         if ($on_click) {
             $tmp = (double) number_format(($value['input'] + $value['output']) / $value_mod, 2, '.', '');
             $clicks[] = $tmp;
         }
         $max = ceil(max(($value['input'] + $value['output']) / $value_mod, $max));
     }
     $x_axis = new x_axis();
     $x_axis->set_labels_from_array($x_labels);
     $x_axis->set_3d(5);
     $x_axis->colour = '#909090';
     if ($max > 0) {
         //Don't know why we sometimes get a division by zero error
         @($max = $max + ($step - $max % $step));
     }
     if ($max / $step > 5) {
         $step = floor($max / 5);
     } else {
         if ($max / $step <= 1) {
             $step = floor($max / 2);
         }
     }
     $y_axis = new y_axis();
     $y_axis->set_range(0, $max, $step);
     $input_bar = new bar_glass();
     $input_bar->set_values($input);
     $input_bar->colour = '#D54C78';
     $output_bar = new bar_glass();
     $output_bar->set_values($output);
     $output_bar->colour = '#78D54C';
     $total_graph = new line_hollow();
     $total_graph->set_colour('#9999FF');
     $total_graph->set_values($total);
     if ($on_click) {
         $click_graph = new line();
         $click_graph->set_values($clicks);
         $click_graph->set_on_click($on_click);
         $chart->add_element($click_graph);
     }
     $chart->set_x_axis($x_axis);
     $chart->set_y_axis($y_axis);
     $chart->add_element($input_bar);
     $chart->add_element($output_bar);
     $chart->add_element($total_graph);
     //$decoded = json_decode($chart->toString());
     return $chart->toString();
 }
Example #9
0
    protected function renderHTML()
    {
        global $g_BizSystem;
        include_once MODULE_PATH . '/ser/config/cms.ChartsStatsAccCfg.php';
        $fetchInterval = $cfg_stats_acc_fetch_interval;
        $sql = "SELECT method, sip_code, time, UNIX_TIMESTAMP(time) as tstamp FROM acc WHERE DATE_SUB(NOW(), INTERVAL " . $fetchInterval . " HOUR) <= time";
        $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;
        $acc_records = array();
        $acc_records['invite'] = array();
        $acc_records['bye'] = array();
        $acc_records['message'] = array();
        $acc_records['other'] = array();
        $acc_records['invite200'] = array();
        $acc_records['invite404'] = array();
        $acc_records['invite487'] = array();
        $acc_records['inviteXYZ'] = array();
        for ($i = 0; $i <= $fetchInterval; $i++) {
            $acc_records['invite'][$i] = 0;
            $acc_records['bye'][$i] = 0;
            $acc_records['message'][$i] = 0;
            $acc_records['other'][$i] = 0;
            $acc_records['invite200'][$i] = 0;
            $acc_records['invite404'][$i] = 0;
            $acc_records['invite487'][$i] = 0;
            $acc_records['inviteXYZ'][$i] = 0;
        }
        $ymax = 0;
        $ymin = 0xfffffff;
        $yidx = 0;
        $ousr = 0;
        $ctime = time();
        $stime = $ctime - 3600 * $fetchInterval;
        while ($row = $resultSet->fetch()) {
            $r_method = $row[0];
            $r_sip_code = $row[1];
            $r_time = $row[2];
            $r_tstamp = $row[3];
            $idx = (int) (($r_tstamp - $stime) / 3600);
            /* method stats */
            if (isset($r_method)) {
                if ($r_method == "INVITE") {
                    $acc_records['invite'][$idx] = $acc_records['invite'][$idx] + 1;
                    if ($r_sip_code == "200") {
                        $acc_records['invite200'][$idx] = $acc_records['invite200'][$idx] + 1;
                    } else {
                        if ($r_sip_code == "404") {
                            $acc_records['invite404'][$idx] = $acc_records['invite404'][$idx] + 1;
                        } else {
                            if ($r_sip_code == "487") {
                                $acc_records['invite487'][$idx] = $acc_records['invite487'][$idx] + 1;
                            } else {
                                $acc_records['inviteXYZ'][$idx] = $acc_records['inviteXYZ'][$idx] + 1;
                            }
                        }
                    }
                } else {
                    if ($r_method == "BYE") {
                        $acc_records['bye'][$idx] = $acc_records['bye'][$idx] + 1;
                    } else {
                        if ($r_method == "MESSAGE") {
                            $acc_records['message'][$idx] = $acc_records['message'][$idx] + 1;
                        } else {
                            $acc_records['other'][$idx] = $acc_records['other'][$idx] + 1;
                        }
                    }
                }
            }
            $yidx = $yidx + 1;
        }
        /* sip method types chart */
        $mtsobj = new open_flash_chart();
        $ctitle = "SIP Method Types";
        $x = new x_axis();
        $xstep = (int) ($fetchInterval / 12);
        if ($fetchInterval % 2 != 0) {
            $xstep = $xstep + 1;
        }
        $x->set_steps($xstep);
        $time_min = $stime;
        $time_max = $ctime;
        $ctitle .= " - From " . date('Y-m-d H:i:s', $time_min);
        $ctitle .= " To " . date('Y-m-d H:i:s', $time_max);
        $time_x_labels = new x_axis_labels();
        $time_x_labels->rotate(20);
        $chart_lbls = array();
        for ($i = 0; $i < $fetchInterval; $i = $i + 1) {
            $chart_lbls[] = date('H:i', $stime + 3600 * $i);
        }
        $time_x_labels->visible_steps($xstep);
        $time_x_labels->set_labels($chart_lbls);
        $x->set_labels($time_x_labels);
        $mtsobj->set_title(new title($ctitle));
        $dot_style = new dot();
        $dot_style->size(3)->halo_size(1);
        $clr = 0;
        $i = 0;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("INVITE", 10);
        $line[$i]->set_values($acc_records['invite']);
        $mtsobj->add_element($line[$i]);
        $i++;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("BYE", 10);
        $line[$i]->set_values($acc_records['bye']);
        $mtsobj->add_element($line[$i]);
        $i++;
        if ($cfg_stats_acc_message) {
            $line[$i] = new line();
            $line[$i]->set_default_dot_style($dot_style);
            $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
            $line[$i]->set_key("MESSAGE", 10);
            $line[$i]->set_values($acc_records['message']);
            $mtsobj->add_element($line[$i]);
            $i++;
        }
        if ($cfg_stats_acc_other) {
            $line[$i] = new line();
            $line[$i]->set_default_dot_style($dot_style);
            $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
            $line[$i]->set_key("OTHER", 10);
            $line[$i]->set_values($acc_records['other']);
            $mtsobj->add_element($line[$i]);
            $i++;
        }
        $val = max($acc_records['invite']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = max($acc_records['bye']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        if ($cfg_stats_acc_message) {
            $val = max($acc_records['message']);
            if ($ymax < $val) {
                $ymax = $val;
            }
        }
        if ($cfg_stats_acc_other) {
            $val = max($acc_records['other']);
            if ($ymax < $val) {
                $ymax = $val;
            }
        }
        $val = min($acc_records['invite']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        $val = min($acc_records['bye']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        if ($cfg_stats_acc_message) {
            $val = min($acc_records['message']);
            if ($ymin > $val) {
                $ymin = $val;
            }
        }
        if ($cfg_stats_acc_other) {
            $val = min($acc_records['other']);
            if ($ymin > $val) {
                $ymin = $val;
            }
        }
        if ($ymax > 10) {
            $y = new y_axis();
            if ($ymin > 10) {
                $y->set_range($ymin - 10, $ymax, (int) (($ymax - $ymin + 10) / 10));
            } else {
                $y->set_range(0, $ymax, (int) ($ymax / 10));
            }
            $mtsobj->set_y_axis($y);
        }
        $mtsobj->set_x_axis($x);
        $mtsobj->set_bg_colour("#A0C0B0");
        /* sip invites chart */
        $ivsobj = new open_flash_chart();
        $ctitle = "SIP INVITEs";
        $ctitle .= " - From " . date('Y-m-d H:i:s', $time_min);
        $ctitle .= " To " . date('Y-m-d H:i:s', $time_max);
        $ivsobj->set_title(new title($ctitle));
        $ymax = 0;
        $ymin = 0xfffffff;
        $i = 0;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("200", 10);
        $line[$i]->set_values($acc_records['invite200']);
        $ivsobj->add_element($line[$i]);
        $i++;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("404", 10);
        $line[$i]->set_values($acc_records['invite404']);
        $ivsobj->add_element($line[$i]);
        $i++;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("487", 10);
        $line[$i]->set_values($acc_records['invite487']);
        $ivsobj->add_element($line[$i]);
        $i++;
        $line[$i] = new line();
        $line[$i]->set_default_dot_style($dot_style);
        $line[$i]->set_colour($chart_colors[$clr++ % $chart_colors_size]);
        $line[$i]->set_key("XYZ", 10);
        $line[$i]->set_values($acc_records['inviteXYZ']);
        $ivsobj->add_element($line[$i]);
        $i++;
        $val = max($acc_records['invite200']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = max($acc_records['invite404']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = max($acc_records['invite487']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = max($acc_records['inviteXYZ']);
        if ($ymax < $val) {
            $ymax = $val;
        }
        $val = min($acc_records['invite200']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        $val = min($acc_records['invite404']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        $val = min($acc_records['invite487']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        $val = min($acc_records['inviteXYZ']);
        if ($ymin > $val) {
            $ymin = $val;
        }
        if ($ymax > 10) {
            $y = new y_axis();
            if ($ymin > 10) {
                $y->set_range($ymin - 10, $ymax, (int) (($ymax - $ymin + 10) / 10));
            } else {
                $y->set_range(0, $ymax, (int) ($ymax / 10));
            }
            $ivsobj->set_y_axis($y);
        }
        $ivsobj->set_x_axis($x);
        $ivsobj->set_bg_colour("#C0C0A0");
        $sHTML = '';
        $sHTML .= '
			<div align="center">
				<p><b>Processed ' . $yidx . ' records. <br />Timezone: ' . date_default_timezone_get() . ' </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_acc_methods",
					"600", "300", "9.0.0", "expressInstall.swf",
					{"get-data":"get_data_acc_methods"} );
				swfobject.embedSWF(
					"' . APP_URL . '/modules/ser/pages/open-flash-chart.swf",
				   	"div_chart_acc_invites",
					"600", "300", "9.0.0", "expressInstall.swf",
					{"get-data":"get_data_acc_invites"} );
			</script> 
			';
            $sHTML .= '
			<br />
			<div align="center">
				<div id="div_chart_acc_methods">
				</div>
				<br />
				<br />
				<div id="div_chart_acc_invites">
				</div>
				<br />
				<br />
			</div>
			';
            $sHTML .= '
			<script type="text/javascript">
				function get_data_acc_methods()
				{
					data = \'' . $mtsobj->toString() . '\';
					return data;
				}
				function get_data_acc_invites()
				{
					data = \'' . $ivsobj->toString() . '\';
					return data;
				}
			</script>
			';
        }
        /* if $yidx */
        return $sHTML;
    }