Exemplo n.º 1
0
function error_text($title, $text)
{
    if (OFF == plugin_config_get('eczlibrary')) {
        $graph = new CanvasGraph(300, 380);
        $txt = new Text($text, 150, 100);
        $txt->Align("center", "center", "center");
        $txt->SetFont($t_graph_font, FS_BOLD);
        $graph->title->Set($title);
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->AddText($txt);
        $graph->Stroke();
    } else {
        $im = imagecreate(300, 300);
        /* @todo check: error graphs dont support utf8 */
        $bg = imagecolorallocate($im, 255, 255, 255);
        $textcolor = imagecolorallocate($im, 0, 0, 0);
        imagestring($im, 5, 0, 0, $text, $textcolor);
        header('Content-type: image/png');
        imagepng($im);
        imagedestroy($im);
    }
    die;
}
Exemplo n.º 2
0
function showError($msj, $G_SIZE = array(400, 300), $G_TITLE = "")
{
    $graph = new CanvasGraph($G_SIZE[0], $G_SIZE[1], "auto");
    if ($msj == 'nothing') {
        global $_MSJ_NOTHING;
        $titulo = utf8_decode($_MSJ_NOTHING);
        $title = new Text($G_TITLE);
        $title->ParagraphAlign('center');
        $title->SetFont(FF_FONT2, FS_BOLD);
        $title->SetMargin(3);
        $title->SetAlign('center');
        $title->Center(0, $G_SIZE[0], $G_SIZE[1] / 2);
        $graph->AddText($title);
    } else {
        $titulo = utf8_decode($msj);
    }
    $t1 = new Text($titulo);
    $t1->SetBox("white", "black", true);
    $t1->ParagraphAlign("center");
    $t1->SetColor("black");
    $graph->AddText($t1);
    $graph->img->SetColor('navy');
    $graph->img->SetTextAlign('center', 'bottom');
    $graph->img->Rectangle(0, 0, $G_SIZE[0] - 1, $G_SIZE[1] - 1);
    $graph->Stroke();
}
Exemplo n.º 3
0
function error_check($bug_count, $title)
{
    if (0 == $bug_count) {
        $t_graph_font = graph_get_font();
        $graph = new CanvasGraph(300, 380);
        $txt = new Text(lang_get('not_enough_data'), 150, 100);
        $txt->Align("center", "center", "center");
        $txt->SetFont($t_graph_font, FS_BOLD);
        $graph->title->Set($title);
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->AddText($txt);
        $graph->Stroke();
        die;
    }
}
    function top($VAR)
    {
        global $smarty, $C_translate, $C_auth;
        # Get the period type, default to month
        if (empty($VAR['period'])) {
            $p = 'm';
        } else {
            $p = $VAR['period'];
        }
        # Load the jpgraph class
        include PATH_GRAPH . "jpgraph.php";
        include PATH_GRAPH . "jpgraph_bar.php";
        # check the validation for this function
        if (!$C_auth->auth_method_by_name($this->module, 'search')) {
            $error = $C_translate->translate('module_non_auth', '', '');
            include PATH_GRAPH . "jpgraph_canvas.php";
            $graph = new CanvasGraph(460, 55, "auto");
            $t1 = new Text($error);
            $t1->Pos(0.2, 0.5);
            $t1->SetOrientation("h");
            $t1->SetBox("white", "black", 'gray');
            $t1->SetFont(FF_FONT1, FS_NORMAL);
            $t1->SetColor("black");
            $graph->AddText($t1);
            $graph->Stroke();
            exit;
        }
        # Get the period start & end
        switch ($p) {
            # By Weeks:
            case 'w':
                $interval = "1";
                $width = ".9";
                $title = 'Top Accounts for Last Last Week';
                $dow = date('w');
                $start_str = mktime(0, 0, 0, date('m'), date('d') - $dow, date('y'));
                $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y'));
                break;
                # By Months:
            # By Months:
            case 'm':
                $interval = "3";
                $width = ".6";
                $title = 'Top Accounts for Last Last Month';
                $start_str = mktime(0, 0, 0, date('m'), 1, date('y'));
                $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y'));
                break;
                # By Years:
            # By Years:
            case 'y':
                $interval = "1";
                $width = ".8";
                $title = 'Top Accounts for Last Last Year';
                $start_str = mktime(0, 0, 0, 1, 1, date('y'));
                $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y'));
                break;
        }
        ##############################@@@@@@@@
        # Get accounts & sales for this period
        ##############################@@@@@@@@
        $db =& DB();
        $sql = 'SELECT account_id,total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE
				   date_orig    >=  ' . $db->qstr($start_str) . ' AND  date_orig    <=  ' . $db->qstr($end_str) . ' AND
				   site_id      =  ' . $db->qstr(DEFAULT_SITE);
        $result = $db->Execute($sql);
        if (@$result->RecordCount() == 0) {
            $file = fopen(PATH_THEMES . 'default_admin/images/invisible.gif', 'r');
            fpassthru($file);
            exit;
        }
        while (!$result->EOF) {
            $amt = $result->fields['total_amt'];
            $acct = $result->fields['account_id'];
            if (!isset($arr[$acct])) {
                $arr[$acct] = 0;
            }
            $arr[$acct] += $amt;
            $result->MoveNext();
        }
        $i = 0;
        while (list($key, $var) = each(@$arr)) {
            # Get the user name
            $sql = 'SELECT first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account WHERE
						   id           =  ' . $db->qstr($key) . ' AND
						   site_id      =  ' . $db->qstr(DEFAULT_SITE);
            $rs = $db->Execute($sql);
            $_lbl[] = strtoupper(substr($rs->fields['first_name'], 0, 1)) . ". " . $rs->fields['last_name'];
            $_datay[] = $var;
            $i++;
        }
        ### Sort the arrays
        array_multisort($_datay, SORT_DESC, SORT_NUMERIC, $_lbl);
        ### Limit the results to 10 or less
        for ($i = 0; $i < count($_lbl); $i++) {
            $lbl[$i] = $_lbl[$i];
            $datay[$i] = $_datay[$i];
            if ($i >= 9) {
                $i = count($_lbl);
            }
        }
        $i = count($lbl);
        # Get the Currency
        $sql = 'SELECT symbol FROM ' . AGILE_DB_PREFIX . 'currency WHERE
					id           =  ' . $db->qstr(DEFAULT_CURRENCY) . ' AND
					site_id      =  ' . $db->qstr(DEFAULT_SITE);
        $rs = $db->Execute($sql);
        $currency_iso = $rs->fields['symbol'];
        // Size of graph
        $width = 265;
        $height = 75 + $i * 15;
        // Set the basic parameters of the graph
        $graph = new Graph($width, $height, 'auto');
        $graph->SetScale("textlin");
        $graph->yaxis->scale->SetGrace(50);
        $graph->SetMarginColor('#F9F9F9');
        $graph->SetFrame(true, '#CCCCCC', 1);
        $graph->SetColor('#FFFFFF');
        $top = 45;
        $bottom = 10;
        $left = 95;
        $right = 15;
        $graph->Set90AndMargin($left, $right, $top, $bottom);
        // Label align for X-axis
        $graph->xaxis->SetLabelAlign('right', 'center', 'right');
        // Label align for Y-axis
        $graph->yaxis->SetLabelAlign('center', 'bottom');
        $graph->xaxis->SetTickLabels($lbl);
        // Titles
        $graph->title->SetFont(FF_FONT1, FS_BOLD, 9.5);
        $title = $C_translate->translate('graph_top', 'account_admin', '');
        $graph->title->Set($title);
        // Create a bar pot
        $bplot = new BarPlot($datay);
        $bplot->SetFillColor("#506DC7");
        $bplot->SetWidth(0.2);
        // Show the values
        $bplot->value->Show();
        $bplot->value->SetFont(FF_FONT1, FS_NORMAL, 8);
        $bplot->value->SetAlign('center', 'center');
        $bplot->value->SetColor("black", "darkred");
        $bplot->value->SetFormat($currency_iso . '%.2f');
        $graph->Add($bplot);
        $graph->Stroke();
        return;
    }
Exemplo n.º 5
0
 function BAR_graph($module, $type, $start, $extra_fields)
 {
     global $C_translate, $C_auth;
     include_once PATH_CORE . 'validate.inc.php';
     $dt = new CORE_validate();
     include PATH_GRAPH . "jpgraph.php";
     ####################################################################
     ### Check if 'search' is authorized for this account
     ####################################################################
     # check the validation for this function
     if ($C_auth->auth_method_by_name($module, 'search')) {
         # validate this file exists, and include it.
         if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) {
             include_once PATH_MODULES . '/' . $module . '/' . $module . '.inc.php';
         } else {
             ### Not exist!
             $error = $C_translate->translate('module_non_existant', '', '');
         }
     } else {
         ### Not auth
         $error = $C_translate->translate('module_non_auth', '', '');
     }
     if (isset($error)) {
         include PATH_GRAPH . "jpgraph_canvas.php";
         // Create the graph.
         $graph = new CanvasGraph(460, 55, "auto");
         $t1 = new Text($error);
         $t1->Pos(0.2, 0.5);
         $t1->SetOrientation("h");
         $t1->SetBox("white", "black", 'gray');
         $t1->SetFont(FF_FONT1, FS_NORMAL);
         $t1->SetColor("black");
         $graph->AddText($t1);
         $graph->Stroke();
         exit;
     }
     ####################################################################
     ### BY WEEK
     ####################################################################
     if ($type == 'week') {
         $FONT_SIZE = 7;
         $AbsWidth = 12;
         $interval = 4;
         $type = $C_translate->translate('week', '', '');
         if ($start == "" || $start <= 12) {
             ## Get the beginning/end of this week
             $start_str = mktime(24, 0, 0, 12, 31, date("Y") - 1);
             $start = date(UNIX_DATE_FORMAT, $start_str);
             $end_str = mktime(24, 0, 0, 12, 30, date("Y", $start_str));
             $end = date(UNIX_DATE_FORMAT, $end_str);
         } else {
             ## Get the beginning/end of the specified week
             $start_str = mktime(24, 0, 0, 12, 31, date("{$start}") - 1);
             $start = date(UNIX_DATE_FORMAT, $start_str);
             $end_str = mktime(24, 0, 0, 12, 30, date("Y", $start_str));
             $end = date(UNIX_DATE_FORMAT, $end_str);
         }
         ### Set the constraint array:
         $curr_str = $start_str;
         while ($curr_str <= $end_str) {
             $new_curr_str = mktime(0, 0, 0, date("m", $curr_str), date("d", $curr_str) + 7, date("Y", $curr_str));
             $constraint_array[] = array('start' => $curr_str, 'end' => $new_curr_str);
             $curr_str = $new_curr_str;
             $default_array[] = 0;
         }
     } else {
         if ($type == 'month') {
             $FONT_SIZE = 10;
             $AbsWidth = 12;
             $TickLables = $gDateLocale->GetShortMonth();
             $interval = 1;
             $type = $C_translate->translate('month', '', '');
             if ($start == "" || $start < 12) {
                 ## Get the beginning/end of this week
                 $start_str = mktime(24, 0, 0, 12, 31, date("Y") - 1);
                 $start = date(UNIX_DATE_FORMAT, $start_str);
                 $end_str = mktime(24, 0, 0, 12, 30, date("Y", $start_str));
                 $end = date(UNIX_DATE_FORMAT, $end_str);
             } else {
                 ## Get the beginning/end of the specified week
                 ## Get the beginning/end of this week
                 $start_str = mktime(24, 0, 0, 12, 31, date("{$start}") - 1);
                 $start = date(UNIX_DATE_FORMAT, $start_str);
                 $end_str = mktime(24, 0, 0, 12, 30, date("Y", $start_str));
                 $end = date(UNIX_DATE_FORMAT, $end_str);
             }
             ### Set the constraint array:
             $curr_str = $start_str;
             while ($curr_str <= $end_str) {
                 $new_curr_str = mktime(0, 0, 0, date("m", $curr_str) + 1, date("d", $curr_str), date("Y", $curr_str));
                 $constraint_array[] = array('start' => $curr_str, 'end' => $new_curr_str);
                 $curr_str = $new_curr_str;
                 $default_array[] = 0;
             }
         } else {
             if ($type == 'year') {
                 $FONT_SIZE = 10;
                 $interval = 1;
                 $AbsWidth = 13;
                 $type = $C_translate->translate('year', '', '');
                 ## Get the beginning/end of this year - 10
                 $start_str = mktime(0, 0, 0, 1, 1, date("Y") - 9);
                 $start = date(UNIX_DATE_FORMAT, $start_str);
                 $end_str = mktime(0, 0, 0, 12, 30, date("Y", $start_str) + 9);
                 $end = date(UNIX_DATE_FORMAT, $end_str);
                 ### Set the constraint array:
                 $curr_str = $start_str;
                 while ($curr_str <= $end_str) {
                     $new_curr_str = mktime(0, 0, 0, date("m", $curr_str), date("d", $curr_str), date("Y", $curr_str) + 1);
                     $constraint_array[] = array('start' => $curr_str, 'end' => $new_curr_str);
                     $TickLables[] = date("Y", $curr_str);
                     $curr_str = $new_curr_str;
                     $default_array[] = 0;
                 }
             } else {
                 $FONT_SIZE = 8;
                 $interval = 3;
                 $AbsWidth = 4;
                 $type = $C_translate->translate('day', '', '');
                 if ($start == "" || $start > 12 || $start < 1) {
                     ## Get the beginning/end of this week
                     $start_str = mktime(0, 0, 0, date("m"), 1, date("Y"));
                     $start = date(UNIX_DATE_FORMAT, $start_str);
                     $end_str = mktime(0, 0, 0, date("m", $start_str) + 1, 1, date("Y", $start_str));
                     $end = date(UNIX_DATE_FORMAT, $end_str);
                 } else {
                     ## Get the beginning/end of the specified week
                     $start_str = mktime(0, 0, 0, date("{$start}"), 1, date("Y"));
                     $start = date(UNIX_DATE_FORMAT, $start_str);
                     $end_str = mktime(0, 0, 0, date("m", $start_str) + 1, 1, date("Y", $start_str));
                     $end = date(UNIX_DATE_FORMAT, $end_str);
                 }
                 ### Set the constraint array:
                 $curr_str = $start_str;
                 while ($curr_str < $end_str) {
                     $new_curr_str = mktime(0, 0, 0, date("m", $curr_str), date("d", $curr_str) + 1, date("Y", $curr_str));
                     $constraint_array[] = array('start' => $curr_str, 'end' => $new_curr_str);
                     $TickLables[] = date("j", $curr_str);
                     $curr_str = $new_curr_str;
                     $default_array[] = 0;
                 }
             }
         }
     }
     # initialize the module, if it has not already been initialized
     $eval = '$' . $module . ' = new ' . $module . '; ';
     $eval .= '$this_Obj  = $' . $module . ';';
     eval($eval);
     # run the function
     $array = call_user_func(array($module, "graph"), $start_str, $end_str, $constraint_array, $default_array, $extra_fields);
     include PATH_GRAPH . "jpgraph_bar.php";
     $datay = $array['results'];
     // Create the graph. These two calls are always required
     $graph = new Graph(550, 200, "auto");
     $graph->SetScale("textlin");
     $graph->yaxis->scale->SetGrace(25);
     $graph->SetMarginColor('#F9F9F9');
     $graph->SetFrame(true, 'darkgreen', 0);
     $graph->SetColor('#FFFFFF');
     #$graph->SetFrame(false);
     // Adjust the margin a bit to make more room for titles
     $graph->img->SetMargin(45, 10, 15, 25);
     // Create a bar pot
     $bplot = new BarPlot($datay);
     // Set the X
     if (isset($TickLables)) {
         $graph->xaxis->SetTickLabels($TickLables);
     }
     $graph->xaxis->SetTextLabelInterval($interval);
     $graph->xaxis->SetColor("navy");
     $graph->yaxis->SetColor("navy");
     // Adjust fill color
     $bplot->SetFillColor('#506DC7');
     $bplot->value->Show();
     $bplot->value->SetFont(FF_FONT1, FS_NORMAL, $FONT_SIZE);
     $bplot->value->SetAngle(90);
     $bplot->value->SetFormat('%0.0f');
     $bplot->value->SetColor("darkblue");
     $graph->Add($bplot);
     // Setup the titles
     $title = $array['title'];
     $graph->title->Set($title . "     {$start} - {$end}");
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->title->SetColor("black");
     // Display the graph
     $graph->Stroke();
 }
Exemplo n.º 6
0
<?php

// content="text/plain; charset=utf-8"
require_once "jpgraph/jpgraph.php";
require_once "jpgraph/jpgraph_canvas.php";
// Create the graph.
$graph = new CanvasGraph(350, 200);
$t1 = new Text("a good\nas you can see right now per see\nThis is a text with\nseveral lines\n");
$t1->SetPos(0.05, 100);
$t1->SetFont(FF_FONT1, FS_NORMAL);
$t1->SetBox("white", "black", true);
$t1->ParagraphAlign("right");
$t1->SetColor("black");
$graph->AddText($t1);
$graph->Stroke();
Exemplo n.º 7
0
     $numstick = $limit;
 }
 if ($limit == 0 || $limit == "") {
     $graph = new CanvasGraph(660, 200, "auto");
     $graph->SetMarginColor('white');
     $graph->SetMargin(2, 60, 2, 25);
     $graph->InitFrame();
     $text = new Text("       [This chart does not have enough data]");
     $text->SetPos(400, 60, 'right');
     $text->SetColor("black");
     $graph->AddText($text);
     $graph2 = new CanvasGraph(660, 170, 'auto');
     $graph2->SetMarginColor('white');
     $graph2->SetMargin(2, 60, 2, 25);
     $graph2->InitFrame();
     $graph2->AddText($text);
     if ($type == 1) {
         $graph->Stroke($realpath . $prename . "1W_1.png");
         $graph2->Stroke($realpath . $prename . "1W_2.png");
     } elseif ($type == 2) {
         //echo '111';
         $graph->Stroke($realpath . $prename . "1M_1.png");
         $graph2->Stroke($realpath . $prename . "1M_2.png");
     } elseif ($type == 3) {
         $graph->Stroke($realpath . $prename . "3M_2.png");
         $graph2->Stroke($realpath . $prename . "3M_2.png");
     } elseif ($type == 4) {
         $graph->Stroke($realpath . $prename . "6M_2.png");
         $graph2->Stroke($realpath . $prename . "6M_2.png");
     } elseif ($type == 5) {
         $graph->Stroke($realpath . $prename . "1Y_1.png");
Exemplo n.º 8
0
function ejecutarGrafico($value_criteria, $date_start, $date_end)
{
    global $arrLang;
    $data_graph = leerDatosGrafico($value_criteria, $date_start, $date_end);
    if (count($data_graph["values"]) > 0) {
        // Create the Pie Graph.
        $graph = new PieGraph(630, 220, "auto");
        $graph->SetMarginColor('#fafafa');
        $graph->SetFrame(true, '#999999');
        $graph->legend->SetFillColor("#fafafa");
        $graph->legend->SetColor("#444444", "#999999");
        $graph->legend->SetShadow('gray@0.6', 4);
        // Set A title for the plot
        $graph->title->Set(utf8_decode($data_graph["title"]));
        $graph->title->SetColor("#444444");
        $graph->legend->Pos(0.1, 0.2);
        // Create 3D pie plot
        $p1 = new PiePlot3d($data_graph["values"]);
        $p1->SetCenter(0.4);
        $p1->SetSize(100);
        // Adjust projection angle
        $p1->SetAngle(60);
        // Adjsut angle for first slice
        $p1->SetStartAngle(45);
        // Display the slice values
        $p1->value->SetColor("black");
        // Add colored edges to the 3D pie
        // NOTE: You can't have exploded slices with edges!
        $p1->SetEdge("black");
        $p1->SetLegends($data_graph["legend"]);
        $graph->Add($p1);
        $graph->Stroke();
    } else {
        $graph = new CanvasGraph(630, 220, "auto");
        $title = new Text(utf8_decode($data_graph["title"]));
        $title->ParagraphAlign('center');
        $title->SetFont(FF_FONT2, FS_BOLD);
        $title->SetMargin(3);
        $title->SetAlign('center');
        $title->Center(0, 630, 110);
        $graph->AddText($title);
        $t1 = new Text(utf8_decode($arrLang["No records found"]));
        $t1->SetBox("white", "black", true);
        $t1->ParagraphAlign("center");
        $t1->SetColor("black");
        $graph->AddText($t1);
        $graph->img->SetColor('navy');
        $graph->img->SetTextAlign('center', 'bottom');
        $graph->img->Rectangle(0, 0, 629, 219);
        $graph->Stroke();
        /*
               //no hay datos - por ahora muestro una imagen en blanco con mensaje no records found
                header('Content-type: image/png');
                $titulo=utf8_decode($data_graph["title"]);
                $im = imagecreate(630, 220);
                $background_color = imagecolorallocate($im, 255, 255, 255);
                $text_color = imagecolorallocate($im, 233, 14, 91);
                imagestring($im, 10, 5, 5, $titulo. "  -  No records found", $text_color);
                imagepng($im);
                imagedestroy($im);*/
    }
}
Exemplo n.º 9
0
/**
 * Display Error 'graph'
 *
 * @param string $p_title Error title.
 * @param string $p_text  Error text.
 * @todo check error graphs do not support utf8
 * @return void
 */
function error_text($p_title, $p_text)
{
    if (OFF == plugin_config_get('eczlibrary')) {
        $t_graph = new CanvasGraph(300, 380);
        $t_graph_font = graph_get_font();
        $t_text = new Text($p_text, 150, 100);
        $t_text->Align('center', 'center', 'center');
        $t_text->SetFont($t_graph_font, FS_BOLD);
        $t_graph->title->Set($p_title);
        $t_graph->title->SetFont($t_graph_font, FS_BOLD);
        $t_graph->AddText($t_text);
        $t_graph->Stroke();
    } else {
        $t_image = imagecreate(300, 300);
        $t_text_color = imagecolorallocate($t_image, 0, 0, 0);
        imagestring($t_image, 5, 0, 0, $p_text, $t_text_color);
        header('Content-type: image/png');
        imagepng($t_image);
        imagedestroy($t_image);
    }
    die;
}
 /** Constroi o gráfico entre periodos de anos 
 			retorna true se o grafico foi montado e false se não foi
 		**/
 function buildGraphicByYear($stats, $startYear, $lastYear)
 {
     $graficoStatus = false;
     // Para descobrir se entrou no for e vai construir um gráfico
     $stat = $stats->getRequests();
     // Pega todos os anos entre o Ano Inicial e o Ano Final
     $anos = array();
     for ($j = 0, $year = $startYear; $year <= $lastYear; $year++, $j++) {
         $anos[$j] = $year;
     }
     foreach ($stat as $s) {
         $mes = intval($s->getMonth());
         $ano = intval($s->getYear());
         $values[$ano][$mes] = $s->getNumberOfRequests();
     }
     /*
     "gabarito" da linha dos graficos com 12 posicoes, uma para cada mes
     os valores "-" sao considerados NULLs pelo jpgraph
     */
     $data = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0");
     /*
     "gabarito" para as cores das linhas do gráfico
     */
     $cores = array("blue", "yellow", "purple", "cyan", "pink", "red", "orange", "green", "black", "sienna", "darkred", "darkgreen");
     // Create the graph. These two calls are always required
     //			$graph = new Graph(700,400,"auto");
     $graph = new Graph(900, 300, "auto");
     $graph->SetScale("textlin");
     /*
     cria um array bi-dimencional contendo array(ano{array com a quantidade de acessos por mes})
     */
     $colorIndex = 0;
     $bars = array();
     foreach ($values as $ano => $meses) {
         /*
         valores será a variavel que servirá de "datasource" para a barra do grafico
         inicialmente ele eh inicializada com o gabarito, e serao preenchidos os valores
         dos meses no laço for logo abaixo
         */
         $valores = $data;
         for ($k = 0; $k <= count($valores); $k++) {
             if ($meses[$k]) {
                 $valores[$k] = $meses[$k];
             }
         }
         if (count($valores) > 12) {
             unset($valores[0]);
         }
         $valores = array_values($valores);
         /*
         aqui eu uso "Variáveis Variáveis" do PHP para poder
         inserir vária linhas no gráfico
         */
         $nome = "barplot" . $ano;
         ${$nome} = new BarPlot($valores);
         $cor = $cores[$colorIndex];
         ${$nome}->SetFillColor($cor);
         ${$nome}->SetColor($cor);
         /*configs para os valores do ponto*/
         ${$nome}->value->SetColor("darkred");
         ${$nome}->value->SetFont(FF_FONT1, FS_BOLD);
         ${$nome}->value->SetFormat("%0.1d");
         //				$$nome->SetWeight(20);
         // Arrumando para um tamanho mais amigavel
         if (count($anos) < 3) {
             ${$nome}->SetWidth(20);
         } else {
             if (count($anos) < 4) {
                 ${$nome}->SetWidth(15);
             } else {
                 if (count($anos) < 6) {
                     ${$nome}->SetWidth(10);
                 } else {
                     if (count($anos) < 8) {
                         ${$nome}->SetWidth(5);
                     } else {
                         if (count($anos) < 11) {
                             ${$nome}->SetWidth(3);
                         }
                     }
                 }
             }
         }
         ${$nome}->value->Show();
         ${$nome}->value->iHideZero = true;
         ${$nome}->setLegend($ano);
         /*adicionando a linha ao grafico*/
         $colorIndex++;
         // Somente monta o gráfico dos anos exigidos pelo usuário
         for ($i = 0; $i < count($anos); $i++) {
             if ($ano == $startYear + $i) {
                 $graficoStatus = true;
                 // entrou no for significa que o gráfico vai ser construido
                 array_push($bars, ${$nome});
             }
         }
     }
     /****************************************************************
      * Se não existir dados estatísticos para o período selecionado	*
      * Então ele constroi uma imagem com a mensagem de que não		*
      * existem dados estatísticos.									*
      *****************************************************************/
     if ($graficoStatus == false) {
         $graph = new CanvasGraph(600, 30);
         $t1 = new Text(GRAFIC_STATS_FALSE);
         $t1->Pos(0.05, 0.5);
         $t1->SetOrientation('h');
         $t1->SetFont(FF_FONT1, FS_BOLD);
         $t1->SetColor('black');
         $graph->AddText($t1);
         $graph->Stroke();
         return $graficoStatus;
     }
     $gbplot = new GroupBarPlot($bars);
     $gbplot->SetWidth(0.9);
     $graph->Add($gbplot);
     $graph->yaxis->scale->SetGrace(20);
     $graph->img->SetMargin(40, 20, 20, 40);
     $graph->title->Set(ARTICLE_ACCESS);
     $graph->xaxis->title->Set(MONTHS);
     $graph->yaxis->title->Set(ACCESSES);
     $graph->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
     $graph->SetShadow();
     $graph->xaxis->SetTickLabels(explode(",", MONTH_LIST));
     // Adjust the legend position
     //			$graph->legend->SetLayout(LEGEND_VER);
     $graph->legend->Pos(0.04, 0.092, "", "center");
     $graph->legend->SetLayout(LEGEND_HOR);
     // Mostra o gráfico somente se, o ano que o usuario entrou existir estatisticas
     if ($graficoStatus == true) {
         $graph->Stroke();
     }
     return $graficoStatus;
 }
Exemplo n.º 11
0
function grafic_trunk2(&$pDB_ast_cdr, &$pDB_ast, $module_name, $trunk, $dti, $dtf)
{
    //
    require_once "modules/{$module_name}/libs/paloSantoExtention.class.php";
    $objPalo_AST_CDR = new paloSantoExtention($pDB_ast_cdr);
    /* Si la troncal pedida es un grupo, se expande el grupo para averiguar las
       troncales individuales. */
    $regs = NULL;
    if (preg_match('!^DAHDI/(g|r)(\\d+)$!i', $trunk, $regs)) {
        $iGrupoTrunk = (int) $regs[2];
        $gruposTrunk = getTrunkGroupsDAHDI();
        if (is_array($gruposTrunk) && isset($gruposTrunk[$iGrupoTrunk])) {
            $trunk = $gruposTrunk[$iGrupoTrunk];
        }
    }
    //total minutos de llamadas in y out
    $arrayTemp = $objPalo_AST_CDR->loadTrunks($trunk, "numcall", $dti, $dtf);
    $arrResult = $arrayTemp[0];
    //$arrResult[0] => "IN"
    //$arrResult[1] => "OUT"
    $tot = $arrResult[0] + $arrResult[1];
    $usoDisco = $tot != 0 ? 100 * ($arrResult[0] / $tot) : 0;
    if ($tot != 0) {
        $freeDisco = 100 - $usoDisco;
        // Some data
        $data = array($usoDisco, $freeDisco);
        // Create the Pie Graph.
        $graph = new PieGraph(400, 170, "auto");
        //$graph->SetShadow();
        $graph->SetMarginColor('#fafafa');
        $graph->SetFrame(true, '#999999');
        $graph->legend->SetFillColor("#fafafa");
        //$graph->legend->Pos(0.012, 0.5, "right","center");
        $graph->legend->SetColor("#444444", "#999999");
        $graph->legend->SetShadow('gray@0.6', 4);
        //$graph->title->SetColor("#444444");
        // Set A title for the plot
        $graph->title->Set(utf8_decode(_tr("Number of Calls")));
        //$graph->title->SetFont(FF_VERDANA,FS_BOLD,18);
        $graph->title->SetColor("#444444");
        $graph->legend->Pos(0.04, 0.2);
        // Create 3D pie plot
        $p1 = new PiePlot3d($data);
        //$p1->SetTheme("water");
        $p1->SetSliceColors(array("#3333cc", "#9999cc", "#CC3333", "#72394a", "#aa3424"));
        $p1->SetCenter(0.3);
        $p1->SetSize(80);
        // Adjust projection angle
        $p1->SetAngle(45);
        // Adjsut angle for first slice
        $p1->SetStartAngle(45);
        // Display the slice values
        //$p1->value->SetFont(FF_ARIAL,FS_BOLD,11);
        //$p1->value->SetColor("navy");
        $p1->value->SetColor("black");
        // Add colored edges to the 3D pies
        // NOTE: You can't have exploded slices with edges!
        $p1->SetEdge("black");
        $p1->SetLegends(array(utf8_decode(_tr("Incoming Calls") . ":  ") . $arrResult[0], utf8_decode(_tr("Outcoming Calls") . ": ") . $arrResult[1]));
        $graph->Add($p1);
        $graph->Stroke();
    } else {
        $graph = new CanvasGraph(400, 140, "auto");
        $title = new Text(utf8_decode(_tr("Number of Calls")));
        $title->ParagraphAlign('center');
        $title->SetFont(FF_FONT2, FS_BOLD);
        $title->SetMargin(3);
        $title->SetAlign('center');
        $title->Center(0, 400, 70);
        $graph->AddText($title);
        $t1 = new Text(utf8_decode(_tr("There are no data to present")));
        $t1->SetBox("white", "black", true);
        $t1->ParagraphAlign("center");
        $t1->SetColor("black");
        $graph->AddText($t1);
        $graph->img->SetColor('navy');
        $graph->img->SetTextAlign('center', 'bottom');
        $graph->img->Rectangle(0, 0, 399, 139);
        $graph->Stroke();
    }
}