Ejemplo n.º 1
0
 /**
  * @return Text
  */
 private function addTextToGraph($msg, $padding_left, $padding_top, $font_weight, $font_size, $img_width)
 {
     $text = new Text($msg, $padding_left, $padding_top);
     $text->SetFont($this->getFont(), $font_weight, $font_size);
     $text->SetColor($this->getMainColor());
     //word wrap
     $width = $text->GetWidth($this->jpgraph_instance->img) - $padding_left;
     $text->SetWordWrap(floor(strlen($msg) * ($this->img_width - 3 * $padding_left) / $width));
     $text->Stroke($this->jpgraph_instance->img);
     return $text;
 }
Ejemplo n.º 2
0
 function Create()
 {
     if ($this->ready) {
         return;
     }
     $this->graph = new CanvasGraph($this->width, $this->height, 'auto');
     $this->graph->SetMargin(5, 11, 6, 11);
     /*
         $this->graph->SetShadow();
         $this->graph->SetMarginColor( "teal");
         $this->graph->InitFrame(); 
     */
     $hpos = 15;
     $text = new Text("ADEI", $this->width / 2, $hpos);
     $text->SetFont(FF_ARIAL, FS_BOLD, 24);
     $text->Align('center', 'top');
     $text->Stroke($this->graph->img);
     $hpos += $text->GetTextHeight($this->graph->img) + 10;
     //    $msg = "Welcome to the Advanced Data Extraction Infrastructure! Please";
     $msg = preg_replace(array("/\n([^\n])/"), array(' \\1'), file_get_contents("docs/welcome.txt"));
     $text_width = $this->width - 50;
     if ($text_width < 100) {
         return;
     }
     $text = new Text($msg, $this->width / 2, $hpos);
     $text->SetFont(FF_ARIAL, FS_NORMAL, 18);
     $text->Align('center', 'top');
     $width = $text->GetWidth($this->graph->img);
     if ($width > $text_width) {
         $char_width = ceil($width / strlen($msg));
         $cpl = $text_width / $char_width;
         $wmsg = wordwrap($msg, $cpl, "\n", true);
         $text->Set($wmsg);
         $width = $text->GetWidth($this->graph->img);
         while ($width > $text_width && $cpl > 10) {
             $cpl -= $cpl / 10;
             $wmsg = wordwrap($msg, $cpl, "\n", true);
             $text->Set($wmsg);
             $width = $text->GetWidth($this->graph->img);
         }
     }
     $text->Stroke($this->graph->img);
     //    $text->ParagraphAlign('center');
     //    $text->SetBox( "white", "black","gray");
     /*
     //    $text->Align('left', 'top');
     //    $text->ParagraphAlign('left'); 
     //    $text->SetBox( "white", "black","gray"); 
         $width = $text->GetWidth($this->graph->img);
     */
     //    $text->Stroke( $this->graph->img);
 }
Ejemplo n.º 3
0
function generate_image($lang, $idx)
{
    global $LANGUAGES;
    $up_to_date = get_stats($idx, $lang, 'uptodate');
    $up_to_date = $up_to_date[0];
    //
    $outdated = @get_stats($idx, $lang, 'outdated');
    $outdated = $outdated[0];
    //
    $missing = get_stats($idx, $lang, 'notrans');
    $missing = $missing[0];
    //
    $no_tag = @get_stats($idx, $lang, 'norev');
    $no_tag = $no_tag[0];
    $data = array($up_to_date, $outdated, $missing, $no_tag);
    $percent = array();
    $total = array_sum($data);
    // Total ammount in EN manual (to calculate percentage values)
    $total_files_lang = $total - $missing;
    // Total ammount of files in translation
    foreach ($data as $value) {
        $percent[] = round($value * 100 / $total);
    }
    $legend = array($percent[0] . '%% up to date (' . $up_to_date . ')', $percent[1] . '%% outdated (' . $outdated . ')', $percent[2] . '%% missing (' . $missing . ')', $percent[3] . '%% without EN-Revision (' . $no_tag . ')');
    $title = 'Details for ' . $LANGUAGES[$lang] . ' PHP Manual';
    $graph = new PieGraph(530, 300);
    $graph->SetShadow();
    $graph->title->Set($title);
    $graph->title->Align('left');
    $graph->title->SetFont(FF_FONT1, FS_BOLD);
    $graph->legend->Pos(0.02, 0.18, "right", "center");
    $graph->subtitle->Set('(Total: ' . $total_files_lang . ' files)');
    $graph->subtitle->Align('left');
    $graph->subtitle->SetColor('darkred');
    $t1 = new Text(date('m/d/Y'));
    $t1->SetPos(522, 294);
    $t1->SetFont(FF_FONT1, FS_NORMAL);
    $t1->Align("right", 'bottom');
    $t1->SetColor("black");
    $graph->AddText($t1);
    $p1 = new PiePlot3D($data);
    $p1->SetSliceColors(array("#68d888", "#ff6347", "#dcdcdc", "#f4a460"));
    if ($total_files_lang != $up_to_date) {
        $p1->ExplodeAll();
    }
    $p1->SetCenter(0.35, 0.55);
    $p1->value->Show(false);
    $p1->SetLegends($legend);
    $graph->Add($p1);
    $graph->Stroke("../www/images/revcheck/info_revcheck_php_{$lang}.png");
}
Ejemplo n.º 4
0
 function plot()
 {
     $this->_setValues();
     // Create the Pie Graph.
     $graph = new PieGraph(500, 300);
     $graph->SetShadow();
     // Create
     $p1 = new PiePlot($this->_data);
     // Set A title for the plot
     $p1->SetLegends($this->_legends);
     $p1->SetSize(0.3);
     $p1->SetCenter(0.28, 0.5);
     $txt = new Text("Most Visited Titles", 0.15, 0.05);
     $txt->SetFont(FONT1_BOLD);
     $graph->Add($p1);
     $graph->AddText($txt);
     $graph->Stroke();
 }
Ejemplo n.º 5
0
 function CreateMessage($header, $msg)
 {
     $this->graph = new CanvasGraph($this->width, $this->height, 'auto');
     $this->graph->SetMargin(5, 11, 6, 11);
     $this->graph->SetShadow();
     $this->graph->SetMarginColor("teal");
     $this->graph->InitFrame();
     $text_width = $this->width - 50;
     if ($text_width < 100) {
         return;
     }
     $text = new Text($msg, 25, 25);
     $text->SetFont(FF_ARIAL, FS_NORMAL, 24);
     //    $text->Align('left', 'top');
     //    $text->ParagraphAlign('left');
     //    $text->SetBox( "white", "black","gray");
     $width = $text->GetWidth($this->graph->img);
     if ($width > $text_width) {
         $char_width = ceil($width / strlen($msg));
         $cpl = $text_width / $char_width;
         /*
         	Does not taken into the account by GetWidth function
         	$text->SetWordWrap($cpl);
         */
         $wmsg = wordwrap($msg, $cpl, "\n", true);
         $text->Set($wmsg);
         $width = $text->GetWidth($this->graph->img);
         while ($width > $text_width && $cpl > 10) {
             $cpl -= $cpl / 10;
             $wmsg = wordwrap($msg, $cpl, "\n", true);
             $text->Set($wmsg);
             $width = $text->GetWidth($this->graph->img);
         }
     }
     $text->Stroke($this->graph->img);
 }
Ejemplo n.º 6
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();
Ejemplo n.º 7
0
 function Stroke($aGraph)
 {
     $aImg = $aGraph->img;
     if ($this->iX > 0 && $this->iX < 1) {
         $this->iX = round($aImg->width * $this->iX);
     }
     if ($this->iY > 0 && $this->iY < 1) {
         $this->iY = round($aImg->height * $this->iY);
     }
     if ($this->iSize > 0 && $this->iSize < 1) {
         $this->iSize *= min($aImg->width, $aImg->height);
     }
     if ($this->iCenterSize > 0 && $this->iCenterSize < 1) {
         $this->iCenterSize *= $this->iSize;
     }
     $this->scale->AutoScale(($this->iSize - $this->iCenterSize) / 2, round(2.5 * $this->scale->iFontSize));
     $scaling = $this->iAntiAlias ? 2 : 1;
     $value = new Text();
     $value->SetFont($this->iFontFamily, $this->iFontStyle, $this->iFontSize * $scaling);
     $value->SetColor($this->iFontColor);
     $legendheight = round($this->legend->iShow ? 1 : 0);
     $legendheight *= max($this->legend->iCircleRadius * 2, $this->legend->iTxtFontSize * 2) + $this->legend->iMargin + $this->legend->iBottomMargin + 2;
     $legendheight *= $scaling;
     $w = $scaling * $this->getWidth($aImg);
     $h = $scaling * $this->getHeight($aImg);
     // Copy back the double buffered image to the proper canvas
     $ww = $w / $scaling;
     $hh = $h / $scaling;
     // Create the double buffer
     if ($this->iAntiAlias) {
         $dblImg = new RotImage($w, $h);
         // Set the background color
         $dblImg->SetColor($this->iColor);
         $dblImg->FilledRectangle(0, 0, $w, $h);
     } else {
         $dblImg = $aImg;
         // Make sure the ix and it coordinates correpond to the new top left center
         $dblImg->SetTranslation($this->iX - $w / 2, $this->iY - $h / 2);
     }
     if (__DEBUG) {
         $dblImg->SetColor('red');
         $dblImg->Rectangle(0, 0, $w - 1, $h - 1);
     }
     $dblImg->SetColor('black');
     if ($this->iShowBox) {
         $dblImg->SetColor($this->iBoxColor);
         $old = $dblImg->SetLineWeight($this->iBoxWeight);
         $dblImg->SetLineStyle($this->iBoxStyle);
         $dblImg->Rectangle(0, 0, $w - 1, $h - 1);
         $dblImg->SetLineWeight($old);
     }
     $xc = round($w / 2);
     $yc = round(($h - $legendheight) / 2);
     if (__DEBUG) {
         $dblImg->SetColor('red');
         $old = $dblImg->SetLineWeight(2);
         $dblImg->Line($xc - 5, $yc - 5, $xc + 5, $yc + 5);
         $dblImg->Line($xc + 5, $yc - 5, $xc - 5, $yc + 5);
         $dblImg->SetLineWeight($old);
     }
     $this->iSize *= $scaling;
     // Inner circle size
     $ri = $this->iCenterSize / 2;
     // Full circle radius
     $r = round($this->iSize / 2);
     // Get number of grid circles
     $n = $this->scale->GetNumCirc();
     // Plot circle grids
     $ri *= $scaling;
     $rr = round(($r - $ri) / $n);
     for ($i = 1; $i <= $n; ++$i) {
         $this->_ThickCircle($dblImg, $xc, $yc, $rr * $i + $ri, $this->iCircGridWeight, $this->iGridColor1);
     }
     $num = 0;
     if ($this->iType == WINDROSE_TYPEFREE) {
         $this->_StrokeFreeRose($dblImg, $value, $scaling, $xc, $yc, $r, $ri);
     } else {
         // Check if we need to re-code the interpretation of the ordinal
         // number in the data. Internally ordinal value 0 is East and then
         // counted anti-clockwise. The user might choose an encoding
         // that have 0 being the first axis to the right of the "N" axis and then
         // counted clock-wise
         if ($this->iOrdinalEncoding == KEYENCODING_CLOCKWISE) {
             if ($this->iType == WINDROSE_TYPE16) {
                 $const1 = 19;
                 $const2 = 16;
             } elseif ($this->iType == WINDROSE_TYPE8) {
                 $const1 = 9;
                 $const2 = 8;
             } else {
                 $const1 = 4;
                 $const2 = 4;
             }
             $tmp = array();
             $n = count($this->iData);
             foreach ($this->iData as $key => $val) {
                 if (is_numeric($key)) {
                     $key = ($const1 - $key) % $const2;
                 }
                 $tmp[$key] = $val;
             }
             $this->iData = $tmp;
         }
         $this->_StrokeRegularRose($dblImg, $value, $scaling, $xc, $yc, $r, $ri);
     }
     // Stroke the labels
     $this->scale->iFontSize *= $scaling;
     $this->scale->iZFontSize *= $scaling;
     $this->scale->StrokeLabels($dblImg, $xc, $yc, $ri, $rr);
     // Stroke the inner circle again since the legs
     // might have written over it
     $this->_ThickCircle($dblImg, $xc, $yc, $ri, $this->iCircGridWeight, $this->iGridColor1);
     if ($ww > $aImg->width) {
         JpgraphError::RaiseL(22020);
         //('Windrose plot is too large to fit the specified Graph size. Please use WindrosePlot::SetSize() to make the plot smaller or increase the size of the Graph in the initial WindroseGraph() call.');
     }
     $x = $xc;
     $y = $h;
     $this->_StrokeLegend($dblImg, $x, $y, $scaling);
     if ($this->iAntiAlias) {
         $aImg->Copy($dblImg->img, $this->iX - $ww / 2, $this->iY - $hh / 2, 0, 0, $ww, $hh, $w, $h);
     }
     // We need to restore the translation matrix
     $aImg->SetTranslation(0, 0);
 }
Ejemplo n.º 8
0
 function Stroke($aData, $aFile = '', $aShowDetails = false, $aShowEncodingDetails = false)
 {
     $textmargin = 5;
     $this->iEncoder->AddChecksum($this->iUseChecksum);
     $spec = $this->iEncoder->Enc($aData);
     $this->AdjustSpec($spec);
     if ($this->iFontFam == -1) {
         if ($this->iModuleWidth > 1) {
             $this->iFontFam = FF_FONT2;
             $this->iFontStyle = FS_BOLD;
         } else {
             $this->iFontFam = FF_FONT1;
             $this->iFontStyle = FS_BOLD;
         }
     }
     $s = '';
     $n = count($spec->iBar);
     $g = new CanvasGraph(0, 0);
     $g->img->SetImgFormat($this->iImgFormat);
     if ($aShowDetails) {
         $s = $spec->iEncoding . "\n";
         $s .= 'Data: ' . $spec->iData . "\n";
         if ($spec->iInfo != '') {
             $s .= 'Info: ' . $spec->iInfo . "\n";
         }
     }
     $w = round($spec->iModuleWidth);
     $totwidth = $spec->iLeftMargin * $w;
     $n = count($spec->iBar);
     for ($i = 0; $i < $n; ++$i) {
         $b = $spec->iBar[$i];
         $bn = strlen($b[3]);
         for ($j = 0; $j < $bn; ++$j) {
             $wb = substr($b[3], $j, 1) * $w;
             $totwidth += $wb;
         }
     }
     if ($spec->iInterCharModuleSpace) {
         $totwidth += ($n - 2) * $w;
     }
     $totwidth += $spec->iRightMargin * $w + 1;
     $height = $this->iHeight;
     if ($aShowDetails) {
         $g->img->SetFont(FF_FONT2);
         $height += $g->img->GetTextHeight($s);
     }
     $g->img->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
     $th = $g->img->GetTextHeight($spec->iData);
     if ($spec->iStrokeDataBelow) {
         $height += $th + $this->iDataBelowMargin;
     }
     if ($height < round(0.15 * ($totwidth - $spec->iRightMargin * $w - $spec->iLeftMargin * $w))) {
         $height = round(0.15 * $totwidth);
     }
     $g->img->SetFont(FF_FONT2);
     $tw = 2 * $textmargin + $g->img->GetTextWidth($s);
     $width = $totwidth;
     if ($width < $tw) {
         $width = $tw;
     }
     if ($aShowEncodingDetails) {
         $g->img->SetFont(FF_FONT2);
         $height += $n * $g->img->GetTextHeight('0');
         $width = max(300, $totwidth);
     }
     $g = new CanvasGraph($width, $height);
     $g->img->SetImgFormat($this->iImgFormat);
     $g->SetMarginColor('white');
     if ($this->iShowFrame) {
         $g->frame_color = $this->iFrameColor;
         $g->InitFrame();
     }
     $g->img->SetColor('black');
     $x = $w * $spec->iLeftMargin;
     $ystart = $this->iTopMargin;
     $yend = $height - $this->iBottomMargin - 1;
     if ($aShowDetails) {
         $ystart += $g->img->GetTextHeight($s);
     }
     if ($aShowEncodingDetails) {
         $g->img->SetFont(FF_FONT2);
         $ystart += $n * $g->img->GetTextHeight('0');
     }
     if ($spec->iStrokeDataBelow) {
         $yend -= $th + $this->iDataBelowMargin;
     }
     $inunder = false;
     $under_s = '';
     $under_x = 0;
     for ($i = 0; $i < $n; ++$i) {
         $b = $spec->iBar[$i];
         if ($aShowEncodingDetails) {
             $s .= sprintf("%02d", $i) . " : {$b['0']}, {$b['1']}, {$b['2']}, {$b['3']}\n";
         }
         $bn = strlen($b[3]);
         if ($b[2] == 0 && !$this->iNoHumanText) {
             if (!$inunder) {
                 $inunder = true;
                 $under_x = $x;
                 $under_s = $b[0];
             } else {
                 $under_s .= $b[0];
             }
         } else {
             if ($inunder) {
                 $inunder = false;
                 if ($under_s != '') {
                     $t = new Text($under_s, ($under_x + $x - 1) / 2, $yend - $th / 1.3);
                     $t->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
                     $t->Align('center', 'top');
                     $t->Stroke($g->img);
                 }
             }
         }
         $startx = $x;
         for ($j = 0; $j < $bn; ++$j) {
             $wb = substr($b[3], $j, 1) * $w;
             if ($j % 2 == $b[1]) {
                 $g->img->SetColor($this->iBkgColor);
             } else {
                 $g->img->SetColor($this->iColor);
             }
             if ($b[2] == 1 || $this->iNoHumanText) {
                 $g->img->FilledRectangle($x, $ystart, $x + $wb - 1, $yend);
             } else {
                 $g->img->FilledRectangle($x, $ystart, $x + $wb - 1, $yend - $th);
             }
             $x += $wb;
         }
         if ($this->iDebugBackground) {
             $g->SetAlphaBlending();
             if (($i & 1) == 0) {
                 $g->img->SetColor('lightblue@0.5');
             } else {
                 $g->img->SetColor('yellow@0.5');
             }
             $g->img->FilledRectangle($startx, $ystart - 2, $x, $yend);
         }
         if ($spec->iInterCharModuleSpace) {
             $x += $w;
         }
     }
     $g->img->SetColor($this->iColor);
     if (!($spec->iLeftData === '')) {
         $g->img->SetTextAlign('right', 'top');
         $g->img->SetFont($this->iSmallFontFam, $this->iSmallFontStyle, $this->iSmallFontSize);
         $g->img->StrokeText($w * $spec->iLeftMargin - 3, $yend - $th, $spec->iLeftData);
     }
     if (!($spec->iRightData === '')) {
         $g->img->SetTextAlign('left', 'top');
         $g->img->SetFont($this->iSmallFontFam, $this->iSmallFontStyle, $this->iSmallFontSize);
         $g->img->StrokeText($x + 3, $yend - $th, $spec->iRightData);
     }
     if ($spec->iStrokeDataBelow) {
         $y = $yend + $this->iDataBelowMargin;
         $bw = $totwidth - $spec->iLeftMargin * $w - $spec->iRightMargin * $w;
         $x = $spec->iLeftMargin * $w + floor($bw / 2);
         $g->img->SetTextAlign('center', 'top');
         $g->img->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
         if ($this->iHumanTxt !== '') {
             $g->img->StrokeText($x, $y, $this->iHumanTxt);
         } else {
             $g->img->StrokeText($x, $y, $spec->iData);
         }
     }
     if ($aShowDetails) {
         $g->img->SetColor('navy');
         $g->img->SetTextAlign('left', 'top');
         $g->img->SetFont(FF_FONT2);
         $g->img->StrokeText($textmargin, $this->iTopMargin, $s);
     }
     if (ADD_DEMOTXT === true) {
         $t = new Text("<<DEMO>>", $totwidth / 2, $ystart);
         if ($this->iModuleWidth > 1) {
             if ($this->iModuleWidth > 4) {
                 $t->SetFont(FF_ARIAL, FS_BOLD, 32);
                 $step = 140;
                 $yadj = 50;
             } else {
                 $t->SetFont(FF_ARIAL, FS_BOLD, 24);
                 $step = 110;
                 $yadj = 40;
             }
         } else {
             $t->SetFont(FF_ARIAL, FS_BOLD, 18);
             $step = 80;
             $yadj = 30;
         }
         $t->SetColor('red@0.4');
         $t->Align('center', 'center');
         $t->SetAngle(-25);
         $n = ceil($totwidth / $step);
         for ($i = 0; $i < $n; ++$i) {
             $t->SetPos(-30 + $i * $step, ($yend - $ystart) / 2 - $yadj);
             $t->Stroke($g->img);
         }
     }
     if ($this->iVertical) {
         $g->img->img = $this->Rotate($g->img->img, 90);
     }
     if ($this->iScale != 1) {
         $nwidth = round($width * $this->iScale);
         $nheight = round($height * $this->iScale);
         if ($this->iVertical) {
             $tmp = $height;
             $height = $width;
             $width = $tmp;
             $tmp = $nheight;
             $nheight = $nwidth;
             $nwidth = $tmp;
         }
         $img = @imagecreatetruecolor($nwidth, $nheight);
         if ($img) {
             imagealphablending($img, true);
             imagecopyresampled($img, $g->img->img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
             $g->img->CreateImgCanvas($nwidth, $nheight);
             $g->img->img = $img;
         } else {
             return false;
         }
     }
     return $g->Stroke($aFile);
 }
Ejemplo n.º 9
0
$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();
?>

Ejemplo n.º 10
0
        $legenda[] = $array[0];
        $tot_top10 = $tot_top10 + $array[1];
        $data[] = $array[1];
    }
}
$legenda[] = "Other Titles";
$data[] = $total - $tot_top10;
// operação retirada em 02/2006
// Objetivo: aproveitar o arquivo já processada anteriormente, desde que no mesmo dia
// $OP="rm -f $db_tmp_issn.* ";
// $result=exec($OP);
// **************************************************************
// ********  Apresentação grafico                        ********
// **************************************************************
$graph = new PieGraph(690, 350);
//   $graph->SetShadow ();
// Create
$p1 = new PiePlot($data);
// Set A title for the plot
$p1->SetLegends($legenda);
$p1->SetSize(0.4);
$p1->SetCenter(0.28, 0.5);
$txt = new Text("Most Visited Titles", 0.15, 0.0);
$txt->SetFont(FONT1_BOLD);
$graph->Add($p1);
$graph->AddText($txt);
$graph->Stroke();
?>
 

Ejemplo n.º 11
0
$graph->xaxis->SetLabelMargin(10);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right', 'center');
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(20);
// We don't want to display Y-axis
$graph->yaxis->Hide();
// Now create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetShadow();
//You can change the width of the bars if you like
//$bplot->SetWidth(0.5);
// Set gradient fill for bars
$bplot->SetFillGradient('darkred', 'yellow', GRAD_HOR);
// We want to display the value of each bar at the top
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_BOLD, 10);
//$bplot->value->SetAlign('left','center');
$bplot->value->SetColor("white");
$bplot->value->SetFormat('%.1f');
$bplot->SetValuePos('max');
// Add the bar to the graph
$graph->Add($bplot);
// Add some explanation text
$txt = new Text('Note: Higher value is better.');
$txt->SetPos(190, 399, 'center', 'bottom');
$txt->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->Add($txt);
// .. and stroke the graph
$graph->Stroke();
Ejemplo n.º 12
0
 function Stroke(&$aImg)
 {
     $scaling = $this->iAntiAlias ? 2 : 1;
     $value = new Text();
     $value->SetFont($this->iFontFamily, $this->iFontStyle, $this->iFontSize * $scaling);
     $value->SetColor($this->iFontColor);
     $n = count($this->iLabels);
     if ($n > 0) {
         $maxh = 0;
         $maxw = 0;
         foreach ($this->iLabels as $key => $lbl) {
             $value->Set($lbl);
             $maxh = max($maxh, $value->GetHeight($aImg));
             $maxw = max($maxw, $value->GetWidth($aImg) / 2);
         }
     } else {
         $value->Set("180.8");
         $maxh = $value->GetHeight($aImg);
         $maxw = $value->GetWidth($aImg);
     }
     $maxh += round($this->iFontSize * $scaling * 0.5);
     $maxw += round($this->iFontSize * $scaling * 0.5);
     $valxmarg = 2 * $maxw + 2 * $this->iLabelMargin * $scaling;
     $valymarg = 2 * $maxh + 2 * $this->iLabelMargin * $scaling;
     $w = round($this->iSize * $scaling + $valxmarg);
     $legendwidth = $this->_StrokeLegend($aImg, 0, 0, $scaling, true) + 10 * $scaling;
     $w = max($w, $legendwidth);
     $legendheight = round($this->legend->iShow ? 1 : 0);
     $legendheight *= max($this->legend->iCircleRadius * 2, $this->legend->iTxtFontSize * 2) + $this->legend->iMargin + $this->legend->iBottomMargin + 2;
     $legendheight *= $scaling;
     $h = round($this->iSize * $scaling + $valymarg) + $legendheight;
     if ($this->iAntiAlias) {
         $dblImg = new Image($w, $h);
         $dblImg->SetColor($this->iColor);
         $dblImg->FilledRectangle(0, 0, $w, $h);
     } else {
         $dblImg =& $aImg;
         $dblImg->SetTranslation($this->iX - $w / 2, $this->iY - $h / 2);
     }
     if (__DEBUG) {
         $dblImg->SetColor('red');
         $dblImg->Rectangle(0, 0, $w - 1, $h - 1);
     }
     $dblImg->SetColor('black');
     if ($this->iShowBox) {
         $dblImg->SetColor($this->iBoxColor);
         $dblImg->SetLineWeight($this->iBoxWeight);
         $dblImg->Rectangle(0, 0, $w - 1, $h - 1);
         $dblImg->SetLineWeight(1);
     }
     $xc = round($w / 2);
     $yc = round(($h - $legendheight) / 2);
     $this->iSize *= $scaling;
     $ri = $this->iCenterSize / 2;
     $r = round($this->iSize / 2);
     $n = $this->scale->GetNumCirc();
     $ri *= $scaling;
     $rr = round(($r - $ri) / $n);
     for ($i = 1; $i <= $n; ++$i) {
         $this->_ThickCircle($dblImg, $xc, $yc, $rr * $i + $ri, $this->iCircGridWeight, $this->iGridColor1);
     }
     $num = 0;
     if ($this->iType == WINDROSE_TYPEFREE) {
         $this->_StrokeFreeRose($dblImg, $value, $scaling, $xc, $yc, $r, $ri);
     } else {
         if ($this->iOrdinalEncoding == KEYENCODING_CLOCKWISE) {
             if ($this->iType == WINDROSE_TYPE16) {
                 $const1 = 19;
                 $const2 = 16;
             } elseif ($this->iType == WINDROSE_TYPE8) {
                 $const1 = 9;
                 $const2 = 8;
             } else {
                 $const1 = 4;
                 $const2 = 4;
             }
             $tmp = array();
             $n = count($this->iData);
             foreach ($this->iData as $key => $val) {
                 if (is_numeric($key)) {
                     $key = ($const1 - $key) % $const2;
                 }
                 $tmp[$key] = $val;
             }
             $this->iData = $tmp;
         }
         $this->_StrokeRegularRose($dblImg, $value, $scaling, $xc, $yc, $r, $ri);
     }
     $this->scale->iFontSize *= $scaling;
     $this->scale->iZFontSize *= $scaling;
     $this->scale->StrokeLabels($dblImg, $xc, $yc, $ri, $rr);
     $this->_ThickCircle($dblImg, $xc, $yc, $ri, $this->iCircGridWeight, $this->iGridColor1);
     $ww = $w / $scaling;
     $hh = $h / $scaling;
     if ($ww > $aImg->width) {
         JpgraphError::RaiseL(22020);
     }
     $x = $xc;
     $y = $h;
     $this->_StrokeLegend($dblImg, $x, $y, $scaling);
     if ($this->iAntiAlias) {
         $aImg->Copy($dblImg->img, $this->iX - $ww / 2, $this->iY - $hh / 2, 0, 0, $ww, $hh, $w, $h);
     }
     $aImg->SetTranslation(0, 0);
 }
Ejemplo n.º 13
0
 function Stroke(&$img, &$xscale, &$yscale)
 {
     $img->SetLineWeight($this->weight);
     for ($i = 0; $i < $this->numpoints - 1; $i++) {
         $accy = 0;
         $accy_neg = 0;
         for ($j = 0; $j < $this->nbrplots; ++$j) {
             $img->SetColor($this->plots[$j]->color);
             if ($this->plots[$j]->coords[0][$i] > 0) {
                 $yt = $yscale->Translate($this->plots[$j]->coords[0][$i] + $accy);
                 $accyt = $yscale->Translate($accy);
                 $accy += $this->plots[$j]->coords[0][$i];
             } else {
                 $yt = $yscale->Translate($this->plots[$j]->coords[0][$i] + $accy_neg);
                 $accyt = $yscale->Translate($accy_neg);
                 $accy_neg += $this->plots[$j]->coords[0][$i];
             }
             $xt = $xscale->Translate($i);
             $abswidth = round($this->width * $xscale->scale_factor, 0);
             $pts = array($xt, $accyt, $xt, $yt, $xt + $abswidth, $yt, $xt + $abswidth, $accyt);
             if ($this->plots[$j]->grad) {
                 $grad = new Gradient($img);
                 $grad->FilledRectangle($pts[2], $pts[3], $pts[6], $pts[7], $this->plots[$j]->grad_fromcolor, $this->plots[$j]->grad_tocolor, $this->plots[$j]->grad_style);
             } elseif ($this->plots[$j]->fill_color) {
                 $img->SetColor($this->plots[$j]->fill_color);
                 $img->FilledPolygon($pts, 4);
                 $img->SetColor($this->plots[$j]->color);
             }
             if ($this->bar_shadow) {
                 $ssh = $this->bar_shadow_hsize;
                 $ssv = $this->bar_shadow_vsize;
                 // Create points to create a "upper-right" shadow
                 $sp[0] = $pts[6];
                 $sp[1] = $pts[7];
                 $sp[2] = $pts[4];
                 $sp[3] = $pts[5];
                 $sp[4] = $pts[2];
                 $sp[5] = $pts[3];
                 $sp[6] = $pts[2] + $ssh;
                 $sp[7] = $pts[3] - $ssv;
                 $sp[8] = $pts[4] + $ssh;
                 $sp[9] = $pts[5] - $ssv;
                 $sp[10] = $pts[6] + $ssh;
                 $sp[11] = $pts[7] - $ssv;
                 $img->SetColor($this->bar_shadow_color);
                 $img->FilledPolygon($sp, 4);
             }
             if ($i < count($this->plots[$j]->csimtargets)) {
                 $this->csimareas .= "<area shape=\"rect\" coords=\"";
                 // Hmmm, this is fishy.  Fixes a bug in Opera whereby if Y2<Y1 or X2<X1 the csim doesn't work
                 // This means that the area MUST specify top left and bottom right corners
                 if ($pts[3] < $pts[7]) {
                     if ($pts[2] < $pts[6]) {
                         $this->csimareas .= "{$pts['2']}, {$pts['3']}, {$pts['6']}, {$pts['7']}\"";
                     } else {
                         $this->csimareas .= "{$pts['6']}, {$pts['3']}, {$pts['2']}, {$pts['7']}\"";
                     }
                 } else {
                     if ($pts[2] < $pts[6]) {
                         $this->csimareas .= "{$pts['2']}, {$pts['7']}, {$pts['6']}, {$pts['3']}\"";
                     } else {
                         $this->csimareas .= "{$pts['6']}, {$pts['7']}, {$pts['2']}, {$pts['3']}\"";
                     }
                 }
                 $this->csimareas .= " href=\"" . $this->plots[$j]->csimtargets[$i] . "\"";
                 if (!empty($this->plots[$j]->csimalts[$i])) {
                     $sval = sprintf($this->plots[$j]->csimalts[$i], $this->plots[$j]->coords[0][$i]);
                     $this->csimareas .= " alt=\"{$sval}\"";
                 }
                 $this->csimareas .= ">\r\n";
             }
             $img->Polygon($pts, 4);
         }
         $yt = $yscale->Translate($accy);
         if ($this->show_value) {
             $sval = sprintf($this->show_value_format, $accy);
             $txt = new Text($sval);
             $txt->SetFont($this->show_value_ff, $this->show_value_fs, $this->show_value_fsize);
             $txt->SetColor($this->show_value_color);
             $x = $pts[2] + ($pts[4] - $pts[2]) / 2;
             if ($this->bar_shadow) {
                 $x += $ssh;
             }
             $txt->Pos($x, $yt - $this->show_value_margin);
             $txt->Align("center", "bottom");
             $txt->SetOrientation($this->show_value_angle);
             $txt->Stroke($img);
         }
     }
     return true;
 }
 function Raise($aMsg, $aHalt = true)
 {
     $img_iconerror = 'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaV' . 'BMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/' . 'f0VyckJlZT9YWDxMTDjAwMDy8sLl5bnY2K/MzKW/v5yyspKlpY' . 'iYmH+MjHY/PzV/f2xycmJlZVlZWU9MTEXY2Ms/PzwyMjLFTjea' . 'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx' . 'IAAAsSAdLdfvwAAAAHdElNRQfTBgISOCqusfs5AAABLUlEQVR4' . '2tWV3XKCMBBGWfkranCIVClKLd/7P2Q3QsgCxjDTq+6FE2cPH+' . 'xJ0Ogn2lQbsT+Wrs+buAZAV4W5T6Bs0YXBBwpKgEuIu+JERAX6' . 'wM2rHjmDdEITmsQEEmWADgZm6rAjhXsoMGY9B/NZBwJzBvn+e3' . 'wHntCAJdGu9SviwIwoZVDxPB9+Rc0TSEbQr0j3SA1gwdSn6Db0' . '6Tm1KfV6yzWGQO7zdpvyKLKBDmRFjzeB3LYgK7r6A/noDAfjtS' . 'IXaIzbJSv6WgUebTMV4EoRB8a2mQiQjgtF91HdKDKZ1gtFtQjk' . 'YcWaR5OKOhkYt+ZsTFdJRfPAApOpQYJTNHvCRSJR6SJngQadfc' . 'vd69OLMddVOPCGVnmrFD8bVYd3JXfxXPtLR/+mtv59/ALWiiMx' . 'qL72fwAAAABJRU5ErkJggg==';
     if (function_exists("imagetypes")) {
         $supported = imagetypes();
     } else {
         $supported = 0;
     }
     if (!function_exists('imagecreatefromstring')) {
         $supported = 0;
     }
     if (ob_get_length() || headers_sent() || !($supported & IMG_PNG)) {
         // Special case for headers already sent or that the installation doesn't support
         // the PNG format (which the error icon is encoded in).
         // Dont return an image since it can't be displayed
         die($this->iTitle . ' ' . $aMsg);
     }
     $aMsg = wordwrap($aMsg, 55);
     $lines = substr_count($aMsg, "\n");
     // Create the error icon GD
     $erricon = Image::CreateFromString(base64_decode($img_iconerror));
     // Create an image that contains the error text.
     $w = 400;
     $h = 100 + 15 * max(0, $lines - 3);
     $img = new Image($w, $h);
     // Drop shadow
     $img->SetColor("gray");
     $img->FilledRectangle(5, 5, $w - 1, $h - 1, 10);
     $img->SetColor("gray:0.7");
     $img->FilledRectangle(5, 5, $w - 3, $h - 3, 10);
     // Window background
     $img->SetColor("lightblue");
     $img->FilledRectangle(1, 1, $w - 5, $h - 5);
     $img->CopyCanvasH($img->img, $erricon, 5, 30, 0, 0, 40, 40);
     // Window border
     $img->SetColor("black");
     $img->Rectangle(1, 1, $w - 5, $h - 5);
     $img->Rectangle(0, 0, $w - 4, $h - 4);
     // Window top row
     $img->SetColor("darkred");
     for ($y = 3; $y < 18; $y += 2) {
         $img->Line(1, $y, $w - 6, $y);
     }
     // "White shadow"
     $img->SetColor("white");
     // Left window edge
     $img->Line(2, 2, 2, $h - 5);
     $img->Line(2, 2, $w - 6, 2);
     // "Gray button shadow"
     $img->SetColor("darkgray");
     // Gray window shadow
     $img->Line(2, $h - 6, $w - 5, $h - 6);
     $img->Line(3, $h - 7, $w - 5, $h - 7);
     // Window title
     $m = floor($w / 2 - 5);
     $l = 110;
     $img->SetColor("lightgray:1.3");
     $img->FilledRectangle($m - $l, 2, $m + $l, 16);
     // Stroke text
     $img->SetColor("darkred");
     $img->SetFont(FF_FONT2, FS_BOLD);
     $img->StrokeText($m - 90, 15, $this->iTitle);
     $img->SetColor("black");
     $img->SetFont(FF_FONT1, FS_NORMAL);
     $txt = new Text($aMsg, 52, 25);
     $txt->SetFont(FF_FONT1);
     $txt->Align("left", "top");
     $txt->Stroke($img);
     if ($this->iDest) {
         $img->Stream($this->iDest);
     } else {
         $img->Headers();
         $img->Stream();
     }
     if ($aHalt) {
         die;
     }
 }
Ejemplo n.º 15
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();
 }
Ejemplo n.º 16
0
    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;
    }
Ejemplo n.º 17
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;
}
Ejemplo n.º 18
0
include "../jpgraph_error.php";
include "../jpgraph_bar.php";
$l1datay = array(11, 9, 2, 4, 3, 13, 17);
$l2datay = array(23, 12, 5, 19, 17, 10, 15);
$datax = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul");
// Create the graph.
$graph = new Graph(350, 200, "auto");
$graph->img->SetMargin(40, 70, 20, 40);
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->SetColor(array(250, 250, 250));
$graph->img->SetTransparent("white");
$t1 = new Text("This is a text");
$t1->SetPos(0.5, 0.5);
$t1->SetOrientation("h");
$t1->SetFont(FF_FONT1, FS_BOLD);
$t1->SetBox("white", "black", "gray");
$t1->SetColor("black");
$graph->AddText($t1);
// Create the linear error plot
$l1plot = new LinePlot($l1datay);
$l1plot->SetColor("blue");
$l1plot->SetWeight(2);
$l1plot->SetLegend("Prediction");
// Create the bar plot
$l2plot = new BarPlot($l2datay);
$l2plot->SetFillColor("orange");
$l2plot->SetLegend("Result");
// Add the plots to the graph
$graph->Add($l1plot);
$graph->Add($l2plot);
Ejemplo n.º 19
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();
}
Ejemplo n.º 20
0
$goal1p->SetFillColor("#eeffee");
$graph->Add($goal1p);
// Create a bar pot
$bplot = new BarPlot(array_values($days));
$bplot->SetFillColor("#BBBBEE");
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
$bplot->value->SetAngle(90);
$bplot->value->SetFormatCallback('number_format');
$graph->Add($bplot);
$txt = new Text("Average / Day: " . number_format($average));
$txt->SetColor("black");
$txt->SetFont(FF_ARIAL, FS_BOLD, 10);
$txt->SetPos(30, 295);
$graph->AddText($txt);
$txt = new Text("30 Day Expected: " . number_format($average * 30));
$txt->SetColor("black");
$txt->SetFont(FF_ARIAL, FS_BOLD, 10);
$txt->SetPos(300, 295);
$graph->AddText($txt);
$txt = new Text("TTL: {$user_data['ttl']}");
$txt->SetColor("black");
$txt->SetFont(FF_ARIAL, FS_BOLD, 10);
$txt->SetPos(30, 315);
$graph->AddText($txt);
// Setup the titles
$graph->title->Set("Daily Wordcount");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->HideTicks();
// Display the graph
$graph->Stroke();
Ejemplo n.º 21
0
 function Stroke($aData, $aFile = '', $aOnlyDebug = false)
 {
     $topmargin = 10;
     $bottommargin = 10;
     $textmargin = 5;
     $txtmargin = 4;
     $this->iHeight *= $this->iModuleWidth;
     $spec = $this->iEncoder->Enc($aData);
     if ($aOnlyDebug) {
         return $spec->toString();
     }
     $this->AdjustSpec($spec);
     $data = '';
     if (is_array($aData)) {
         $n = count($aData);
         for ($i = 0; $i < $n; ++$i) {
             $data .= $aData[$i][1];
         }
     } elseif (is_string($aData)) {
         $data = $aData;
     }
     if (!$this->iFontSpecified) {
         if ($this->iModuleWidth > 1) {
             $this->iFontFam = FF_ARIAL;
             $this->iFontStyle = FS_BOLD;
             $this->iFontSize = 10;
         } else {
             $this->iFontFam = FF_ARIAL;
             $this->iFontStyle = FS_NORMAL;
             $this->iFontSize = 7;
         }
     }
     $s = '';
     $g = new CanvasGraph(0, 0);
     // Dummy graph context
     $g->img->SetImgFormat($this->iImgFormat);
     $w = round($spec->iModuleWidth);
     // Calculate total width
     $totwidth = $spec->iLeftMargin * $w;
     $n = count($spec->iBar[0]);
     for ($i = 0; $i < $n; ++$i) {
         $b = $spec->iBar[0][$i];
         $bn = strlen($b[3]);
         for ($j = 0; $j < $bn; ++$j) {
             $wb = substr($b[3], $j, 1) * $w;
             $totwidth += $wb;
         }
     }
     $totwidth += $spec->iRightMargin * $w;
     // Calculate total height
     $height = $this->iHeight * count($spec->iBar) + $topmargin + $bottommargin;
     $g->img->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
     $th = $g->img->GetTextHeight($data) + $txtmargin;
     if ($spec->iStrokeDataBelow) {
         $height += $th;
     }
     $width = $totwidth;
     $g->img->SetFont(FF_FONT2);
     $tw = 2 * $textmargin + $g->img->GetTextWidth($s);
     if ($width < $tw) {
         $width = $tw;
     }
     $g = new CanvasGraph($width, $height);
     $g->img->SetImgFormat($this->iImgFormat);
     $g->SetMarginColor($this->iBkgColor);
     $g->SetColor($this->iBkgColor);
     if ($this->iShowFrame) {
         $g->InitFrame();
     } else {
         $g->frame_weight = 0;
         $g->InitFrame();
     }
     $g->img->SetLineWeight(1);
     $g->img->SetColor('black');
     $x = $w * $spec->iLeftMargin;
     $ystart = $topmargin;
     $inunder = false;
     $under_s = '';
     $startx = $x;
     for ($r = 0; $r < count($spec->iBar); ++$r) {
         $yend = $ystart + $this->iHeight - 1;
         $x = $startx;
         for ($i = 0; $i < $n; ++$i) {
             $b = $spec->iBar[$r][$i];
             $bn = strlen($b[3]);
             for ($j = 0; $j < $bn; ++$j) {
                 $wb = substr($b[3], $j, 1) * $w;
                 if (!($j % 2)) {
                     $g->img->SetColor($this->iColor);
                     $g->img->FilledRectangle($x, $ystart, $x + $wb - 1, $yend);
                 }
                 $x += $wb;
             }
         }
         $ystart += $this->iHeight;
     }
     // row
     $g->img->SetColor($this->iColor);
     if ($spec->iStrokeDataBelow) {
         // Center data underneath
         $y = $yend + $txtmargin;
         $bw = $totwidth - $spec->iLeftMargin * $w - $spec->iRightMargin * $w;
         $x = $spec->iLeftMargin * $w + floor($bw / 2);
         $g->img->SetTextAlign('center', 'top');
         $g->img->SetFont($this->iFontFam, $this->iFontStyle, $this->iFontSize);
         $g->img->StrokeText($x, $y, $data);
     }
     if (ADD_DEMOTXT) {
         $ystart = 0;
         $t = new Text(" DEMO ", $totwidth / 2, $ystart);
         if ($this->iModuleWidth > 1) {
             if ($this->iModuleWidth > 2) {
                 $t->SetFont(FF_ARIAL, FS_BOLD, 24);
                 $step = 120;
             } else {
                 $t->SetFont(FF_ARIAL, FS_BOLD, 16);
                 $step = 100;
             }
         } else {
             $t->SetFont(FF_ARIAL, FS_BOLD, 12);
             $step = 80;
         }
         $t->SetColor('red@0.5');
         $t->Align('center', 'top');
         $t->SetAngle(-15);
         $n = ceil($totwidth / $step);
         for ($y = $ystart; $y < $yend; $y += 50) {
             for ($i = 0; $i < $n; ++$i) {
                 $t->SetPos(-30 + $i * $step, $y);
                 $t->Stroke($g->img);
             }
         }
     }
     if ($this->iVertical) {
         $g->img->img = $this->Rotate($g->img->img, 90);
     }
     if ($this->iScale != 1) {
         $nwidth = round($width * $this->iScale);
         $nheight = round($height * $this->iScale);
         if ($this->iVertical) {
             $tmp = $height;
             $height = $width;
             $width = $tmp;
             $tmp = $nheight;
             $nheight = $nwidth;
             $nwidth = $tmp;
         }
         $img = @imagecreatetruecolor($nwidth, $nheight);
         if ($img) {
             imagealphablending($img, true);
             imagecopyresampled($img, $g->img->img, 0, 0, 0, 0, $nwidth, $nheight, $width, $height);
             $g->img->CreateImgCanvas($nwidth, $nheight);
             $g->img->img = $img;
         } else {
             return false;
         }
     }
     $g->Stroke($aFile);
     return true;
 }
Ejemplo n.º 22
0
 /**
  * 横柱图
  * 
  */
 function createhorizoncolumnar($title, $subtitle, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array())
 {
     vendor("Jpgraph.jpgraph");
     vendor("Jpgraph.jpgraph_bar");
     $datay = $data;
     $datax = $legend;
     //编码转化
     foreach ($datax as $k => $v) {
         $datax[$k] = iconv('utf-8', 'gb2312', $v);
     }
     // Size of graph
     $count = count($datay);
     $addheight = 0;
     if ($count > 10) {
         $addheight = ($count - 10) * 20;
     }
     $height = $height + $addheight;
     // Set the basic parameters of the graph
     $graph = new Graph($width, $height, 'auto');
     $graph->SetScale("textlin");
     // No frame around the image
     $graph->SetFrame(false);
     $graph->SetFrame(false, '#ffffff', 0);
     //去掉周围的边框
     // Rotate graph 90 degrees and set margin
     $graph->Set90AndMargin(70, 10, 50, 30);
     // Set white margin color
     $graph->SetMarginColor('white');
     // Use a box around the plot area
     $graph->SetBox();
     // Use a gradient to fill the plot area
     $graph->SetBackgroundGradient('white', 'white', GRAD_HOR, BGRAD_PLOT);
     // Setup title
     $graph->title->Set(iconv('utf-8', 'gb2312', "{$title}"));
     $graph->title->SetFont(FF_SIMSUN, FS_BOLD, 12);
     $graph->subtitle->Set("(" . iconv('utf-8', 'gb2312', $subtitle) . ")");
     $graph->subtitle->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Setup X-axis
     $graph->xaxis->SetTickLabels($datax);
     $graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 10);
     // Some extra margin looks nicer
     $graph->xaxis->SetLabelMargin(10);
     // Label align for X-axis
     $graph->xaxis->SetLabelAlign('right', 'center');
     // Add some grace to y-axis so the bars doesn't go
     // all the way to the end of the plot area
     $graph->yaxis->scale->SetGrace(10);
     // We don't want to display Y-axis
     $graph->yaxis->Hide();
     // Now create a bar pot
     $bplot = new BarPlot($datay);
     //$bplot->SetShadow();
     //You can change the width of the bars if you like
     //$bplot->SetWidth(0.5);
     // Set gradient fill for bars
     $bplot->SetFillGradient('blue', '#0080C0', GRAD_HOR);
     // We want to display the value of each bar at the top
     $bplot->value->Show();
     $bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 7);
     $bplot->value->SetAlign('left', 'center');
     $bplot->value->SetColor("black");
     $bplot->value->SetFormat('%.0f');
     //$bplot->SetValuePos('max');
     // Add the bar to the graph
     $graph->Add($bplot);
     // Add some explanation text
     $txt = new Text('');
     $txt->SetPos(130, 399, 'center', 'bottom');
     $txt->SetFont(FF_COMIC, FS_NORMAL, 8);
     $graph->Add($txt);
     // .. and stroke the graph
     $graph->Stroke();
 }
Ejemplo n.º 23
0
 function SetDatapoints($datapoints)
 {
     $ny = count($datapoints);
     $nx = count($datapoints[0]);
     $t = new Text();
     $t->SetFont(FF_ARIAL, FS_NORMAL, 8);
     for ($x = 0; $x < $nx; ++$x) {
         for ($y = 0; $y < $ny; ++$y) {
             list($x1, $y1) = $this->scale->Translate($x, $y);
             if ($datapoints[$y][$x] > 0) {
                 $t->SetColor('blue');
             } else {
                 $t->SetColor('black');
             }
             $t->SetFont(FF_ARIAL, FS_BOLD, 8);
             $t->Set($datapoints[$y][$x]);
             $t->Stroke($this->g->img, $x1, $y1);
             $t->SetColor('gray');
             $t->SetFont(FF_ARIAL, FS_NORMAL, 8);
             $t->Set("({$y},{$x})");
             $t->Stroke($this->g->img, $x1 + 10, $y1);
         }
     }
 }
Ejemplo n.º 24
0
pg_close($coop);
include "../../../include/jpgraph/jpgraph.php";
include "../../../include/jpgraph/jpgraph_bar.php";
include "../../../include/jpgraph/jpgraph_line.php";
include "../../../include/network.php";
$nt = new NetworkTable("IACLIMATE");
$cities = $nt->table;
$graph = new Graph(600, 400, "example1");
$graph->SetScale("textlin", 0, 100);
$graph->img->SetMargin(40, 5, 35, 60);
$graph->xaxis->SetTickLabels($xdata);
$graph->xaxis->SetTextTickInterval(100);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetTitle("Precip [inches]");
$graph->xaxis->SetTitleMargin(30);
$graph->yaxis->SetTitle("Cumulative Distribution (percent)");
$graph->title->Set($cities[$station]['name'] . " Precip Accumulation Probabilities");
$graph->subtitle->Set($subtitle);
$l1 = new LinePlot($ydata);
$l1->SetColor("blue");
$l1->SetWeight(2);
$l1->AddArea($hm, $hm, LP_AREA_FILLED, "lightred");
$l1->AddArea($h95, $h95, LP_AREA_FILLED, "lightred");
$l1->AddArea($h5, $h5, LP_AREA_FILLED, "lightred");
$txt = new Text("Diagnostics\n  Min: {$lowVal} ({$lowYear})\n  95%: " . ($lowVal + $h95 * 0.01) . "\n~Mean: " . ($lowVal + $hm * 0.01) . "\n   SD: {$stddev}\n   5%: " . ($lowVal + $h5 * 0.01) . "\n  Max: {$hiVal} ({$hiYear})\n");
$txt->SetPos(0.71, 0.128);
$txt->SetFont(FF_FONT1, FS_NORMAL);
$txt->SetColor("blue");
$graph->Add($l1);
$graph->Add($txt);
$graph->Stroke();
Ejemplo n.º 25
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();
?>

Ejemplo n.º 26
0
 function StrokeAngleLabels($pos, $type)
 {
     if (!$this->show_angle_label) {
         return;
     }
     $x0 = round($this->img->left_margin + $this->img->plotwidth / 2) + 1;
     $d = max($this->img->plotwidth, $this->img->plotheight) * 1.42;
     $a = $this->angle_step;
     $t = new Text();
     $t->SetColor($this->angle_fontcolor);
     $t->SetFont($this->angle_fontfam, $this->angle_fontstyle, $this->angle_fontsize);
     $xright = $this->img->width - $this->img->right_margin;
     $ytop = $this->img->top_margin;
     $xleft = $this->img->left_margin;
     $ybottom = $this->img->height - $this->img->bottom_margin;
     $ha = 'left';
     $va = 'center';
     $w = $this->img->plotwidth / 2;
     $h = $this->img->plotheight / 2;
     $xt = $x0;
     $yt = $pos;
     $margin = 5;
     $tl = $this->angle_tick_len;
     // Outer len
     $tl2 = $this->angle_tick_len2;
     // Interior len
     $this->img->SetColor($this->angle_tick_color);
     $rot90 = $this->img->a == 90;
     if ($type == POLAR_360) {
         $ca1 = atan($h / $w) / M_PI * 180;
         $ca2 = 180 - $ca1;
         $ca3 = $ca1 + 180;
         $ca4 = 360 - $ca1;
         $end = 360;
         while ($a < $end) {
             $ca = cos($a / 180 * M_PI);
             $sa = sin($a / 180 * M_PI);
             $x = $d * $ca;
             $y = $d * $sa;
             $xt = 1000;
             $yt = 1000;
             if ($a <= $ca1 || $a >= $ca4) {
                 $yt = $pos - $w * $y / $x;
                 $xt = $xright + $margin;
                 if ($rot90) {
                     $ha = 'center';
                     $va = 'top';
                 } else {
                     $ha = 'left';
                     $va = 'center';
                 }
                 $x1 = $xright - $tl2;
                 $x2 = $xright + $tl;
                 $y1 = $y2 = $yt;
             } elseif ($a > $ca1 && $a < $ca2) {
                 $xt = $x0 + $h * $x / $y;
                 $yt = $ytop - $margin;
                 if ($rot90) {
                     $ha = 'left';
                     $va = 'center';
                 } else {
                     $ha = 'center';
                     $va = 'bottom';
                 }
                 $y1 = $ytop + $tl2;
                 $y2 = $ytop - $tl;
                 $x1 = $x2 = $xt;
             } elseif ($a >= $ca2 && $a <= $ca3) {
                 $yt = $pos + $w * $y / $x;
                 $xt = $xleft - $margin;
                 if ($rot90) {
                     $ha = 'center';
                     $va = 'bottom';
                 } else {
                     $ha = 'right';
                     $va = 'center';
                 }
                 $x1 = $xleft + $tl2;
                 $x2 = $xleft - $tl;
                 $y1 = $y2 = $yt;
             } else {
                 $xt = $x0 - $h * $x / $y;
                 $yt = $ybottom + $margin;
                 if ($rot90) {
                     $ha = 'right';
                     $va = 'center';
                 } else {
                     $ha = 'center';
                     $va = 'top';
                 }
                 $y1 = $ybottom - $tl2;
                 $y2 = $ybottom + $tl;
                 $x1 = $x2 = $xt;
             }
             if ($a != 0 && $a != 180) {
                 $t->Align($ha, $va);
                 if ($this->show_angle_mark) {
                     $a .= '°';
                 }
                 $t->Set($a);
                 $t->Stroke($this->img, $xt, $yt);
                 if ($this->show_angle_tick) {
                     $this->img->Line($x1, $y1, $x2, $y2);
                 }
             }
             $a += $this->angle_step;
         }
     } else {
         // POLAR_HALF
         $ca1 = atan($h / $w * 2) / M_PI * 180;
         $ca2 = 180 - $ca1;
         $end = 180;
         while ($a < $end) {
             $ca = cos($a / 180 * M_PI);
             $sa = sin($a / 180 * M_PI);
             $x = $d * $ca;
             $y = $d * $sa;
             if ($a <= $ca1) {
                 $yt = $pos - $w * $y / $x;
                 $xt = $xright + $margin;
                 if ($rot90) {
                     $ha = 'center';
                     $va = 'top';
                 } else {
                     $ha = 'left';
                     $va = 'center';
                 }
                 $x1 = $xright - $tl2;
                 $x2 = $xright + $tl;
                 $y1 = $y2 = $yt;
             } elseif ($a > $ca1 && $a < $ca2) {
                 $xt = $x0 + 2 * $h * $x / $y;
                 $yt = $ytop - $margin;
                 if ($rot90) {
                     $ha = 'left';
                     $va = 'center';
                 } else {
                     $ha = 'center';
                     $va = 'bottom';
                 }
                 $y1 = $ytop + $tl2;
                 $y2 = $ytop - $tl;
                 $x1 = $x2 = $xt;
             } elseif ($a >= $ca2) {
                 $yt = $pos + $w * $y / $x;
                 $xt = $xleft - $margin;
                 if ($rot90) {
                     $ha = 'center';
                     $va = 'bottom';
                 } else {
                     $ha = 'right';
                     $va = 'center';
                 }
                 $x1 = $xleft + $tl2;
                 $x2 = $xleft - $tl;
                 $y1 = $y2 = $yt;
             }
             $t->Align($ha, $va);
             if ($this->show_angle_mark) {
                 $a .= '°';
             }
             $t->Set($a);
             $t->Stroke($this->img, $xt, $yt);
             if ($this->show_angle_tick) {
                 $this->img->Line($x1, $y1, $x2, $y2);
             }
             $a += $this->angle_step;
         }
     }
 }
Ejemplo n.º 27
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;
    }
}
Ejemplo n.º 28
0
 function Stroke($img, $aVal, $x, $y)
 {
     if ($this->show) {
         if ($this->negformat == "") {
             $this->negformat = $this->format;
         }
         if ($this->negcolor == "") {
             $this->negcolor = $this->color;
         }
         if ($aVal === NULL || is_string($aVal) && ($aVal == "" || $aVal == "-" || $aVal == "x")) {
             return;
         }
         if (is_numeric($aVal) && $aVal == 0 && $this->iHideZero) {
             return;
         }
         // Since the value is used in different cirumstances we need to check what
         // kind of formatting we shall use. For example, to display values in a line
         // graph we simply display the formatted value, but in the case where the user
         // has already specified a text string we don't fo anything.
         if ($this->iFormCallback != '') {
             $f = $this->iFormCallback;
             $sval = call_user_func($f, $aVal);
         } elseif (is_numeric($aVal)) {
             if ($aVal >= 0) {
                 $sval = sprintf($this->format, $aVal);
             } else {
                 $sval = sprintf($this->negformat, $aVal);
             }
         } else {
             $sval = $aVal;
         }
         $y = $y - sign($aVal) * $this->margin;
         $txt = new Text($sval, $x, $y);
         $txt->SetFont($this->ff, $this->fs, $this->fsize);
         if ($this->valign == "") {
             if ($aVal >= 0) {
                 $valign = "bottom";
             } else {
                 $valign = "top";
             }
         } else {
             $valign = $this->valign;
         }
         $txt->Align($this->halign, $valign);
         $txt->SetOrientation($this->angle);
         if ($aVal > 0) {
             $txt->SetColor($this->color);
         } else {
             $txt->SetColor($this->negcolor);
         }
         $txt->Stroke($img);
     }
 }
Ejemplo n.º 29
0
// Create targets for the bars image maps. One for each column
$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');