Source
xxxxxxxxxx
$text_tag_x = (strlen($label) * 4 > $this->width - $x) ? $this->x + $x - 10 : $this->x + $x;
<?php declare(strict_types = 0);
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/**
* SVG graphs axis class.
*/
class CSvgGraphAxis extends CSvgGroup {
private const ZBX_STYLE_CLASS = 'svg-graph-axis';
private const ZBX_STYLE_GRAPH_AXIS_LEFT = 'svg-graph-axis-left';
private const ZBX_STYLE_GRAPH_AXIS_RIGHT = 'svg-graph-axis-right';
private const ZBX_STYLE_GRAPH_AXIS_BOTTOM = 'svg-graph-axis-bottom';
/**
* Axis triangle icon size.
*
* @var int
*/
private const ZBX_ARROW_SIZE = 5;
private const ZBX_ARROW_OFFSET = 5;
/**
* Array of labels. Key is coordinate, value is text label.
*
* @var array
*/
private $labels;
/**
* Axis type. One of CSvgGraphAxis::AXIS_* constants.
*
* @var int
*/
private $type;
/**
* Color for labels.
*
* @var string
*/
private $text_color;
/**
* Color for axis.
*
* @var string
*/
private $line_color;
public function __construct(array $labels, int $type) {
parent::__construct();
$this->labels = $labels;
$this->type = $type;
}
public function setTextColor(string $color): self {
$this->text_color = $color;
return $this;
}
public function setLineColor(string $color): self {
$this->line_color = $color;
return $this;
}
/**
* Return CSS style definitions for axis as array.
*