本文整理汇总了PHP中set_image_header函数的典型用法代码示例。如果您正苦于以下问题:PHP set_image_header函数的具体用法?PHP set_image_header怎么用?PHP set_image_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_image_header函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: basename
$page['file'] = basename($_SERVER['PHP_SELF']);
}
if ($_REQUEST['fullscreen'] = get_request('fullscreen', 0)) {
define('ZBX_PAGE_NO_MENU', 1);
}
include_once 'include/locales/en_gb.inc.php';
process_locales();
set_zbx_locales();
require_once 'include/menu.inc.php';
zbx_define_menu_restrictions();
/* Init CURRENT NODE ID */
init_nodes();
/* switch($page["type"]) */
switch ($page['type']) {
case PAGE_TYPE_IMAGE:
set_image_header();
define('ZBX_PAGE_NO_MENU', 1);
break;
case PAGE_TYPE_XML:
header('Content-Type: text/xml');
header('Content-Disposition: attachment; filename="' . $page['file'] . '"');
if (!defined('ZBX_PAGE_NO_MENU')) {
define('ZBX_PAGE_NO_MENU', 1);
}
break;
case PAGE_TYPE_JS:
header('Content-Type: application/javascript; charset=UTF-8');
if (!defined('ZBX_PAGE_NO_MENU')) {
define('ZBX_PAGE_NO_MENU', 1);
}
break;
开发者ID:phedders,项目名称:zabbix,代码行数:31,代码来源:page_header.php
示例2: draw
public function draw()
{
$start_time = microtime(true);
set_image_header();
$this->selectData();
$this->shiftY = 30;
$this->shiftYLegend = 20;
$this->shiftXleft = 10;
$this->shiftXright = 0;
$this->fullSizeX = $this->sizeX;
$this->fullSizeY = $this->sizeY;
if ($this->sizeX < 300 || $this->sizeY < 200) {
$this->showLegend(0);
}
if ($this->drawLegend == 1) {
$this->sizeX -= $this->shiftXleft + $this->shiftXright + $this->shiftlegendright;
$this->sizeY -= $this->shiftY + $this->shiftYLegend + 12 * $this->num + 8;
} else {
$this->sizeX -= $this->shiftXleft * 2;
$this->sizeY -= $this->shiftY * 2;
}
$this->sizeX = min($this->sizeX, $this->sizeY);
$this->sizeY = min($this->sizeX, $this->sizeY);
$this->calc3dheight($this->sizeY);
$this->exploderad = (int) $this->sizeX / 100;
$this->exploderad3d = (int) $this->sizeX / 60;
if (function_exists('ImageColorExactAlpha') && function_exists('ImageCreateTrueColor') && @imagecreatetruecolor(1, 1)) {
$this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY);
} else {
$this->im = imagecreate($this->fullSizeX, $this->fullSizeY);
}
$this->initColors();
$this->drawRectangle();
$this->drawHeader();
// for each metric
for ($item = 0; $item < $this->num; $item++) {
$data =& $this->data[$this->items[$item]['itemid']][$this->items[$item]['calc_type']];
if (!isset($data)) {
continue;
}
$calc_fnc = $this->items[$item]['calc_fnc'];
switch ($calc_fnc) {
case CALC_FNC_MAX:
$values[$item] = abs($data->max);
break;
case CALC_FNC_MIN:
$values[$item] = abs($data->min);
break;
case CALC_FNC_AVG:
$values[$item] = abs($data->avg);
break;
case CALC_FNC_LST:
$values[$item] = abs($data->lst);
break;
}
}
switch ($this->type) {
case GRAPH_TYPE_EXPLODED:
$this->drawElementPie($values);
break;
case GRAPH_TYPE_3D:
$this->drawElementPie3D($values);
break;
case GRAPH_TYPE_3D_EXPLODED:
$this->drawElementPie3D($values);
break;
default:
$this->drawElementPie($values);
break;
}
$this->drawLogo();
if ($this->drawLegend == 1) {
$this->drawLegend();
}
$str = sprintf('%0.2f', microtime(true) - $start_time);
$str = _s('Data from %1$s. Generated in %2$s sec.', $this->dataFrom, $str);
$strSize = imageTextSize(6, 0, $str);
imageText($this->im, 6, 0, $this->fullSizeX - $strSize['width'] - 5, $this->fullSizeY - 5, $this->getColor('Gray'), $str);
unset($this->items, $this->data);
imageOut($this->im);
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:81,代码来源:class.cpie.php
示例3: draw
public function draw()
{
$start_time = getmicrotime();
set_image_header();
check_authorisation();
$this->selectData();
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_LEFT);
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_RIGHT);
$this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_LEFT);
$this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_RIGHT);
//*
if ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] == $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT]) {
if ($this->graphOrientation[GRAPH_YAXIS_SIDE_LEFT] == '-') {
$this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = 0;
} else {
if ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] == 0) {
$this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = 1;
} else {
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0;
}
}
} else {
if ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] > $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT]) {
if ($this->graphOrientation[GRAPH_YAXIS_SIDE_LEFT] == '-') {
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0.2 * $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT];
} else {
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0;
}
}
}
if ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] == $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT]) {
if ($this->graphOrientation[GRAPH_YAXIS_SIDE_RIGHT] == '-') {
$this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = 0;
} else {
if ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] == 0) {
$this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = 1;
// $this->skipRightScale = 1;
} else {
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0;
}
}
} else {
if ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] > $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT]) {
if ($this->graphOrientation[GRAPH_YAXIS_SIDE_RIGHT] == '-') {
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0.2 * $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT];
} else {
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0;
}
}
}
//*/
$this->calcMinMaxInterval();
$this->updateShifts();
$this->calcTriggers();
$this->calcZero();
$this->calcPercentile();
$this->fullSizeX = $this->sizeX + $this->shiftXleft + $this->shiftXright + 1;
$this->fullSizeY = $this->sizeY + $this->shiftY + $this->legendOffsetY;
if ($this->drawLegend) {
$trCount = $this->m_showTriggers ? count($this->triggers) : 0;
$this->fullSizeY += 14 * ($this->num + 1 + ($this->sizeY < 120 ? 0 : count($this->triggers))) + 8;
}
//if graph height is big enough, we reserve space for percent line legend
if ($this->sizeY >= ZBX_GRAPH_LEGEND_HEIGHT) {
foreach ($this->percentile as $percentile) {
if ($percentile['percent'] > 0 && $percentile['value']) {
$this->fullSizeY += 14;
}
}
}
if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) {
$this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY);
} else {
$this->im = imagecreate($this->fullSizeX, $this->fullSizeY);
}
$this->initColors();
$this->drawRectangle();
$this->drawHeader();
$this->drawWorkPeriod();
//*/ grid
$this->drawTimeGrid();
$this->drawVerticalGrid();
$this->drawXYAxisScale($this->graphtheme['gridbordercolor']);
//-----*/
$maxX = $this->sizeX;
// For each metric
for ($item = 0; $item < $this->num; $item++) {
$minY = $this->m_minY[$this->items[$item]['axisside']];
$maxY = $this->m_maxY[$this->items[$item]['axisside']];
$data =& $this->data[$this->items[$item]['itemid']][$this->items[$item]['calc_type']];
if (!isset($data)) {
continue;
}
if ($this->items[$item]['calc_type'] == GRAPH_ITEM_AGGREGATED) {
$drawtype = GRAPH_ITEM_DRAWTYPE_LINE;
$max_color = $this->getColor('HistoryMax');
$avg_color = $this->getColor('HistoryAvg');
$min_color = $this->getColor('HistoryMin');
$minmax_color = $this->getColor('HistoryMinMax');
$calc_fnc = CALC_FNC_ALL;
//.........这里部分代码省略.........
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:class.cchart.php
示例4: draw
public function draw()
{
$start_time = microtime(true);
set_image_header();
$this->selectData();
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_LEFT);
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_RIGHT);
$this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_LEFT);
$this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_RIGHT);
if ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] == $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT]) {
if ($this->graphOrientation[GRAPH_YAXIS_SIDE_LEFT] == '-') {
$this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = 0;
} elseif ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] == 0) {
$this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = 1;
} else {
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0;
}
} elseif ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] > $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT]) {
if ($this->graphOrientation[GRAPH_YAXIS_SIDE_LEFT] == '-') {
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0.2 * $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT];
} else {
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0;
}
}
if ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] == $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT]) {
if ($this->graphOrientation[GRAPH_YAXIS_SIDE_RIGHT] == '-') {
$this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = 0;
} elseif ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] == 0) {
$this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = 1;
} else {
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0;
}
} elseif ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] > $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT]) {
if ($this->graphOrientation[GRAPH_YAXIS_SIDE_RIGHT] == '-') {
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0.2 * $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT];
} else {
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0;
}
}
$this->calcMinMaxInterval();
$this->updateShifts();
$this->calcTriggers();
$this->calcZero();
$this->calcPercentile();
$this->fullSizeX = $this->sizeX + $this->shiftXleft + $this->shiftXright + 1;
$this->fullSizeY = $this->sizeY + $this->shiftY + $this->legendOffsetY - 40;
//减去日期所占用的距离35
if ($this->drawLegend) {
$this->fullSizeY += 14 * ($this->num + 1 + ($this->sizeY < 120 ? 0 : count($this->triggers))) + 8;
}
// if graph height is big enough, we reserve space for percent line legend
if ($this->sizeY >= ZBX_GRAPH_LEGEND_HEIGHT) {
foreach ($this->percentile as $percentile) {
if ($percentile['percent'] > 0 && $percentile['value']) {
$this->fullSizeY += 14;
}
}
}
if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) {
$this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY);
} else {
$this->im = imagecreate($this->fullSizeX, $this->fullSizeY);
}
$this->initColors();
$this->drawRectangle();
$this->drawHeader();
$this->drawWorkPeriod();
$this->drawTimeGrid();
$this->drawVerticalGrid();
$this->drawXYAxisScale($this->graphtheme['gridbordercolor']);
$maxX = $this->sizeX;
// for each metric
for ($item = 0; $item < $this->num; $item++) {
$minY = $this->m_minY[$this->items[$item]['axisside']];
$maxY = $this->m_maxY[$this->items[$item]['axisside']];
$data =& $this->data[$this->items[$item]['itemid']][$this->items[$item]['calc_type']];
if (!isset($data)) {
continue;
}
if ($this->type == GRAPH_TYPE_STACKED) {
$drawtype = $this->items[$item]['drawtype'];
$max_color = $this->getColor('ValueMax', GRAPH_STACKED_ALFA);
$avg_color = $this->getColor($this->items[$item]['color'], GRAPH_STACKED_ALFA);
$min_color = $this->getColor('ValueMin', GRAPH_STACKED_ALFA);
$minmax_color = $this->getColor('ValueMinMax', GRAPH_STACKED_ALFA);
$calc_fnc = $this->items[$item]['calc_fnc'];
} else {
$drawtype = $this->items[$item]['drawtype'];
$max_color = $this->getColor('ValueMax', GRAPH_STACKED_ALFA);
$avg_color = $this->getColor($this->items[$item]['color'], GRAPH_STACKED_ALFA);
$min_color = $this->getColor('ValueMin', GRAPH_STACKED_ALFA);
$minmax_color = $this->getColor('ValueMinMax', GRAPH_STACKED_ALFA);
$calc_fnc = $this->items[$item]['calc_fnc'];
}
// for each X
$draw = true;
$prevDraw = true;
for ($i = 1, $j = 0; $i < $maxX; $i++) {
// new point
if ($data['count'][$i] == 0 && $i != $maxX - 1) {
//.........这里部分代码省略.........
开发者ID:kai-cn,项目名称:zatree,代码行数:101,代码来源:class.cchart_zabbix.php
示例5: draw
public function draw()
{
$start_time = microtime(true);
set_image_header();
$this->column = uint_in_array($this->type, array(GRAPH_TYPE_COLUMN, GRAPH_TYPE_COLUMN_STACKED));
$this->fullSizeX = $this->sizeX;
$this->fullSizeY = $this->sizeY;
if ($this->sizeX < 300 || $this->sizeY < 200) {
$this->showLegend(0);
}
$this->calcShifts();
$this->sizeX -= $this->shiftXleft + $this->shiftXright + $this->shiftlegendright + $this->shiftXCaptionLeft + $this->shiftXCaptionRight;
$this->sizeY -= $this->shiftY + $this->shiftYLegend + $this->shiftYCaptionBottom + $this->shiftYCaptionTop;
$this->calcSeriesWidth();
$this->calcMiniMax();
$this->correctMiniMax();
if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) {
$this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY);
} else {
$this->im = imagecreate($this->fullSizeX, $this->fullSizeY);
}
$this->initColors();
$this->drawRectangle();
$this->drawHeader();
$this->drawGrid();
$this->drawSideValues();
$this->drawLogo();
$this->drawLegend();
$count = 0;
if ($this->column) {
$start = $this->shiftXleft + $this->shiftXCaptionLeft + floor($this->seriesDistance / 2);
} else {
$start = $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - floor($this->seriesDistance / 2);
}
foreach ($this->series as $key => $series) {
foreach ($series as $num => $serie) {
$axis = $serie['axis'];
$value = $serie['value'];
$color = $this->getColor($this->seriesColor[$num], $this->opacity);
if ($this->column) {
imagefilledrectangle($this->im, $start, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - round($this->sizeY / $this->maxValue[$axis] * $value), $start + $this->columnWidth, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop, $color);
imagerectangle($this->im, $start, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - round($this->sizeY / $this->maxValue[$axis] * $value), $start + $this->columnWidth, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop, $this->getColor('Black No Alpha'));
} else {
imagefilledrectangle($this->im, $this->shiftXleft + $this->shiftXCaptionLeft, $start - $this->columnWidth, $this->shiftXleft + $this->shiftXCaptionLeft + round($this->sizeX / $this->maxValue[$axis] * $value), $start, $color);
imagerectangle($this->im, $this->shiftXleft + $this->shiftXCaptionLeft, $start - $this->columnWidth, $this->shiftXleft + $this->shiftXCaptionLeft + round($this->sizeX / $this->maxValue[$axis] * $value), $start, $this->getColor('Black No Alpha'));
}
$start = $this->column ? $start + $this->columnWidth : $start - $this->columnWidth;
}
$count++;
if ($this->column) {
$start = $count * ($this->seriesWidth + $this->seriesDistance) + $this->shiftXleft + $this->shiftXCaptionLeft + floor($this->seriesDistance / 2);
} else {
$start = $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - $count * ($this->seriesWidth + $this->seriesDistance) - floor($this->seriesDistance / 2);
}
}
$str = sprintf('%0.2f', microtime(true) - $start_time);
$str = _s('Generated in %s sec', $str);
$strSize = imageTextSize(6, 0, $str);
imageText($this->im, 6, 0, $this->fullSizeX - $strSize['width'] - 5, $this->fullSizeY - 5, $this->getColor('Gray'), $str);
unset($this->items, $this->data);
imageOut($this->im);
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:62,代码来源:CBarGraphDraw.php
示例6: draw
public function draw()
{
$start_time = getmicrotime();
set_image_header();
check_authorisation();
$this->selectData();
$this->shiftY = 20;
$this->shiftYLegend = 20;
$this->shiftXleft = 10;
$this->shiftXright = 0;
$this->fullSizeX = $this->sizeX;
$this->fullSizeY = $this->sizeY;
if ($this->sizeX < 300 || $this->sizeY < 200) {
$this->switchlegend(0);
}
if ($this->drawlegendallow == 1) {
$this->sizeX -= $this->shiftXleft + $this->shiftXright + $this->shiftlegendright;
$this->sizeY -= $this->shiftY + $this->shiftYLegend + 12 * $this->num + 8;
} else {
$this->sizeX -= $this->shiftXleft * 2;
$this->sizeY -= $this->shiftY * 2;
}
// SDI($this->sizeX.','.$this->sizeY);
$this->sizeX = min($this->sizeX, $this->sizeY);
$this->sizeY = min($this->sizeX, $this->sizeY);
$this->calc3dhight($this->sizeY);
$this->exploderad = (int) $this->sizeX / 100;
$this->exploderad3d = (int) $this->sizeX / 60;
if (function_exists('ImageColorExactAlpha') && function_exists('ImageCreateTrueColor') && @imagecreatetruecolor(1, 1)) {
$this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY);
} else {
$this->im = imagecreate($this->fullSizeX, $this->fullSizeY);
}
$this->initColors();
$this->drawRectangle();
$this->drawHeader();
$maxX = $this->sizeX;
// For each metric
for ($item = 0; $item < $this->num; $item++) {
$minY = $this->m_minY[$this->items[$item]['axisside']];
$maxY = $this->m_maxY[$this->items[$item]['axisside']];
$data =& $this->data[$this->items[$item]['itemid']][$this->items[$item]['calc_type']];
if (!isset($data)) {
continue;
}
$drawtype = $this->items[$item]['drawtype'];
$max_color = $this->GetColor('ValueMax');
$avg_color = $this->GetColor($this->items[$item]['color']);
$min_color = $this->GetColor('ValueMin');
$minmax_color = $this->GetColor('ValueMinMax');
$calc_fnc = $this->items[$item]['calc_fnc'];
switch ($calc_fnc) {
case CALC_FNC_MAX:
$values[$item] = abs($data->max);
break;
case CALC_FNC_MIN:
$values[$item] = abs($data->min);
break;
case CALC_FNC_AVG:
$values[$item] = abs($data->avg);
break;
case CALC_FNC_LST:
$values[$item] = abs($data->lst);
break;
}
}
switch ($this->type) {
case GRAPH_TYPE_EXPLODED:
$this->drawElementPie($values);
break;
case GRAPH_TYPE_3D:
$this->drawElementPie3D($values);
break;
case GRAPH_TYPE_3D_EXPLODED:
$this->drawElementPie3D($values);
break;
default:
$this->drawElementPie($values);
break;
}
$this->drawLogo();
if ($this->drawlegendallow == 1) {
$this->drawLegend();
}
$end_time = getmicrotime();
$str = sprintf("%0.2f", getmicrotime() - $start_time);
ImageString($this->im, 0, $this->fullSizeX - 120, $this->fullSizeY - 12, "Generated in {$str} sec", $this->GetColor('Gray'));
unset($this->items, $this->data);
ImageOut($this->im);
}
开发者ID:rennhak,项目名称:zabbix,代码行数:90,代码来源:class.cpie.php
示例7: draw
public function draw()
{
$start_time = microtime(true);
set_image_header();
$this->selectData();
if (isset($this->axis_valuetype[GRAPH_YAXIS_SIDE_RIGHT])) {
$sides[] = GRAPH_YAXIS_SIDE_RIGHT;
}
if (isset($this->axis_valuetype[GRAPH_YAXIS_SIDE_LEFT]) || !isset($sides)) {
$sides[] = GRAPH_YAXIS_SIDE_LEFT;
}
foreach ($sides as $graphSide) {
$this->m_minY[$graphSide] = $this->calculateMinY($graphSide);
$this->m_maxY[$graphSide] = $this->calculateMaxY($graphSide);
if ($this->m_minY[$graphSide] === null) {
$this->m_minY[$graphSide] = 0;
}
if ($this->m_maxY[$graphSide] === null) {
$this->m_maxY[$graphSide] = 1;
}
if ($this->m_minY[$graphSide] == $this->m_maxY[$graphSide]) {
if ($this->graphOrientation[$graphSide] == '-') {
$this->m_maxY[$graphSide] = 0;
} elseif ($this->m_minY[$graphSide] == 0) {
$this->m_maxY[$graphSide] = 1;
} else {
$this->m_minY[$graphSide] = 0;
}
} elseif ($this->m_minY[$graphSide] > $this->m_maxY[$graphSide]) {
if ($this->graphOrientation[$graphSide] == '-') {
$this->m_minY[$graphSide] = bcmul($this->m_maxY[$graphSide], 0.2);
} else {
$this->m_minY[$graphSide] = 0;
}
}
// If max Y-scale bigger min Y-scale only for 10% or less, then we don't allow Y-scale duplicate
if ($this->m_maxY[$graphSide] && $this->m_minY[$graphSide]) {
if ($this->m_minY[$graphSide] < 0) {
$absMinY = bcmul($this->m_minY[$graphSide], '-1');
} else {
$absMinY = $this->m_minY[$graphSide];
}
if ($this->m_maxY[$graphSide] < 0) {
$absMaxY = bcmul($this->m_maxY[$graphSide], '-1');
} else {
$absMaxY = $this->m_maxY[$graphSide];
}
if ($absMaxY < $absMinY) {
$oldAbMaxY = $absMaxY;
$absMaxY = $absMinY;
$absMinY = $oldAbMaxY;
}
if (bcdiv(bcsub($absMaxY, $absMinY), $absMaxY) <= 0.1) {
if ($this->m_minY[$graphSide] > 0) {
$this->m_minY[$graphSide] = bcmul($this->m_minY[$graphSide], 0.95);
} else {
$this->m_minY[$graphSide] = bcmul($this->m_minY[$graphSide], 1.05);
}
if ($this->m_maxY[$graphSide] > 0) {
$this->m_maxY[$graphSide] = bcmul($this->m_maxY[$graphSide], 1.05);
} else {
$this->m_maxY[$graphSide] = bcmul($this->m_maxY[$graphSide], 0.95);
}
}
}
}
$this->calcMinMaxInterval();
$this->updateShifts();
$this->calcTriggers();
$this->calcZero();
$this->calcPercentile();
$this->fullSizeX = $this->sizeX + $this->shiftXleft + $this->shiftXright + 1;
$this->fullSizeY = $this->sizeY + $this->shiftY + $this->legendOffsetY;
if ($this->drawLegend) {
$this->fullSizeY += 14 * ($this->num + 1 + ($this->sizeY < 120 ? 0 : count($this->triggers))) + 8;
}
// if graph height is big enough, we reserve space for percent line legend
if ($this->sizeY >= ZBX_GRAPH_LEGEND_HEIGHT) {
foreach ($this->percentile as $percentile) {
if ($percentile['percent'] > 0 && $percentile['value']) {
$this->fullSizeY += 14;
}
}
}
if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) {
$this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY);
} else {
$this->im = imagecreate($this->fullSizeX, $this->fullSizeY);
}
$this->initColors();
$this->drawRectangle();
$this->drawHeader();
$this->drawWorkPeriod();
$this->drawTimeGrid();
$this->drawHorizontalGrid();
$this->drawXYAxisScale();
$maxX = $this->sizeX;
// for each metric
for ($item = 0; $item < $this->num; $item++) {
$minY = $this->m_minY[$this->items[$item]['axisside']];
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CLineGraphDraw.php
示例8: draw
public function draw()
{
$start_time = getmicrotime();
set_image_header();
check_authorisation();
$this->selectData();
$this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_LEFT);
$this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_RIGHT);
$this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_LEFT);
$this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_RIGHT);
$this->correctMinMax();
$this->updateShifts();
$this->calcTriggers();
$this->calcZero();
$this->calcPercentile();
$this->fullSizeX = $this->sizeX + $this->shiftXleft + $this->shiftXright + 1;
$this->fullSizeY = $this->sizeY + $this->shiftY + 62;
$this->fullSizeY += 12 * ($this->num + ($this->sizeY < 120 ? 0 : count($this->triggers))) + 8;
foreach ($this->percentile as $side => $percentile) {
if ($percentile['percent'] > 0 && $percentile['value']) {
$this->fullSizeY += 12;
}
}
if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) {
$this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY);
} else {
$this->im = imagecreate($this->fullSizeX, $this->fullSizeY);
}
$this->initColors();
$this->drawRectangle();
$this->drawHeader();
if ($this->num == 0) {
// $this->noDataFound();
}
$this->drawWorkPeriod();
$this->drawGrid();
$maxX = $this->sizeX;
// For each metric
for ($item = 0; $item < $this->num; $item++) {
$minY = $this->m_minY[$this->items[$item]['axisside']];
$maxY = $this->m_maxY[$this->items[$item]['axisside']];
$data =& $this->data[$this->items[$item]['itemid']][$this->items[$item]['calc_type']];
if (!isset($data)) {
continue;
}
if ($this->items[$item]['calc_type'] == GRAPH_ITEM_AGGREGATED) {
$drawtype = GRAPH_ITEM_DRAWTYPE_LINE;
$max_color = $this->getColor('HistoryMax');
$avg_color = $this->getColor('HistoryAvg');
$min_color = $this->getColor('HistoryMin');
$minmax_color = $this->getColor('HistoryMinMax');
$calc_fnc = CALC_FNC_ALL;
} else {
if ($this->type == GRAPH_TYPE_STACKED) {
$drawtype = $this->items[$item]['drawtype'];
$max_color = $this->getColor('ValueMax', GRAPH_STACKED_ALFA);
$avg_color = $this->getColor($this->items[$item]['color'], GRAPH_STACKED_ALFA);
$min_color = $this->getColor('ValueMin', GRAPH_STACKED_ALFA);
$minmax_color = $this->getColor('ValueMinMax', GRAPH_STACKED_ALFA);
$calc_fnc = $this->items[$item]['calc_fnc'];
} else {
$drawtype = $this->items[$item]['drawtype'];
$max_color = $this->getColor('ValueMax', GRAPH_STACKED_ALFA);
$avg_color = $this->getColor($this->items[$item]['color'], GRAPH_STACKED_ALFA);
$min_color = $this->getColor('ValueMin', GRAPH_STACKED_ALFA);
$minmax_color = $this->getColor('ValueMinMax', GRAPH_STACKED_ALFA);
$calc_fnc = $this->items[$item]['calc_fnc'];
}
}
// For each X
for ($i = 1, $j = 0; $i < $maxX; $i++) {
// new point
if ($data->count[$i] == 0 && $i != $maxX - 1) {
continue;
}
$diff = abs($data->clock[$i] - $data->clock[$j]);
$cell = ($this->to_time - $this->from_time) / $this->sizeX;
$delay = $this->items[$item]['delay'];
if ($cell > $delay) {
$draw = (bool) ($diff < ZBX_GRAPH_MAX_SKIP_CELL * $cell);
} else {
$draw = (bool) ($diff < ZBX_GRAPH_MAX_SKIP_DELAY * $delay);
}
if ($draw == false && $this->items[$item]['calc_type'] == GRAPH_ITEM_AGGREGATED) {
$draw = $i - $j < 5;
}
if ($this->items[$item]['type'] == ITEM_TYPE_TRAPPER) {
$draw = true;
}
//SDI($draw);
if ($draw) {
$this->drawElement($data, $i, $j, 0, $this->sizeX, $minY, $maxY, $drawtype, $max_color, $avg_color, $min_color, $minmax_color, $calc_fnc, $this->items[$item]['axisside']);
}
//echo '\nDraw II \n'; printf('%0.4f',(getmicrotime()-$start_time));
$j = $i;
}
}
$this->drawLeftSide();
$this->drawRightSide();
$this->drawTriggers();
//.........这里部分代码省略.........
开发者ID:phedders,项目名称:zabbix,代码行数:101,代码来源:class.cchart.php
注:本文中的set_image_header函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论