mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
2011-04-13 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php include/graphs/functions_pchart.php include/graphs/fgraph.php include/functions_reporting.php include/pchart_graph.php include/fgraph.php: Change the slicebar graph made by Javi to make it more generic and to use the new pChart library. This graph has been included into the graphs abstraction too git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4201 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
794ab4ed7b
commit
7fe638e70d
@ -1,3 +1,15 @@
|
|||||||
|
2011-04-13 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* include/functions_graph.php
|
||||||
|
include/graphs/functions_pchart.php
|
||||||
|
include/graphs/fgraph.php
|
||||||
|
include/functions_reporting.php
|
||||||
|
include/pchart_graph.php
|
||||||
|
include/fgraph.php: Change the slicebar graph
|
||||||
|
made by Javi to make it more generic and to
|
||||||
|
use the new pChart library. This graph has been
|
||||||
|
included into the graphs abstraction too
|
||||||
|
|
||||||
2011-04-13 Miguel de Dios <miguel.dedios@artica.es>
|
2011-04-13 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* include/graphs/functions_pchart.php: added lost lines of source code to
|
* include/graphs/functions_pchart.php: added lost lines of source code to
|
||||||
|
@ -2405,20 +2405,6 @@ function graph_custom_sql_graph ($id, $width, $height, $type = 1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function graph_sla_horizontal ($id, $period, $sla_min, $sla_max, $daysWeek, $time_from, $time_to, $sla_limit, $width, $height) {
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
$engine = get_graph_engine ();
|
|
||||||
|
|
||||||
$engine->width = $width;
|
|
||||||
$engine->height = $height;
|
|
||||||
$engine->fontpath = $config['fontpath'];
|
|
||||||
$days = json_decode ($daysWeek, true);
|
|
||||||
$data = get_agentmodule_sla_array ($id, $period, $sla_min, $sla_max, $sla_limit, $days, $time_from, $time_to);
|
|
||||||
$engine->graph_sla_horizontal ($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function myErrorHandler($errno, $errstr, $errfile, $errline)
|
function myErrorHandler($errno, $errstr, $errfile, $errline)
|
||||||
{
|
{
|
||||||
switch ($errno) {
|
switch ($errno) {
|
||||||
|
@ -725,4 +725,14 @@ function progress_bar2($progress, $width, $height, $title = '', $mode = 1) {
|
|||||||
return "<img title='" . $title . "' alt='" . $title . "' src='include/graphs/fgraph.php?graph_type=progressbar&width=".$width."&height=".$height."&progress=".$progress.
|
return "<img title='" . $title . "' alt='" . $title . "' src='include/graphs/fgraph.php?graph_type=progressbar&width=".$width."&height=".$height."&progress=".$progress.
|
||||||
"&mode=" . $mode . "&out_of_lim_str=".$out_of_lim_str."&title=".$title."&font=".$config['fontpath']."' />";
|
"&mode=" . $mode . "&out_of_lim_str=".$out_of_lim_str."&title=".$title."&font=".$config['fontpath']."' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function graph_sla_slicebar ($id, $period, $sla_min, $sla_max, $daysWeek, $time_from, $time_to, $sla_limit, $width, $height) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$days = json_decode ($daysWeek, true);
|
||||||
|
$data = get_agentmodule_sla_array ($id, $period, $sla_min, $sla_max, $sla_limit, $days, $time_from, $time_to);
|
||||||
|
$colors = array(1 => '#38B800', 2 => '#FFFF00', 3 => '#FF0000', 4 => '#C3C3C3');
|
||||||
|
|
||||||
|
return slicesbar_graph($data, $width, $height, $colors, $config['fontpath'], $config['round_corner']);
|
||||||
|
}
|
||||||
?>
|
?>
|
@ -26,6 +26,7 @@ require_once ($config["homedir"]."/include/functions.php");
|
|||||||
require_once ($config["homedir"]."/include/functions_db.php");
|
require_once ($config["homedir"]."/include/functions_db.php");
|
||||||
require_once ($config["homedir"]."/include/functions_agents.php");
|
require_once ($config["homedir"]."/include/functions_agents.php");
|
||||||
include_once ($config["homedir"]."/include/fgraph.php");
|
include_once ($config["homedir"]."/include/fgraph.php");
|
||||||
|
include_once ($config["homedir"]."/include/functions_graph.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2117,10 +2118,7 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
|
|||||||
$data[0] = printSmallFont(get_agentmodule_agent_name ($sla['id_agent_module']));
|
$data[0] = printSmallFont(get_agentmodule_agent_name ($sla['id_agent_module']));
|
||||||
$data[0] .= "<br>";
|
$data[0] .= "<br>";
|
||||||
$data[0] .= printSmallFont(get_agentmodule_name ($sla['id_agent_module']));
|
$data[0] .= printSmallFont(get_agentmodule_name ($sla['id_agent_module']));
|
||||||
$data[1] = "<img src='include/fgraph.php?tipo=sla_horizontal_graph&id=".$sla['id_agent_module'].
|
$data[1] = graph_sla_slicebar($sla['id_agent_module'], $content['period'], $sla['sla_min'], $sla['sla_max'], $daysWeek, $content['time_from'], $content['time_to'], $sla['sla_limit'], 550, 25);
|
||||||
"&period=".$content['period']."&value1=".$sla['sla_min']."&value2=".$sla['sla_max'].
|
|
||||||
"&value3=".$content['time_from']."&value4=".$content['time_to']."&percent=".$sla['sla_limit'].
|
|
||||||
"&daysWeek=".$daysWeek."&height=25&width=550'>";
|
|
||||||
array_push ($table2->data, $data);
|
array_push ($table2->data, $data);
|
||||||
}
|
}
|
||||||
$table->colspan[4][0] = 3;
|
$table->colspan[4][0] = 3;
|
||||||
|
@ -56,6 +56,20 @@ switch($graph_type) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function slicesbar_graph($chart_data, $width, $height, $colors, $font, $round_corner) {
|
||||||
|
$graph = array();
|
||||||
|
$graph['data'] = $chart_data;
|
||||||
|
$graph['width'] = $width;
|
||||||
|
$graph['height'] = $height;
|
||||||
|
$graph['font'] = $font;
|
||||||
|
$graph['round_corner'] = $round_corner;
|
||||||
|
$graph['color'] = $colors;
|
||||||
|
|
||||||
|
$id_graph = serialize_in_temp($graph);
|
||||||
|
|
||||||
|
return "<img src='include/graphs/functions_pchart.php?graph_type=slicebar&id_graph=".$id_graph."'>";
|
||||||
|
}
|
||||||
|
|
||||||
function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array(), $legend = array(), $xaxisname = "", $yaxisname = "") {
|
function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array(), $legend = array(), $xaxisname = "", $yaxisname = "") {
|
||||||
if($flash_chart) {
|
if($flash_chart) {
|
||||||
echo fs_2d_column_chart ($chart_data, $width, $height);
|
echo fs_2d_column_chart ($chart_data, $width, $height);
|
||||||
|
@ -66,6 +66,12 @@ $yaxisname = '';
|
|||||||
if(isset($graph['yaxisname'])) {
|
if(isset($graph['yaxisname'])) {
|
||||||
$yaxisname = $graph['yaxisname'];
|
$yaxisname = $graph['yaxisname'];
|
||||||
}
|
}
|
||||||
|
if(isset($graph['font'])) {
|
||||||
|
$font = $graph['font'];
|
||||||
|
}
|
||||||
|
if(isset($graph['round_corner'])) {
|
||||||
|
$round_corner = $graph['round_corner'];
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$colors = array();
|
$colors = array();
|
||||||
@ -146,6 +152,7 @@ switch($graph_type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case 'slicebar':
|
||||||
case 'polar':
|
case 'polar':
|
||||||
case 'radar':
|
case 'radar':
|
||||||
case 'pie3d':
|
case 'pie3d':
|
||||||
@ -153,13 +160,21 @@ switch($graph_type) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($graph_type != 'pie3d') && ($graph_type != 'pie2d')) {
|
switch($graph_type) {
|
||||||
|
case 'slicebar':
|
||||||
|
case 'polar':
|
||||||
|
case 'radar':
|
||||||
|
case 'pie3d':
|
||||||
|
case 'pie2d':
|
||||||
|
break;
|
||||||
|
case 'default':
|
||||||
if(!is_array(reset($data_values))) {
|
if(!is_array(reset($data_values))) {
|
||||||
$data_values = array($data_values);
|
$data_values = array($data_values);
|
||||||
if(is_array($colors) && !empty($colors)) {
|
if(is_array($colors) && !empty($colors)) {
|
||||||
$colors = array($colors);
|
$colors = array($colors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rgb_color = array();
|
$rgb_color = array();
|
||||||
@ -206,6 +221,9 @@ switch($graph_type) {
|
|||||||
case 'pie2d':
|
case 'pie2d':
|
||||||
pch_pie_graph($graph_type, array_values($data), array_keys($data), $width, $height);
|
pch_pie_graph($graph_type, array_values($data), array_keys($data), $width, $height);
|
||||||
break;
|
break;
|
||||||
|
case 'slicebar':
|
||||||
|
pch_slicebar_graph($graph_type, $data, $width, $height, $colors, $font, $round_corner);
|
||||||
|
break;
|
||||||
case 'polar':
|
case 'polar':
|
||||||
case 'radar':
|
case 'radar':
|
||||||
pch_kiviat_graph($graph_type, array_values($data), array_keys($data), $width, $height);
|
pch_kiviat_graph($graph_type, array_values($data), array_keys($data), $width, $height);
|
||||||
@ -230,6 +248,63 @@ switch($graph_type) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pch_slicebar_graph ($graph_type, $data, $width, $height, $colors, $font, $round_corner) {
|
||||||
|
/* CAT:Slicebar charts */
|
||||||
|
|
||||||
|
set_time_limit (0);
|
||||||
|
|
||||||
|
// Dataset definition
|
||||||
|
$myPicture = new pImage($width,$height);
|
||||||
|
|
||||||
|
$myPicture->setFontProperties(array("FontName"=>"../fonts/code.ttf","FontSize"=>8,"R"=>80,"G"=>80,"B"=>80));
|
||||||
|
|
||||||
|
// Round corners defined in global setup
|
||||||
|
if ($round_corner != 0)
|
||||||
|
$radius = ($height > 18) ? 8 : 0;
|
||||||
|
else
|
||||||
|
$radius = 0;
|
||||||
|
|
||||||
|
$ratio = $width / count($data);
|
||||||
|
|
||||||
|
/* Color stuff */
|
||||||
|
$colorsrgb = array();
|
||||||
|
foreach($colors as $key => $col) {
|
||||||
|
$rgb = html2rgb($col);
|
||||||
|
$colorsrgb[$key]['R'] = $rgb[0];
|
||||||
|
$colorsrgb[$key]['G'] = $rgb[1];
|
||||||
|
$colorsrgb[$key]['B'] = $rgb[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach ($data as $d) {
|
||||||
|
$color = $colorsrgb[$d];
|
||||||
|
$myPicture->drawRoundedFilledRectangle ($i, 0, $ratio+$i,
|
||||||
|
$height, $radius, array('R' => $color['R'], 'G' => $color['G'], 'B' => $color['B']));
|
||||||
|
$i+=$ratio;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($round_corner) {
|
||||||
|
/* Under this value, the rounded rectangle is painted great */
|
||||||
|
if ($ratio <= 16) {
|
||||||
|
/* Clean a bit of pixels */
|
||||||
|
for ($i = 0; $i < 7; $i++) {
|
||||||
|
$myPicture->drawLine (0, $i, 6 - $i, $i, array('R' => 255, 'G' => 255, 'B' => 255));
|
||||||
|
}
|
||||||
|
$end = $height - 1;
|
||||||
|
for ($i = 0; $i < 7; $i++) {
|
||||||
|
$myPicture->drawLine (0, $end - $i, 5 - $i, $end - $i, array('R' => 255, 'G' => 255, 'B' => 255));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$myPicture->drawRoundedRectangle (0, 0, $width,
|
||||||
|
$height - 1, $radius, array('R' => 157, 'G' => 157, 'B' => 157));
|
||||||
|
|
||||||
|
$myPicture->Stroke ();
|
||||||
|
}
|
||||||
|
|
||||||
function pch_pie_graph ($graph_type, $data_values, $legend_values, $width, $height) {
|
function pch_pie_graph ($graph_type, $data_values, $legend_values, $width, $height) {
|
||||||
/* CAT:Pie charts */
|
/* CAT:Pie charts */
|
||||||
|
|
||||||
@ -511,13 +586,11 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
|
|||||||
|
|
||||||
if (isset($size['Height'])) {
|
if (isset($size['Height'])) {
|
||||||
/* Define the chart area */
|
/* Define the chart area */
|
||||||
//$myPicture->setGraphArea(40,$size['Height'],$width,$height - 90);
|
$myPicture->setGraphArea(40,$size['Height'],$width,$height - 90);
|
||||||
$myPicture->setGraphArea(40,$size['Height'],$width,$height - $margin_bottom);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Define the chart area */
|
/* Define the chart area */
|
||||||
//$myPicture->setGraphArea(40, 5,$width,$height - 90);
|
$myPicture->setGraphArea(40, 5,$width,$height - 90);
|
||||||
$myPicture->setGraphArea(40, 5,$width,$height - $margin_bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the scale */
|
/* Draw the scale */
|
||||||
|
@ -652,76 +652,5 @@ class PchartGraph extends PandoraGraphAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function graph_sla_horizontal ($data) {
|
|
||||||
set_time_limit (0);
|
|
||||||
// Dataset definition
|
|
||||||
$this->graph = new pChart ($this->width, $this->height);
|
|
||||||
$this->graph->setFontProperties ($this->fontpath, 8);
|
|
||||||
|
|
||||||
// Round corners defined in global setup
|
|
||||||
global $config;
|
|
||||||
if ($config["round_corner"] != 0)
|
|
||||||
$radius = ($this->height > 18) ? 8 : 0;
|
|
||||||
else
|
|
||||||
$radius = 0;
|
|
||||||
|
|
||||||
$ratio = $this->width / count($data);
|
|
||||||
|
|
||||||
/* Color stuff */
|
|
||||||
$bgcolor = $this->get_rgb_values ($this->background_color);
|
|
||||||
$r = hexdec (substr ($this->background_color, 1, 2));
|
|
||||||
$g = hexdec (substr ($this->background_color, 3, 2));
|
|
||||||
$b = hexdec (substr ($this->background_color, 5, 2));
|
|
||||||
$black = '#FFFFFF';
|
|
||||||
$colorOK = '#38B800';
|
|
||||||
$colorEdge = '#FFFF00';
|
|
||||||
$colorWrong = '#FF0000';
|
|
||||||
$colorUnknown = '#C3C3C3';
|
|
||||||
$color_black = $this->get_rgb_values ($black);
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
foreach ($data as $d) {
|
|
||||||
switch ($d) {
|
|
||||||
case 1:
|
|
||||||
$color = $this->get_rgb_values ($colorOK);
|
|
||||||
breaK;
|
|
||||||
case 2:
|
|
||||||
$color = $this->get_rgb_values ($colorEdge);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$color = $this->get_rgb_values ($colorWrong);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
$color = $this->get_rgb_values ($colorUnknown);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$this->graph->drawFilledRoundedRectangle ($i, 0, $ratio+$i,
|
|
||||||
$this->height, $radius, $color['r'], $color['g'], $color['b']);
|
|
||||||
$i+=$ratio;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($config["round_corner"]) {
|
|
||||||
/* Under this value, the rounded rectangle is painted great */
|
|
||||||
if ($ratio <= 16) {
|
|
||||||
/* Clean a bit of pixels */
|
|
||||||
for ($i = 0; $i < 7; $i++) {
|
|
||||||
$this->graph->drawLine (0, $i, 6 - $i, $i, 255, 255, 255);
|
|
||||||
}
|
|
||||||
$end = $this->height - 1;
|
|
||||||
for ($i = 0; $i < 7; $i++) {
|
|
||||||
$this->graph->drawLine (0, $end - $i, 5 - $i, $end - $i, 255, 255, 255);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->border) {
|
|
||||||
$this->graph->drawRoundedRectangle (0, 0, $this->width,
|
|
||||||
$this->height - 1, $radius, 157, 157, 157);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->graph->Stroke ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user