本文整理汇总了PHP中CanvasGraph类的典型用法代码示例。如果您正苦于以下问题:PHP CanvasGraph类的具体用法?PHP CanvasGraph怎么用?PHP CanvasGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CanvasGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showError
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();
}
示例2: CanvasGraph
<?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('');
示例3: error_text
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;
}
示例4: array
<?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();
示例5: top
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);
}
}
//.........这里部分代码省略.........
示例6: CanvasGraph
<?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
示例7: buildGraphicByYear
//.........这里部分代码省略.........
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;
}
示例8: CanvasGraph
<?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);
示例9: CanvasGraph
<?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();
示例10: CanvasGraph
//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) {
示例11: BAR_graph
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', '', '');
//.........这里部分代码省略.........
示例12: Draw
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();
}
示例13: ejecutarGrafico
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);*/
}
}
示例14: error_text
/**
* 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;
}
示例15: Stroke
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];
//.........这里部分代码省略.........