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(); }
<?php // $Id: canvas_jpgarchex.php,v 1.1.1.1 2005/11/30 23:01:53 gth2 Exp $ include "../jpgraph.php"; include "../jpgraph_canvas.php"; include "../jpgraph_canvtools.php"; // Scale we are using $ymax = 24; $xmax = 20; // Setup the basic canvas $g = new CanvasGraph(700, 650, 'auto'); $g->SetMargin(2, 3, 2, 3); $g->SetMarginColor("teal"); $g->InitFrame(); // ... and a scale $scale = new CanvasScale($g); $scale->Set(0, $xmax, 0, $ymax); // ... we need shape since we want the indented rectangle $shape = new Shape($g, $scale); $shape->SetColor('black'); // ... basic parameters for the overall image $l = 2; // Left margin $r = 18; // Row number to start the lowest line on $width = 16; // Total width // Setup the two basic rectangle text object we will use $tt = new CanvasRectangleText(); $tt->SetFont(FF_ARIAL, FS_NORMAL, 14); $tt->SetFillColor('');
function error_text($title, $text) { if (OFF == plugin_config_get('eczlibrary')) { $graph = new CanvasGraph(300, 380); $txt = new Text($text, 150, 100); $txt->Align("center", "center", "center"); $txt->SetFont($t_graph_font, FS_BOLD); $graph->title->Set($title); $graph->title->SetFont($t_graph_font, FS_BOLD); $graph->AddText($txt); $graph->Stroke(); } else { $im = imagecreate(300, 300); /* @todo check: error graphs dont support utf8 */ $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 0, 0, 0); imagestring($im, 5, 0, 0, $text, $textcolor); header('Content-type: image/png'); imagepng($im); imagedestroy($im); } die; }
<?php require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_canvas.php'; require_once 'jpgraph/jpgraph_table.php'; $cols = 4; $rows = 3; $data = array(array('', 'Jan', 'Feb', 'Mar', 'Apr'), array('Min', '15.2', '12.5', '9.9', '70.0'), array('Max', '23.9', '14.2', '18.6', '71.3')); // Setup basic graph canvas $graph = new CanvasGraph(300, 200); // Create a basic table $table = new GTextTable($cols, $rows); $table->Set($data); $table->SetCellCSIMTarget(1, 1, 'tableex02.php', 'View details'); $table->SetRowFont(0, FF_FONT1, FS_BOLD); $table->SetRowColor(0, 'navy'); $table->SetRowFillColor(0, 'lightgray'); $table->SetColFont(0, FF_FONT1, FS_BOLD); $table->SetColColor(0, 'navy'); $table->SetColFillColor(0, 'lightgray'); $graph->Add($table); $graph->StrokeCSIM();
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; }
<?php require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_canvas.php'; require_once 'jpgraph/jpgraph_table.php'; // Setup graph context $graph = new CanvasGraph(430, 150); // Setup the basic table $data = array(array('', 'w631', 'w632', 'w633', 'w634', 'w635', 'w636'), array('Critical (sum)', 13, 17, 15, 8, 3, 9), array('High (sum)', 34, 35, 26, 20, 22, 16), array('Low (sum)', 41, 43, 49, 45, 51, 47), array('Sum:', 88, 95, 90, 73, 76, 72)); // Setup a basic table $table = new GTextTable(); $table->Set($data); // Setup fonts $table->SetFont(FF_TIMES, FS_NORMAL, 11); $table->SetColFont(0, FF_ARIAL, FS_NORMAL, 11); $table->SetRowFont(0, FF_ARIAL, FS_NORMAL, 11); $table->SetRowFont(4, FF_TIMES, FS_BOLD, 14); // Turn off the grid $table->SetGrid(0); // Setup color $table->SetRowFillColor(0, 'lightgray@0.5'); $table->SetRowFillColor(4, 'lightgray@0.5'); $table->SetColFillColor(0, 'lightgray@0.5'); $table->SetFillColor(0, 0, 4, 0, 'lightgray@0.5'); // Set default minimum column width $table->SetMinColWidth(45); // Set default table alignment $table->SetAlign('right'); // Add table to the graph $graph->Add($table); // and send it back to the client
/** Constroi o gráfico entre periodos de anos retorna true se o grafico foi montado e false se não foi **/ function buildGraphicByYear($stats, $startYear, $lastYear) { $graficoStatus = false; // Para descobrir se entrou no for e vai construir um gráfico $stat = $stats->getRequests(); // Pega todos os anos entre o Ano Inicial e o Ano Final $anos = array(); for ($j = 0, $year = $startYear; $year <= $lastYear; $year++, $j++) { $anos[$j] = $year; } foreach ($stat as $s) { $mes = intval($s->getMonth()); $ano = intval($s->getYear()); $values[$ano][$mes] = $s->getNumberOfRequests(); } /* "gabarito" da linha dos graficos com 12 posicoes, uma para cada mes os valores "-" sao considerados NULLs pelo jpgraph */ $data = array("0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"); /* "gabarito" para as cores das linhas do gráfico */ $cores = array("blue", "yellow", "purple", "cyan", "pink", "red", "orange", "green", "black", "sienna", "darkred", "darkgreen"); // Create the graph. These two calls are always required // $graph = new Graph(700,400,"auto"); $graph = new Graph(900, 300, "auto"); $graph->SetScale("textlin"); /* cria um array bi-dimencional contendo array(ano{array com a quantidade de acessos por mes}) */ $colorIndex = 0; $bars = array(); foreach ($values as $ano => $meses) { /* valores será a variavel que servirá de "datasource" para a barra do grafico inicialmente ele eh inicializada com o gabarito, e serao preenchidos os valores dos meses no laço for logo abaixo */ $valores = $data; for ($k = 0; $k <= count($valores); $k++) { if ($meses[$k]) { $valores[$k] = $meses[$k]; } } if (count($valores) > 12) { unset($valores[0]); } $valores = array_values($valores); /* aqui eu uso "Variáveis Variáveis" do PHP para poder inserir vária linhas no gráfico */ $nome = "barplot" . $ano; ${$nome} = new BarPlot($valores); $cor = $cores[$colorIndex]; ${$nome}->SetFillColor($cor); ${$nome}->SetColor($cor); /*configs para os valores do ponto*/ ${$nome}->value->SetColor("darkred"); ${$nome}->value->SetFont(FF_FONT1, FS_BOLD); ${$nome}->value->SetFormat("%0.1d"); // $$nome->SetWeight(20); // Arrumando para um tamanho mais amigavel if (count($anos) < 3) { ${$nome}->SetWidth(20); } else { if (count($anos) < 4) { ${$nome}->SetWidth(15); } else { if (count($anos) < 6) { ${$nome}->SetWidth(10); } else { if (count($anos) < 8) { ${$nome}->SetWidth(5); } else { if (count($anos) < 11) { ${$nome}->SetWidth(3); } } } } } ${$nome}->value->Show(); ${$nome}->value->iHideZero = true; ${$nome}->setLegend($ano); /*adicionando a linha ao grafico*/ $colorIndex++; // Somente monta o gráfico dos anos exigidos pelo usuário for ($i = 0; $i < count($anos); $i++) { if ($ano == $startYear + $i) { $graficoStatus = true; // entrou no for significa que o gráfico vai ser construido array_push($bars, ${$nome}); } } } /**************************************************************** * Se não existir dados estatÃsticos para o perÃodo selecionado * * Então ele constroi uma imagem com a mensagem de que não * * existem dados estatÃsticos. * *****************************************************************/ if ($graficoStatus == false) { $graph = new CanvasGraph(600, 30); $t1 = new Text(GRAFIC_STATS_FALSE); $t1->Pos(0.05, 0.5); $t1->SetOrientation('h'); $t1->SetFont(FF_FONT1, FS_BOLD); $t1->SetColor('black'); $graph->AddText($t1); $graph->Stroke(); return $graficoStatus; } $gbplot = new GroupBarPlot($bars); $gbplot->SetWidth(0.9); $graph->Add($gbplot); $graph->yaxis->scale->SetGrace(20); $graph->img->SetMargin(40, 20, 20, 40); $graph->title->Set(ARTICLE_ACCESS); $graph->xaxis->title->Set(MONTHS); $graph->yaxis->title->Set(ACCESSES); $graph->title->SetFont(FF_FONT1, FS_BOLD); $graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); $graph->SetShadow(); $graph->xaxis->SetTickLabels(explode(",", MONTH_LIST)); // Adjust the legend position // $graph->legend->SetLayout(LEGEND_VER); $graph->legend->Pos(0.04, 0.092, "", "center"); $graph->legend->SetLayout(LEGEND_HOR); // Mostra o gráfico somente se, o ano que o usuario entrou existir estatisticas if ($graficoStatus == true) { $graph->Stroke(); } return $graficoStatus; }
<?php // $Id: listfontsex1.php,v 1.3 2002/10/25 22:44:15 aditus Exp $ include "../jpgraph.php"; include "../jpgraph_canvas.php"; include "../jpgraph_canvtools.php"; $g = new CanvasGraph(550, 450, 'auto'); $scale = new CanvasScale($g); $scale->Set(0, 27, 0, 53); $g->SetMargin(5, 6, 5, 6); $g->SetColor('white'); $g->SetMarginColor("teal"); $g->InitFrame(); $t = new CanvasRectangleText(); $t->SetFillColor('lightgreen'); $t->SetFontColor('navy'); $t->SetFont(FF_ARIAL, FS_NORMAL, 16); $t->Set("\n\n\n\n\n\n\n\n\n\n\nTTF Fonts", 0.5, 19, 26, 32); $t->Stroke($g->img, $scale); $t = new CanvasRectangleText(); $t->SetFillColor(''); $t->SetFontColor('black'); $t->SetColor(''); $t->SetShadow(''); $t->SetFont(FF_ARIAL, FS_BOLD, 18); $t->Set('Family', 1, 1, 8); $t->Stroke($g->img, $scale); $t->Set('Italic style', 9, 1, 8); $t->Stroke($g->img, $scale); $t->Set('Bold style', 17.5, 1, 8); $t->Stroke($g->img, $scale);
<?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();
//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) { $graph->Stroke($realpath . $prename . "3M_2.png"); $graph2->Stroke($realpath . $prename . "3M_2.png"); } elseif ($type == 4) {
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(); }
public function Draw($aTitle, $aStart, $aEnd, $n = 64, $aReverse = false, $addColorNames = false) { // Setup to draw colormap with names platoe colors $lmarg = ColorMapDriver::LMARG; // left margin $rmarg = ColorMapDriver::RMARG; // right margin $width = ColorMapDriver::WIDTH; // Overall image width // Module height $mh = ColorMapDriver::MODHEIGHT; // Step between each map $ymarg = $mh + ColorMapDriver::MAPMARG; if ($addColorNames) { $ymarg += 50; } // Start position $xs = $lmarg; $ys = ColorMapDriver::YSTART; // Setup a basic canvas graph $height = ($aEnd - $aStart + 1) * $ymarg + 50; $graph = new CanvasGraph($width, $height); $graph->img->SetColor('darkgray'); $graph->img->Rectangle(0, 0, $width - 1, $height - 1); $t = new Text($aTitle, $width / 2, 5); $t->SetAlign('center', 'top'); $t->SetFont(FF_ARIAL, FS_BOLD, 14); $t->Stroke($graph->img); // Instantiate a colormap $cm = new ColorMap(); $cm->InitRGB($graph->img->rgb); for ($mapidx = $aStart; $mapidx <= $aEnd; ++$mapidx, $ys += $ymarg) { $cm->SetMap($mapidx, $aReverse); $n = $cm->SetNumColors($n); list($mapidx, $maparray) = $cm->GetCurrMap(); $ncols = count($maparray); $colbuckets = $cm->GetBuckets(); // The module width will depend on the actual number of colors $mw = round(($width - $lmarg - $rmarg) / $n); // Draw color map title (name) $t->Set('Basic colors: ' . $ncols . ', Total colors: ' . $n); $t->SetAlign('center', 'bottom'); $t->SetAngle(0); $t->SetFont(FF_TIMES, FS_NORMAL, 14); $t->Stroke($graph->img, $width / 2, $ys - 3); // Add the name/number of the map to the left $t->SetAlign('right', 'center'); $t->Set('Map: ' . $mapidx); $t->SetFont(FF_ARIAL, FS_NORMAL, 14); $t->Stroke($graph->img, $xs - 20, round($ys + $mh / 2)); // Setup text properties for the color names if ($addColorNames) { $t->SetAngle(30); $t->SetFont(FF_ARIAL, FS_NORMAL, 12); $t->SetAlign('right', 'top'); } // Loop through all colors in the map $x = $xs; $y = $ys; $k = 0; for ($i = 0; $i < $n; ++$i) { $graph->img->SetColor($colbuckets[$i]); $graph->img->FilledRectangle($x, $y, $x + $mw, $y + $mh); // Mark all basic colors in the map with a bar and name if ($i % (($n - $ncols) / ($ncols - 1) + 1) == 0) { $graph->img->SetColor('black'); $graph->img->FilledRectangle($x, $y + $mh + 4, $x + $mw - 1, $y + $mh + 6); if ($addColorNames) { $t->Set($maparray[$k++]); $t->Stroke($graph->img, $x + $mw / 2, $y + $mh + 10); } } $x += $mw; } // Draw a border around the map $graph->img->SetColor('black'); $graph->img->Rectangle($xs, $ys, $xs + $mw * $n, $ys + $mh); } // Send back to client $graph->Stroke(); }
function ejecutarGrafico($value_criteria, $date_start, $date_end) { global $arrLang; $data_graph = leerDatosGrafico($value_criteria, $date_start, $date_end); if (count($data_graph["values"]) > 0) { // Create the Pie Graph. $graph = new PieGraph(630, 220, "auto"); $graph->SetMarginColor('#fafafa'); $graph->SetFrame(true, '#999999'); $graph->legend->SetFillColor("#fafafa"); $graph->legend->SetColor("#444444", "#999999"); $graph->legend->SetShadow('gray@0.6', 4); // Set A title for the plot $graph->title->Set(utf8_decode($data_graph["title"])); $graph->title->SetColor("#444444"); $graph->legend->Pos(0.1, 0.2); // Create 3D pie plot $p1 = new PiePlot3d($data_graph["values"]); $p1->SetCenter(0.4); $p1->SetSize(100); // Adjust projection angle $p1->SetAngle(60); // Adjsut angle for first slice $p1->SetStartAngle(45); // Display the slice values $p1->value->SetColor("black"); // Add colored edges to the 3D pie // NOTE: You can't have exploded slices with edges! $p1->SetEdge("black"); $p1->SetLegends($data_graph["legend"]); $graph->Add($p1); $graph->Stroke(); } else { $graph = new CanvasGraph(630, 220, "auto"); $title = new Text(utf8_decode($data_graph["title"])); $title->ParagraphAlign('center'); $title->SetFont(FF_FONT2, FS_BOLD); $title->SetMargin(3); $title->SetAlign('center'); $title->Center(0, 630, 110); $graph->AddText($title); $t1 = new Text(utf8_decode($arrLang["No records found"])); $t1->SetBox("white", "black", true); $t1->ParagraphAlign("center"); $t1->SetColor("black"); $graph->AddText($t1); $graph->img->SetColor('navy'); $graph->img->SetTextAlign('center', 'bottom'); $graph->img->Rectangle(0, 0, 629, 219); $graph->Stroke(); /* //no hay datos - por ahora muestro una imagen en blanco con mensaje no records found header('Content-type: image/png'); $titulo=utf8_decode($data_graph["title"]); $im = imagecreate(630, 220); $background_color = imagecolorallocate($im, 255, 255, 255); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 10, 5, 5, $titulo. " - No records found", $text_color); imagepng($im); imagedestroy($im);*/ } }
/** * Display Error 'graph' * * @param string $p_title Error title. * @param string $p_text Error text. * @todo check error graphs do not support utf8 * @return void */ function error_text($p_title, $p_text) { if (OFF == plugin_config_get('eczlibrary')) { $t_graph = new CanvasGraph(300, 380); $t_graph_font = graph_get_font(); $t_text = new Text($p_text, 150, 100); $t_text->Align('center', 'center', 'center'); $t_text->SetFont($t_graph_font, FS_BOLD); $t_graph->title->Set($p_title); $t_graph->title->SetFont($t_graph_font, FS_BOLD); $t_graph->AddText($t_text); $t_graph->Stroke(); } else { $t_image = imagecreate(300, 300); $t_text_color = imagecolorallocate($t_image, 0, 0, 0); imagestring($t_image, 5, 0, 0, $p_text, $t_text_color); header('Content-type: image/png'); imagepng($t_image); imagedestroy($t_image); } die; }
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($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; }
<?php // content="text/plain; charset=utf-8" // $Id: canvasex03.php,v 1.1 2002/08/27 20:08:57 aditus Exp $ require_once 'jpgraph/jpgraph.php'; require_once 'jpgraph/jpgraph_canvas.php'; require_once 'jpgraph/jpgraph_canvtools.php'; // Define work space $xmax = 20; $ymax = 20; // Setup a basic canvas we can work $g = new CanvasGraph(400, 200, 'auto'); $g->SetMargin(5, 11, 6, 11); $g->SetShadow(); $g->SetMarginColor("teal"); // We need to stroke the plotarea and margin before we add the // text since we otherwise would overwrite the text. $g->InitFrame(); // Create a new scale $scale = new CanvasScale($g); $scale->Set(0, $xmax, 0, $ymax); // The shape class is wrapper around the Imgae class which translates // the coordinates for us $shape = new Shape($g, $scale); $shape->SetColor('black'); // Add a black line $shape->SetColor('black'); $shape->Line(0, 0, 20, 20); // .. and a circle (x,y,diameter) $shape->Circle(5, 14, 2); // .. and a filled circle (x,y,diameter)
function error_check($bug_count, $title) { if (0 == $bug_count) { $t_graph_font = graph_get_font(); $graph = new CanvasGraph(300, 380); $txt = new Text(lang_get('not_enough_data'), 150, 100); $txt->Align("center", "center", "center"); $txt->SetFont($t_graph_font, FS_BOLD); $graph->title->Set($title); $graph->title->SetFont($t_graph_font, FS_BOLD); $graph->AddText($txt); $graph->Stroke(); die; } }
$img->Line($x, $y, $x + $s1 * $w, $y); } else { $x = $x + $s2 * $w * $r; $w = (1 - $r) * $w; $h = $h / (1 - $r) * $r; $s2 *= -1; $img->SetColor($color1); $img->Line($x, $y, $x, $y - $s2 * $h); } $img->SetColor($color2); $img->FilledRectangle($x - 1, $y - 1, $x + 1, $y + 1); $img->Arc($x, $y, 2 * $w + 1, 2 * $h + 1, $sa, $ea); $img->Arc($x, $y, 2 * $w, 2 * $h, $sa, $ea); $img->Arc($x, $y, 2 * $w - 1, 2 * $h - 1, $sa, $ea); $img->Line($x_old, $y_old, $x, $y); $x_old = $x; $y_old = $y; } } $g = new CanvasGraph($w, $h); //$gr = 1.61803398874989484820; $p = SeaShell($g->img, 0, 20, $w - 1, $h - 21, $r, 19); $g->img->SetColor('black'); $g->img->Rectangle(0, 20, $w - 1, $h - 1); $g->img->SetFont(FF_FONT2, FS_BOLD); $g->img->SetTextAlign('center', 'top'); $g->img->StrokeText($w / 2, 0, "Canvas Spiral"); $g->Stroke(); ?>
function grafic_trunk2(&$pDB_ast_cdr, &$pDB_ast, $module_name, $trunk, $dti, $dtf) { // require_once "modules/{$module_name}/libs/paloSantoExtention.class.php"; $objPalo_AST_CDR = new paloSantoExtention($pDB_ast_cdr); /* Si la troncal pedida es un grupo, se expande el grupo para averiguar las troncales individuales. */ $regs = NULL; if (preg_match('!^DAHDI/(g|r)(\\d+)$!i', $trunk, $regs)) { $iGrupoTrunk = (int) $regs[2]; $gruposTrunk = getTrunkGroupsDAHDI(); if (is_array($gruposTrunk) && isset($gruposTrunk[$iGrupoTrunk])) { $trunk = $gruposTrunk[$iGrupoTrunk]; } } //total minutos de llamadas in y out $arrayTemp = $objPalo_AST_CDR->loadTrunks($trunk, "numcall", $dti, $dtf); $arrResult = $arrayTemp[0]; //$arrResult[0] => "IN" //$arrResult[1] => "OUT" $tot = $arrResult[0] + $arrResult[1]; $usoDisco = $tot != 0 ? 100 * ($arrResult[0] / $tot) : 0; if ($tot != 0) { $freeDisco = 100 - $usoDisco; // Some data $data = array($usoDisco, $freeDisco); // Create the Pie Graph. $graph = new PieGraph(400, 170, "auto"); //$graph->SetShadow(); $graph->SetMarginColor('#fafafa'); $graph->SetFrame(true, '#999999'); $graph->legend->SetFillColor("#fafafa"); //$graph->legend->Pos(0.012, 0.5, "right","center"); $graph->legend->SetColor("#444444", "#999999"); $graph->legend->SetShadow('gray@0.6', 4); //$graph->title->SetColor("#444444"); // Set A title for the plot $graph->title->Set(utf8_decode(_tr("Number of Calls"))); //$graph->title->SetFont(FF_VERDANA,FS_BOLD,18); $graph->title->SetColor("#444444"); $graph->legend->Pos(0.04, 0.2); // Create 3D pie plot $p1 = new PiePlot3d($data); //$p1->SetTheme("water"); $p1->SetSliceColors(array("#3333cc", "#9999cc", "#CC3333", "#72394a", "#aa3424")); $p1->SetCenter(0.3); $p1->SetSize(80); // Adjust projection angle $p1->SetAngle(45); // Adjsut angle for first slice $p1->SetStartAngle(45); // Display the slice values //$p1->value->SetFont(FF_ARIAL,FS_BOLD,11); //$p1->value->SetColor("navy"); $p1->value->SetColor("black"); // Add colored edges to the 3D pies // NOTE: You can't have exploded slices with edges! $p1->SetEdge("black"); $p1->SetLegends(array(utf8_decode(_tr("Incoming Calls") . ": ") . $arrResult[0], utf8_decode(_tr("Outcoming Calls") . ": ") . $arrResult[1])); $graph->Add($p1); $graph->Stroke(); } else { $graph = new CanvasGraph(400, 140, "auto"); $title = new Text(utf8_decode(_tr("Number of Calls"))); $title->ParagraphAlign('center'); $title->SetFont(FF_FONT2, FS_BOLD); $title->SetMargin(3); $title->SetAlign('center'); $title->Center(0, 400, 70); $graph->AddText($title); $t1 = new Text(utf8_decode(_tr("There are no data to present"))); $t1->SetBox("white", "black", true); $t1->ParagraphAlign("center"); $t1->SetColor("black"); $graph->AddText($t1); $graph->img->SetColor('navy'); $graph->img->SetTextAlign('center', 'bottom'); $graph->img->Rectangle(0, 0, 399, 139); $graph->Stroke(); } }