本文整理汇总了PHP中Graph::SetFrame方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::SetFrame方法的具体用法?PHP Graph::SetFrame怎么用?PHP Graph::SetFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::SetFrame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShowHBar
/**
* Show Horizontal Bar graph
*/
function ShowHBar(&$legend, &$value)
{
$height = 50 + count($value) * 18;
$width = 500;
// Set the basic parameters of the graph
$graph = new Graph($width, $height, 'auto');
$graph->SetScale("textlin");
$top = 30;
$bottom = 20;
$left = 100;
$right = 50;
$graph->Set90AndMargin($left, $right, $top, $bottom);
$graph->xaxis->SetTickLabels($legend);
$graph->SetFrame(false);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right', 'center', 'right');
// Label align for Y-axis
$graph->yaxis->SetLabelAlign('center', 'bottom');
// Create a bar pot
$bplot = new BarPlot($value);
$bplot->SetFillColor("orange");
$bplot->SetWidth(0.5);
// We want to display the value of each bar at the top
$graph->yaxis->scale->SetGrace(10);
$graph->yaxis->SetLabelAlign('center', 'bottom');
$graph->yaxis->SetLabelFormat('%d');
$bplot->value->Show();
$bplot->value->SetFormat('%.d votes');
// Setup color for gradient fill style
$bplot->SetFillGradient("navy", "lightsteelblue", GRAD_MIDVER);
$graph->Add($bplot);
$graph->Stroke();
}
示例2: renderGraph
public function renderGraph()
{
require_once 'libs/jpgraph/jpgraph.php';
require_once 'libs/jpgraph/jpgraph_bar.php';
$graph = new Graph($this->_controllerAction->getRequest()->getParam('type') == 'month' ? 400 : 300, 200, 'auto');
$graph->SetMarginColor('white');
$graph->SetFrame(false);
$graph->SetScale("textlin");
$graph->img->SetMargin(0, 30, 20, 40);
$graph->yaxis->scale->SetGrace(20);
$graph->yaxis->HideLabels();
$graph->yaxis->HideTicks();
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$labelsy = array();
$datay = array();
switch ($this->_controllerAction->getRequest()->getParam('type')) {
case 'month':
$this->_populateMonthData($labelsy, $datay);
break;
case 'year':
$this->_populateYearData($labelsy, $datay);
break;
default:
$this->_populateWeekData($labelsy, $datay);
}
$graph->xaxis->SetTickLabels($labelsy);
$bplot = new BarPlot($datay);
$bplot->SetFillGradient("navy", "lightsteelblue", GRAD_WIDE_MIDVER);
$bplot->value->Show();
$bplot->value->SetFormat('%d');
$graph->Add($bplot);
$graph->Stroke();
}
示例3: 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();
}
示例4: LineGraph
function LineGraph($w, $h, $title, $data1, $data2, $datax, $output)
{
// Create the graph. These two calls are always required
$graph = new Graph($w, $h, "auto");
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
$graph->SetFrame(true);
// Adjust the margin
$graph->img->SetMargin(40, 100, 20, 40);
$graph->SetShadow(false);
// Create the linear plot
$lineplot = new LinePlot($data1);
$lineplot->SetWeight(2);
$lineplot->SetColor("blue");
$lineplot->mark->SetType(MARK_DIAMOND);
$lineplot->mark->SetWidth(5);
$lineplot->mark->SetFillColor('blue');
$lineplot->value->SetMargin(-20);
$lineplot->value->show();
$lineplot->value->SetColor('blue');
$lineplot->value->SetFormat('%0.0f');
$lineplot->SetLegend($_SESSION[Tahun1]);
$lineplot2 = new LinePlot($data2);
$lineplot2->SetColor("green");
$lineplot2->SetWeight(2);
$lineplot2->mark->SetType(MARK_FILLEDCIRCLE);
$lineplot2->mark->SetWidth(3);
$lineplot2->mark->SetFillColor('green');
$lineplot2->value->show();
$lineplot2->value->SetColor('darkgreen');
$lineplot2->value->SetFormat('%0.0f');
$lineplot2->SetLegend($_SESSION[Tahun2]);
// Add the plot to the graph
$graph->Add($lineplot);
$graph->xaxis->SetTickLabels($datax);
$graph->title->Set($title);
$graph->xaxis->title->Set("");
$graph->yaxis->title->Set("");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
$graph->Add($lineplot2);
$graph->legend->SetShadow(false);
$graph->legend->SetFillColor('white');
$graph->legend->SetPos(0.01, 0.88, 'right', 'center');
// Display the graph
$graph->Stroke($output);
}
示例5: executeBarGraph
public function executeBarGraph()
{
//Set the response header to a image JPEG datastream
$this->getResponse()->setContent('image/jpeg');
// Change this defines to where Your fonts are stored
DEFINE("TTF_DIR", "/usr/share/fonts/truetype/freefont/");
// Change this define to a font file that You know that You have
DEFINE("TTF_SANS", "FreeSans.ttf");
$util = new util();
$dataDVDrip = $util->getTotalFormat('DVDrip', 'movies');
$dataHDrip = $util->getTotalFormat('HDrip', 'movies');
$data720p = $util->getTotalFormat('720p', 'movies');
$data1080p = $util->getTotalFormat('1080p', 'movies');
$datay = array($dataDVDrip, $dataHDrip, $data720p, $data1080p);
$graph = new Graph(199, 145);
$graph->SetScale('textlin');
$graph->SetColor('black');
$graph->SetMarginColor('#393939');
$graph->SetFrame(true, '#393939');
$top = 25;
$bottom = 20;
$left = 50;
$right = 20;
$graph->Set90AndMargin($left, $right, $top, $bottom);
// Setup labels
$lbl = array("DVDrip", "HDrip", "720p", "1080p");
$graph->xaxis->SetTickLabels($lbl);
$graph->xaxis->SetColor('white');
$graph->xaxis->SetLabelAlign('right', 'center', 'right');
$graph->yaxis->SetLabelAlign('center', 'bottom');
$graph->yaxis->SetColor('white');
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.5);
$bplot->SetFillGradient(array(250, 2, 2), array(109, 2, 2), GRAD_VERT);
$graph->Add($bplot);
$graph->Stroke();
return sfView::NONE;
}
示例6: Graph
}
}
//
require_once 'ossim_conf.inc';
$conf = $GLOBALS["CONF"];
$jpgraph = $conf->get_conf("jpgraph_path");
require_once "{$jpgraph}/jpgraph.php";
require_once "{$jpgraph}/jpgraph_line.php";
// Setup the graph.
$graph = new Graph(600, 300, "auto");
$graph->SetScale("textlin");
$graph->SetMargin(100, 10, 20, 86);
$graph->SetMarginColor("#fafafa");
$graph->xaxis->SetTickLabels(array(_("Ene"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"), _("Jul"), _("Ago"), _("Sep"), _("Oct"), _("Nov"), _("Dic")));
$graph->SetColor("#fafafa");
$graph->SetFrame(true, '#fafafa', 0);
$dplot[0] = new LinePLot($data1['value']);
$dplot[1] = new LinePLot($data2['value']);
$dplot[2] = new LinePLot($data3['value']);
$dplot[3] = new LinePLot($data4['value']);
$dplot[4] = new LinePLot($data5['value']);
$dplot[0]->SetColor(COLOR1);
$dplot[0]->SetLegend('QoS-Impact');
$dplot[0]->mark->SetType(MARK_SQUARE);
$dplot[0]->mark->SetColor(COLOR1);
$dplot[0]->mark->SetFillColor(COLOR1);
//
$dplot[1]->SetColor(COLOR2);
$dplot[1]->SetLegend('Information-Leak-Impact');
$dplot[1]->mark->SetType(MARK_UTRIANGLE);
$dplot[1]->mark->SetColor(COLOR2);
示例7: createhorizoncolumnar
/**
* 横柱图
*
*/
function createhorizoncolumnar($title, $subtitle, $data = array(), $size = 40, $height = 100, $width = 80, $legend = array())
{
vendor("Jpgraph.jpgraph");
vendor("Jpgraph.jpgraph_bar");
$datay = $data;
$datax = $legend;
//编码转化
foreach ($datax as $k => $v) {
$datax[$k] = iconv('utf-8', 'gb2312', $v);
}
// Size of graph
$count = count($datay);
$addheight = 0;
if ($count > 10) {
$addheight = ($count - 10) * 20;
}
$height = $height + $addheight;
// Set the basic parameters of the graph
$graph = new Graph($width, $height, 'auto');
$graph->SetScale("textlin");
// No frame around the image
$graph->SetFrame(false);
$graph->SetFrame(false, '#ffffff', 0);
//去掉周围的边框
// Rotate graph 90 degrees and set margin
$graph->Set90AndMargin(70, 10, 50, 30);
// Set white margin color
$graph->SetMarginColor('white');
// Use a box around the plot area
$graph->SetBox();
// Use a gradient to fill the plot area
$graph->SetBackgroundGradient('white', 'white', GRAD_HOR, BGRAD_PLOT);
// Setup title
$graph->title->Set(iconv('utf-8', 'gb2312', "{$title}"));
$graph->title->SetFont(FF_SIMSUN, FS_BOLD, 12);
$graph->subtitle->Set("(" . iconv('utf-8', 'gb2312', $subtitle) . ")");
$graph->subtitle->SetFont(FF_SIMSUN, FS_NORMAL, 10);
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_SIMSUN, FS_NORMAL, 10);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(10);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right', 'center');
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(10);
// We don't want to display Y-axis
$graph->yaxis->Hide();
// Now create a bar pot
$bplot = new BarPlot($datay);
//$bplot->SetShadow();
//You can change the width of the bars if you like
//$bplot->SetWidth(0.5);
// Set gradient fill for bars
$bplot->SetFillGradient('blue', '#0080C0', GRAD_HOR);
// We want to display the value of each bar at the top
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL, FS_NORMAL, 7);
$bplot->value->SetAlign('left', 'center');
$bplot->value->SetColor("black");
$bplot->value->SetFormat('%.0f');
//$bplot->SetValuePos('max');
// Add the bar to the graph
$graph->Add($bplot);
// Add some explanation text
$txt = new Text('');
$txt->SetPos(130, 399, 'center', 'bottom');
$txt->SetFont(FF_COMIC, FS_NORMAL, 8);
$graph->Add($txt);
// .. and stroke the graph
$graph->Stroke();
}
示例8: array
<?php
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
// Some data
$datay = array(7, 19, 11, 4, 20);
// Create the graph and setup the basic parameters
$graph = new Graph(300, 200, 'auto');
$graph->img->SetMargin(40, 30, 40, 50);
$graph->SetScale("textint");
$graph->SetFrame(true, 'blue', 1);
$graph->SetColor('lightblue');
$graph->SetMarginColor('lightblue');
// Setup X-axis labels
$a = $gDateLocale->GetShortMonth();
$graph->xaxis->SetTickLabels($a);
$graph->xaxis->SetFont(FF_FONT1);
$graph->xaxis->SetColor('darkblue', 'black');
// Setup "hidden" y-axis by given it the same color
// as the background (this could also be done by setting the weight
// to zero)
$graph->yaxis->SetColor('lightblue', 'darkblue');
$graph->ygrid->SetColor('white');
// Setup graph title ands fonts
$graph->title->Set('Using grace = 50%');
$graph->title->SetFont(FF_FONT2, FS_BOLD);
$graph->xaxis->SetTitle('Year 2002', 'center');
$graph->xaxis->SetTitleMargin(10);
$graph->xaxis->title->SetFont(FF_FONT2, FS_BOLD);
// Add some grace to the top so that the scale doesn't
示例9: array
//.........这里部分代码省略.........
$xlabels[$k] = $v . "\n %.1f%%";
}
$lplot[$lplotct]->SetLabels($xlabels, 1.0);
$graph->Add($lplot[$lplotct]);
break;
case "STACKEDBAR":
case "BAR":
$lplot[$lplotct] = new BarPlot($v["data"]);
$lplot[$lplotct]->SetColor($v["linecolor"]);
$lplot[$lplotct]->SetWidth(0.8);
//$lplot[$lplotct]->SetWeight(5);
if ($v["fillcolor"]) {
$lplot[$lplotct]->SetFillColor($v["fillcolor"]);
}
if ($v["legend"]) {
$lplot[$lplotct]->SetLegend($v["legend"]);
}
$graph->Add($lplot[$lplotct]);
break;
case "LINE":
default:
if (count($v["data"]) == 1) {
$v["data"][] = 0;
}
$lplot[$lplotct] = new LinePlot($v["data"]);
$lplot[$lplotct]->SetColor($v["linecolor"]);
//$lplot[$lplotct]->SetWeight(5);
if ($v["fillcolor"]) {
$lplot[$lplotct]->SetFillColor($v["fillcolor"]);
}
if ($v["legend"]) {
$lplot[$lplotct]->SetLegend($v["legend"]);
}
$graph->Add($lplot[$lplotct]);
break;
}
$lplotct++;
}
$graph->title->Set($this->title_actual);
$graph->xaxis->title->Set($this->xtitle_actual);
$graph->yaxis->title->Set($this->ytitle_actual);
$graph->xgrid->SetColor($this->xgridcolor_actual);
$graph->ygrid->SetColor($this->ygridcolor_actual);
switch ($this->xgriddisplay_actual) {
case "all":
$graph->xgrid->Show(true, true);
break;
case "major":
$graph->xgrid->Show(true, false);
break;
case "minor":
$graph->xgrid->Show(false, true);
break;
case "none":
default:
$graph->xgrid->Show(false, false);
break;
}
switch ($this->ygriddisplay_actual) {
case "all":
$graph->ygrid->Show(true, true);
break;
case "major":
$graph->ygrid->Show(true, false);
break;
case "minor":
$graph->ygrid->Show(false, true);
break;
case "none":
default:
$graph->ygrid->Show(false, false);
break;
}
$graph->title->SetFont($fontfamilies[$this->titlefont_actual], $fontstyles[$this->titlefontstyle_actual], $this->titlefontsize_actual);
$graph->title->SetColor($this->titlecolor_actual);
$graph->xaxis->SetFont($fontfamilies[$this->xaxisfont_actual], $fontstyles[$this->xaxisfontstyle_actual], $this->xaxisfontsize_actual);
$graph->xaxis->SetColor($this->xaxiscolor_actual, $this->xaxisfontcolor_actual);
$graph->yaxis->SetFont($fontfamilies[$this->yaxisfont_actual], $fontstyles[$this->yaxisfontstyle_actual], $this->yaxisfontsize_actual);
$graph->yaxis->SetColor($this->yaxiscolor_actual, $this->yaxisfontcolor_actual);
$graph->xaxis->title->SetFont($fontfamilies[$this->xtitlefont_actual], $fontstyles[$this->xtitlefontstyle_actual], $this->xtitlefontsize_actual);
$graph->xaxis->title->SetColor($this->xtitlecolor_actual);
$graph->yaxis->title->SetFont($fontfamilies[$this->ytitlefont_actual], $fontstyles[$this->ytitlefontstyle_actual], $this->ytitlefontsize_actual);
$graph->yaxis->title->SetColor($this->ytitlecolor_actual);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetLabelMargin(5);
$graph->yaxis->SetLabelMargin(5);
$graph->xaxis->SetTickLabels($this->xlabels);
$graph->xaxis->SetTextLabelInterval($this->xticklabelinterval_actual);
$graph->yaxis->SetTextLabelInterval($this->yticklabelinterval_actual);
$graph->xaxis->SetTextTickInterval($this->xtickinterval_actual);
$graph->yaxis->SetTextTickInterval($this->ytickinterval_actual);
$graph->SetFrame(true, 'darkblue', 2);
$graph->SetFrameBevel(2, true, 'black');
if ($this->gridpos_actual == "front") {
$graph->SetGridDepth(DEPTH_FRONT);
}
// Display the graph
$handle = $graph->Stroke(_IMG_HANDLER);
return $handle;
}
示例10: top
//.........这里部分代码省略.........
$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;
}
示例11: BarPlot
*/
// Setup font for axis
$graph->xaxis->SetFont(FF_FONT1, FS_NORMAL, 8);
$graph->yaxis->SetFont(FF_FONT1, FS_NORMAL, 11);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
if ($gorientation == "v") {
$graph->img->SetAngle(90);
$graph->Set90AndMargin(120, 40, 40, 40);
} else {
$graph->xaxis->SetLabelAngle(90);
}
//Setup Frame
$graph->SetFrame(true, "#fafafa");
//$graph->SetFrame(false);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.6);
// Setup color for gradient fill style
$bplot->SetFillColor($color . "@0.3");
//$bplot->SetShadow($color."@0.7",5,5);
// Set color for the frame of each bar
$bplot->SetColor($color . "@1");
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
unset($graph);
$geoloc->close();
?>
示例12: run
//.........这里部分代码省略.........
$endtitle .= $endyear;
}
$title = $starttitle . ' - ' . $endtitle . ' in ' . $parameters['interval'] . "s.";
$disp = true;
$correct = 0;
if ($parameters['interval'] == 'week') {
$correct = 86400;
}
for ($start = $parameters['start']; $start < $parameters['end']; $start += $steps[$parameters['interval']]) {
if ($parameters['interval'] == 'month') {
$steps['month'] = $steps['day'] * date('t', $_start);
}
$end = $start + $steps[$parameters['interval']] - 1;
if ($start <= $timestamp) {
$apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start + $correct, 'end' => $end + $correct, 'constraints' => $parameters['constraints'], 'interval' => '');
for ($j = 0; $j < count($parameters["what"]); $j++) {
$y[$j][] = phpOpenTracker::get(array_merge(array('api_call' => $parameters["what"][$j]), $apiCallParameters));
}
} else {
for ($j = 0; $j < count($parameters["what"]); $j++) {
$y[$j][] = 0;
}
}
switch ($parameters['interval']) {
case 'hour':
$x_label[] = date('H', mktime($hour, 0, 0, $startmonth, $startday, $startyear)) . ':00';
$disp = !$disp;
$hour++;
break;
case 'week':
$x_label[] = date('W', mktime(0, 0, 0, 1, ($week - 2) * 7, $startyear));
$week++;
break;
case 'day':
$x_label[] = date('d', mktime(0, 0, 0, $startmonth, $day, $startyear));
$day++;
break;
case 'month':
$x_label[] = date('m', mktime(0, 0, 0, $month, 1, $startyear));
$month++;
break;
case 'year':
$x_label[] = date('Y', mktime(0, 0, 0, 1, 1, $year));
$year++;
break;
}
}
if ($y == null) {
$apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start, 'end' => $end, 'constraints' => $parameters['constraints']);
for ($j = 0; $j < count($parameters["what"]); $j++) {
$y[$j][] = phpOpenTracker::get(array_merge(array('api_call' => $parameters["what"][$j]), $apiCallParameters));
}
$x_label[] = '';
$title = "Total";
}
if ($parameters['interval'] == 'hour') {
$angle = 50;
} else {
$angle = 0;
}
$x_label = $this->clearLabels($x_label, $parameters);
$graph = new Graph($parameters['width'], $parameters['height'], 'auto');
$graph->img->SetMargin(40, 10, 20, 10);
$graph->SetScale('textlin');
$graph->SetMarginColor('white');
$graph->SetFrame(0);
$graph->xgrid->Show();
for ($j = 0; $j < count($parameters["what"]); $j++) {
$plot[$j] = new BarPlot($y[$j]);
$plot[$j]->SetFillColor($parameters["whatcolors"][$j]);
$plot[$j]->SetShadow();
$plot[$j]->SetWeight(0);
}
$gbarplot = new GroupBarPlot($plot);
$gbarplot->SetWidth(0.6);
$graph->add($gbarplot);
$graph->xaxis->SetTickLabels($x_label);
if ($c["usettf"]) {
$graph->xaxis->SetLabelAngle($angle);
}
if ($c["usettf"]) {
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
if ($c["usettf"]) {
$graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->yaxis->SetColor('black');
if ($c["usettf"]) {
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
if ($c["usettf"]) {
$graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->title->Set($title);
if ($c["usettf"]) {
$graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
}
$graph->img->SetAntiAliasing("white");
$graph->Stroke();
}
示例13: array
<?php
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_bar.php';
$data1y = array(47, 80, 40, 116);
$graph = new Graph(400, 300, 'auto');
$graph->SetScale('textlin');
$theme_class = new AquaTheme();
$graph->SetTheme($theme_class);
// after setting theme, you can change details as you want
$graph->SetFrame(true, 'lightgray');
// set frame visible
$graph->xaxis->SetTickLabels(array('A', 'B', 'C', 'D'));
// change xaxis lagels
$graph->title->Set("Theme Example");
// add title
// add barplot
$bplot = new BarPlot($data1y);
$graph->Add($bplot);
// you can change properties of the plot only after calling Add()
$bplot->SetWeight(0);
$bplot->SetFillGradient('#FFAAAA:0.7', '#FFAAAA:1.2', GRAD_VER);
$graph->Stroke();
示例14: lineGraph_1
public static function lineGraph_1($level_data, $level_name, $title, $project_id)
{
require_once '../app/classes/jpgraph/jpgraph.php';
require_once '../app/classes/jpgraph/jpgraph_line.php';
// Setup the graph
$graph = new Graph(1500, 500);
$graph->SetMarginColor('white');
$graph->SetScale("textlin");
$graph->SetFrame(false);
$graph->SetMargin(30, 50, 30, 30);
$graph->title->Set($title);
$graph->title->SetFont(FF_CHINESE, FS_NORMAL, 11);
$graph->yaxis->HideZeroLabel();
$graph->ygrid->SetFill(true, '#EFEFEF@0.5', '#BBCCFF@0.5');
$graph->xgrid->Show();
$graph->xaxis->SetTickLabels(array_keys($level_data[0]));
$i = 0;
foreach ($level_data as $data) {
$p1 = new LinePlot(array_values($data));
$p1->SetLegend($level_name[$i++]);
$graph->Add($p1);
}
$graph->legend->SetShadow('gray@0.4', 5);
$graph->legend->SetPos(0.1, 0.1, 'right', 'top');
// Output line
$date = date('H_i_s');
$stamp = rand(100, 900);
$fileName = './tmp/' . $project_id . $date . '_' . $stamp . '.jpeg';
$graph->Stroke($fileName);
return $fileName;
}
示例15: graph_cumulative_bydate
function graph_cumulative_bydate($p_metrics, $p_graph_width = 300, $p_graph_height = 380)
{
$t_graph_font = graph_get_font();
error_check(is_array($p_metrics) ? count($p_metrics) : 0, lang_get('cumulative') . ' ' . lang_get('by_date'));
foreach ($p_metrics as $i => $vals) {
if ($i > 0) {
$plot_date[] = $i;
$reported_plot[] = $p_metrics[$i][0];
$resolved_plot[] = $p_metrics[$i][1];
$still_open_plot[] = $p_metrics[$i][2];
}
}
$graph = new Graph($p_graph_width, $p_graph_height);
$graph->img->SetMargin(40, 40, 40, 170);
$graph->img->SetAntiAliasing();
$graph->SetScale('linlin');
$graph->SetMarginColor('white');
$graph->SetFrame(false);
$graph->title->Set(lang_get('cumulative') . ' ' . lang_get('by_date'));
$graph->title->SetFont($t_graph_font, FS_BOLD);
$graph->legend->Pos(0.05, 0.9, 'right', 'bottom');
$graph->legend->SetShadow(false);
$graph->legend->SetFillColor('white');
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->SetFont($t_graph_font);
$graph->yaxis->scale->ticks->SetDirection(-1);
$graph->yaxis->SetFont($t_graph_font);
if (FF_FONT2 <= $t_graph_font) {
$graph->xaxis->SetLabelAngle(60);
} else {
$graph->xaxis->SetLabelAngle(90);
# can't rotate non truetype fonts
}
$graph->xaxis->SetLabelFormatCallback('graph_date_format');
$graph->xaxis->SetFont($t_graph_font);
$p1 = new LinePlot($reported_plot, $plot_date);
$p1->SetColor('blue');
$p1->SetCenter();
$p1->SetLegend(lang_get('legend_reported'));
$graph->Add($p1);
$p3 = new LinePlot($still_open_plot, $plot_date);
$p3->SetColor('red');
$p3->SetCenter();
$p3->SetLegend(lang_get('legend_still_open'));
$graph->Add($p3);
$p2 = new LinePlot($resolved_plot, $plot_date);
$p2->SetColor('black');
$p2->SetCenter();
$p2->SetLegend(lang_get('legend_resolved'));
$graph->Add($p2);
if (ON == config_get('show_queries_count')) {
$graph->subtitle->Set(db_count_queries() . ' queries (' . db_count_unique_queries() . ' unique) (' . db_time_queries() . 'sec)');
$graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8);
}
$graph->Stroke();
}