/** * @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; }
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"); }
$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(); ?>
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; }
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; } } }
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();
$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(); ?>
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(); }
function top($VAR) { global $smarty, $C_translate, $C_auth; # Get the period type, default to month if (empty($VAR['period'])) { $p = 'm'; } else { $p = $VAR['period']; } # Load the jpgraph class include PATH_GRAPH . "jpgraph.php"; include PATH_GRAPH . "jpgraph_bar.php"; # check the validation for this function if (!$C_auth->auth_method_by_name($this->module, 'search')) { $error = $C_translate->translate('module_non_auth', '', ''); include PATH_GRAPH . "jpgraph_canvas.php"; $graph = new CanvasGraph(460, 55, "auto"); $t1 = new Text($error); $t1->Pos(0.2, 0.5); $t1->SetOrientation("h"); $t1->SetBox("white", "black", 'gray'); $t1->SetFont(FF_FONT1, FS_NORMAL); $t1->SetColor("black"); $graph->AddText($t1); $graph->Stroke(); exit; } # Get the period start & end switch ($p) { # By Weeks: case 'w': $interval = "1"; $width = ".9"; $title = 'Top Accounts for Last Last Week'; $dow = date('w'); $start_str = mktime(0, 0, 0, date('m'), date('d') - $dow, date('y')); $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y')); break; # By Months: # By Months: case 'm': $interval = "3"; $width = ".6"; $title = 'Top Accounts for Last Last Month'; $start_str = mktime(0, 0, 0, date('m'), 1, date('y')); $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y')); break; # By Years: # By Years: case 'y': $interval = "1"; $width = ".8"; $title = 'Top Accounts for Last Last Year'; $start_str = mktime(0, 0, 0, 1, 1, date('y')); $end_str = mktime(23, 59, 59, date('m'), date('d'), date('y')); break; } ##############################@@@@@@@@ # Get accounts & sales for this period ##############################@@@@@@@@ $db =& DB(); $sql = 'SELECT account_id,total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE date_orig >= ' . $db->qstr($start_str) . ' AND date_orig <= ' . $db->qstr($end_str) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); $result = $db->Execute($sql); if (@$result->RecordCount() == 0) { $file = fopen(PATH_THEMES . 'default_admin/images/invisible.gif', 'r'); fpassthru($file); exit; } while (!$result->EOF) { $amt = $result->fields['total_amt']; $acct = $result->fields['account_id']; if (!isset($arr[$acct])) { $arr[$acct] = 0; } $arr[$acct] += $amt; $result->MoveNext(); } $i = 0; while (list($key, $var) = each(@$arr)) { # Get the user name $sql = 'SELECT first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account WHERE id = ' . $db->qstr($key) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); $rs = $db->Execute($sql); $_lbl[] = strtoupper(substr($rs->fields['first_name'], 0, 1)) . ". " . $rs->fields['last_name']; $_datay[] = $var; $i++; } ### Sort the arrays array_multisort($_datay, SORT_DESC, SORT_NUMERIC, $_lbl); ### Limit the results to 10 or less for ($i = 0; $i < count($_lbl); $i++) { $lbl[$i] = $_lbl[$i]; $datay[$i] = $_datay[$i]; if ($i >= 9) { $i = count($_lbl); } } $i = count($lbl); # Get the Currency $sql = 'SELECT symbol FROM ' . AGILE_DB_PREFIX . 'currency WHERE id = ' . $db->qstr(DEFAULT_CURRENCY) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); $rs = $db->Execute($sql); $currency_iso = $rs->fields['symbol']; // Size of graph $width = 265; $height = 75 + $i * 15; // Set the basic parameters of the graph $graph = new Graph($width, $height, 'auto'); $graph->SetScale("textlin"); $graph->yaxis->scale->SetGrace(50); $graph->SetMarginColor('#F9F9F9'); $graph->SetFrame(true, '#CCCCCC', 1); $graph->SetColor('#FFFFFF'); $top = 45; $bottom = 10; $left = 95; $right = 15; $graph->Set90AndMargin($left, $right, $top, $bottom); // Label align for X-axis $graph->xaxis->SetLabelAlign('right', 'center', 'right'); // Label align for Y-axis $graph->yaxis->SetLabelAlign('center', 'bottom'); $graph->xaxis->SetTickLabels($lbl); // Titles $graph->title->SetFont(FF_FONT1, FS_BOLD, 9.5); $title = $C_translate->translate('graph_top', 'account_admin', ''); $graph->title->Set($title); // Create a bar pot $bplot = new BarPlot($datay); $bplot->SetFillColor("#506DC7"); $bplot->SetWidth(0.2); // Show the values $bplot->value->Show(); $bplot->value->SetFont(FF_FONT1, FS_NORMAL, 8); $bplot->value->SetAlign('center', 'center'); $bplot->value->SetColor("black", "darkred"); $bplot->value->SetFormat($currency_iso . '%.2f'); $graph->Add($bplot); $graph->Stroke(); return; }
function 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(); }
function Stroke(&$img, &$xscale, &$yscale) { $numpoints = count($this->coords[0]); if (isset($this->coords[1])) { if (count($this->coords[1]) != $numpoints) { JpGraphError::Raise("JpGraph Error: Number of X and Y points are not equal.<br>\r\n\t\t\t\t\tNumber of X-points:" . count($this->coords[1]) . "<br>\r\n\t\t\t\t\tNumber of Y-points:{$numpoints}"); } else { $exist_x = true; } } else { $exist_x = false; } if ($exist_x) { $xs = $this->coords[1][0]; } else { $xs = 0; } $img->SetStartPoint($xscale->Translate($xs), $yscale->Translate($this->coords[0][0])); if ($this->filled) { $cord[] = $xscale->Translate($xs); $cord[] = $yscale->Translate($yscale->GetMinVal()); } $cord[] = $xscale->Translate($xs); $cord[] = $yscale->Translate($this->coords[0][0]); $yt_old = $yscale->Translate($this->coords[0][0]); $img->SetColor($this->color); $img->SetLineWeight($this->weight); $img->SetLineStyle($this->line_style); for ($pnts = 1; $pnts < $numpoints; ++$pnts) { if ($exist_x) { $x = $this->coords[1][$pnts]; } else { $x = $pnts; } $xt = $xscale->Translate($x); $yt = $yscale->Translate($this->coords[0][$pnts]); $cord[] = $xt; $cord[] = $yt; if ($this->step_style) { $img->StyleLineTo($xt, $yt_old); $img->StyleLineTo($xt, $yt); } else { $y = $this->coords[0][$pnts]; if (is_numeric($y) || is_string($y) && $y != "-") { $tmp1 = $this->coords[0][$pnts]; $tmp2 = $this->coords[0][$pnts - 1]; if (is_numeric($tmp1) && (is_numeric($tmp2) || $tmp2 == "-")) { $img->StyleLineTo($xt, $yt); } else { $img->SetStartPoint($xt, $yt); } } } $yt_old = $yt; if ($this->value->show) { $sval = sprintf($this->value->format, $this->coords[0][$pnts]); $txt = new Text($sval, $xt, $yt - $this->value->margin); $txt->SetFont($this->value->ff, $this->value->fs, $this->value->fsize); $txt->Align("center", "bottom"); $txt->SetOrientation($this->value->angle); $txt->SetColor($this->value->color); $txt->Stroke($img); } } if ($this->filled) { $cord[] = $xt; $cord[] = $yscale->Translate($yscale->GetMinVal()); $img->SetColor($this->fill_color); $img->FilledPolygon($cord); $img->SetColor($this->color); $img->Polygon($cord); } $adjust = 0; if ($this->filled) { $adjust = 2; } for ($i = $adjust; $i < count($cord) - $adjust; $i += 2) { if (is_numeric($this->coords[0][($i - $adjust) / 2])) { $this->mark->Stroke($img, $cord[$i], $cord[$i + 1]); } } }
$odo[$i] = new Odometer(); $odo[$i]->SetColor('lightgray:1.9'); $odo[$i]->needle->Set(10 + $i * 17); $odo[$i]->needle->SetShadow(); if ($i < 2) { $fsize = 10; } else { $fsize = 8; } $odo[$i]->scale->label->SetFont(FF_ARIAL, FS_NORMAL, $fsize); $odo[$i]->AddIndication(92, 100, 'red'); $odo[$i]->AddIndication(80, 92, 'orange'); $odo[$i]->AddIndication(60, 80, 'yellow'); } // Create the layout $row1 = new LayoutHor(array($odo[0], $odo[1])); $row2 = new LayoutHor(array($odo[2], $odo[3], $odo[4])); $col1 = new LayoutVert(array($row1, $row2)); // Add the odometer to the graph $graph->Add($col1); // Add an icon and text $icon = new IconPlot('jpglogo.jpg', 250, 10, 0.85, 30); $icon->SetAnchor('center', 'top'); $graph->Add($icon); $t = new Text('JpGraph', 250, 70); $t->SetAlign('center', 'top'); #$t->SetFont(FF_VERA,FS_BOLD,11); $t->SetColor('darkgray'); $graph->Add($t); // ... and finally stroke and stream the image back to the browser $graph->Stroke();
/** * Construct the graph * */ private function Init() { // Setup limits for color indications $lowx = $this->iXMin; $highx = $this->iXMax; $lowy = $this->iYMin; $highy = $this->iYMax; $width = $this->iWidth; $height = $this->iHeight; // Margins $lm = 50; $rm = 40; $tm = 60; $bm = 40; if ($width <= 300 || $height <= 250) { $labelsize = 8; $lm = 25; $rm = 25; $tm = 45; $bm = 25; } elseif ($width <= 450 || $height <= 300) { $labelsize = 8; $lm = 30; $rm = 30; $tm = 50; $bm = 30; } elseif ($width <= 600 || $height <= 400) { $labelsize = 9; } else { $labelsize = 11; } if ($this->iSubTitle == '') { $tm -= $labelsize + 4; } $graph = new Graph($width, $height); $graph->SetScale('intint', $lowy, $highy, $lowx, $highx); $graph->SetMargin($lm, $rm, $tm, $bm); $graph->SetMarginColor($this->iMarginColor[$this->iColorMap]); $graph->SetClipping(); $graph->title->Set($this->iTitle); $graph->subtitle->Set($this->iSubTitle); $graph->title->SetFont(FF_ARIAL, FS_BOLD, $labelsize + 4); $graph->subtitle->SetFont(FF_ARIAL, FS_BOLD, $labelsize + 1); $graph->SetBox(true, 'black@0.3'); $graph->xaxis->SetFont(FF_ARIAL, FS_BOLD, $labelsize); $graph->yaxis->SetFont(FF_ARIAL, FS_BOLD, $labelsize); $graph->xaxis->scale->ticks->Set(CCBPGraph::TickStep, CCBPGraph::TickStep); $graph->yaxis->scale->ticks->Set(CCBPGraph::TickStep, CCBPGraph::TickStep); $graph->xaxis->HideZeroLabel(); $graph->yaxis->HideZeroLabel(); $graph->xaxis->SetLabelFormatString('%d%%'); $graph->yaxis->SetLabelFormatString('%d%%'); // For the x-axis we adjust the color so labels on the left of the Y-axis are in black $n1 = floor(abs($this->iXMin / 25)) + 1; $n2 = floor($this->iXMax / 25); if ($this->iColorMap == 0) { $xlcolors = array(); for ($i = 0; $i < $n1; ++$i) { $xlcolors[$i] = 'black'; } for ($i = 0; $i < $n2; ++$i) { $xlcolors[$n1 + $i] = 'lightgray:1.5'; } $graph->xaxis->SetColor('gray', $xlcolors); $graph->yaxis->SetColor('gray', 'lightgray:1.5'); } else { $graph->xaxis->SetColor('darkgray', 'darkgray:0.8'); $graph->yaxis->SetColor('darkgray', 'darkgray:0.8'); } $graph->SetGridDepth(DEPTH_FRONT); $graph->ygrid->SetColor('gray@0.6'); $graph->ygrid->SetLineStyle('dotted'); $graph->ygrid->Show(); $graph->xaxis->SetWeight(1); $graph->yaxis->SetWeight(1); $ytitle = new Text(CCBPGraph::YTitle, floor($lm * 0.75), ($height - $tm - $bm) / 2 + $tm); #$ytitle->SetFont(FF_VERA,FS_BOLD,$labelsize+1); $ytitle->SetAlign('right', 'center'); $ytitle->SetAngle(90); $graph->Add($ytitle); $xtitle = new Text(CCBPGraph::XTitle, ($width - $lm - $rm) / 2 + $lm, $height - 10); #$xtitle->SetFont(FF_VERA,FS_BOLD,$labelsize); $xtitle->SetAlign('center', 'bottom'); $graph->Add($xtitle); $df = 'D j:S M, Y'; if ($width < 400) { $df = 'D j:S M'; } $time = new Text(date($df), $width - 10, $height - 10); $time->SetAlign('right', 'bottom'); #$time->SetFont(FF_VERA,FS_NORMAL,$labelsize-1); $time->SetColor('darkgray'); $graph->Add($time); // Use an accumulated fille line graph to create the colored bands $n = 3; for ($i = 0; $i < $n; ++$i) { $b = $this->iColorInd[$i][0]; $k = ($this->iColorInd[$i][1] - $this->iColorInd[$i][0]) / $this->iXMax; $colarea[$i] = array(array($lowx, $lowx * $k + $b), array($highx, $highx * $k + $b)); } $colarea[3] = array(array($lowx, $highy), array($highx, $highy)); $cb = array(); for ($i = 0; $i < 4; ++$i) { $cb[$i] = new LinePlot(array($colarea[$i][0][1], $colarea[$i][1][1]), array($colarea[$i][0][0], $colarea[$i][1][0])); $cb[$i]->SetFillColor($this->iColorSpec[$this->iColorMap][$i]); $cb[$i]->SetFillFromYMin(); } $graph->Add(array_slice(array_reverse($cb), 0, 4)); $this->graph = $graph; }
function strokeLabels() { $t = new Text(); $t->SetColor($this->labelColor); $t->SetFont($this->labelFF, $this->labelFS, $this->labelFSize); $t->SetAlign('center', 'center'); foreach ($this->labels as $cont_idx => $pos) { if ($cont_idx >= 10) { return; } foreach ($pos as $idx => $coord) { $t->Set(sprintf("%.1f", $coord[2])); $t->SetAngle($coord[3]); $t->Stroke($this->g->img, $coord[0], $coord[1]); } } }
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 ($aVal >= 0) { $sval = sprintf($this->format, $aVal); } else { $sval = sprintf($this->negformat, $aVal); } $txt = new Text($sval, $x, $y - sign($aVal) * $this->margin); $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); } }
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); } } }
<?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->Pos(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();
//SERVICELAAG $grafiekServ = new Pdf_en_GrafiekService(); $leerling = $grafiekServ->maakPuntenLeerling($trimister, $id); $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;
<?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();
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; }
$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();
function setupGraph($XUnits = "hours", $startTime, $count, $options = array()) { global $conf; $graph = new Graph($conf['graph']['width'], $conf['graph']['height'], "auto"); $graph->SetScale("intlin"); //$graph->SetScale("linlin",$mintemp,$maxtemp,$mintime, $maxtime); //$graph->SetShadow(); $rightMargin = 20; if (isset($options['showMargin']) && $options['showMargin'] == 1) { $rightMargin = 110; } $graph->img->SetMargin(50, $rightMargin, 20, 40); $graph->SetBox(true, 'black', 2); $graph->SetColor($conf['graph']['bgcolor']); $graph->SetMarginColor($conf['html']['bgcolor']); //$graph->title->Set("Digitemp Activity"); $graph->title->Set("Digitemp Activity starting " . date("H:i:s m/d/Y", $startTime)); /** $txt =new Text("Starting ".date("H:i:s m/d/Y", $startTime)); $txt->Pos( 0.59,0.01); $txt->SetColor( "blue"); $graph->AddText( $txt); **/ //junk: $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->xgrid->Show(); $graph->legend->Pos(0.02, 0.02, "right", "top"); /* $graph->yaxis->SetPos(0); $graph->yaxis->SetWeight(2); $graph->yaxis->SetFont(FF_FONT1,FS_BOLD); $graph->yaxis->SetColor('black','darkblue'); */ $graph->xaxis->SetWeight(2); $graph->xaxis->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->SetColor('black', 'darkblue'); // echo "Setting limits to $mintime, $maxtime, $mintemp, $maxtemp"; //$graph->SetScale("linlin",$mintemp,$maxtemp,$mintime, $maxtime); $graph->xaxis->title->Set("Time ({$XUnits})"); $graph->yaxis->title->Set('Temperature (' . $options['units'] . ')'); $txt2 = new Text("Measurements shown: {$count}"); $txt2->Pos(0.02, 0.96); $txt2->SetColor("blue"); $graph->AddText($txt2); return $graph; }
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); }
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); }
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); }
$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); $graph->title->Set("Example 16.3"); $graph->xaxis->title->Set("Month");
// content="text/plain; charset=utf-8" require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_bar.php'; $datay = array(12, 8, 19, 3, 10, 5); // Create the graph. These two calls are always required $graph = new Graph(300, 200); $graph->SetScale('textlin'); // Add a drop shadow $graph->SetShadow(); // Adjust the margin a bit to make more room for titles $graph->img->SetMargin(40, 30, 20, 40); // Create a bar pot $bplot = new BarPlot($datay); $graph->Add($bplot); // Create and add a new text $txt = new Text("This is a text\nwith many\nand even\nmore\nlines of text"); $txt->SetPos(0.5, 0.5, 'center', 'center'); $txt->SetFont(FF_FONT2, FS_BOLD); $txt->ParagraphAlign('center'); $txt->SetBox('yellow', 'navy', 'gray'); $txt->SetColor('red'); $graph->AddText($txt); // Setup the titles $graph->title->Set("A simple bar graph"); $graph->xaxis->title->Set("X-title"); $graph->yaxis->title->Set("Y-title"); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); // Display the graph $graph->Stroke();
function 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); } }
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; }