Source
'spp' => (int) ($options['time_period']['time_to'] - $options['time_period']['time_from']) / $graph->getCanvasWidth()
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 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.
**/
/**
* Class calculates graph data and makes SVG graph.
*/
class CSvgGraphHelper {
/**
* Calculate graph data and draw SVG graph based on given graph configuration.
*
* @param array $options Options for graph.
* @param array $options['data_sets'] Graph data set options.
* @param int $options['data_source'] Data source of graph.
* @param bool $options['dashboard_time'] True if dashboard time is used.
* @param array $options['time_period'] Graph time period used.
* @param array $options['left_y_axis'] Options for graph left Y axis.
* @param array $options['right_y_axis'] Options for graph right Y axis.
* @param array $options['x_axis'] Options for graph X axis.
* @param array $options['legend'] Options for graph legend.
* @param int $options['legend_lines'] Number of lines in the legend.
* @param array $options['problems'] Graph problems options.
* @param array $options['overrides'] Graph override options.
*
* @return array
*/
public static function get(array $options, $width, $height) {
$metrics = [];
$errors = [];
// Find which metrics will be shown in graph and calculate time periods and display options.
self::getMetrics($metrics, $options['data_sets']);
// Apply overrides for previously selected $metrics.
self::applyOverrides($metrics, $options['overrides']);
// Apply time periods for each $metric, based on graph/dashboard time as well as metric level timeshifts.
self::getTimePeriods($metrics, $options['time_period']);
// Find what data source (history or trends) will be used for each metric.
self::getGraphDataSource($metrics, $errors, $options['data_source'], $width);
// Load Data for each metric.
self::getMetricsData($metrics, $width);
// Load aggregated Data for each dataset.
self::getMetricsAggregatedData($metrics);
// Legend single line height is 18. Value should be synchronized with $svg-legend-line-height in 'screen.scss'.
$legend_height = ($options['legend'] == SVG_GRAPH_LEGEND_TYPE_SHORT) ? $options['legend_lines'] * 18 : 0;