Exemple #1
0
// The label array values may have printf() formatting in them. The argument to the
// form,at string will be the value of the slice (either the percetage or absolute
// depending on what was specified in the SetLabelType() above.
$lbl = array("adam\n%.1f%%", "bertil\n%.1f%%", "johan\n%.1f%%", "peter\n%.1f%%", "daniel\n%.1f%%", "erik\n%.1f%%");
$p1->SetLabels($lbl);
// Uncomment this line to remove the borders around the slices
// $p1->ShowBorder(false);
// Add drop shadow to slices
$p1->SetShadow();
// Explode all slices 15 pixels
$p1->ExplodeAll(15);
// Setup the CSIM targets
$targ = array("piec_csimex1.php#1", "piec_csimex1.php#2", "piec_csimex1.php#3", "piec_csimex1.php#4", "piec_csimex1.php#5", "piec_csimex1.php#6");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$p1->SetCSIMTargets($targ, $alts);
$p1->SetMidCSIM("piec_csimex1.php#7", "Center");
// Setup a small help text in the image
$txt = new Text("Note: This is an example of image map. Hold\nyour mouse over the slices to see the values.\nThe URL just points back to this page");
$txt->SetFont(FF_FONT1, FS_BOLD);
$txt->SetPos(0.5, 0.97, 'center', 'bottom');
$txt->SetBox('yellow', 'black');
$txt->SetShadow();
$graph->AddText($txt);
// Add plot to pie graph
$graph->Add($p1);
// .. and send the image on it's marry way to the browser
$graph->StrokeCSIM();
?>


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();
}
$txt = "The day was rapidly becoming more and\nmore strange.\n\nNot only had he managed to\nget by the first pass without so much as\na hint of questions but now when he\ncould feel that the second pass wouldn't\nlong be noone had yet seen him.";
$w = 950;
$h = 250;
$xm = 20;
$ym = 20;
$tw = 300;
$g = new CanvasGraph($w, $h);
$img = $g->img;
// Alignment for anchor points to use
$palign = array('left', 'center', 'right');
$n = count($palign);
$t = new Text($txt);
$y = $ym;
for ($i = 0; $i < $n; ++$i) {
    $x = $xm + $i * $tw;
    $t->SetColor('black');
    $t->SetAlign('left', 'top');
    $t->SetFont(FF_ARIAL, FS_NORMAL, 11);
    $t->SetBox();
    $t->SetParagraphAlign($palign[$i]);
    $t->Stroke($img, $x, $y);
    $img->SetColor('black');
    $img->SetFont(FF_FONT1, FS_BOLD);
    $img->SetTextAlign('center', 'top');
    $img->StrokeText($x + 140, $y + 160, '"' . $palign[$i] . '"' . ' pargraph align');
}
// .. and send back to browser
$g->Stroke();
?>

Exemple #4
0
$targ = array("bar_clsmex1.php#1", "bar_clsmex1.php#2", "bar_clsmex1.php#3", "bar_clsmex1.php#4", "bar_clsmex1.php#5", "bar_clsmex1.php#6");
$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
$bplot->SetCSIMTargets($targ, $alts);
$bplot->SetFillColor("orange");
$bplot->SetLegend('Year 2001 %%', '#kalle ', '%s');
// Display the values on top of each bar
$bplot->SetShadow();
$bplot->value->SetFormat(" \$ %2.1f", 70);
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 9);
$bplot->value->SetColor("blue");
$bplot->value->Show();
$graph->Add($bplot);
// Create a big "button" that has an image map action
$txt1 = new Text("A simple text with\ntwo rows");
$txt1->SetFont(FF_ARIAL);
$txt1->SetBox('lightblue', 'black', 'white@1', 5);
$txt1->SetParagraphAlign('center');
$txt1->SetPos(40, 50);
$txt1->SetCSIMTarget('#88', 'Text element');
$graph->Add($txt1);
// Add image map to the graph title as well (you can do this to the
// sub- and subsub-title as well)
$graph->title->Set("Image maps barex1");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->title->SetCSIMTarget('#45', 'Title for Bar');
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
// Setup the axis title image map and font style
$graph->yaxis->title->SetFont(FF_FONT2, FS_BOLD);
$graph->yaxis->title->SetCSIMTarget('#55', 'Y-axis title');
$graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD);
    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;
    }
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();
    }
}
Exemple #7
0
<?php

// content="text/plain; charset=utf-8"
// $Id: canvasex01.php,v 1.3 2002/10/23 08:17:23 aditus Exp $
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_canvas.php';
// Setup a basic canvas we can work
$g = new CanvasGraph(400, 300, 'auto');
$g->SetMargin(5, 11, 6, 11);
$g->SetShadow();
$g->SetMarginColor("teal");
// We need to stroke the plotarea and margin before we add the
// text since we otherwise would overwrite the text.
$g->InitFrame();
// Draw a text box in the middle
$txt = "This\nis\na TEXT!!!";
$t = new Text($txt, 200, 10);
$t->SetFont(FF_ARIAL, FS_BOLD, 40);
// How should the text box interpret the coordinates?
$t->Align('center', 'top');
// How should the paragraph be aligned?
$t->ParagraphAlign('center');
// Add a box around the text, white fill, black border and gray shadow
$t->SetBox("white", "black", "gray");
// Stroke the text
$t->Stroke($g->img);
// Stroke the graph
$g->Stroke();
?>

Exemple #8
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();
Exemple #9
0
// Create the graph -- these two calls are required
$graph = new Graph(650, 450);
$graph->SetScale("textlin");
/////////////////////////////////////////IF LEERLING || KLASGEMIDDELDE IS EMPTY
/////////////////////////////////////////MAAK ZELF ARRAYS
if (empty($leerling) || empty($klasgemiddelde)) {
    //punten leerling
    $leerling = array("WIS" => 95, "GES" => 45, "AAR" => 75, "NED" => 69, "LO" => 76);
    $klasgemiddelde = array("WIS" => 81, "GES" => 63, "AAR" => 70, "NED" => 73, "LO" => 65);
    $txt = new Text();
    $txt->SetFont(FF_ARIAL, FS_NORMAL, 25);
    $txt->SetColor('gray');
    $txt->Set(" VOORBEELDGRAFIEK");
    $txt->SetParagraphAlign('left');
    $txt->SetPos(0.5600000000000001, 0.65, 'right');
    $txt->SetBox('black');
    $graph->Add($txt);
}
//TOTAAL KLASGEMIDDELDE EN TOTAAL GEMIDDELDE LEERLING BEREKENEN
$counter = 0;
$totaal = 0;
foreach ($klasgemiddelde as $key => $value) {
    $totaal += $value;
    $counter++;
}
$klasgemid = round($totaal / $counter, 1) . "%";
$counter2 = 0;
$totaal2 = 0;
foreach ($leerling as $value) {
    $totaal2 += $value;
    $counter2++;
Exemple #10
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("This is a text with more text");
$t1->SetPos(0.05, 0.5);
$t1->SetOrientation("h");
$t1->SetFont(FF_FONT1, FS_NORMAL);
$t1->SetBox("white", "black", 'gray');
$t1->SetColor("black");
$graph->AddText($t1);
$graph->Stroke();
 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();
 }
Exemple #12
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);*/
    }
}
Exemple #13
0
$activity2->SetPattern(BAND_RDIAG, "yellow");
$activity2->SetFillColor("red");
// Set absolute height
$activity2->SetHeight(10);
// Specify progress to 30%
$activity2->progress->Set(0.3);
$activity2->progress->SetPattern(BAND_HVCROSS, "blue");
// Finally add the bar to the graph
$graph->Add($activity);
$graph->Add($activity2);
// Add text to top left corner of graph
$txt1 = new Text();
$txt1->SetPos(5, 2);
$txt1->Set("Note:\nEstimate done w148");
$txt1->SetFont(FF_ARIAL, FS_BOLD, 12);
$txt1->SetColor('darkred');
$graph->Add($txt1);
// Add text to the top bar
$txt2 = new Text();
$txt2->SetScalePos("2002-01-01", 1);
$txt2->SetFont(FF_ARIAL, FS_BOLD, 12);
$txt2->SetAlign('left', 'center');
$txt2->Set("Remember this!");
$txt2->SetBox('yellow');
$graph->Add($txt2);
// Add a vertical line
$vline = new GanttVLine("2001-12-24", "Phase 1");
$vline->SetDayOffset(0.5);
//$graph->Add($vline);
// ... and display it
$graph->Stroke();
Exemple #14
0
}
$graph->Add($p1);
/*
$p3 = new LinePlot($kills);
$p3->SetBarCenter();
$p3->SetLegend("Kills");
$p3->SetFillColor('gray@0.65');

$graph->AddY2($p3);
/**/
if (!$sum) {
    $t = new Text("Not enough history\navailable\nto chart graph");
    $t->SetPos(0.5, 0.5, 'center', 'center');
    $t->SetFont(FF_FONT2, FS_BOLD);
    $t->ParagraphAlign('centered');
    $t->SetBox('lightyellow', 'black', 'gray');
    $t->SetColor('orangered4');
    $graph->yaxis->HideLabels();
    $graph->xaxis->HideLabels();
    $graph->legend->Hide();
    $graph->AddText($t);
}
//if (imgdef($q['antialias'], false)) $graph->img->SetAntiAliasing();
stdImgFooter($graph);
$graph->Stroke();
function xlabels($x)
{
    global $labels, $smooth;
    $idx = floor($x / $smooth);
    $idx = $x / $smooth;
    //	return $labels[$idx];
Exemple #15
0
 function StrokeLabels($aImg, $xc, $yc, $ri, $rr)
 {
     if ($this->iHideLabels) {
         return;
     }
     // Setup some convinient vairables
     $a = $this->iAngle * M_PI / 180.0;
     $n = $this->iNumCirc;
     $d = $this->iDelta;
     // Setup the font and font color
     $val = new Text();
     $val->SetFont($this->iFontFamily, $this->iFontStyle, $this->iFontSize);
     $val->SetColor($this->iFontColor);
     if ($this->iFontBkgColor !== false) {
         $val->SetBox($this->iFontBkgColor, $this->iFontFrameColor);
     }
     // Position the labels relative to the radiant circles
     if ($this->iLblAlign == LBLALIGN_TOP) {
         if ($a > 0 && $a <= M_PI / 2) {
             $val->SetAlign('left', 'bottom');
         } elseif ($a > M_PI / 2 && $a <= M_PI) {
             $val->SetAlign('right', 'bottom');
         }
     } elseif ($this->iLblAlign == LBLALIGN_CENTER) {
         $val->SetAlign('center', 'center');
     }
     // Stroke the labels close to each circle
     $v = $d;
     $si = sin($a);
     $co = cos($a);
     for ($i = 0; $i < $n; ++$i, $v += $d) {
         $r = $ri + ($i + 1) * $rr;
         $x = $xc + $co * $r;
         $y = $yc - $si * $r;
         $val->Set(sprintf($this->iLblFmt, $v));
         $val->Stroke($aImg, $x, $y);
     }
     // Print the text in the zero circle
     if ($this->iLblZeroTxt === null) {
         $this->iLblZeroTxt = sprintf($this->iLblFmt, $this->iZeroSum);
     } else {
         $this->iLblZeroTxt = sprintf($this->iLblZeroTxt, $this->iZeroSum);
     }
     $val->Set($this->iLblZeroTxt);
     $val->SetAlign('center', 'center');
     $val->SetParagraphAlign('center');
     $val->SetColor($this->iZFontColor);
     $val->SetFont($this->iZFontFamily, $this->iZFontStyle, $this->iZFontSize);
     $val->Stroke($aImg, $xc, $yc);
 }
 function StrokeLabels(&$aImg, $xc, $yc, $ri, $rr)
 {
     if ($this->iHideLabels) {
         return;
     }
     $a = $this->iAngle * M_PI / 180.0;
     $n = $this->iNumCirc;
     $d = $this->iDelta;
     $val = new Text();
     $val->SetFont($this->iFontFamily, $this->iFontStyle, $this->iFontSize);
     $val->SetColor($this->iFontColor);
     if ($this->iFontBkgColor !== false) {
         $val->SetBox($this->iFontBkgColor, $this->iFontFrameColor);
     }
     if ($this->iLblAlign == LBLALIGN_TOP) {
         if ($a > 0 && $a <= M_PI / 2) {
             $val->SetAlign('left', 'bottom');
         } elseif ($a > M_PI / 2 && $a <= M_PI) {
             $val->SetAlign('right', 'bottom');
         }
     } elseif ($this->iLblAlign == LBLALIGN_CENTER) {
         $val->SetAlign('center', 'center');
     }
     $v = $d;
     $si = sin($a);
     $co = cos($a);
     for ($i = 0; $i < $n; ++$i, $v += $d) {
         $r = $ri + ($i + 1) * $rr;
         $x = $xc + $co * $r;
         $y = $yc - $si * $r;
         $val->Set(sprintf($this->iLblFmt, $v));
         $val->Stroke($aImg, $x, $y);
     }
     if ($this->iLblZeroTxt === null) {
         $this->iLblZeroTxt = sprintf($this->iLblFmt, $this->iZeroSum);
     } else {
         $this->iLblZeroTxt = sprintf($this->iLblZeroTxt, $this->iZeroSum);
     }
     $val->Set($this->iLblZeroTxt);
     $val->SetAlign('center', 'center');
     $val->SetParagraphAlign('center');
     $val->SetColor($this->iZFontColor);
     $val->SetFont($this->iZFontFamily, $this->iZFontStyle, $this->iZFontSize);
     $val->Stroke($aImg, $xc, $yc);
 }
Exemple #17
0
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
$datay = array(12, 8, 19, 3, 10, 5);
// Create the graph. These two calls are always required
$graph = new Graph(300, 200);
$graph->SetScale('textlin');
// Add a drop shadow
$graph->SetShadow();
// Adjust the margin a bit to make more room for titles
$graph->img->SetMargin(40, 30, 20, 40);
// Create a bar pot
$bplot = new BarPlot($datay);
$graph->Add($bplot);
// Create and add a new text
$txt = new Text("This is a text\nwith many\nand even\nmore\nlines of text");
$txt->SetPos(0.5, 0.5, 'center', 'center');
$txt->SetFont(FF_FONT2, FS_BOLD);
$txt->ParagraphAlign('center');
$txt->SetBox('yellow', 'navy', 'gray');
$txt->SetColor('red');
$graph->AddText($txt);
// Setup the titles
$graph->title->Set("A simple bar graph");
$graph->xaxis->title->Set("X-title");
$graph->yaxis->title->Set("Y-title");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
// Display the graph
$graph->Stroke();
function init_graphs()
{
    global $rundate;
    // Create the graphs
    $tdate1 = new Text();
    $tdate1->SetFont(FF_ARIAL, FS_NORMAL, 8);
    $tdate1->SetColor("#000000");
    $tdate1->Set("generated at: {$rundate}");
    $tdate1->SetBox("#ffffff", "#8b898b", "#aaaaaa", 0, 0);
    $tdate1->SetPos(280, 220);
    $tdate2 = new Text();
    $tdate2->SetFont(FF_ARIAL, FS_NORMAL, 8);
    $tdate2->SetColor("#000000");
    $tdate2->Set("generated at: {$rundate}");
    $tdate2->SetBox("#ffffff", "#8b898b", "#aaaaaa", 0, 0);
    $tdate2->SetPos(560, 420);
    // ** ------------- **
    $graph1 = new Graph(470, 250, "auto");
    $graph1->SetScale("textlin");
    $graph1->SetShadow();
    $graph1->SetBox();
    $graph1->img->SetMargin(60, 30, 30, 80);
    $graph1->SetMarginColor('#ececec');
    $graph1->title->SetFont(FF_ARIAL, FS_BOLD, 12);
    $graph1->AddText($tdate1);
    // --------------
    $graph1->ygrid->Show(true, true);
    $graph1->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
    $graph1->yaxis->title->SetAngle(90);
    $graph1->yaxis->SetTitleMargin(40);
    $graph1->yaxis->title->Text("Translated Messages", "high");
    $graph1->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
    $graph1->yaxis->SetLabelAngle(0);
    $graph1->yaxis->SetPos('min');
    // -------------
    $graph1->xgrid->Show(false, false);
    $graph1->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
    $graph1->xaxis->title->SetAngle(0);
    $graph1->xaxis->title->Text("Days");
    $graph1->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
    $graph1->xaxis->SetLabelAngle(30);
    $graph1->xaxis->SetTextLabelInterval(10);
    $graph1->xaxis->SetPos('min');
    $sline = new PlotLine(HORIZONTAL, 0, "black", 1);
    $graph1->Add($sline);
    // ** ------------- **
    $graph2 = new Graph(750, 450, "auto");
    $graph2->SetScale("textlin");
    $graph2->SetShadow();
    $graph2->SetBox();
    $graph2->img->SetMargin(60, 30, 30, 80);
    $graph2->SetMarginColor('#ececec');
    $graph2->title->SetFont(FF_ARIAL, FS_BOLD, 12);
    $graph2->AddText($tdate2);
    // --------------
    $graph2->ygrid->Show(true, true);
    $graph2->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
    $graph2->yaxis->title->SetAngle(90);
    $graph2->yaxis->SetTitleMargin(40);
    $graph2->yaxis->title->Text("Translated Messages", "high");
    $graph2->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
    $graph2->yaxis->SetLabelAngle(0);
    $graph2->yaxis->SetPos('min');
    // -------------
    $graph2->xgrid->Show(true, false);
    $graph2->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
    $graph2->xaxis->title->SetAngle(0);
    $graph2->xaxis->title->Text("Days");
    $graph2->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
    $graph2->xaxis->SetLabelAngle(30);
    $graph2->xaxis->SetTextLabelInterval(10);
    $graph2->xaxis->SetPos('min');
    $sline = new PlotLine(HORIZONTAL, 0, "black", 1);
    $graph2->Add($sline);
    return array($graph1, $graph2);
}