Source
<?php declare(strict_types = 0);
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
namespace Widgets\SvgGraph\Includes;
use CDiv,
CSpan;
class CSvgGraphLegend extends CDiv {
// Legend single line height is 18px. Value should be synchronized with $svg-legend-line-height in scss.
private const LINE_HEIGHT = 18;
private const ZBX_STYLE_CLASS = 'svg-graph-legend';
private const ZBX_STYLE_GRAPH_LEGEND_STATISTIC = 'svg-graph-legend-statistic';
private const ZBX_STYLE_GRAPH_LEGEND_HEADER = 'svg-graph-legend-header';
private const ZBX_STYLE_GRAPH_LEGEND_ITEM = 'svg-graph-legend-item';
private const ZBX_STYLE_GRAPH_LEGEND_NO_DATA = 'svg-graph-legend-no-data';
private const ZBX_STYLE_GRAPH_LEGEND_VALUE = 'svg-graph-legend-value';
private array $legend_items;
private int $columns_count = 0;
private int $lines_count = 0;
private int $lines_mode = 0;
private bool $show_statistic = false;
/**
* @param array $legend_items
* @param string $legend_items[]['name']
* @param string $legend_items[]['color']
* @param string $legend_items[]['units']
* @param string $legend_items[]['min']
* @param string $legend_items[]['avg']
* @param string $legend_items[]['max']
*/
public function __construct(array $legend_items) {
parent::__construct();
$this->legend_items = $legend_items;
}
public function setColumnsCount(int $columns_count): self {
$this->columns_count = $columns_count;
return $this;
}
private function getLinesCount(): int {
if ($this->lines_mode == WidgetForm::LEGEND_LINES_MODE_FIXED) {