2011-04-26 Sergio Martin <sergio.martin@artica.es>

* include/graphs/functions_pchart.php
	include/graphs/functions_gd.php
	include/graphs/fgraph.php: Merged sancho works from 
	integria passing fonts and sizes in integria. Little 
	fixes



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4280 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-04-26 17:52:25 +00:00
parent 4f5933213a
commit b0447ea423
4 changed files with 33 additions and 22 deletions

View File

@ -1,3 +1,11 @@
2011-04-26 Sergio Martin <sergio.martin@artica.es>
* include/graphs/functions_pchart.php
include/graphs/functions_gd.php
include/graphs/fgraph.php: Merged sancho works from
integria passing fonts and sizes in integria. Little
fixes
2011-04-25 Javier Lanz <javier.lanz@artica.es>
* include/functions_reporting.php: Fixed a small font problem displaying

View File

@ -134,7 +134,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
function threshold_graph($flash_chart, $chart_data, $width, $height) {
if($flash_chart) {
echo fs_2d_column_chart ($chart_data, $width, $height);
echo fs_area_chart ($chart_data, $width, $height);
}
else {
echo "<img src='include/graphs/functions_pchart.php?graph_type=threshold&data=".json_encode($chart_data)."&width=".$width."&height=".$height."'>";

View File

@ -40,6 +40,10 @@ if($id_graph) {
exit;
}
if (!isset($graph['fontsize'])) {
$graph['fontsize'] = 6;
}
$graph_type = get_parameter('graph_type', '');
switch($graph_type) {
@ -50,7 +54,8 @@ if($id_graph) {
json_decode($graph['data'], true),
$graph['max'],
$graph['font'],
$graph['title']);
$graph['title'],
$graph['fontsize']);
break;
case 'progressbar':
gd_progress_bar ($graph['width'],
@ -60,13 +65,14 @@ if($id_graph) {
$graph['font'],
$graph['out_of_lim_str'],
$graph['out_of_lim_image'],
$graph['mode']);
$graph['mode'],
$graph['fontsize']);
break;
}
}
function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title) {
function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title, $fontsize = 8) {
// $title is for future use
$nvalues = count($data);
@ -112,7 +118,7 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title)
foreach($data as $label => $value) {
ImageFilledRectangle($image, $leftmargin, $margin_up, ($value/$size_per)+$leftmargin, $margin_up+$rectangle_height -1 , $colors[$c]);
if ($mode != 2) {
ImageTTFText($image, 7, 0, 0, $margin_up+8, $black, $font, $label);
ImageTTFText($image, $fontsize, 0, 0, $margin_up+8, $black, $font, $label);
}
$margin_up += $rectangle_height + 1;
@ -131,9 +137,9 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title)
imageline($image, $risk_low, 0, $risk_low , $height, $grey);
imageline($image, $risk_med , 0, $risk_med , $height, $grey);
imageline($image, $risk_high, 0, $risk_high , $height, $grey);
ImageTTFText($image, 7, 0, $risk_low-20, $height, $grey, $font, "Low");
ImageTTFText($image, 7, 0, $risk_med-20, $height, $grey, $font, "Med.");
ImageTTFText($image, 7, 0, $risk_high-25, $height, $grey, $font, "High");
ImageTTFText($image, $fontsize, 0, $risk_low-20, $height, $grey, $font, "Low");
ImageTTFText($image, $fontsize, 0, $risk_med-20, $height, $grey, $font, "Med.");
ImageTTFText($image, $fontsize, 0, $risk_high-25, $height, $grey, $font, "High");
}
imagePNG($image);
imagedestroy($image);
@ -143,7 +149,7 @@ function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title)
// Draw a dynamic progress bar using GDlib directly
// ***************************************************************************
function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image, $mode = 1) {
function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim_str, $out_of_lim_image, $mode = 1, $fontsize=10) {
if($out_of_lim_str === false) {
$out_of_lim_str = "Out of limits";
}
@ -214,11 +220,11 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
if ($rating > 50)
if ($rating > 100)
ImageTTFText($image, 8, 0, ($width/4), ($height/2)+($height/5), $back, $font, $out_of_lim_str);
ImageTTFText($image, $fontsize, 0, ($width/4), ($height/2)+($height/5), $back, $font, $out_of_lim_str);
else
ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $font, $rating."%");
ImageTTFText($image, $fontsize, 0, ($width/2)-($width/10), ($height/2)+($height/5), $back, $font, $rating."%");
else
ImageTTFText($image, 8, 0, ($width/2)-($width/10), ($height/2)+($height/5), $text, $font, $rating."%");
ImageTTFText($image, $fontsize, 0, ($width/2)-($width/10), ($height/2)+($height/5), $text, $font, $rating."%");
break;
}
imagePNG($image);

View File

@ -42,6 +42,7 @@ $yaxisname = '';
$legend = null;
$colors = null;
$font_size = 8;
$force_steps = true;
$graph_type = get_parameter('graph_type', '');
@ -61,18 +62,16 @@ if (!isset($graph)) {
$data = $graph['data'];
$width = $graph['width'];
$height = $graph['height'];
$colors = null;
$force_steps = true;
if (isset($graph['color']))
if (isset($graph['color'])) {
$colors = $graph['color'];
$legend = null;
if (isset($graph['legend']))
}
if (isset($graph['legend'])) {
$legend = $graph['legend'];
$xaxisname = '';
}
if(isset($graph['xaxisname'])) {
$xaxisname = $graph['xaxisname'];
}
$yaxisname = '';
if(isset($graph['yaxisname'])) {
$yaxisname = $graph['yaxisname'];
}
@ -377,7 +376,6 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
$water_mark_height = 0;
$water_mark_width = 0;
debugPrint($water_mark, true);
if (!empty($water_mark)) {
$size_water_mark = getimagesize($water_mark);
$water_mark_height = $size_water_mark[1];
@ -412,7 +410,6 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
$max_chars = $len;
}
}
debugPrint($max_chars, true);
$legend_with_aprox = 32 + (7 * $max_chars);
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
@ -554,7 +551,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
"Mode"=>SCALE_MODE_START0, "LabelRotation" => 60);
$margin_left = 40;
$margin_top = 10;
$margin_bottom = 8 * $max_chars;
$margin_bottom = 10 * $max_chars;
break;
case "hbar":
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,