Example #1
0
 function get_statistic()
 {
     $this->load->library('OpenFlashChartLib', NULL, 'OFCL');
     $data_1 = array();
     $data_2 = array();
     // generate 7 data points
     for ($i = 0; $i <= 7; $i++) {
         $x = mktime(0, 0, 0, date("m"), date("d") - $i, date('Y'));
         $param['sms_date'] = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $i, date("Y")));
         $param['user_id'] = $this->session->userdata('id_user');
         $y = $this->Kalkun_model->get_sms_used('date', $param);
         $data_1[] = new scatter_value($x, $y);
         $data_2[] = $y;
     }
     $def = new solid_dot();
     $def->size(4)->halo_size(0)->colour('#21759B')->tooltip('#date:d M y#<br>#val# SMS');
     $line = new scatter_line('#21759B', 3);
     $line->set_values($data_1);
     $line->set_default_dot_style($def);
     $line->set_key("SMS used in last 7 days", 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();
     if (max($data_2) > 0) {
         $max = max($data_2);
     } else {
         $max = 10;
     }
     $y->set_range(0, $max, 10);
     $chart = new open_flash_chart();
     //$chart->set_title( $title );
     $chart->add_element($line);
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     echo $chart->toPrettyString();
 }
	while ( $val = mssql_fetch_assoc( $query ) )	{
		$jumlah[] = $val[ 'jumlah' ];
		$bulan[] = getMonthName( $val[ 'bulan' ] );
		$total = $val[ 'total' ];
	}*/
$max = 0;
$title = new title('Jumlah Data Peserta KB Per Kelurahan, Total : ' . $total . ' ( ' . date("D M d Y") . ' ) ');
$title->set_style('{font-size:20px; color: #bcd6ff; margin:0px; background-color: #5E83BF;}');
$bar = new bar_3d();
$bar->set_values($jumlah);
$bar->colour = '#9999FF';
$bar->set_on_show(new bar_on_show('grow-up', 1, 0));
$labels = new x_axis_labels();
$labels->set_labels($kelurahan);
$labels->set_size(11);
$labels->rotate(315);
$y_base = new y_axis_base();
$y_base->set_range(0, $maxJumlah + round($maxJumlah / 2), round($maxJumlah / 10));
$x = new x_axis();
$x->set_labels($labels);
$x->set_3d(5);
$y = new y_axis();
$y->set_labels($y_labels);
$tags = new ofc_tags();
$tags->font('Verdana', 10)->colour('#000000')->align_x_center()->text('#y#');
$i = 0;
foreach ($jumlah as $j) {
    $tags->append_tag(new ofc_tag($i, $j));
    $i++;
}
$chart = new open_flash_chart();
Example #3
0
 /**
  * Build The Bar Gharph.
  *
  * @param  array  $params  assoc array of name/value pairs          
  *
  * @return object $chart   object of open flash chart.
  * @static
  */
 static function &barChart(&$params)
 {
     $chart = null;
     if (empty($params)) {
         return $chart;
     }
     $values = CRM_Utils_Array::value('values', $params);
     if (!is_array($values) || empty($values)) {
         return $chart;
     }
     // get the required data.
     $xValues = $yValues = array();
     foreach ($values as $xVal => $yVal) {
         $yValues[] = (double) $yVal;
         // we has to have x values as string.
         $xValues[] = (string) $xVal;
     }
     $chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart');
     //set y axis parameters.
     $yMin = 0;
     // calculate max scale for graph.
     $yMax = max($yValues);
     if ($mod = $yMax % str_pad(5, strlen($yMax) - 1, 0)) {
         $yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod;
     }
     $ySteps = $yMax / 5;
     // $bar = new bar( );
     // glass seem to be more cool
     $bar = new bar_glass();
     //set values.
     $bar->set_values($yValues);
     // call user define function to handle on click event.
     if ($onClickFunName = CRM_Utils_Array::value('on_click_fun_name', $params)) {
         $bar->set_on_click($onClickFunName);
     }
     // get the currency.
     require_once 'CRM/Utils/Money.php';
     $config =& CRM_Core_Config::singleton();
     $symbol = $config->defaultCurrencySymbol;
     // set the tooltip.
     $bar->set_tooltip("{$symbol} #val#");
     // create x axis label obj.
     $xLabels = new x_axis_labels();
     $xLabels->set_labels($xValues);
     // set angle for labels.
     if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) {
         $xLabels->rotate($xLabelAngle);
     }
     // create x axis obj.
     $xAxis = new x_axis();
     $xAxis->set_labels($xLabels);
     //create y axis and set range.
     $yAxis = new y_axis();
     $yAxis->set_range($yMin, $yMax, $ySteps);
     // create chart title obj.
     $title = new title($chartTitle);
     // create chart.
     $chart = new open_flash_chart();
     // add x axis w/ labels to chart.
     $chart->set_x_axis($xAxis);
     // add y axis values to chart.
     $chart->add_y_axis($yAxis);
     // set title to chart.
     $chart->set_title($title);
     // add bar element to chart.
     $chart->add_element($bar);
     // add x axis legend.
     if ($xName = CRM_Utils_Array::value('xname', $params)) {
         $xLegend = new x_legend($xName);
         $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_x_legend($xLegend);
     }
     // add y axis legend.
     if ($yName = CRM_Utils_Array::value('yname', $params)) {
         $yLegend = new y_legend($yName);
         $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_y_legend($yLegend);
     }
     return $chart;
 }
Example #4
0
    $datalist[] = 1 * $tmp[1];
    $labellist[] = $tmp[0];
}
//Prevent error on no data
if (count($datalist < 1)) {
    $datalist[] = 0;
    $labellist[] = 0;
}
$title = new title("Checking account forecast");
$default_dot = new dot();
$default_dot->tooltip('$#val#');
$line = new line();
$line->set_values($datalist);
$line->set_default_dot_style($default_dot);
$x_labels = new x_axis_labels();
$x_labels->rotate(45);
$x_labels->set_labels($labellist);
$x_labels->set_steps(3);
$x = new x_axis();
$x->set_labels($x_labels);
$y = new y_axis();
$y->set_range(min(min($datalist) - 10, 0), round(max($datalist) * 1.1));
$y->set_label_text("\$#val#");
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($line);
$chart->set_x_axis($x);
$chart->set_y_axis($y);
$chart->set_bg_colour('#FFFFFF');
echo $chart->toPrettyString();
?>
Example #5
0
 function getNewUsersByTime($timePhase, $fromDate = '', $toDate = '')
 {
     $this->load->library('ofc');
     $userId = $this->common->getUserId();
     $this->ofc->open_flash_chart();
     $this->ofc->set_bg_colour(CHART_BG_COLOR);
     $toTime = date("Y-m-d", strtotime("-1 day"));
     if ($timePhase == "7day") {
         $fromTime = date("Y-m-d", strtotime("-8 day"));
         $color = CHART_LINE_1;
         $key = "近7日新增用户";
         $title = new title("近7日新增用户统计");
     }
     if ($timePhase == "1month") {
         $title = new title("近30天新增用户统计");
         $fromTime = date("Y-m-d", strtotime("-31 day"));
         $color = CHART_LINE_2;
         $key = "近30天新增用户统计";
     }
     if ($timePhase == "3month") {
         $title = new title("近三个月新增用户统计");
         $fromTime = date("Y-m-d", strtotime("-92 day"));
         $color = CHART_LINE_3;
         $key = "近三个月新增用户统计";
     }
     if ($timePhase == "all") {
         $title = new title("所有新增用户统计");
         $fromTime = '1970-01-01';
         $color = CHART_LINE_4;
         $key = "所有新增用户统计";
     }
     if ($timePhase == "any") {
         $title = new title("所有新增用户统计");
         $fromTime = $fromDate;
         $toTime = $toDate;
         $color = CHART_LINE_4;
         $key = "所有新增用户统计";
     }
     $fromTime = $this->product->getUserStartDate($userId, $fromTime);
     $query = $this->newusermodel->getNewUsersByUserId($fromTime, $toTime, $userId);
     $data = array();
     $maxY = 0;
     $recordCount = $query->num_rows();
     $steps = $recordCount - 1 <= 10 ? 2 : (int) (((int) $recordCount - 1) / 10);
     $xlabelArray = array();
     if ($query != null && $query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             $dot = new dot();
             $dot->size(3)->halo_size(1)->colour($color);
             $dot->tooltip($row->startdate . " 新增" . $row->totalusers . "用户");
             $dot->value((int) $row->totalusers);
             if ((int) $row->totalusers > $maxY) {
                 $maxY = (int) $row->totalusers;
             }
             array_push($xlabelArray, date('y-m-d', strtotime($row->startdate)));
             array_push($data, $dot);
         }
     }
     $y = new y_axis();
     $y->set_range(0, $this->common->getMaxY($maxY), $this->common->getStepY($maxY));
     $x = new x_axis();
     $x->set_range(0, $recordCount > 1 ? $recordCount - 1 : 1);
     $x_labels = new x_axis_labels();
     $x_labels->set_steps($steps);
     $x_labels->set_vertical();
     $x_labels->set_colour(CHART_LABEL_COLOR);
     $x_labels->set_size(13);
     $x_labels->set_labels($xlabelArray);
     $x_labels->rotate(-25);
     $x->set_labels($x_labels);
     $x->set_steps(1);
     $this->ofc->set_y_axis($y);
     $this->ofc->set_x_axis($x);
     $dot = new dot();
     $dot->size(3)->halo_size(1)->colour($color);
     $line = new line();
     $line->set_default_dot_style($dot);
     $line->set_values($data);
     $line->set_width(2);
     $line->set_colour($color);
     $line->colour($color);
     $line->set_key($key, 12);
     $this->ofc->add_element($line);
     $title->set_style("{font-size: 14px; color:#000000; font-family: Verdana; text-align: center;}");
     // 		$x_legend = new x_legend("<a href=\"javascript:changeChartName('chartNewUser')\">新增用户</a> <a href=\"javascript:changeChartName('chartActiveUser')\">活跃用户</a> <a href=\"javascript:changeChartName('chartStartUser')\">启动用户</a>");
     // 		$this->ofc->set_x_legend( $x_legend );
     // 		$x_legend->set_style( '{font-size: 14px; color: #778877}' );
     $this->ofc->set_title($title);
     echo $this->ofc->toPrettyString();
 }
Example #6
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;
    }
 /**
  *
  * Set the xLabels
  * Note we can no longer set angle for labels as openFlashPlayer
  * doesn't seem to render it anymore - presumably after being upgraded
  *  I think the fonts would need to be embedded
  * @return object x_axis_labels
  */
 function setXLabels()
 {
     $xLabels = new x_axis_labels();
     $xLabels->set_labels($this->xlabels);
     $xLabels->set_size($this->xlabelSize);
     if ($this->xlabelAngle) {
         $xLabels->rotate($this->xlabelAngle);
     }
     return $xLabels;
 }
        }
    } else {
        $c = '#0066CC';
    }
    $tags->append_tag(new ofc_tag($x, $v, $c));
    $x++;
}
$chart = new open_flash_chart();
//$chart->set_bg_colour('#ffffff');
$chart->set_title($title);
$chart->add_element($bar);
$chart->add_element($tags);
//$chart->add_element( $bar2 );
$xal = new x_axis_labels();
$x_labels = array_keys($data);
$xal->rotate(20);
$xal->set_labels($x_labels);
$xal->set_size($xfs);
$xal->set_colour('#hhffhh');
$x = new x_axis();
$x->set_offset(true);
$x->set_labels($xal);
$x->set_3d(5);
$x->colour = '#909090';
//$x->set_labels_from_array( $x_labels );
$chart->set_x_axis($x);
$yal = new y_axis_labels();
$yal->set_size($yfs);
$y = new y_axis();
$y->set_labels($yal);
$y_max = ceil($y_max / $step) * $step;
Example #9
0
        } else {
            $c = '#066303';
        }
    } else {
        $c = '#066303';
    }
    $tags->append_tag(new ofc_tag($x, $v, $c));
    $x++;
}
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$chart->add_element($tags);
$xal = new x_axis_labels();
$x_labels = array_keys($data);
$xal->rotate(15);
//ROTATING GRAPH LABELS
$xal->set_labels($x_labels);
$xal->set_size($xfs);
$xal->set_colour('#hhffhh');
$x = new x_axis();
$x->set_offset(true);
$x->set_labels($xal);
$x->set_3d(5);
$x->colour = '#909090';
$chart->set_x_axis($x);
$yal = new y_axis_labels();
$yal->set_size($yfs);
$y = new y_axis();
$y->set_labels($yal);
$y_max = ceil($y_max / $step) * $step + 10;
 function get_daily_entries($form, $colors = false, $type = "DATE")
 {
     global $wpdb, $frmdb;
     if (!$colors) {
         $colors = array('#EF8C08', '#21759B', '#1C9E05');
     }
     $type = strtoupper($type);
     //Chart for Entries Submitted
     $values = array();
     $labels = array();
     if ($type == 'HOUR') {
         $start_timestamp = strtotime('-48 hours');
     } else {
         if ($type == 'MONTH') {
             $start_timestamp = strtotime('-1 year');
         } else {
             if ($type == 'YEAR') {
                 $start_timestamp = strtotime('-10 years');
             } else {
                 $start_timestamp = strtotime('-1 month');
             }
         }
     }
     $end_timestamp = time();
     if ($type == 'HOUR') {
         $query = "SELECT en.created_at as endate,COUNT(*) as encount FROM {$frmdb->entries} en WHERE en.created_at >= '" . date("Y-n-j H", $start_timestamp) . ":00:00' AND en.form_id={$form->id} GROUP BY endate";
     } else {
         $query = "SELECT DATE(en.created_at) as endate,COUNT(*) as encount FROM {$frmdb->entries} en WHERE en.created_at >= '" . date("Y-n-j", $start_timestamp) . " 00:00:00' AND en.form_id={$form->id} GROUP BY {$type}(en.created_at)";
     }
     $entries_array = $wpdb->get_results($query);
     $temp_array = $counts_array = $dates_array = array();
     // Refactor Array for use later on
     foreach ($entries_array as $e) {
         $e_key = $e->endate;
         if ($type == 'HOUR') {
             $e_key = date('Y-m-d H', strtotime($e->endate)) . ':00:00';
         } else {
             if ($type == 'MONTH') {
                 $e_key = date('Y-m', strtotime($e->endate)) . '-01';
             } else {
                 if ($type == 'YEAR') {
                     $e_key = date('Y', strtotime($e->endate)) . '-01-01';
                 }
             }
         }
         $temp_array[$e_key] = $e->encount;
     }
     // Get the dates array
     if ($type == 'HOUR') {
         for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60) {
             if (!in_array(date('Y-m-d H', $e) . ':00:00', $dates_array)) {
                 $dates_array[] = date('Y-m-d H', $e) . ':00:00';
             }
         }
         $date_format = get_option('time_format');
     } else {
         if ($type == 'MONTH') {
             for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24 * 25) {
                 if (!in_array(date('Y-m', $e) . '-01', $dates_array)) {
                     $dates_array[] = date('Y-m', $e) . '-01';
                 }
             }
             $date_format = 'F Y';
         } else {
             if ($type == 'YEAR') {
                 for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24 * 364) {
                     if (!in_array(date('Y', $e) . '-01-01', $dates_array)) {
                         $dates_array[] = date('Y', $e) . '-01-01';
                     }
                 }
                 $date_format = 'Y';
             } else {
                 for ($e = $start_timestamp; $e <= $end_timestamp; $e += 60 * 60 * 24) {
                     $dates_array[] = date("Y-m-d", $e);
                 }
                 $date_format = get_option('date_format');
             }
         }
     }
     // Make sure counts array is in order and includes zero click days
     foreach ($dates_array as $date_str) {
         if (isset($temp_array[$date_str])) {
             $counts_array[$date_str] = $temp_array[$date_str];
         } else {
             $counts_array[$date_str] = 0;
         }
     }
     foreach ($counts_array as $date => $count) {
         $labels[] = date_i18n($date_format, strtotime($date));
         $values[] = (int) $count;
     }
     if ($type == 'MONTH') {
         $title = __('Monthly Entries', 'formidable');
     } else {
         if ($type == 'YEAR') {
             $title = __('Yearly Entries', 'formidable');
         } else {
             if ($type == 'HOUR') {
                 $title = __('Hourly Entries', 'formidable');
             } else {
                 $title = __('Daily Entries', 'formidable');
             }
         }
     }
     $title = new title($title);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour($colors[0]);
     $line_1_default_dot->tooltip('#x_label#<br>#val# Entries');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($values);
     $line_1->set_colour($colors[1]);
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $chart->set_bg_colour('#FFFFFF');
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->rotate(340);
     $x_labels->set_labels($labels);
     if (count($labels) > 15) {
         $x_labels->visible_steps(2);
     }
     $x->set_labels($x_labels);
     $chart->set_x_axis($x);
     $y = new y_axis();
     if (!empty($values)) {
         $max = max($values) + 1;
         $step = ceil($max / 10);
         $y->set_range(0, $max, $step);
     }
     $chart->add_element($line_1);
     $chart->set_y_axis($y);
     return $chart->toPrettyString();
 }
Example #11
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;
    }
Example #12
0
 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;
 }
 public function clientimpressionAction()
 {
     ini_set('display_errors', 1);
     $frontController = Zend_Controller_Front::getInstance();
     $frontController->throwExceptions(true);
     // filter!
     if (!$this->clientdashboardfilter()) {
         return;
     }
     $this->view->activeTab = 'clientimpression';
     include 'open-flash-chart.php';
     $request = $this->getRequest();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $campaign_id = $formData['campaign_id'];
     } else {
         $campaign_id = $request->getParam('id');
     }
     $this->_helper->layout->setLayout($this->getCampaignTemplate($campaign_id));
     $this->view->campaign_id = $campaign_id;
     // get date from db
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('report', array('left(create_date,10) as date', 'accesscode'))->where('report.campaign_id = ?', $campaign_id)->where('report.state = "APPROVED"')->order('date');
     $results = $db->fetchAll($select);
     $accesscodeDbMatchArray = array();
     foreach ($results as $result) {
         $accesscodeDbMatchArray[$result['accesscode']] = $result['date'];
     }
     $accesscodeArray = array_keys($accesscodeDbMatchArray);
     $campaignModel = new Campaign();
     $campaign = $campaignModel->fetchRow('id = ' . $campaign_id);
     // get impression value from ws
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('dashboard_mapping');
     $select->where('survey_id = ?', $campaign->i2_survey_id);
     $select->where('mark="FRIENDS"');
     $mappings = $db->fetchRow($select);
     $indicate2Connect = new Indicate2_Connect();
     $response = $indicate2Connect->getAnswerSetForSurvey(array($campaign->i2_survey_id, $campaign->i2_survey_id_en), null, array(array('ContextIndex' => $mappings['context_index'], 'QuestionIndex' => $mappings['question_index'])), 0);
     //        Zend_Debug::dump($mappings);die;
     $optionArray = array();
     if (isset($response->QuestionType) && is_array($response->QuestionType)) {
         foreach ($response->QuestionType as $questionType) {
             foreach ($questionType->SelectionQuestionOptionType as $optionObject) {
                 //get min value, like '11-15' = 11
                 $optionArray[$optionObject->OptionId] = (int) $optionObject->OptionText;
             }
         }
     } else {
         if (isset($response->QuestionType->SelectionQuestionOptionType)) {
             foreach ($response->QuestionType->SelectionQuestionOptionType as $optionObject) {
                 //get min value, like '11-15' = 11
                 if ($optionObject->OptionText == '>=10') {
                     $optionArray[$optionObject->OptionId] = 10;
                 }
                 $optionArray[$optionObject->OptionId] = (int) $optionObject->OptionText;
             }
         }
     }
     $answerArray = array();
     $i = 0;
     if (isset($response->AnswerSetType)) {
         foreach ($response->AnswerSetType as $answerObject) {
             $answerArray[$i++] = array($answerObject->AccessCode, iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answerObject->AnswerType->AnswerText))));
         }
     }
     // create x axis date value (endDate = expireDate/now + 10 days)
     $this->view->startDate = $startDate = date("Y-m-d", strtotime($campaign->create_date));
     if (strtotime($campaign->expire_date) > strtotime(date("Y-m-d"))) {
         $this->view->xmax = $endDate = date("Y-m-d", strtotime("+10 days", strtotime(date("Y-m-d"))));
     } else {
         $this->view->xmax = $endDate = date("Y-m-d", strtotime("+10 days", strtotime($campaign->expire_date)));
     }
     if ($request->isPost()) {
         $formData = $request->getPost();
         $this->view->xmax = $endDate = $formData['x_max'];
     }
     $resultArray = array();
     $xDateArrayLength = 0;
     while (1) {
         $resultArray[$startDate] = 0;
         $startDate = date("Y-m-d", strtotime("+1 days", strtotime($startDate)));
         $xDateArrayLength++;
         if ($startDate == $endDate) {
             $resultArray[$startDate] = 0;
             $xDateArrayLength++;
             break;
         }
     }
     //var_dump($resultArray);die;
     // set sparks initial impressions for each campaign, it should be added if a new campaign is lanuched!
     switch ($campaign_id) {
         case '1':
             $staticsparks = array(50, 110);
             break;
         case '2':
             $staticsparks = array(50, 150, 250, 400, 450);
             break;
         case '3':
             $staticsparks = array(100, 350, 750, 1200, 1500);
             break;
         case '4':
             $staticsparks = array(50, 200, 250);
             break;
         case '5':
             $staticsparks = array(50, 150);
             break;
         case '6':
             $staticsparks = array(50, 150, 350, 500, 900, 1700, 2300, 2500);
             break;
         case '7':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 150, 350, 500, 900, 1038);
             break;
         case '8':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '9':
             $staticsparks = array(0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '10':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '13':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 50, 100, 150, 300, 450, 600, 750, 900, 1200);
             break;
         default:
             break;
     }
     for ($temp = count($staticsparks); $temp < $xDateArrayLength; $temp++) {
         $staticsparks[$temp] = $staticsparks[$temp - 1];
     }
     // set everyday impression by using ws data
     foreach ($answerArray as $answer) {
         if (!isset($accesscodeDbMatchArray[$answer[0]])) {
             continue;
         }
         if (date("Y-m-d", strtotime($accesscodeDbMatchArray[$answer[0]])) > date("Y-m-d", strtotime($this->view->xmax))) {
             continue;
         }
         if (!array_key_exists($accesscodeDbMatchArray[$answer[0]], $resultArray)) {
             $resultArray[$accesscodeDbMatchArray[$answer[0]]] = $optionArray[$answer[1]];
         } else {
             $resultArray[$accesscodeDbMatchArray[$answer[0]]] += $optionArray[$answer[1]];
         }
     }
     //Zend_Debug::dump($optionArray);
     //Zend_Debug::dump($resultArray);
     //Zend_Debug::dump($answerArray);
     //Zend_Debug::dump($accesscodeDbMatchArray);
     // set line value
     $sparks = 0;
     $data_1 = array();
     $data_2min = array();
     $data_2max = array();
     $data_3min = array();
     $data_3max = array();
     $i = 0;
     $data_1[0] = $data_2max[0] = $data_2min[0] = $data_3min[0] = $data_3max[0] = $accumulate = 0;
     $temp = 0;
     foreach ($resultArray as $result) {
         if ($result != 0) {
             $xTodayLength = $temp;
         }
         $temp++;
     }
     foreach ($resultArray as $result) {
         if ($i == 0) {
             $i++;
             continue;
         }
         $accumulate = $result + $accumulate;
         $data_1[$i] = $accumulate + $staticsparks[$i];
         $data_2min[$i] = floor($accumulate * 2.5 + $staticsparks[$i]);
         $data_2max[$i] = $accumulate * 5 + $staticsparks[$i];
         $data_2avg[$i] = $accumulate * 3.75;
         $data_3min[$i] = floor($data_2avg[$i] * 3) + $data_2min[$i];
         $data_3max[$i] = floor($data_2avg[$i] * 4) + $data_2max[$i];
         $max = $data_3max[$i];
         if ($i == $xTodayLength) {
             break;
         }
         $i++;
     }
     // set max y axis value
     $dateArray = array_keys($resultArray);
     $y = new y_axis();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $max = $formData['y_max'];
     } else {
         if ($max < 10000) {
             $max = ceil($max / 100) * 100;
         } else {
             $max = ceil($max / 1000) * 1000;
         }
     }
     $y->set_range(0, $max, $max / 10);
     $this->view->ymax = $max;
     // draw lines
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($dateArray);
     $x_labels->set_steps(floor($xDateArrayLength / 42) + 1);
     $x_labels->rotate(40);
     $x->set_labels($x_labels);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour('#007DCD')->tooltip('#x_label#: #val#');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($data_1);
     $line_1->set_colour("#007DCD");
     $line_1->set_width(1);
     $line_2min_default_dot = new dot();
     $line_2min_default_dot->colour('#81C909')->tooltip('#x_label#: #val#');
     $line_2min = new line();
     $line_2min->set_default_dot_style($line_2min_default_dot);
     $line_2min->set_values($data_2min);
     $line_2min->set_colour("#81C909");
     $line_2min->set_width(1);
     $line_2_default_dot = new dot();
     $line_2_default_dot->colour('#81C909')->tooltip('#x_label#: #val#');
     $line_2 = new line();
     $line_2->set_default_dot_style($line_2_default_dot);
     $line_2->set_values($data_2max);
     $line_2->set_colour("#81C909");
     $line_2->set_width(1);
     $line_3_default_dot = new dot();
     $line_3_default_dot->colour('#FF0000')->tooltip('#x_label#: #val#');
     $line_3 = new line();
     $line_3->set_default_dot_style($line_3_default_dot);
     $line_3->set_values($data_3min);
     $line_3->set_colour("#FF0000");
     $line_3->set_width(1);
     $line_3max_default_dot = new dot();
     $line_3max_default_dot->colour('#FF0000')->tooltip('#x_label#: #val#');
     $line_3max = new line();
     $line_3max->set_default_dot_style($line_3max_default_dot);
     $line_3max->set_values($data_3max);
     $line_3max->set_colour("#FF0000");
     $line_3max->set_width(1);
     //tags
     $tags = new ofc_tags();
     $tags->font("Verdana", 10)->colour("#2F2F2F")->align_x_right();
     $this->view->chart = new open_flash_chart();
     // create event
     $campaignEventModel = new CampaignEvent();
     $campaignEvents = $campaignEventModel->fetchAll('campaign_id = ' . $campaign_id, 'event_date');
     $eventTotal = count($campaignEvents);
     $eventTemp = 0;
     foreach ($campaignEvents as $campaignEvent) {
         $eventDate = floor((strtotime($campaignEvent->event_date) - strtotime($campaign->create_date)) / 86400);
         $eventDescription = $campaignEvent->event_name;
         // event line
         $eventline = new scatter_line('#C5BE97', 1);
         $def = new hollow_dot();
         $def->size(0)->halo_size(0);
         $eventline->set_default_dot_style($def);
         $v = array(new scatter_value($eventDate, 0), new scatter_value($eventDate, $this->view->ymax));
         $eventline->set_values($v);
         $this->view->chart->add_element($eventline);
         // event description
         $tagAndArrow_Yvalue = 1 - ($eventTotal - $eventTemp++) / 10;
         if ($tagAndArrow_Yvalue == 0) {
             $tagAndArrow_Yvalue = 0.1;
         }
         $tag_xvalue = $eventDate + 2;
         $t = new ofc_tag($tag_xvalue, $this->view->ymax * $tagAndArrow_Yvalue);
         $t->text($eventDescription)->style(false, false, false, 1.0)->padding(0, 0);
         $tags->append_tag($t);
         // event arrow
         $arrowStart_x = $tag_xvalue;
         $arrowStart_y = $this->view->ymax * $tagAndArrow_Yvalue;
         $arrowEnd_x = $tag_xvalue - 1.5;
         $arrowEnd_y = $this->view->ymax * $tagAndArrow_Yvalue;
         $arrowColor = '#000000';
         $arrowBarbLength = 7;
         $a = new ofc_arrow($arrowStart_x, $arrowStart_y, $arrowEnd_x, $arrowEnd_y, $arrowColor, $arrowBarbLength);
         $this->view->chart->add_element($a);
     }
     $this->view->chart->add_element($line_1);
     $this->view->chart->add_element($line_2min);
     $this->view->chart->add_element($line_2);
     $this->view->chart->add_element($line_3);
     $this->view->chart->add_element($line_3max);
     $this->view->chart->add_element($tags);
     $this->view->chart->set_y_axis($y);
     $this->view->chart->set_x_axis($x);
     $this->view->chart->set_bg_colour('#FFFFFF');
 }
 function admin_graphs($id = null)
 {
     App::import('Vendor', 'Newsletter.php-ofc-library', array('file' => 'php-ofc-library/open-flash-chart.php'));
     //Configure::write('debug', 0);
     //$this->layout = null;
     // generate some random data
     srand((double) microtime() * 1000000);
     $title = new title(__d("newsletter", "Views per time", true));
     $chart = new open_flash_chart();
     $chart->set_title($title);
     $newsletter = $this->Newsletter->read(null, $id);
     // Views
     $dates = array();
     $values = array();
     //// init sender class ////
     App::import('Lib', 'Newsletter.ClassCollection');
     $senderOpt = NewsletterConfig::load('sender');
     if (!is_array($senderOpt)) {
         $senderOpt = array('name' => $senderOpt);
     }
     $sender = ClassCollection::getObject('NewsletterSender', $senderOpt['name']);
     //// query ////
     $opt = array('type' => 'graph', 'query' => array('fields' => array('count(*) as nb', 'DATE(NewsletterEvent.date) as date'), 'conditions' => array('NewsletterSended.newsletter_id' => $id, 'or' => array('NewsletterEvent.action' => 'view', array('NewsletterEvent.action IS NULL', 'NewsletterEvent.url' => null))), 'group' => 'DATE(NewsletterEvent.date)', 'order' => 'DATE(NewsletterEvent.date)', 'model' => 'NewsletterEvent'));
     $data = $this->_get_stats(array('viewByDays' => $opt), $newsletter, $sender);
     //debug($data);
     $dates = $data['viewByDays'];
     $min_value = 99999999;
     $max_value = 0;
     foreach ($dates as $d => $val) {
         if ($val < $min_value) {
             $min_value = $val;
         }
         if ($val > $max_value) {
             $max_value = $val;
         }
     }
     if ($max_value == $min_value) {
         $max_value++;
         $min_value--;
     }
     $min_value = 0;
     //debug($dates);
     $min_date = key($dates);
     end($dates);
     $max_date = key($dates);
     for ($cur_date = $min_date; $cur_date <= $max_date; $cur_date = $cur_date + 86400) {
         $x = strtotime('00:00:00', $cur_date);
         if (isset($dates[$cur_date])) {
             $values[] = new scatter_value($x, $dates[$cur_date]);
         } else {
             $values[] = new scatter_value($x, 0);
         }
     }
     if ($max_date == $min_date) {
         $max_date += 86400;
     }
     //debug($values);
     //pr($views);
     $line_dot = new line();
     $line_dot->set_values($values);
     $line_dot->set_text("Views");
     $chart->add_element($line_dot);
     $y = new y_axis();
     $y->set_range($min_value, $max_value, ($max_value - $min_value) / 10);
     $x = new x_axis();
     // grid line and tick every 10
     $x->set_range(mktime(0, 0, 0, date("m", $min_date), date("d", $min_date), date("Y", $min_date)), mktime(0, 0, 0, date("m", $max_date), date("d", $max_date), date("Y", $max_date)));
     // 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:d-m-Y#');
     // generate labels for every day
     $labels->set_steps(86400);
     // only display every other label (every other day)
     $labels->visible_steps(ceil(($max_date - $min_date) / 86400 / 20));
     $labels->rotate(90);
     $x->set_labels($labels);
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     $chart->set_bg_colour("#FFFFFF");
     //print_r($views);
     //$this->set("allviews",$views[0][0]['count(*)']);
     $line_dot = new line();
     $line_dot->set_values(array(2, 1));
     $line_dot->set_text("Unique views");
     $line_dot->colour("#0000000");
     //$chart->add_element($line_dot);
     //
     echo $chart->toPrettyString();
     exit;
     //$this->render(false);
 }
Example #15
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;
}
Example #16
0
 private function getChart($aGraphs)
 {
     $this->prepareData();
     $oLabels = new x_axis_labels();
     $oLabels->set_labels($this->aData[0]);
     $oLabels->rotate(-45);
     $oX = new x_axis();
     $oX->set_labels($oLabels);
     $oX->set_colours('#000000', '#ffffff');
     $oChart = new open_flash_chart();
     $oChart->set_bg_colour('#FFFFFF');
     $oTitle = new title($this->getTitle());
     $oTitle->set_style('font-size: 12px; font-weight: bold;');
     $oChart->set_title($oTitle);
     $oTooltip = new tooltip('#val#');
     $oTooltip->set_body_style('font-size: 10px');
     $oTooltip->set_stroke(1);
     $oTooltip->set_shadow(true);
     $oTooltip->set_background_colour('#ffffcc');
     $oTooltip->set_colour('#cccc99');
     $oChart->set_tooltip($oTooltip);
     $aY = array();
     foreach ($aGraphs as $k => $v) {
         $y = empty($v['y-right']) ? 0 : 1;
         $scale = empty($v['scale']) ? 1 : $v['scale'];
         if (!isset($aY[$y])) {
             $aY[$y] = new y_axis();
             $aY[$y]->set_colours($v['colour'], '#f6f6f6');
         }
         if (empty($v['y-remap'])) {
             $this->setAxisRange($aY[$y], $k, $scale);
         } else {
             $this->remapSeries($aY[$y], $k, $scale);
         }
         $oSeries = $this->getSeries($k, $v['type'], $v['colour']);
         if (!empty($this->drillDown)) {
             $oSeries->set_on_click($this->drillDown);
         }
         $oSeries->set_on_show($v['effect']);
         if ($y) {
             $oSeries->attach_to_right_y_axis();
         }
         $aGraphs[$k] = $oSeries;
     }
     $oChart->set_x_axis($oX);
     foreach ($aY as $y => $e) {
         $method = $y ? 'set_y_axis_right' : 'set_y_axis';
         $oChart->{$method}($e);
     }
     foreach ($aGraphs as $e) {
         $oChart->add_element($e);
     }
     return $oChart;
 }
Example #17
0
// 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 ) );
//$bar_stack->append_stack( array( 5, new bar_stack_value(5, '#ff0000') ) );
//$bar_stack->append_stack( array( 2, 2, 2, 2, new bar_stack_value(2, '#ff00ff') ) );
$bar_stack->set_keys(array(new bar_stack_key('#C4D318', 'En Peligro de Vencer', 12), new bar_stack_key('#77CC6D', 'Tiempo Ok', 12), new bar_stack_key('#ff0000', 'Vencidos', 12)));
$bar_stack->set_tooltip('X label [#x_label#], Radicados [#val#]<br>Total [#total#]');
$y = new y_axis();
$y->set_range(0, $noTotalRads, 2);
$x = new x_axis();
$animation_1 = 'pop';
$delay_1 = 0.25;
$cascade_1 = 10;
//$x->set_labels->set_vertical();
$bar_stack->set_on_show(new bar_on_show($animation_1, $cascade_1, $delay_1));
$x_labels = new x_axis_labels();
//$x_labels->set_steps( 1 );
$x_labels->rotate(15);
$x_labels->set_labels($arrayTipos);
$x->set_labels($x_labels);
//$x->rotate(90);
$tooltip = new tooltip();
$tooltip->set_hover();
$chart = new open_flash_chart();
$chart->set_bg_colour('#FFFFFF');
$chart->set_title($title);
$chart->add_element($bar_stack);
$chart->set_x_axis($x);
$chart->add_y_axis($y);
$chart->set_tooltip($tooltip);
echo $chart->toPrettyString();
Example #18
0
 function subscription()
 {
     acymailing::setTitle(JText::_('CHARTS'), 'stats', 'diagram&task=subscription');
     $listsClass = acymailing::get('class.list');
     $lists = $listsClass->getLists('listid');
     $db =& JFactory::getDBO();
     $db->setQuery('SELECT min(subdate) as minsubdate, min(unsubdate) as minunsubdate FROM ' . acymailing::table('listsub'));
     $dates = $db->loadObject();
     $spaces = array();
     $intervals = 10;
     $dates->maxsubdate = time();
     $delay = ($dates->maxsubdate - $dates->minsubdate) / $intervals;
     for ($i = 0; $i < $intervals; $i++) {
         $spaces[$i] = (int) ($dates->minsubdate + $delay * $i);
     }
     $spaces[$intervals] = $dates->maxsubdate;
     $results = array();
     $legendX = array();
     for ($i = 0; $i <= $intervals; $i++) {
         $legendX[] = acymailing::getDate($spaces[$i]);
         $db->setQuery('SELECT count(subid) as total, listid FROM ' . acymailing::table('listsub') . ' WHERE `status` != 2 AND `subdate` < ' . $spaces[$i] . ' AND (`status` = 1 OR `unsubdate`>' . $spaces[$i] . ') GROUP BY listid');
         $results[$i] = $db->loadObjectList('listid');
     }
     $title = new title(JText::_('SUB_HISTORY'));
     $title->set_style('font-size:20px; color: #FF8040');
     $lines = array();
     $maxSub = 0;
     foreach ($lists as $listid => $oneList) {
         $lines[$listid] = new line_base();
         $values = array();
         for ($i = 0; $i <= $intervals; $i++) {
             $values[] = empty($results[$i][$listid]->total) ? 0 : (int) $results[$i][$listid]->total;
         }
         $lines[$listid]->set_values($values);
         $lines[$listid]->set_text($oneList->name);
         $lines[$listid]->set_colour($oneList->color);
         $maxSub = max($maxSub, max($values));
     }
     $x_axis = new x_axis();
     $xlabelobject = new x_axis_labels();
     $xlabelobject->rotate(-20);
     $xlabelobject->set_labels($legendX);
     $x_axis->set_labels($xlabelobject);
     $y_axis = new y_axis();
     $y_axis->range(0, $maxSub, intval($maxSub / 10));
     $chart = new open_flash_chart();
     $chart->set_x_axis($x_axis);
     $chart->set_y_axis($y_axis);
     $chart->set_title($title);
     foreach ($lines as $oneLine) {
         $chart->add_element($oneLine);
     }
     $this->assignRef('chart', $chart);
 }
Example #19
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 #20
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();
}
 /**
  * Build The 3-D Bar Gharph.
  *
  * @param  array  $params  assoc array of name/value pairs          
  *
  * @return object $chart   object of open flash chart.
  * @static
  */
 static function &bar_3dChart(&$params)
 {
     $chart = null;
     if (empty($params)) {
         return $chart;
     }
     // $params['values'] should contains the values for each
     // criteria defined in $params['criteria']
     $values = CRM_Utils_Array::value('values', $params);
     $criterias = CRM_Utils_Array::value('criteria', $params);
     if (!is_array($values) || empty($values) || !is_array($criterias) || empty($criterias)) {
         return $chart;
     }
     // get the required data.
     $xReferences = $xValueLabels = $xValues = $yValues = array();
     foreach ($values as $xVal => $yVal) {
         if (!is_array($yVal) || empty($yVal)) {
             continue;
         }
         $xValueLabels[] = (string) $xVal;
         foreach ($criterias as $criteria) {
             $xReferences[$criteria][$xVal] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
             $yValues[] = (double) CRM_Utils_Array::value($criteria, $yVal, 0);
         }
     }
     if (empty($xReferences)) {
         return $chart;
     }
     // get the currency.
     require_once 'CRM/Utils/Money.php';
     $config = CRM_Core_Config::singleton();
     $symbol = $config->defaultCurrencySymbol;
     // set the tooltip.
     $tooltip = CRM_Utils_Array::value('tip', $params, "{$symbol} #val#");
     $count = 0;
     foreach ($xReferences as $criteria => $values) {
         $toolTipVal = $tooltip;
         // for seperate tooltip for each criteria
         if (is_array($tooltip)) {
             $toolTipVal = CRM_Utils_Array::value($criteria, $tooltip, "{$symbol} #val#");
         }
         // create bar_3d object
         $xValues[$count] = new bar_3d();
         // set colour pattel
         $xValues[$count]->set_colour(self::$_colours[$count]);
         // define colur pattel with bar criterias
         $xValues[$count]->key((string) $criteria, 12);
         // define bar chart values
         $xValues[$count]->set_values(array_values($values));
         // set tooltip
         $xValues[$count]->set_tooltip($toolTipVal);
         $count++;
     }
     $chartTitle = CRM_Utils_Array::value('legend', $params) ? $params['legend'] : ts('Bar Chart');
     //set y axis parameters.
     $yMin = 0;
     // calculate max scale for graph.
     $yMax = ceil(max($yValues));
     if ($mod = $yMax % str_pad(5, strlen($yMax) - 1, 0)) {
         $yMax += str_pad(5, strlen($yMax) - 1, 0) - $mod;
     }
     // if max value of y-axis <= 0, then set default values
     if ($yMax <= 0) {
         $ySteps = 1;
         $yMax = 5;
     } else {
         $ySteps = $yMax / 5;
     }
     // create x axis label obj.
     $xLabels = new x_axis_labels();
     $xLabels->set_labels($xValueLabels);
     // set angle for labels.
     if ($xLabelAngle = CRM_Utils_Array::value('xLabelAngle', $params)) {
         $xLabels->rotate($xLabelAngle);
     }
     // create x axis obj.
     $xAxis = new x_axis();
     $xAxis->set_labels($xLabels);
     //create y axis and set range.
     $yAxis = new y_axis();
     $yAxis->set_range($yMin, $yMax, $ySteps);
     // create chart title obj.
     $title = new title($chartTitle);
     // create chart.
     $chart = new open_flash_chart();
     // add x axis w/ labels to chart.
     $chart->set_x_axis($xAxis);
     // add y axis values to chart.
     $chart->add_y_axis($yAxis);
     // set title to chart.
     $chart->set_title($title);
     foreach ($xValues as $bar) {
         // add bar element to chart.
         $chart->add_element($bar);
     }
     // add x axis legend.
     if ($xName = CRM_Utils_Array::value('xname', $params)) {
         $xLegend = new x_legend($xName);
         $xLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_x_legend($xLegend);
     }
     // add y axis legend.
     if ($yName = CRM_Utils_Array::value('yname', $params)) {
         $yLegend = new y_legend($yName);
         $yLegend->set_style("{font-size: 13px; color:#000000; font-family: Verdana; text-align: center;}");
         $chart->set_y_legend($yLegend);
     }
     return $chart;
 }
$candle->set_tooltip('#x_label#<br>Max Price: #high#<br>Ave Price: #open#<br>Act Price: #close#<br>Min Price: #low#');
//$candle->set_key('Product Price (EUR)', 12);
$chart = new open_flash_chart();
$chart->set_bg_colour('#FFFFFF');
/*
$title = new title('Monthly Total VC');
$title->set_style("{font-size: 20px; color: #A2ACBA; text-align: center;}");
$chart->set_title($title);
*/
$chart->add_element($area);
$chart->add_element($area2);
$chart->add_element($area3);
$chart->add_element($candle);
$x_labels = new x_axis_labels();
$x_labels->set_steps(1);
$x_labels->rotate(30);
//ROTATE GRAPH LABELS
//$x_labels->set_vertical();
$x_labels->set_labels($period_label);
$x = new x_axis();
$x->set_grid_colour('#D7E4A3');
$x->set_offset($period_offset);
$x->set_steps(1);
// Add the X Axis Labels to the X Axis
$x->set_labels($x_labels);
$chart->set_x_axis($x);
//
// LOOK:
//
$x_legend = new x_legend("{$period_start} to {$period_end}");
$x_legend->set_style('{font-size: 20px; }');
Example #23
0
//-----/end get ranges  -----------------
// Prepare the x-axis
$x = new x_axis();
$x->set_range($lowest, $highest);
// Calculate the steps and visible steps
$step = ($highest - $lowest) / 60;
$step_vis = 2;
// do not allow steps to be less than 30 minutes
if ($step < 26400) {
    # 86400
    $step = 26400;
    $step_vis = 1;
}
$x->set_steps($step);
$labels = new x_axis_labels();
$labels->text('#date:Y-m-d#');
$labels->set_steps($step);
$labels->visible_steps($step_vis);
$labels->rotate(90);
$x->set_labels($labels);
// Prepare the y-axis
$y = new y_axis();
// $maximum is already set above
// set the range and y-step
$y->set_range(0, $maximum + getIdealYSteps($maximum));
$y->set_steps(getIdealYSteps($maximum));
#	$chart->add_element( $s );
$chart->set_x_axis($x);
$chart->add_y_axis($y);
// echo a pretty ofc-string anyway
echo $chart->toPrettyString();
Example #24
0
         // else if ($posy==5)    $type = new bow();
         // $type2->tooltip($listeJoueurs[$j]['nom']."<br>Jeu:#x_label#<br>Moy. #val#");
         $bar_glass = new bar_glass();
         // $bar->set_default_dot_style($type2);
         //$bar->set_width( 1 );
         $bar_glass->set_colour($G_MesCouleurs[$i]);
         $bar_glass->set_values($data_val2[$i]);
         $bar_glass->set_key($listeJeux[$i]["titre"], 10);
         $chart2->add_element($bar_glass);
         //$posy=$posy+1;
         //if ($posy==6) $posy=0;
     }
 }
 $labels2 = new x_axis_labels();
 $labels2->set_labels($tab_libelles2);
 $labels2->rotate(270);
 // Absisses
 $x2 = new x_axis();
 //$x->set_labels( $x_labels );
 $x2->set_stroke(2);
 $x2->set_tick_height(2);
 $x2->set_colour("#d000d0");
 $x2->set_labels($labels2);
 // Tooltip du graphe !
 $chart2->set_tooltip($t);
 $title2 = new title("Evolution par joueur");
 $chart2->set_title($title2);
 $chart2->set_y_axis($y2);
 $chart2->set_x_axis($x2);
 $fp = fopen($fichierImage, "w");
 // ouverture du fichier en écriture
Example #25
0
 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();
 }
Example #26
0
            $c = '#066303';
        }
    } else {
        $c = '#066303';
    }
    $tags->append_tag(new ofc_tag($x, $v, $c));
    $x++;
}
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
$chart->add_element($tags);
$xal = new x_axis_labels();
$x_labels = array_keys($data);
$fullscreen ? $rotate = 20 : ($rotate = 45);
$xal->rotate($rotate);
$xal->set_labels($x_labels);
$xal->set_size($xfs);
$xal->set_colour('#hhffhh');
$x = new x_axis();
$x->set_offset(true);
$x->set_labels($xal);
$x->set_3d(5);
$x->colour = '#909090';
$chart->set_x_axis($x);
$yal = new y_axis_labels();
$yal->set_size($yfs);
$y = new y_axis();
$y->set_labels($yal);
$y_max = ceil($y_max / $step) * $step;
if ($y_max == $step) {
Example #27
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();
 }
Example #28
0
function get_linear_graph($dates, $vals, $keys = array())
{
    include 'php-ofc-library/open-flash-chart.php';
    $max_y = 0;
    $arr_filled = array();
    for ($i = 0; $i < count($dates); $i++) {
        $year[] = $dates[$i];
        for ($m = 0; $m < count($vals); $m++) {
            $price[$m][] = (int) $vals[$m][$i];
            if ($max_y < (int) $vals[$m][$i]) {
                $max_y = (int) $vals[$m][$i];
            }
            if (@$arr_filled[$m] != $vals[$m][$i] and @$arr_filled[$m] == 0) {
                @($arr_filled[$m] = (int) $vals[$m][$i]);
            }
        }
    }
    while ($max_y % 10 != 0) {
        $max_y++;
    }
    $chart = new open_flash_chart();
    //$title = new title( 'UK Petrol price (pence) per Litre' );
    $d = new anchor();
    if (count($dates) > 60) {
        $d->size(2);
    } else {
        $d->size(3);
    }
    $d->halo_size(1);
    $d->colour('#3D5C56');
    $d->rotation(0);
    $d->sides(4);
    for ($i = 0; $i < count($price); $i++) {
        if ($arr_filled[$i] == 0) {
            continue;
        }
        if ($i == 0) {
            $color = '#5E0722';
        } elseif ($i == 1) {
            $color = '#00FF00';
        } else {
            $color = '#FF0000';
        }
        $area = new area();
        $area->set_colour($color);
        $area->set_default_dot_style($d);
        $area->set_values($price[$i]);
        if (isset($keys[$i])) {
            $area->set_key($keys[$i], 12);
        }
        // mb_convert_encoding($keys[$i], "UTF-8", "Windows-1251")
        $area->set_width(2);
        $chart->add_element($area);
    }
    $x_labels = new x_axis_labels();
    if (count($dates) > 40) {
        $x_labels->set_steps(7);
    } else {
        $x_labels->set_steps(1);
    }
    $x_labels->set_vertical();
    $x_labels->set_colour('#000000');
    $x_labels->set_labels($year);
    $x_labels->rotate(-55);
    $x_labels->set_size(12);
    $x = new x_axis();
    $x->set_colour('#000000');
    $x->set_grid_colour('#DDDDDD');
    //$x->set_offset( false );
    $x->set_steps(1);
    // Add the X Axis Labels to the X Axis
    $x->set_labels($x_labels);
    $chart->set_x_axis($x);
    $y = new y_axis();
    $y->set_range(0, $max_y);
    $y->set_colour('#000000');
    $y->set_grid_colour('#DDDDDD');
    $chart->add_y_axis($y);
    $chart->set_bg_colour("#FFFFFF");
    ?>


<script type="text/javascript" src="script/json/json2.js"></script>
<script type="text/javascript" src="script/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "600", "350", "9.0.0");
</script>

<script type="text/javascript">

function ofc_ready()
{

}

function open_flash_chart_data()
{
	return JSON.stringify(data);
}

function findSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft")!= -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

var data = <?php 
    echo $chart->toPrettyString();
    ?>
;

</script>
<?php 
}