2013-06-10 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_html.php, include/functions_reporting.php, include/graphs/functions_utils.php, include/graphs/fgraph.php, include/graphs/functions_pchart.php: fixed the graphs in the reports. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8281 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
a40f68bdaf
commit
0a2ac656a5
|
@ -1,3 +1,10 @@
|
|||
2013-06-10 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_html.php, include/functions_reporting.php,
|
||||
include/graphs/functions_utils.php, include/graphs/fgraph.php,
|
||||
include/graphs/functions_pchart.php: fixed the graphs in the
|
||||
reports.
|
||||
|
||||
2013-06-10 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/styles/datepicker.css
|
||||
|
|
|
@ -1639,22 +1639,22 @@ function html_print_image ($src, $return = false, $options = false, $return_src
|
|||
|
||||
}
|
||||
|
||||
if (!$relative) {
|
||||
$src_tmp = $src;
|
||||
$src = ui_get_full_url($src);
|
||||
}
|
||||
|
||||
// If metaconsole is activated and image doesn't exists try to search on normal console
|
||||
if (defined('METACONSOLE')) {
|
||||
if (!$relative) {
|
||||
if (false === @file_get_contents($src, 0, null, 0, 1)) {
|
||||
$src = ui_get_full_url('../../' . $src_tmp);
|
||||
$src = ui_get_full_url('../../' . $src);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$src = '../../' . $src;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!$relative) {
|
||||
$src = ui_get_full_url($src);
|
||||
}
|
||||
}
|
||||
|
||||
// Only return src field of image
|
||||
if ($return_src) {
|
||||
|
|
|
@ -3471,7 +3471,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
|
||||
$dataslice[1] = graph_sla_slicebar ($sla['id_agent_module'], $content['period'],
|
||||
$sla['sla_min'], $sla['sla_max'], $report['datetime'], $content, $content['time_from'],
|
||||
$content['time_to'], 650, 25, ui_get_full_url(false) . '/', 1, $sla_data_arrays[$k], false);
|
||||
$content['time_to'], 650, 25, ui_get_full_url(false, false, false, false), 1, $sla_data_arrays[$k], false);
|
||||
|
||||
array_push ($tableslice->data, $dataslice);
|
||||
}
|
||||
|
@ -3494,7 +3494,9 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
$data_pie_graph = json_encode ($data_graph);
|
||||
if ($show_graphs && !empty($slas)) {
|
||||
$data[0] = pie3d_graph(false, $data_graph,
|
||||
500, 150, __("other"), ui_get_full_url(false) . '/', $config['homedir'] . "/images/logo_vertical_water.png",
|
||||
500, 150, __("other"),
|
||||
ui_get_full_url(false, false, false, false),
|
||||
$config['homedir'] . "/images/logo_vertical_water.png",
|
||||
$config['fontpath'], $config['font_size']);
|
||||
|
||||
|
||||
|
@ -3540,7 +3542,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
|||
//RUNNING
|
||||
|
||||
// Put description at the end of the module (if exists)
|
||||
if ($content["description"] != ""){
|
||||
if ($content["description"] != "") {
|
||||
$table->colspan[1][0] = 3;
|
||||
$data_desc = array();
|
||||
$data_desc[0] = $content["description"];
|
||||
|
|
|
@ -435,7 +435,7 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
|
|||
}
|
||||
|
||||
function pie3d_graph($flash_chart, $chart_data, $width, $height,
|
||||
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||
$others_str = "other", $homedir = "", $water_mark = "", $font = '',
|
||||
$font_size = '', $ttl = 1, $legend_position = false, $colors = '') {
|
||||
|
||||
return pie_graph('3d', $flash_chart, $chart_data, $width, $height,
|
||||
|
@ -456,7 +456,7 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
|
|||
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||
$font_size = '', $ttl = 1, $legend_position = false, $colors = '') {
|
||||
|
||||
if(empty($chart_data)) {
|
||||
if (empty($chart_data)) {
|
||||
return graph_nodata_image($width, $height, 'pie');
|
||||
}
|
||||
|
||||
|
|
|
@ -77,33 +77,33 @@ if (isset($graph['color'])) {
|
|||
if (isset($graph['legend'])) {
|
||||
$legend = $graph['legend'];
|
||||
}
|
||||
if(isset($graph['xaxisname'])) {
|
||||
if (isset($graph['xaxisname'])) {
|
||||
$xaxisname = $graph['xaxisname'];
|
||||
}
|
||||
if(isset($graph['yaxisname'])) {
|
||||
if (isset($graph['yaxisname'])) {
|
||||
$yaxisname = $graph['yaxisname'];
|
||||
}
|
||||
if(isset($graph['round_corner'])) {
|
||||
if (isset($graph['round_corner'])) {
|
||||
$round_corner = $graph['round_corner'];
|
||||
}
|
||||
if(isset($graph['font'])) {
|
||||
if (isset($graph['font'])) {
|
||||
if (!empty($graph['font'])) {
|
||||
$font = $graph['font'];
|
||||
}
|
||||
}
|
||||
if(isset($graph['font_size'])) {
|
||||
if (isset($graph['font_size'])) {
|
||||
if (!empty($graph['font_size'])) {
|
||||
$font_size = $graph['font_size'];
|
||||
}
|
||||
}
|
||||
if(isset($graph['antialiasing'])) {
|
||||
if (isset($graph['antialiasing'])) {
|
||||
$antialiasing = $graph['antialiasing'];
|
||||
}
|
||||
$force_height = true;
|
||||
if(isset($graph['force_height'])) {
|
||||
if (isset($graph['force_height'])) {
|
||||
$force_height = $graph['force_height'];
|
||||
}
|
||||
if(isset($graph['period'])) {
|
||||
if (isset($graph['period'])) {
|
||||
$period = $graph['period'];
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ if (!$force_height) {
|
|||
}
|
||||
|
||||
$water_mark = '';
|
||||
if(isset($graph['water_mark'])) {
|
||||
if (isset($graph['water_mark'])) {
|
||||
//"/var/www/pandora_console/images/logo_vertical_water.png";
|
||||
$water_mark = $graph['water_mark'];
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ $c = 1;
|
|||
switch($graph_type) {
|
||||
case 'hbar':
|
||||
case 'vbar':
|
||||
foreach($data as $i => $values) {
|
||||
foreach($values as $name => $val) {
|
||||
foreach ($data as $i => $values) {
|
||||
foreach ($values as $name => $val) {
|
||||
$data_values[$name][] = $val;
|
||||
}
|
||||
|
||||
|
@ -168,13 +168,13 @@ switch($graph_type) {
|
|||
$fine_colors = array();
|
||||
|
||||
// If is set fine colors we store it or set default
|
||||
if(isset($colors[reset(array_keys($data_values))]['fine'])) {
|
||||
if (isset($colors[reset(array_keys($data_values))]['fine'])) {
|
||||
$fine = $colors[reset(array_keys($data_values))]['fine'];
|
||||
if($fine === true) {
|
||||
if ($fine === true) {
|
||||
$fine = $default_fine_colors;
|
||||
}
|
||||
|
||||
foreach($fine as $i => $fine_color) {
|
||||
foreach ($fine as $i => $fine_color) {
|
||||
$rgb_fine = html_html2rgb($fine_color);
|
||||
$fine_colors[$i]['R'] = $rgb_fine[0];
|
||||
$fine_colors[$i]['G'] = $rgb_fine[1];
|
||||
|
@ -192,7 +192,7 @@ switch($graph_type) {
|
|||
case 'line':
|
||||
case 'threshold':
|
||||
case 'scatter':
|
||||
foreach($data as $i => $d) {
|
||||
foreach ($data as $i => $d) {
|
||||
$data_values[] = $d;
|
||||
|
||||
|
||||
|
@ -409,8 +409,8 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
|
|||
/* Create the pPie object */
|
||||
$PieChart = new pPie($myPicture,$MyData);
|
||||
|
||||
foreach($data_values as $key => $value) {
|
||||
if(isset($colors[$key])) {
|
||||
foreach ($data_values as $key => $value) {
|
||||
if (isset($colors[$key])) {
|
||||
$PieChart->setSliceColor($key, hex_2_rgb($colors[$key]));
|
||||
}
|
||||
}
|
||||
|
@ -430,13 +430,14 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
|
|||
$max_chars = graph_get_max_index($legend_values);
|
||||
$legend_with_aprox = 32 + (7 * $max_chars);
|
||||
|
||||
if($legend_position != 'hidden') {
|
||||
if ($legend_position != 'hidden') {
|
||||
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
|
||||
}
|
||||
|
||||
/* Enable shadow computing */
|
||||
$myPicture->setShadow(TRUE,array("X"=>3,"Y"=>3,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
||||
|
||||
$myPicture->setShadow(TRUE,
|
||||
array("X" => 3, "Y" => 3, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
|
||||
|
||||
/* Render the picture */
|
||||
$myPicture->stroke();
|
||||
}
|
||||
|
|
|
@ -135,6 +135,9 @@ function graph_get_max_index($legend_values) {
|
|||
function setup_watermark($water_mark, &$water_mark_file, &$water_mark_url) {
|
||||
if (!is_array($water_mark)) {
|
||||
$water_mark_file = $water_mark;
|
||||
$water_mark_url = '';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($water_mark['file'])) {
|
||||
|
@ -155,160 +158,147 @@ function setup_watermark($water_mark, &$water_mark_file, &$water_mark_url) {
|
|||
// Function to convert hue to RGB
|
||||
|
||||
function hue_2_rgb($v1,$v2,$vh) {
|
||||
if ($vh < 0) {
|
||||
$vh += 1;
|
||||
};
|
||||
|
||||
if ($vh > 1) {
|
||||
$vh -= 1;
|
||||
};
|
||||
|
||||
if ((6 * $vh) < 1) {
|
||||
return ($v1 + ($v2 - $v1) * 6 * $vh);
|
||||
};
|
||||
|
||||
if ((2 * $vh) < 1) {
|
||||
return ($v2);
|
||||
};
|
||||
|
||||
if ((3 * $vh) < 2) {
|
||||
return ($v1 + ($v2 - $v1) * ((2 / 3 - $vh) * 6));
|
||||
};
|
||||
|
||||
return ($v1);
|
||||
if ($vh < 0) {
|
||||
$vh += 1;
|
||||
};
|
||||
|
||||
if ($vh > 1) {
|
||||
$vh -= 1;
|
||||
};
|
||||
|
||||
if ((6 * $vh) < 1) {
|
||||
return ($v1 + ($v2 - $v1) * 6 * $vh);
|
||||
};
|
||||
|
||||
if ((2 * $vh) < 1) {
|
||||
return ($v2);
|
||||
};
|
||||
|
||||
if ((3 * $vh) < 2) {
|
||||
return ($v1 + ($v2 - $v1) * ((2 / 3 - $vh) * 6));
|
||||
};
|
||||
|
||||
return ($v1);
|
||||
};
|
||||
|
||||
function hex_2_rgb($hexcode) {
|
||||
$hexcode = str_replace('#', '', $hexcode);
|
||||
|
||||
// $hexcode is the six digit hex colour code we want to convert
|
||||
|
||||
$redhex = substr($hexcode,0,2);
|
||||
$greenhex = substr($hexcode,2,2);
|
||||
$bluehex = substr($hexcode,4,2);
|
||||
|
||||
// $var_r, $var_g and $var_b are the three decimal fractions to be input to our RGB-to-HSL conversion routine
|
||||
|
||||
$var_r = hexdec($redhex);
|
||||
$var_g = hexdec($greenhex);
|
||||
$var_b = hexdec($bluehex);
|
||||
|
||||
return array('R' => $var_r, 'G' => $var_g, 'B' => $var_b);
|
||||
|
||||
$redhex = substr($hexcode,0,2);
|
||||
$greenhex = substr($hexcode,2,2);
|
||||
$bluehex = substr($hexcode,4,2);
|
||||
|
||||
// $var_r, $var_g and $var_b are the three decimal fractions to be input to our RGB-to-HSL conversion routine
|
||||
|
||||
$var_r = hexdec($redhex);
|
||||
$var_g = hexdec($greenhex);
|
||||
$var_b = hexdec($bluehex);
|
||||
|
||||
return array('R' => $var_r, 'G' => $var_g, 'B' => $var_b);
|
||||
}
|
||||
|
||||
function get_complementary_rgb ($hexcode) {
|
||||
$rgb = hex_2_rgb($hexcode);
|
||||
|
||||
$var_r = $rgb['R'] / 255;
|
||||
$var_g = $rgb['G'] / 255;
|
||||
$var_b = $rgb['B'] / 255;
|
||||
|
||||
$var_r = $rgb['R'] / 255;
|
||||
$var_g = $rgb['G'] / 255;
|
||||
$var_b = $rgb['B'] / 255;
|
||||
|
||||
//Now plug these values into the rgb2hsl routine. Below is my PHP version of EasyRGB.com's generic code for that conversion:
|
||||
|
||||
// Input is $var_r, $var_g and $var_b from above
|
||||
// Output is HSL equivalent as $h, $s and $l — these are again expressed as fractions of 1, like the input values
|
||||
|
||||
$var_min = min($var_r,$var_g,$var_b);
|
||||
$var_max = max($var_r,$var_g,$var_b);
|
||||
$del_max = $var_max - $var_min;
|
||||
|
||||
$l = ($var_max + $var_min) / 2;
|
||||
|
||||
if ($del_max == 0)
|
||||
{
|
||||
$h = 0;
|
||||
$s = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($l < 0.5)
|
||||
{
|
||||
$s = $del_max / ($var_max + $var_min);
|
||||
|
||||
// Input is $var_r, $var_g and $var_b from above
|
||||
// Output is HSL equivalent as $h, $s and $l — these are again expressed as fractions of 1, like the input values
|
||||
|
||||
$var_min = min($var_r,$var_g,$var_b);
|
||||
$var_max = max($var_r,$var_g,$var_b);
|
||||
$del_max = $var_max - $var_min;
|
||||
|
||||
$l = ($var_max + $var_min) / 2;
|
||||
|
||||
if ($del_max == 0) {
|
||||
$h = 0;
|
||||
$s = 0;
|
||||
}
|
||||
else {
|
||||
if ($l < 0.5) {
|
||||
$s = $del_max / ($var_max + $var_min);
|
||||
}
|
||||
else
|
||||
{
|
||||
$s = $del_max / (2 - $var_max - $var_min);
|
||||
else {
|
||||
$s = $del_max / (2 - $var_max - $var_min);
|
||||
};
|
||||
|
||||
|
||||
$del_r = ((($var_max - $var_r) / 6) + ($del_max / 2)) / $del_max;
|
||||
$del_g = ((($var_max - $var_g) / 6) + ($del_max / 2)) / $del_max;
|
||||
$del_b = ((($var_max - $var_b) / 6) + ($del_max / 2)) / $del_max;
|
||||
|
||||
if ($var_r == $var_max)
|
||||
{
|
||||
$h = $del_b - $del_g;
|
||||
|
||||
if ($var_r == $var_max) {
|
||||
$h = $del_b - $del_g;
|
||||
}
|
||||
elseif ($var_g == $var_max)
|
||||
{
|
||||
$h = (1 / 3) + $del_r - $del_b;
|
||||
elseif ($var_g == $var_max) {
|
||||
$h = (1 / 3) + $del_r - $del_b;
|
||||
}
|
||||
elseif ($var_b == $var_max)
|
||||
{
|
||||
$h = (2 / 3) + $del_g - $del_r;
|
||||
elseif ($var_b == $var_max) {
|
||||
$h = (2 / 3) + $del_g - $del_r;
|
||||
};
|
||||
|
||||
if ($h < 0)
|
||||
{
|
||||
$h += 1;
|
||||
|
||||
if ($h < 0) {
|
||||
$h += 1;
|
||||
};
|
||||
|
||||
if ($h > 1)
|
||||
{
|
||||
$h -= 1;
|
||||
|
||||
if ($h > 1) {
|
||||
$h -= 1;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//So now we have the colour as an HSL value, in the variables $h, $s and $l. These three output variables are again held as fractions of 1 at this stage, rather than as degrees and percentages. So e.g., cyan (180° 100% 50%) would come out as $h = 0.5, $s = 1, and $l = 0.5.
|
||||
|
||||
|
||||
//Next find the value of the opposite Hue, i.e., the one that's 180°, or 0.5, away (I'm sure the mathematicians have a more elegant way of doing this, but):
|
||||
|
||||
// Calculate the opposite hue, $h2
|
||||
|
||||
|
||||
// Calculate the opposite hue, $h2
|
||||
|
||||
$h2 = $h + 0.5;
|
||||
|
||||
|
||||
if ($h2 > 1) {
|
||||
$h2 -= 1;
|
||||
};
|
||||
|
||||
|
||||
//The HSL value of the complementary colour is now in $h2, $s, $l. So we're ready to convert this back to RGB (again, my PHP version of the EasyRGB.com formula). Note the input and output formats are different this time, see my comments at the top of the code:
|
||||
|
||||
|
||||
// Input is HSL value of complementary colour, held in $h2, $s, $l as fractions of 1
|
||||
// Output is RGB in normal 255 255 255 format, held in $r, $g, $b
|
||||
// Hue is converted using function hue_2_rgb, shown at the end of this code
|
||||
|
||||
if ($s == 0)
|
||||
{
|
||||
$r = $l * 255;
|
||||
$g = $l * 255;
|
||||
$b = $l * 255;
|
||||
|
||||
if ($s == 0) {
|
||||
$r = $l * 255;
|
||||
$g = $l * 255;
|
||||
$b = $l * 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($l < 0.5)
|
||||
{
|
||||
$var_2 = $l * (1 + $s);
|
||||
}
|
||||
else
|
||||
{
|
||||
$var_2 = ($l + $s) - ($s * $l);
|
||||
};
|
||||
$var_1 = 2 * $l - $var_2;
|
||||
|
||||
$r = 255 * hue_2_rgb($var_1,$var_2,$h2 + (1 / 3));
|
||||
$g = 255 * hue_2_rgb($var_1,$var_2,$h2);
|
||||
$b = 255 * hue_2_rgb($var_1,$var_2,$h2 - (1 / 3));
|
||||
else {
|
||||
if ($l < 0.5) {
|
||||
$var_2 = $l * (1 + $s);
|
||||
}
|
||||
else {
|
||||
$var_2 = ($l + $s) - ($s * $l);
|
||||
};
|
||||
$var_1 = 2 * $l - $var_2;
|
||||
|
||||
$r = 255 * hue_2_rgb($var_1,$var_2,$h2 + (1 / 3));
|
||||
$g = 255 * hue_2_rgb($var_1,$var_2,$h2);
|
||||
$b = 255 * hue_2_rgb($var_1,$var_2,$h2 - (1 / 3));
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//And after that routine, we finally have $r, $g and $b in 255 255 255 (RGB) format, which we can convert to six digits of hex:
|
||||
|
||||
|
||||
$rhex = sprintf("%02X",round($r));
|
||||
$ghex = sprintf("%02X",round($g));
|
||||
$bhex = sprintf("%02X",round($b));
|
||||
|
||||
|
||||
$rgbhex = $rhex.$ghex.$bhex;
|
||||
|
||||
|
||||
return $rgbhex;
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue