Beispiel #1
0
 function _StrokeLegend($aImg, $x, $y, $scaling = 1, $aReturnWidth = false)
 {
     if (!$this->legend->iShow) {
         return 0;
     }
     $nlc = count($this->iLegColors);
     $nlw = count($this->iLegweights);
     // Setup font for ranges
     $value = new Text();
     $value->SetAlign('center', 'bottom');
     $value->SetFont($this->legend->iLblFontFamily, $this->legend->iLblFontStyle, $this->legend->iLblFontSize * $scaling);
     $value->SetColor($this->legend->iLblFontColor);
     // Remember x-center
     $xcenter = $x;
     // Construct format string
     $fmt = $this->legend->iFormatString . '-' . $this->legend->iFormatString;
     // Make sure that the length of each range is enough to cover the
     // size of the labels
     $tst = sprintf($fmt, $this->iRanges[0], $this->iRanges[1]);
     $value->Set($tst);
     $w = $value->GetWidth($aImg);
     $l = round(max($this->legend->iLength * $scaling, $w * 1.5));
     $r = $this->legend->iCircleRadius * $scaling;
     $len = 2 * $r + $this->scale->iMaxNum * $l;
     // We are called just to find out the width
     if ($aReturnWidth) {
         return $len;
     }
     $x -= round($len / 2);
     $x += $r;
     // 4 pixels extra vertical margin since the circle sometimes is +/- 1 pixel of the
     // theorethical radius due to imperfection in the GD library
     //$y -= round(max($r,$scaling*$this->iLegweights[($this->scale->iMaxNum-1) % $nlw])+4*$scaling);
     $y -= ($this->legend->iCircleRadius + 2) * $scaling + $this->legend->iBottomMargin * $scaling;
     // Adjust for bottom text
     if ($this->legend->iTxt != '') {
         // Setup font for text
         $value->Set($this->legend->iTxt);
         $y -= $value->GetHeight($aImg);
     }
     // Stroke 0-circle
     $this->_ThickCircle($aImg, $x, $y, $r, $this->legend->iCircleWeight, $this->legend->iCircleColor);
     // Remember the center of the circe
     $xc = $x;
     $yc = $y;
     $value->SetAlign('center', 'bottom');
     $x += $r + 1;
     // Stroke all used ranges
     $txty = $y - round($this->iLegweights[($this->scale->iMaxNum - 1) % $nlw] * $scaling) - 4 * $scaling;
     if ($this->scale->iMaxNum >= count($this->iRanges)) {
         JpGraphError::RaiseL(22007);
         //('To few values for the range legend.');
     }
     $i = 0;
     $idx = 0;
     while ($i < $this->scale->iMaxNum) {
         $y1 = $y - round($this->iLegweights[$i % $nlw] * $scaling);
         $y2 = $y + round($this->iLegweights[$i % $nlw] * $scaling);
         $x2 = $x + $l;
         $aImg->SetColor($this->iLegColors[$i % $nlc]);
         $aImg->FilledRectangle($x, $y1, $x2, $y2);
         if ($this->iRangeStyle == RANGE_OVERLAPPING) {
             $lbl = sprintf($fmt, $this->iRanges[$idx], $this->iRanges[$idx + 1]);
         } else {
             $lbl = sprintf($fmt, $this->iRanges[$idx], $this->iRanges[$idx + 1]);
             ++$idx;
         }
         $value->Set($lbl);
         $value->Stroke($aImg, $x + $l / 2, $txty);
         $x = $x2;
         ++$i;
         ++$idx;
     }
     // Setup circle font
     $value->SetFont($this->legend->iCircleFontFamily, $this->legend->iCircleFontStyle, $this->legend->iCircleFontSize * $scaling);
     $value->SetColor($this->legend->iCircleFontColor);
     // Stroke 0-circle text
     $value->Set($this->legend->iZCircleTxt);
     $value->SetAlign('center', 'center');
     $value->ParagraphAlign('center');
     $value->Stroke($aImg, $xc, $yc);
     // Setup circle font
     $value->SetFont($this->legend->iTxtFontFamily, $this->legend->iTxtFontStyle, $this->legend->iTxtFontSize * $scaling);
     $value->SetColor($this->legend->iTxtFontColor);
     // Draw the text under the legend
     $value->Set($this->legend->iTxt);
     $value->SetAlign('center', 'top');
     $value->SetParagraphAlign('center');
     $value->Stroke($aImg, $xcenter, $y2 + $this->legend->iTxtMargin * $scaling);
 }
Beispiel #2
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 _StrokeLegend(&$aImg, $x, $y, $scaling = 1, $aReturnWidth = false)
 {
     if (!$this->legend->iShow) {
         return;
     }
     $nlc = count($this->iLegColors);
     $nlw = count($this->iLegweights);
     $value = new Text();
     $value->SetAlign('center', 'bottom');
     $value->SetFont($this->legend->iLblFontFamily, $this->legend->iLblFontStyle, $this->legend->iLblFontSize * $scaling);
     $value->SetColor($this->legend->iLblFontColor);
     $xcenter = $x;
     $fmt = $this->legend->iFormatString . '-' . $this->legend->iFormatString;
     $tst = sprintf($fmt, $this->iRanges[0], $this->iRanges[1]);
     $value->Set($tst);
     $w = $value->GetWidth($aImg);
     $l = round(max($this->legend->iLength * $scaling, $w * 1.5));
     $r = $this->legend->iCircleRadius * $scaling;
     $len = 2 * $r + $this->scale->iMaxNum * $l;
     if ($aReturnWidth) {
         return $len;
     }
     $x -= round($len / 2);
     $x += $r;
     $y -= ($this->legend->iCircleRadius + 2) * $scaling + $this->legend->iBottomMargin * $scaling;
     if ($this->legend->iTxt != '') {
         $value->Set($this->legend->iTxt);
         $y -= $value->GetHeight($aImg);
     }
     $this->_ThickCircle($aImg, $x, $y, $r, $this->legend->iCircleWeight, $this->legend->iCircleColor);
     $xc = $x;
     $yc = $y;
     $value->SetAlign('center', 'bottom');
     $x += $r + 1;
     $txty = $y - round($this->iLegweights[($this->scale->iMaxNum - 1) % $nlw] * $scaling) - 4 * $scaling;
     if ($this->scale->iMaxNum >= count($this->iRanges)) {
         JpGraphError::RaiseL(22007);
     }
     $i = 0;
     $idx = 0;
     while ($i < $this->scale->iMaxNum) {
         $y1 = $y - round($this->iLegweights[$i % $nlw] * $scaling);
         $y2 = $y + round($this->iLegweights[$i % $nlw] * $scaling);
         $x2 = $x + $l;
         $aImg->SetColor($this->iLegColors[$i % $nlc]);
         $aImg->FilledRectangle($x, $y1, $x2, $y2);
         if ($this->iRangeStyle == RANGE_OVERLAPPING) {
             $lbl = sprintf($fmt, $this->iRanges[$idx], $this->iRanges[$idx + 1]);
         } else {
             $lbl = sprintf($fmt, $this->iRanges[$idx], $this->iRanges[$idx + 1]);
             ++$idx;
         }
         $value->Set($lbl);
         $value->Stroke($aImg, $x + $l / 2, $txty);
         $x = $x2;
         ++$i;
         ++$idx;
     }
     $value->SetFont($this->legend->iCircleFontFamily, $this->legend->iCircleFontStyle, $this->legend->iCircleFontSize * $scaling);
     $value->SetColor($this->legend->iCircleFontColor);
     $value->Set($this->legend->iZCircleTxt);
     $value->SetAlign('center', 'center');
     $value->ParagraphAlign('center');
     $value->Stroke($aImg, $xc, $yc);
     $value->SetFont($this->legend->iTxtFontFamily, $this->legend->iTxtFontStyle, $this->legend->iTxtFontSize * $scaling);
     $value->SetColor($this->legend->iTxtFontColor);
     $value->Set($this->legend->iTxt);
     $value->SetAlign('center', 'top');
     $value->SetParagraphAlign('center');
     $value->Stroke($aImg, $xcenter, $y2 + $this->legend->iTxtMargin * $scaling);
 }
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();
}
Beispiel #5
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();
Beispiel #6
0
include "../jpgraph.php";
include "../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, "auto");
$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('cenetered');
$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();
Beispiel #7
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);*/
    }
}
Beispiel #8
0
    $graph->legend->SetShadow(imgdef($q['legend']['shadow']['color'], 'gray@0.5'), imgdef($q['legend']['shadow']['width'], '2'));
}
$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;
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();
    }
}