示例#1
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");
}
示例#2
0
$graph->AddY2($lineFound);
//
// Infotexte einfuegen
//
$txtStat1 = new Text(tr('graph_statistics_04') . strftime('%d-%m-%Y', time()));
$txtStat1->SetPos(55, 55);
$txtStat1->SetFont(FF_ARIAL, FS_NORMAL, 10);
$lineHeight = $txtStat1->GetFontHeight($graph->img);
$hiddenCaches = XDb::xSimpleQueryValue("SELECT COUNT(*) FROM `caches` WHERE (`status`=1 OR `status`=2 OR `status`=3)", 0);
$txtStat2 = new Text(tr('graph_statistics_05') . str_replace(',', '.', number_format($hiddenCaches)));
$txtStat2->SetPos(55, 55 + $lineHeight * 1.5);
$txtStat2->SetFont(FF_ARIAL, FS_NORMAL, 8);
$txtStat2->SetColor('blue');
$activeCaches = XDb::xSimpleQueryValue("SELECT COUNT(*) FROM `caches` WHERE `status`=1", 0);
$txtStat3 = new Text(tr('graph_statistics_06') . str_replace(',', '.', number_format($activeCaches)));
$txtStat3->SetPos(55, 55 + $lineHeight * 2.5);
$txtStat3->SetFont(FF_ARIAL, FS_NORMAL, 8);
$txtStat3->SetColor('blue');
$foundEntries = XDb::xMultiVariableQueryValue("SELECT COUNT(*) FROM `cache_logs` WHERE `type`=1 AND `deleted`=0", 0);
$txtStat5 = new Text(tr('graph_statistics_07') . str_replace(',', '.', number_format($foundEntries)));
$txtStat5->SetPos(55, 55 + $lineHeight * 5.0);
$txtStat5->SetFont(FF_ARIAL, FS_NORMAL, 8);
$txtStat5->SetColor('darkgreen');
$graph->AddText($txtStat1);
$graph->AddText($txtStat2);
$graph->AddText($txtStat3);
$graph->AddText($txtStat5);
//
// Display the graph
//
$graph->Stroke();
示例#3
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();
示例#4
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);
 }
示例#5
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();
 }
示例#6
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();
示例#7
0
$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);
$graph->xaxis->title->SetCSIMTarget('#55', 'X-axis title');
// Send back the HTML page which will call this script again
示例#8
0
include "../jpgraph.php";
include "../jpgraph_line.php";
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
示例#9
0
$wp1 = new WindrosePlot($data);
$wp1->SetType(WINDROSE_TYPE16);
// This is the default encoding
$wp1->SetDataKeyEncoding(KEYENCODING_ANTICLOCKWISE);
$wp1->legend->Hide();
$wp1->SetPos($xpos1, $ypos1);
$wp1->SetSize(0.5);
// Create the second plot
$wp2 = new WindrosePlot($data);
$wp2->SetType(WINDROSE_TYPE16);
$wp2->SetDataKeyEncoding(KEYENCODING_CLOCKWISE);
$wp2->legend->Hide();
$wp2->SetPos($xpos2, $ypos1);
$wp2->SetSize(0.5);
$txt1 = new Text('KEYENCODING_ANTICLOCKWISE');
$txt1->SetFont(FF_COURIER, FS_BOLD, 12);
$txt1->SetPos($xpos1, $ypos2);
$txt1->SetAlign('center', 'top');
$txt2 = new Text('KEYENCODING_CLOCKWISE');
$txt2->SetFont(FF_COURIER, FS_BOLD, 12);
$txt2->SetPos($xpos2, $ypos2);
$txt2->SetAlign('center', 'top');
// Finally add it to the graph and send back to the client
$graph->Add($wp1);
$graph->Add($txt1);
$graph->Add($wp2);
$graph->Add($txt2);
$graph->Stroke();
?>

示例#10
0
if ($z == 2) {
    $omimai = " 熊本地震の被災地の皆様に、心よりお見舞い申し上げます。\n";
} elseif ($z == 1) {
    $omimai = "東日本大震災の被災地の皆様に、心よりお見舞い申し上げます。\n";
} elseif ($z == 0) {
    $omimai = "鳥取県中部地震の被災地の皆様に、心よりお見舞い申し上げます。\n";
}
$omimai .= " 一日も早く、復興が出来ますように、お祈り申し上げます。\n";
$omimai .= "                           " . $data_time . "更新";
$graph->xaxis->title->Set($omimai);
$graph->xaxis->title->SetFont(FF_GOTHIC, FS_NORMAL, 10);
$graph->xaxis->title->SetMargin(-585);
$graph->Set90AndMargin(312, 89, 90, 90);
$graph->SetBackgroundGradient('white', 'green:1.5', GRAD_HOR, BGRAD_PLOT);
$txt = new Text($data_w);
$txt->SetPos(686, -16);
$data_XXX = $xml->pref[10]->time_x;
$url = "http://s-proj.com/utils/checkHoliday.php?kind=h&date=" . $data_XXX;
$holiday_status = file_get_contents($url);
if ($holiday_status == "holiday") {
    $txt->SetColor("#FF0000");
} else {
    $txt->SetColor("#000000");
}
if ($data_w == "土") {
    $txt->SetColor("#0000FF");
}
$txt->SetFont(FF_GOTHIC, FS_NORMAL, 10);
$graph->AddText($txt);
$graph->add($bplot);
$graph->Stroke();
示例#11
0
// ($row,$title,$startdate,$enddate)
$activity2 = new GanttBar(1, "Project", "2001-12-21", "2001-12-27", "[30%]");
// Yellow diagonal line pattern on a red background
$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);
示例#12
0
 private function templateGraph()
 {
     $sites2 = $this->getSites2();
     //		echo 'User1';
     //		var_dump($this->user1->displayUsername());
     //		if ($this->user2 !== false) {
     //			echo 'User2';
     //			var_dump($this->user2->displayUsername());
     //		}
     //		echo 'Sites';
     //		var_dump($sites2);
     //		var_dump(sprintf('%d_%d_%d', Common::getGet('y'), Common::getGet('m'), Common::getGet('d')));
     //		echo 'Start';
     //		var_dump($this->start);
     //		echo 'End';
     //		var_dump($this->end);
     //		echo 'Icons';
     //		var_dump($this->withIcons);
     //		echo 'Numbers';
     //		var_dump($this->withNumbers);
     $dir = dirname(GWF_JPGRAPH_PATH) . '/';
     require_once $dir . 'jpgraph.php';
     require_once $dir . 'jpgraph_date.php';
     require_once $dir . 'jpgraph_line.php';
     require_once $dir . 'jpgraph_plotline.php';
     $xdata = array();
     $ydata = array();
     $ylast = array();
     $maxperc = 0;
     $db = gdo_db();
     $uid1 = $this->user1->getVar('user_id');
     $uid2 = $this->user2 === false ? 0 : $this->user2->getVar('user_id');
     //		$history = GWF_TABLE_PREFIX.'wc_user_history2';
     $start = GWF_Time::getTimestamp($this->start);
     $end = GWF_Time::getTimestamp($this->end) + GWF_Time::ONE_DAY;
     $no_data = true;
     $xdata[$uid1] = array();
     $ydata[$uid1] = array();
     $ylast[$uid1] = array();
     if ($uid2 === 0) {
         $where2 = '';
     } else {
         $where2 = " OR userhist_uid={$uid2}";
         $xdata[$uid2] = array();
         $ydata[$uid2] = array();
         $ylast[$uid2] = array();
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_HistoryUser2.php';
     $history = GDO::table('WC_HistoryUser2');
     $where = "(userhist_uid={$uid1}{$where2}) AND userhist_date BETWEEN {$start} AND {$end}";
     $orderby = 'userhist_date ASC';
     if (false === ($result = $history->select('userhist_uid, userhist_sid, userhist_percent, userhist_date', $where, $orderby))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     //		$query = "SELECT userhist_uid, userhist_sid, userhist_percent, userhist_date FROM $history WHERE (userhist_uid=$uid1$where2) AND userhist_date BETWEEN $start AND $end ORDER BY userhist_date ASC";
     //		if (false === ($result = $db->queryRead($query))) {
     //			return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     //		}
     //		while (false !== ($row = $db->fetchRow($result)))
     while (false !== ($row = $history->fetch($result, GDO::ARRAY_N))) {
         $siteid = $row[1];
         if (!in_array($siteid, $sites2, true)) {
             continue;
             // site not wanted in graph...
         }
         $userid = $row[0];
         $percent = $row[2] / 100;
         $time = $row[3];
         if ($percent > $maxperc) {
             $maxperc = $percent;
         }
         if (!isset($xdata[$userid][$siteid])) {
             $xdata[$userid][$siteid] = array();
             $ydata[$userid][$siteid] = array();
             $ylast[$userid][$siteid] = 0;
             //				$first[$siteid] = $percent;
             if (!$this->withZoom) {
                 $xdata[$userid][$siteid][] = $start;
                 $ydata[$userid][$siteid][] = $percent;
             }
         }
         $xdata[$userid][$siteid][] = $time;
         $ydata[$userid][$siteid][] = $percent;
         $ylast[$userid][$siteid] = $percent;
         $no_data = false;
     }
     if (!$this->withZoom) {
         foreach (array_keys($ydata[$uid1]) as $siteid) {
             $xdata[$uid1][$siteid][] = $end;
             $ydata[$uid1][$siteid][] = $ylast[$uid1][$siteid];
         }
         if (isset($ydata[$uid2])) {
             foreach (array_keys($ydata[$uid2]) as $siteid) {
                 $xdata[$uid2][$siteid][] = $end;
                 $ydata[$uid2][$siteid][] = $ylast[$uid2][$siteid];
             }
         }
     }
     //		$xdata[$siteid][] = $end;
     //		$ydata[$siteid][] = $percent;
     //		$ylast[$siteid] = $percent;
     //		foreach ($sites2 as $siteid)
     //		{
     //			$xdata[$siteid][] = $end;
     //			$ydata[$siteid][] = isset($ylast[$siteid]) ;
     //		}
     //define the graph
     $dateformat = "d.M.y";
     $datemargin = strlen(date($dateformat)) * 11;
     //		$graph = new Graph($this->module->cfgGraphWidth()*2, $this->module->cfgGraphHeight()*2);
     $graph = new Graph($this->width, $this->height);
     if ($no_data) {
         $graph->SetScale('textint', 0, 100, 0, 1);
     } else {
         $graph->SetScale('datlin', 0, 100);
         $graph->xaxis->scale->SetDateFormat($dateformat);
     }
     $graph->SetColor(array(238, 238, 238));
     $graph->SetMarginColor(array(208, 211, 237));
     $graph->title->Set($this->getGraphTitle());
     $graph->yaxis->title->Set($this->module->lang('percentage'));
     $graph->SetShadow();
     $graph->xaxis->SetLabelAngle(90);
     $graph->img->SetMargin(40, 170, 20, $datemargin);
     //		$graph->img->SetMargin(40, 140, 0, $datemargin);
     $graph->legend->Pos(0.015, 0.05, "right", "top");
     $weights = array($uid1 => 3, $uid2 => 1);
     $labeled = array();
     //make a line for each site (and user)
     foreach ($ydata as $userid => $ydata2) {
         $curr_weight = $weights[$userid];
         foreach ($ydata2 as $siteid => $data) {
             //			var_dump($data);
             if (!isset($this->sites[$siteid])) {
                 continue;
             }
             $site = $this->sites[$siteid];
             $site instanceof WC_Site;
             $lineplot = new LinePlot($data, $xdata[$userid][$siteid]);
             list($color, $style) = $this->getColorAndStyle($site);
             $lineplot->SetStyle($style);
             $lineplot->SetColor($color);
             $lineplot->SetWeight($curr_weight);
             if ($this->withNumbers) {
                 $lineplot->value->Show();
             }
             if ($this->withIcons) {
                 $path = 'dbimg/logo_gif/' . $siteid . '.gif';
                 if (is_readable($path)) {
                     $lineplot->mark->SetType(MARK_IMG, $path, 0.5);
                 }
             }
             if (!in_array($siteid, $labeled, true)) {
                 $lineplot->SetLegend($site->getVar('site_name'));
                 $labeled[] = $siteid;
             }
             $graph->Add($lineplot);
         }
     }
     //		$graph->img->SetAntiAliasing();
     if ($no_data) {
         if (count($this->sites) === 0) {
             $text = $this->module->lang('err_no_sites');
         } else {
             $text = $this->module->lang('err_graph_empty');
         }
         $txt = new Text($text);
         //			$txt->SetFont(FF_ARIAL,FS_NORMAL,18);
         $txt->SetColor("#0000ff");
         $txt->SetPos(0.45, 0.45, 'center', 'center');
         $graph->AddText($txt);
     }
     $graph->Stroke();
     die;
 }
示例#13
0
 public function init($title, $xdata, $ydata, $width = 350, $height = 320)
 {
     // 1. Setup some member variables
     //$graph_width=$width;
     //$graph_height=$height;
     //$graph_title=$title;
     // 2. We'll need a graph object
     $this->graph = new \Graph($width, $height);
     // 3. Set some random values
     $this->graph->SetScale("textlin");
     $this->graph->title->Set($title);
     // 4. Build the linear regression class
     $linreg = new \LinearRegression($xdata, $ydata);
     // 4.1 Get the basic linear regression statistics
     list($stderr, $corr) = $linreg->GetStat();
     list($xd, $yd) = $linreg->GetY(1, count($xdata));
     list($b, $m) = $linreg->GetAB();
     // 4.2 Create the regression line
     $lplot = new \LinePlot($yd);
     $lplot->SetWeight(3);
     $lplot->SetColor('navy');
     // 5. Calculate regression and goal statistics
     //$mp = CakeNumber::precision($m, 0);
     //$bp = CakeNumber::precision($b, 0);
     // 5.1 y=mx+b
     //$s = "y = ".CakeNumber::precision($m,$p)."x + $bp";
     $s = "y = {$m} x + {$b}";
     $txt = new \Text($s);
     $txt->SetPos($this->left_margin, $this->stats_base_y);
     // Set color and font for the text
     $txt->SetColor('red');
     $txt->SetFont(FF_FONT2, FS_BOLD);
     $this->graph->AddText($txt);
     // 4.2 present amount
     //$present_amt = end($this->ydata);
     //App::uses("CakeNumber", "Utility");
     //$txt = new Text("p=" . CakeNumber::precision($present_amt,0));
     //$txt->SetPos($this->left_margin, $this->stats_base_y+$this->stats_line_ht);
     //$this->graph->AddText($txt);
     // 4.3 the goal
     //$delta = $this->goal - $present_amt;
     //$deltaP = $delta/$m;
     //$deltaP = CakeNumber::precision($deltaP, 1);
     //$s = "g = $this->goal";
     //$txt = new Text($s);
     //$txt->SetPos($this->left_margin, $this->stats_base_y+$this->stats_line_ht*2);
     //$this->graph->AddText($txt);
     //$s = "t = $deltaP";
     //$txt = new Text($s);
     //$txt->SetPos($this->left_margin, $this->stats_base_y+$this->stats_line_ht*3);
     //$this->graph->AddText($txt);
     $this->graph->Add($lplot);
     //$this->graph->legend->SetPos(0.5,0.98,'center','bottom');
     //$this->graph->legend->SetAbsPos(0,0);
     //$this->graph->yaxis->SetColor('red');// this works here, but not earlier
     //$this->graph->xaxis->SetColor('blue');
     //$this->graph->SetAxisLabelBackground(1,'red');
     //$this->graph->SetAxisLabelBackground(2,'green');
     //$this->graph->SetBackgroundCFlag(2,BGIMG_FILLPLOT,100); // no discernable effect
     //$this->graph->SetBackgroundGradient('navy','silver',2,BGRAD_FRAME); // no discernable effect
     //$this->graph->SetBox(true, array(80,80,80), 10);
     //$this->graph->SetBox();
     //$this->graph->SetFrame(true,'darkblue',20);
     //$this->graph->SetFrameBevel(20,true,'black');
     //$this->graph->SetMarginColor('silver');
     //$this->graph->SetMargin($this->left_margin,50,50,50); // left, right, top, bottom
     //$this->graph->SetMargin(50,50,50,0); // left, right, top, bottom
 }
示例#14
0
$lineplot7->SetLegend("Dew Point");
$lineplot7->SetColor("green");
$lineplot7->SetWeight(3);
$bp1 = new BarPlot($pcpn, $times);
$bp1->SetLegend("Precip");
$bp1->SetFillColor("black");
$bp1->SetAbsWidth(1.0);
// Create the linear plot
$fz = new LinePlot($freezing, $times);
$fz->SetColor("blue");
// Title Box
$tx1 = new Text($cities[$station]['name'] . " \nMeteogram ");
$tx1->SetPos(0.01, 0.01, 'left', 'top');
$tx1->SetFont(FF_FONT1, FS_BOLD, 16);
$tx2 = new Text("Time series showing temperatures\n   from the pavement sensors and \n   the sub-surface sensor ");
$tx2->SetPos(0.01, 0.11, 'left', 'top');
$tx2->SetFont(FF_FONT1, FS_NORMAL, 10);
include "{$rootpath}/include/mlib.php";
$mySOb = array();
if ($mode == "hist") {
    $ptext = "Historical Plot for dates:\n";
    $tx3 = new Text($ptext . $plotTitle);
} else {
    /*
     $tx3 = new Text("Last Ob @ ". strftime("%m/%d %I:%M %p", $mySOb['ts']) ." 
      Sensor 0: ". $mySOb['tmpf0'] ." F 
      Sensor 1: ". $mySOb['tmpf1'] ." F 
      Sensor 2: ". $mySOb['tmpf2'] ." F 
      Sensor 3: ". $mySOb['tmpf3'] ." F 
     Air  Temp: ". $myOb['tmpf'] ." F
     Dew Point: ". $myOb['dwpf'] ." F
示例#15
0
<?php

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");
$txt->SetPos(10, 25);
$txt->SetFont(FF_FONT1, FS_BOLD);
$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();
示例#16
0
$klasgemiddelde = $grafiekServ->maakKlasgemiddelde($trimister, $klas);
// 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;
示例#17
0
// content="text/plain; charset=utf-8"
require_once '../../vendor/autoload.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\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, 40, 40);
// Create a bar pot
$bplot = new Plot\BarPlot($datay);
$graph->Add($bplot);
// Create and add a new text
$txt = new Text('This is a text');
$txt->SetPos(10, 20);
$txt->SetColor('darkred');
$txt->SetFont(FF_FONT2, FS_BOLD);
$txt->SetBox('yellow', 'navy', 'gray@0.5');
$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();
示例#18
0
         $numstick = 120;
         break;
 }
 //end switch
 $result = $db->sql_query($sql);
 $limit = $db->sql_numrows($result);
 if ($limit < $numstick) {
     $numstick = $limit;
 }
 if ($limit == 0 || $limit == "") {
     $graph = new CanvasGraph(660, 200, "auto");
     $graph->SetMarginColor('white');
     $graph->SetMargin(2, 60, 2, 25);
     $graph->InitFrame();
     $text = new Text("       [This chart does not have enough data]");
     $text->SetPos(400, 60, 'right');
     $text->SetColor("black");
     $graph->AddText($text);
     $graph2 = new CanvasGraph(660, 170, 'auto');
     $graph2->SetMarginColor('white');
     $graph2->SetMargin(2, 60, 2, 25);
     $graph2->InitFrame();
     $graph2->AddText($text);
     if ($type == 1) {
         $graph->Stroke($realpath . $prename . "1W_1.png");
         $graph2->Stroke($realpath . $prename . "1W_2.png");
     } elseif ($type == 2) {
         //echo '111';
         $graph->Stroke($realpath . $prename . "1M_1.png");
         $graph2->Stroke($realpath . $prename . "1M_2.png");
     } elseif ($type == 3) {
示例#19
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;
 }
示例#20
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();
示例#21
0
<?php

// content="text/plain; charset=utf-8"
require_once '../jpgraph.php';
require_once '../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, 40, 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');
$txt->SetPos(0, 20);
$txt->SetColor('darkred');
$txt->SetFont(FF_FONT2, FS_BOLD);
$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();
示例#22
0
<?php

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");
$txt->SetPos(0, 0);
$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();
示例#23
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();
示例#24
0
$legtext25->SetPos(70, 597);
$legtext25->SetColor("black");
$legtext25->SetFont(FF_FONT1, FS_BOLD, 16);
$graph->AddText($legtext25);
$legende50 = new ScatterPlot(array(120), array(50));
$legende50->mark->SetType(MARK_FILLEDCIRCLE);
$legende50->mark->SetColor("orange@0.5");
$legende50->mark->SetFillColor("orange@0.4");
$legende50->mark->SetSize(10);
$graph->Add($legende50);
$legtext50 = new Text(" < 50%");
$legtext50->SetPos(70, 567);
$legtext50->SetColor("black");
$legtext50->SetFont(FF_FONT1, FS_BOLD, 16);
$graph->AddText($legtext50);
$legende100 = new ScatterPlot(array(150), array(50));
$legende100->mark->SetType(MARK_FILLEDCIRCLE);
$legende100->mark->SetColor("red@0.5");
$legende100->mark->SetFillColor("red@0.4");
$legende100->mark->SetSize(10);
$graph->Add($legende100);
$legtext100 = new Text(" > 50%");
$legtext100->SetPos(70, 537);
$legtext100->SetColor("black");
$legtext100->SetFont(FF_FONT1, FS_BOLD, 16);
$graph->AddText($legtext100);
$graph->Stroke();
?>


示例#25
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();
?>


示例#26
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();
示例#27
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();
示例#28
0
文件: 1min_V.php 项目: muthulatha/iem
$graph->y2axis->SetColor("red");
$graph->title->SetFont(FF_FONT1, FS_BOLD, 16);
$graph->yaxis->SetTitle("Wind Direction");
$graph->y2axis->SetTitle("Wind Speed [MPH]");
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->xaxis->SetTitle("Valid Local Time");
$graph->xaxis->SetTitleMargin(30);
$graph->yaxis->SetTitleMargin(30);
//$graph->y2axis->SetTitleMargin(28);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD, 12);
$graph->xaxis->SetPos("min");
// Create the linear plot
$lineplot = new LinePlot($mph);
$graph->AddY2($lineplot);
$lineplot->SetLegend("5 second Wind Speed");
$lineplot->SetColor("red");
// Create the linear plot
$sp1 = new ScatterPlot($drct);
$graph->Add($sp1);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor("blue");
$sp1->mark->SetWidth(3);
// Box for error notations
$t1 = new Text("Dups: " . $dups . " Missing: " . $missing);
$t1->SetPos(0.4, 0.95);
$t1->SetOrientation("h");
$t1->SetFont(FF_FONT1, FS_BOLD);
//$t1->SetBox("white","black",true);
$t1->SetColor("black");
$graph->AddText($t1);
$graph->Stroke();
示例#29
0
function create_graph_barplot($text, $datay, $width, $height)
{
    $margex = 140;
    $graph = new Graph($width, $height);
    $tab_txt = explode('|', $text);
    $txt = new Text($tab_txt[0]);
    $txt->SetPos(0, $height - 40);
    $txt->SetColor('red');
    $txtb = new Text($tab_txt[1] . ' ' . $tab_txt[2] . ' ' . $tab_txt[3]);
    $txtb->SetPos(0, $height / 2);
    $graph->AddText($txt);
    $graph->AddText($txtb);
    $graph->SetScale('textlin', 0, max($datay));
    $graph->SetBox();
    $graph->xaxis->HideLabels();
    $graph->yaxis->HideLabels();
    $graph->yaxis->SetPos('max');
    $graph->yaxis->SetTitle(max($datay), 'high');
    $graph->yaxis->SetTitleMargin(15);
    $graph->yaxis->SetTitleSide(SIDE_RIGHT);
    $graph->xgrid->Show();
    $graph->img->SetMargin($margex, 15, 1, 1);
    $graph->SetFrame(true, 'black', 0);
    $graph->ygrid->SetWeight(0, 0);
    $graph->ygrid->SetFill(false);
    $graph->xaxis->SetTextTickInterval(12, 0);
    $bplot = new BarPlot($datay);
    $graph->Add($bplot);
    return $graph;
}
示例#30
0
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);
}