本文整理汇总了PHP中Graph::AddText方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::AddText方法的具体用法?PHP Graph::AddText怎么用?PHP Graph::AddText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::AddText方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
// 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();
示例2: create_graph_barplot
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;
}
示例3: AddText
function AddText($aTxt, $aToY2 = false)
{
parent::AddText($aTxt);
}
示例4: AddText
function AddText(&$aTxt)
{
parent::AddText($aTxt);
}
示例5: array
$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");
$graph->yaxis->title->Set("x10,000 US\$");
示例6: ScatterPlot
}
$pays[$i]->mark->SetSize(10);
$graph->Add($pays[$i]);
$i++;
}
$legende25 = new ScatterPlot(array(90), array(50));
$legende25->mark->SetType(MARK_FILLEDCIRCLE);
$legende25->mark->SetColor("yellow@0.5");
$legende25->mark->SetFillColor("yellow@0.4");
$legende25->mark->SetSize(10);
$graph->Add($legende25);
$legtext25 = new Text(" < 25%");
$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");
示例7: setupGraph
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;
}
示例8: templateGraph
//.........这里部分代码省略.........
// $first[$siteid] = $percent;
if (!$this->withZoom) {
$xdata[$userid][$siteid][] = $start;
$ydata[$userid][$siteid][] = $percent;
}
}
$xdata[$userid][$siteid][] = $time;
$ydata[$userid][$siteid][] = $percent;
$ylast[$userid][$siteid] = $percent;
$no_data = false;
}
if (!$this->withZoom) {
foreach (array_keys($ydata[$uid1]) as $siteid) {
$xdata[$uid1][$siteid][] = $end;
$ydata[$uid1][$siteid][] = $ylast[$uid1][$siteid];
}
if (isset($ydata[$uid2])) {
foreach (array_keys($ydata[$uid2]) as $siteid) {
$xdata[$uid2][$siteid][] = $end;
$ydata[$uid2][$siteid][] = $ylast[$uid2][$siteid];
}
}
}
// $xdata[$siteid][] = $end;
// $ydata[$siteid][] = $percent;
// $ylast[$siteid] = $percent;
// foreach ($sites2 as $siteid)
// {
// $xdata[$siteid][] = $end;
// $ydata[$siteid][] = isset($ylast[$siteid]) ;
// }
//define the graph
$dateformat = "d.M.y";
$datemargin = strlen(date($dateformat)) * 11;
// $graph = new Graph($this->module->cfgGraphWidth()*2, $this->module->cfgGraphHeight()*2);
$graph = new Graph($this->width, $this->height);
if ($no_data) {
$graph->SetScale('textint', 0, 100, 0, 1);
} else {
$graph->SetScale('datlin', 0, 100);
$graph->xaxis->scale->SetDateFormat($dateformat);
}
$graph->SetColor(array(238, 238, 238));
$graph->SetMarginColor(array(208, 211, 237));
$graph->title->Set($this->getGraphTitle());
$graph->yaxis->title->Set($this->module->lang('percentage'));
$graph->SetShadow();
$graph->xaxis->SetLabelAngle(90);
$graph->img->SetMargin(40, 170, 20, $datemargin);
// $graph->img->SetMargin(40, 140, 0, $datemargin);
$graph->legend->Pos(0.015, 0.05, "right", "top");
$weights = array($uid1 => 3, $uid2 => 1);
$labeled = array();
//make a line for each site (and user)
foreach ($ydata as $userid => $ydata2) {
$curr_weight = $weights[$userid];
foreach ($ydata2 as $siteid => $data) {
// var_dump($data);
if (!isset($this->sites[$siteid])) {
continue;
}
$site = $this->sites[$siteid];
$site instanceof WC_Site;
$lineplot = new LinePlot($data, $xdata[$userid][$siteid]);
list($color, $style) = $this->getColorAndStyle($site);
$lineplot->SetStyle($style);
$lineplot->SetColor($color);
$lineplot->SetWeight($curr_weight);
if ($this->withNumbers) {
$lineplot->value->Show();
}
if ($this->withIcons) {
$path = 'dbimg/logo_gif/' . $siteid . '.gif';
if (is_readable($path)) {
$lineplot->mark->SetType(MARK_IMG, $path, 0.5);
}
}
if (!in_array($siteid, $labeled, true)) {
$lineplot->SetLegend($site->getVar('site_name'));
$labeled[] = $siteid;
}
$graph->Add($lineplot);
}
}
// $graph->img->SetAntiAliasing();
if ($no_data) {
if (count($this->sites) === 0) {
$text = $this->module->lang('err_no_sites');
} else {
$text = $this->module->lang('err_graph_empty');
}
$txt = new Text($text);
// $txt->SetFont(FF_ARIAL,FS_NORMAL,18);
$txt->SetColor("#0000ff");
$txt->SetPos(0.45, 0.45, 'center', 'center');
$graph->AddText($txt);
}
$graph->Stroke();
die;
}
示例9: Text
/*
$tx3 = new Text("Last Ob @ ". strftime("%m/%d %I:%M %p", $mySOb['ts']) ."
Sensor 0: ". $mySOb['tmpf0'] ." F
Sensor 1: ". $mySOb['tmpf1'] ." F
Sensor 2: ". $mySOb['tmpf2'] ." F
Sensor 3: ". $mySOb['tmpf3'] ." F
Air Temp: ". $myOb['tmpf'] ." F
Dew Point: ". $myOb['dwpf'] ." F
SubS Temp: ". $mySOb['subt'] ." F
");
*/
}
//$tx3->SetPos(0.31,0.001, 'left', 'top');
//$tx3->SetFont(FF_FONT1, FS_NORMAL, 8);
//$tx3->SetColor("blue");
$graph->AddText($tx1);
$graph->AddText($tx2);
//$graph->AddText($tx3);
// Add the plot to the graph
$graph->Add($fz);
if (max($tcs0) != "" && isset($_GET["s0"])) {
$graph->Add($lineplot);
}
if (max($tcs1) != "" && isset($_GET["s1"])) {
$graph->Add($lineplot2);
}
if (max($tcs2) != "" && isset($_GET["s2"])) {
$graph->Add($lineplot3);
}
if (max($tcs3) != "" && isset($_GET["s3"])) {
$graph->Add($lineplot4);
示例10: graphB
private function graphB(WC_Site $site, $field)
{
$graphtitle = $this->module->lang('gt_site_' . $field, array($site->getVar('site_name')));
$siteid = $site->getID();
$history = GDO::table('WC_HistorySite');
if (false === ($result = $history->select("sitehist_date, {$field}", 'sitehist_sid=' . $siteid, 'sitehist_date ASC'))) {
return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
// $db = gdo_db();
// $table = $history->getTableName();
// if (false === ($result = $db->query("SELECT sitehist_date, $field FROM $table WHERE sitehist_sid=$siteid ORDER BY sitehist_date ASC"))) {
// return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
// }
//load in the data
$xdataarray = array();
$ydataarray = array();
$highestvalue = 0;
// while (false !== ($row = $db->fetchRow($result)))
while (false !== ($row = $history->fetch($result, GDO::ARRAY_N))) {
$value = (int) $row[1];
$xdataarray[] = $row[0];
$ydataarray[] = $value;
if ($value > $highestvalue) {
$highestvalue = $value;
}
}
$history->free($result);
// add current value
$xdataarray[] = time();
$ydataarray[] = $value = $site->getVar(str_replace('hist_', '_', $field));
if ($value > $highestvalue) {
$highestvalue = $value;
}
// var_dump($xdataarray);
// var_dump($ydataarray);
// var_dump($xticks);
if ($highestvalue === 0) {
$graph = new Graph($this->module->cfgGraphWidth(), $this->module->cfgGraphHeight());
$graph->SetScale('intlin', 1, 2, 1, 2);
$caption = new Text($this->module->lang('err_graph_empty'), 0.1, 0.8);
// $caption->SetFont(FS_BOLD);
$graph->AddText($caption);
$graph->stroke();
die(0);
}
# $dateformat = GWF_HTML::lang('df_8');
// $dateformat = "d.M.y-H:i";
$dateformat = "M.y";
$datemargin = strlen(date($dateformat)) * 11;
//define the graph
$graph = new Graph($this->module->cfgGraphWidth(), $this->module->cfgGraphHeight());
$graph->SetScale('datlin', 0, 1.05 * $highestvalue);
$graph->title->Set($graphtitle);
// $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 12);
$graph->SetColor(array(238, 238, 238));
$graph->SetMarginColor(array(208, 211, 237));
$graph->SetShadow();
$graph->xaxis->SetLabelAngle(90);
// $graph->xaxis->SetTickPositions($xticks, NULL, $xdataarray);
$graph->xaxis->scale->SetDateFormat($dateformat);
$graph->img->SetMargin(50, 40, 40, $datemargin);
$lineplot = new LinePlot($ydataarray, $xdataarray);
$lineplot->SetColor("blue");
$lineplot->SetWeight(2);
$graph->Add($lineplot);
// $graph->img->SetAntiAliasing();
// Display the graph
GWF_HTTP::noCache();
$graph->Stroke();
die(0);
}
示例11: Text
$graph->AddY2($lineFound);
//
// Infotexte einfuegen
//
$txtStat1 = new Text(tr('graph_statistics_04') . strftime('%d-%m-%Y', time()));
$txtStat1->SetPos(55, 55);
$txtStat1->SetFont(FF_ARIAL, FS_NORMAL, 10);
$lineHeight = $txtStat1->GetFontHeight($graph->img);
$hiddenCaches = XDb::xSimpleQueryValue("SELECT COUNT(*) FROM `caches` WHERE (`status`=1 OR `status`=2 OR `status`=3)", 0);
$txtStat2 = new Text(tr('graph_statistics_05') . str_replace(',', '.', number_format($hiddenCaches)));
$txtStat2->SetPos(55, 55 + $lineHeight * 1.5);
$txtStat2->SetFont(FF_ARIAL, FS_NORMAL, 8);
$txtStat2->SetColor('blue');
$activeCaches = XDb::xSimpleQueryValue("SELECT COUNT(*) FROM `caches` WHERE `status`=1", 0);
$txtStat3 = new Text(tr('graph_statistics_06') . str_replace(',', '.', number_format($activeCaches)));
$txtStat3->SetPos(55, 55 + $lineHeight * 2.5);
$txtStat3->SetFont(FF_ARIAL, FS_NORMAL, 8);
$txtStat3->SetColor('blue');
$foundEntries = XDb::xMultiVariableQueryValue("SELECT COUNT(*) FROM `cache_logs` WHERE `type`=1 AND `deleted`=0", 0);
$txtStat5 = new Text(tr('graph_statistics_07') . str_replace(',', '.', number_format($foundEntries)));
$txtStat5->SetPos(55, 55 + $lineHeight * 5.0);
$txtStat5->SetFont(FF_ARIAL, FS_NORMAL, 8);
$txtStat5->SetColor('darkgreen');
$graph->AddText($txtStat1);
$graph->AddText($txtStat2);
$graph->AddText($txtStat3);
$graph->AddText($txtStat5);
//
// Display the graph
//
$graph->Stroke();
示例12: init_graphs
function init_graphs()
{
global $rundate;
// Create the graphs
$tdate1 = new Text();
$tdate1->SetFont(FF_ARIAL, FS_NORMAL, 8);
$tdate1->SetColor("#000000");
$tdate1->Set("generated at: {$rundate}");
$tdate1->SetBox("#ffffff", "#8b898b", "#aaaaaa", 0, 0);
$tdate1->SetPos(280, 220);
$tdate2 = new Text();
$tdate2->SetFont(FF_ARIAL, FS_NORMAL, 8);
$tdate2->SetColor("#000000");
$tdate2->Set("generated at: {$rundate}");
$tdate2->SetBox("#ffffff", "#8b898b", "#aaaaaa", 0, 0);
$tdate2->SetPos(560, 420);
// ** ------------- **
$graph1 = new Graph(470, 250, "auto");
$graph1->SetScale("textlin");
$graph1->SetShadow();
$graph1->SetBox();
$graph1->img->SetMargin(60, 30, 30, 80);
$graph1->SetMarginColor('#ececec');
$graph1->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph1->AddText($tdate1);
// --------------
$graph1->ygrid->Show(true, true);
$graph1->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph1->yaxis->title->SetAngle(90);
$graph1->yaxis->SetTitleMargin(40);
$graph1->yaxis->title->Text("Translated Messages", "high");
$graph1->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph1->yaxis->SetLabelAngle(0);
$graph1->yaxis->SetPos('min');
// -------------
$graph1->xgrid->Show(false, false);
$graph1->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph1->xaxis->title->SetAngle(0);
$graph1->xaxis->title->Text("Days");
$graph1->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph1->xaxis->SetLabelAngle(30);
$graph1->xaxis->SetTextLabelInterval(10);
$graph1->xaxis->SetPos('min');
$sline = new PlotLine(HORIZONTAL, 0, "black", 1);
$graph1->Add($sline);
// ** ------------- **
$graph2 = new Graph(750, 450, "auto");
$graph2->SetScale("textlin");
$graph2->SetShadow();
$graph2->SetBox();
$graph2->img->SetMargin(60, 30, 30, 80);
$graph2->SetMarginColor('#ececec');
$graph2->title->SetFont(FF_ARIAL, FS_BOLD, 12);
$graph2->AddText($tdate2);
// --------------
$graph2->ygrid->Show(true, true);
$graph2->yaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph2->yaxis->title->SetAngle(90);
$graph2->yaxis->SetTitleMargin(40);
$graph2->yaxis->title->Text("Translated Messages", "high");
$graph2->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph2->yaxis->SetLabelAngle(0);
$graph2->yaxis->SetPos('min');
// -------------
$graph2->xgrid->Show(true, false);
$graph2->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 10);
$graph2->xaxis->title->SetAngle(0);
$graph2->xaxis->title->Text("Days");
$graph2->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph2->xaxis->SetLabelAngle(30);
$graph2->xaxis->SetTextLabelInterval(10);
$graph2->xaxis->SetPos('min');
$sline = new PlotLine(HORIZONTAL, 0, "black", 1);
$graph2->Add($sline);
return array($graph1, $graph2);
}