本文整理汇总了PHP中BarPlot::setLegend方法的典型用法代码示例。如果您正苦于以下问题:PHP BarPlot::setLegend方法的具体用法?PHP BarPlot::setLegend怎么用?PHP BarPlot::setLegend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BarPlot
的用法示例。
在下文中一共展示了BarPlot::setLegend方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderGraph
public function renderGraph()
{
require_once 'libs/jpgraph/jpgraph.php';
require_once 'libs/jpgraph/jpgraph_bar.php';
require_once 'libs/jpgraph/jpgraph_line.php';
$graph = new Graph(300, 200, 'auto');
$graph->SetMarginColor('white');
$graph->SetFrame(false);
$graph->SetScale("textlin");
$graph->SetY2Scale("lin");
$graph->img->SetMargin(0, 30, 20, 65);
$graph->yaxis->HideLabels();
$graph->yaxis->HideTicks();
$graph->yaxis->scale->SetGrace(20);
$graph->y2axis->SetColor("black", "red");
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$labelsy = array();
$datay = array();
$datay2 = array();
switch ($this->_controllerAction->getRequest()->getParam('type')) {
case 'year':
$this->_populateYearData($labelsy, $datay, $datay2);
break;
default:
$this->_populateWeekData($labelsy, $datay, $datay2);
}
$graph->xaxis->SetTickLabels($labelsy);
$locale = Zend_Registry::get('Zend_Locale');
if ($locale == 'ja') {
// the ttf file for FF_MINCHO is already encoded in utf-8
$legend1 = $this->view->translate('Trusted sites');
$legend2 = $this->view->translate('Sites per user');
} else {
// default ttf files are latin-1 encoded
$legend1 = utf8_decode($this->view->translate('Trusted sites'));
$legend2 = utf8_decode($this->view->translate('Sites per user'));
}
$bplot = new BarPlot($datay);
$bplot->setLegend($legend1);
$bplot->SetFillGradient("navy", "lightsteelblue", GRAD_WIDE_MIDVER);
$bplot->value->Show();
$bplot->value->SetFormat('%d');
$p1 = new LinePlot($datay2);
$p1->SetColor("red");
$p1->SetLegend($legend2);
$graph->Add($bplot);
$graph->AddY2($p1);
$graph->legend->SetLayout(LEGEND_HOR);
if ($locale == 'ja') {
$graph->legend->setFont(FF_MINCHO, FS_NORMAL);
}
$graph->legend->Pos(0.5, 0.99, "center", "bottom");
$graph->Stroke();
}
示例2: addPlots
function addPlots($data)
{
$plots = array();
$labels = array();
$i = 0;
foreach ($data as $key => $plot_data) {
$plot = new BarPlot(array_values($plot_data));
$plot->setLegend(prettify($key));
$plot->setFillColor(self::$colours[$i]);
$i++;
$plots[] = $plot;
$labels = array_merge($labels, array_keys($plot_data));
}
$group_plot = new GroupBarPlot($plots);
$this->grapher->add($group_plot);
$this->grapher->xaxis->setTickLabels($labels);
}
示例3: array
$graph->xaxis->SetPosAbsDelta(15);
$graph->yaxis->SetPosAbsDelta(-15);
$graph->xaxis->SetLabelAngle(50);
// Legend
$graph->legend->SetMarkAbsSize(5);
$graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 7);
$graph->legend->Pos(0.02, 0.02, "right", "top");
// Create the bar pot
$colors = array("#aa5500", "#55aa00", "#0055aa", "#aa0055", "#5500aa", "#00aa55", "#ff0000", "#00ff00", "#0000ff", "#ffff00", "#ff00ff", "#00ffff");
$listPlots = array();
foreach ($opbysalle as $key => $value) {
$bplot = new BarPlot($value["sejour"]);
$from = $colors[$key];
$to = "#EEEEEE";
$bplot->SetFillGradient($from, $to, GRAD_LEFT_REFLECTION);
$bplot->SetColor("white");
$bplot->setLegend($value["nom"]);
$bplot->value->SetFormat("%01.0f");
$bplot->value->SetColor($colors[$key]);
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
//$bplot->value->show();
$listPlots[] = $bplot;
}
$gbplot = new AccBarPlot($listPlots);
$gbplot->SetWidth(0.6);
$gbplot->value->SetFormat("%01.0f");
$gbplot->value->show();
// Set color for the frame of each bar
$graph->Add($gbplot);
// Finally send the graph to the browser
$graph->Stroke();
示例4: graph1
/**
* Current week top search strings report
*/
public function graph1()
{
$myConfig = $this->getConfig();
$oDb = oxDb::getDb();
$aDataX = array();
$aDataY = array();
$sTimeFrom = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_from"))));
$sTimeTo = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_to"))));
$sSQL = "select count(*) as nrof, oxparameter from oxlogs where oxclass = 'search' and oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxparameter order by nrof desc";
$rs = $oDb->execute($sSQL);
if ($rs != false && $rs->recordCount() > 0) {
while (!$rs->EOF) {
if ($rs->fields[1]) {
$aDataX[] = $rs->fields[0];
$aDataY[] = $rs->fields[1];
}
$rs->moveNext();
}
}
header("Content-type: image/png");
// New graph with a drop shadow
$graph = new Graph(800, max(640, 20 * count($aDataX)));
$graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME);
// Use a "text" X-scale
$graph->setScale("textlin");
$top = 60;
$bottom = 30;
$left = 80;
$right = 30;
$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->setShadow();
// Description
$graph->xaxis->setTickLabels($aDataY);
// Set title and subtitle
$graph->title->set("Suchw�rter");
// Use built in font
$graph->title->setFont(FF_FONT1, FS_BOLD);
// Create the bar plot
$bplot = new BarPlot($aDataX);
$bplot->setFillGradient("navy", "lightsteelblue", GRAD_VER);
$bplot->setLegend("Hits");
$graph->add($bplot);
// Finally output the image
$graph->stroke();
}
示例5: visitor_week
/**
* Collects and renders visitor/week report data
*/
public function visitor_week()
{
$myConfig = $this->getConfig();
$oDb = oxDb::getDb();
$aDataX = array();
$aDataX2 = array();
$aDataX3 = array();
$aDataX4 = array();
$aDataX5 = array();
$aDataX6 = array();
$aDataY = array();
$sTimeTo = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_to"))));
$sTimeFrom = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_from"))));
$sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid order by oxtime";
$aTemp = array();
$rs = $oDb->execute($sSQL);
if ($rs != false && $rs->recordCount() > 0) {
while (!$rs->EOF) {
$aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++;
$rs->moveNext();
}
}
// initializing
list($iFrom, $iTo) = $this->getWeekRange();
for ($i = $iFrom; $i < $iTo; $i++) {
$aDataX[$i] = 0;
$aDataX2[$i] = 0;
$aDataX3[$i] = 0;
$aDataX4[$i] = 0;
$aDataX5[$i] = 0;
$aDataX6[$i] = 0;
$aDataY[] = "KW " . $i;
}
foreach ($aTemp as $key => $value) {
$aDataX[$key] = $value;
$aDataX2[$key] = 0;
$aDataX3[$key] = 0;
$aDataX4[$key] = 0;
$aDataX5[$key] = 0;
$aDataX6[$key] = 0;
$aDataY[] = "KW " . $key;
}
// collects sessions what executed 'order' function
$sQ = "select oxtime, oxsessid FROM `oxlogs` where oxclass = 'order' and oxfnc = 'execute' and oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid";
$aTempOrder = $this->_collectSessions($sQ);
// collects sessions what executed order class
$sQ = "select oxtime, oxsessid from `oxlogs` where oxclass = 'order' and oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid";
$aTempExecOrdersSessions = $this->_collectOrderSessions($sQ, $aTempOrder, $aDataX6, false);
// collects sessions what executed payment class
$sQ = "select oxtime, oxsessid from `oxlogs` where oxclass = 'payment' and oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid";
$aTempPaymentSessions = $this->_collectPaymentSessions($sQ, $aTempOrder, $aTempExecOrdersSessions, $aDataX2, false);
// collects sessions what executed 'user' class
$sQ = "select oxtime, oxsessid from `oxlogs` where oxclass = 'user' and oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid";
$aTempUserSessions = $this->_collectUserSessionsForVisitorMonth($sQ, $aTempOrder, $aTempExecOrdersSessions, $aTempPaymentSessions, $aDataX2, false);
// collects sessions what executed 'tobasket' function
$sQ = "select oxtime, oxsessid from `oxlogs` where oxclass = 'basket' and oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid";
$this->_collectToBasketSessions($sQ, $aTempOrder, $aTempExecOrdersSessions, $aTempPaymentSessions, $aTempUserSessions, $aDataX4, false);
// orders made
$sQ = "select oxorderdate from oxorder where oxorderdate >= {$sTimeFrom} and oxorderdate <= {$sTimeTo} order by oxorderdate";
$this->_collectOrdersMade($sQ, $aDataX5, false);
header("Content-type: image/png");
// New graph with a drop shadow
$graph = $this->getGraph(max(800, count($aDataX) * 80), 600);
// Description
$graph->xaxis->setTickLabels($aDataY);
// Set title and subtitle
$graph->title->set("Woche");
// Create the bar plot
$bplot2 = new BarPlot(array_values($aDataX2));
$bplot2->setFillColor("#9966cc");
$bplot2->setLegend("Best.Abbr. in Bezahlmethoden");
// Create the bar plot
$bplot3 = new BarPlot(array_values($aDataX3));
$bplot3->setFillColor("#ffcc00");
$bplot3->setLegend("Best.Abbr. in Benutzer");
// Create the bar plot
$bplot4 = new BarPlot(array_values($aDataX4));
$bplot4->setFillColor("#6699ff");
$bplot4->setLegend("Best.Abbr. in Warenkorb");
// Create the bar plot
$bplot6 = new BarPlot(array_values($aDataX6));
$bplot6->setFillColor("#ff0099");
$bplot6->setLegend("Best.Abbr. in Bestellbestaetigung");
// Create the bar plot
$bplot5 = new BarPlot(array_values($aDataX5));
$bplot5->setFillColor("silver");
$bplot5->setLegend("Bestellungen");
// Create the grouped bar plot
$gbplot = new groupBarPlot(array($bplot4, $bplot3, $bplot2, $bplot6, $bplot5));
$graph->add($gbplot);
// Finally output the image
$graph->stroke();
}
示例6: array
$graph_title = "Workload by Time Period";
$event_type = "actions";
}
$plots = array();
foreach ($data as $performer => $values) {
ksort($values);
ksort($data[$performer]);
// Create a bar pot
$bplot = new BarPlot(array_values($values));
if ($performer == "customer") {
$color = "#99ccff";
} else {
$color = "#ffcc00";
}
$bplot->SetFillColor($color);
$bplot->setLegend(ucfirst($performer) . " " . $event_type);
$plots[] = $bplot;
}
$graph = new Graph(800, 350);
$graph->SetScale("textlin");
$graph->img->SetMargin(60, 30, 40, 40);
$graph->yaxis->SetTitleMargin(45);
$graph->SetShadow();
// Turn the tickmarks
$graph->xaxis->SetTickDirection(SIDE_DOWN);
$graph->yaxis->SetTickDirection(SIDE_LEFT);
$graph->xaxis->SetTickLabels(array_keys($data["developer"] + $data["customer"]));
// group plots together
$grouped = new GroupBarPlot($plots);
$graph->Add($grouped);
$graph->title->Set($graph_title);
示例7: BarPlot
case 4:
$plottable["Avg Time to First Response"] = $info["time_stats"]["time_to_first_response"]["avg"] / 60;
$plottable["Median Time to First Response"] = $info["time_stats"]["time_to_first_response"]["median"] / 60;
break;
}
// Create a bar pot
$bplot = new BarPlot(array_values($plottable));
$bplot->showValue(true);
$bplot->SetValueFont(FF_FONT2, FS_NORMAL, 9);
if (!empty($graph_types[$graph_id]["value_format"])) {
$value_format = $graph_types[$graph_id]["value_format"];
} else {
$value_format = '%d';
}
$bplot->SetValueFormat($value_format, 90);
$bplot->setLegend($info["title"]);
if (isset($colors[$color_index])) {
$color = $colors[$color_index];
} else {
$color_index = 0;
$color = $colors[$color_index];
}
$color_index++;
$bplot->SetFillColor($color);
$plots[] = $bplot;
$labels = array_keys($plottable);
}
// figure out width of legend to propery set margin.
$legend_width = imagefontwidth(FF_FONT1) * $max_title_len + 30;
if (!empty($graph_types[$graph_id]["size"]["group"])) {
$width = $graph_types[$graph_id]["size"]["group"] * count($data) + 200;
示例8: visitor_week
/**
* Collects and renders visitor/week report data
*/
public function visitor_week()
{
$myConfig = $this->getConfig();
$oDb = oxDb::getDb();
$aDataX = array();
$aDataY = array();
$sTimeTo = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_to"))));
$sTimeFrom = $oDb->quote(date("Y-m-d H:i:s", strtotime(oxRegistry::getConfig()->getRequestParameter("time_from"))));
$sSQL = "select oxtime, count(*) as nrof from oxlogs where oxtime >= {$sTimeFrom} and oxtime <= {$sTimeTo} group by oxsessid order by oxtime";
$aTemp = array();
$rs = $oDb->execute($sSQL);
if ($rs != false && $rs->recordCount() > 0) {
while (!$rs->EOF) {
//$aTemp[date( "W", strtotime( $rs->fields[0]))]++;
$aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++;
$rs->moveNext();
}
}
// initializing
list($iFrom, $iTo) = $this->getWeekRange();
for ($i = $iFrom; $i < $iTo; $i++) {
$aDataX[$i] = 0;
$aDataX2[$i] = 0;
$aDataX3[$i] = 0;
$aDataY[] = "KW " . $i;
}
foreach ($aTemp as $key => $value) {
$aDataX[$key] = $value;
$aDataX2[$key] = 0;
$aDataX3[$key] = 0;
$aDataY[] = "KW " . $key;
}
// buyer
$sSQL = "select oxorderdate from oxorder where oxorderdate >= {$sTimeFrom} and oxorderdate <= {$sTimeTo} order by oxorderdate";
$aTemp = array();
$rs = $oDb->execute($sSQL);
if ($rs != false && $rs->recordCount() > 0) {
while (!$rs->EOF) {
//$aTemp[date( "W", strtotime( $rs->fields[0]))]++;
$aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++;
$rs->moveNext();
}
}
foreach ($aTemp as $key => $value) {
$aDataX2[$key] = $value;
}
// newcustomer
$sSQL = "select oxcreate from oxuser where oxcreate >= {$sTimeFrom} and oxcreate <= {$sTimeTo} order by oxcreate";
$aTemp = array();
$rs = $oDb->execute($sSQL);
if ($rs != false && $rs->recordCount() > 0) {
while (!$rs->EOF) {
//$aTemp[date( "W", strtotime( $rs->fields[0]))]++;
$aTemp[oxRegistry::get("oxUtilsDate")->getWeekNumber($myConfig->getConfigParam('iFirstWeekDay'), strtotime($rs->fields[0]))]++;
$rs->moveNext();
}
}
foreach ($aTemp as $key => $value) {
$aDataX3[$key] = $value;
}
header("Content-type: image/png");
// New graph with a drop shadow
$graph = new Graph(max(800, count($aDataX) * 80), 600);
$graph->setBackgroundImage($myConfig->getImageDir(true) . "/reportbgrnd.jpg", BGIMG_FILLFRAME);
// Use a "text" X-scale
$graph->setScale("textlin");
// Label align for X-axis
$graph->xaxis->setLabelAlign('center', 'top', 'right');
// Label align for Y-axis
$graph->yaxis->setLabelAlign('right', 'bottom');
$graph->setShadow();
// Description
$graph->xaxis->setTickLabels($aDataY);
// Set title and subtitle
$graph->title->set("Woche");
// Use built in font
$graph->title->setFont(FF_FONT1, FS_BOLD);
$aDataFinalX = array();
foreach ($aDataX as $dData) {
$aDataFinalX[] = $dData;
}
// Create the bar plot
$bplot = new BarPlot($aDataFinalX);
$bplot->setFillGradient("navy", "lightsteelblue", GRAD_VER);
$bplot->setLegend("Besucher");
$aDataFinalX2 = array();
foreach ($aDataX2 as $dData) {
$aDataFinalX2[] = $dData;
}
// Create the bar plot
$bplot2 = new BarPlot($aDataFinalX2);
$bplot2->setFillColor("orange");
$bplot2->setLegend("Kaeufer");
$aDataFinalX3 = array();
foreach ($aDataX3 as $dData) {
$aDataFinalX3[] = $dData;
}
//.........这里部分代码省略.........