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

* include/graphs/functions_pchart.php
	include/graphs/functions_fsgraph.php
	include/graphs/functions_gd.php
	include/graphs/fgraph.php: Fixed long index bug into
	stacked and line graphs.
	Add entry for radar and polar charts (kiviat)
	Clean code



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4198 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-04-13 08:49:18 +00:00
parent 67c4e33021
commit 285eb8e2c8
5 changed files with 57 additions and 58 deletions

View File

@ -1,3 +1,13 @@
2011-04-13 Sergio Martin <sergio.martin@artica.es>
* include/graphs/functions_pchart.php
include/graphs/functions_fsgraph.php
include/graphs/functions_gd.php
include/graphs/fgraph.php: Fixed long index bug into
stacked and line graphs.
Add entry for radar and polar charts (kiviat)
Clean code
2011-04-12 Miguel de Dios <miguel.dedios@artica.es> 2011-04-12 Miguel de Dios <miguel.dedios@artica.es>
* include/graphs/functions_fsgraph.php: fixed the "fs_area_graph" when * include/graphs/functions_fsgraph.php: fixed the "fs_area_graph" when

View File

@ -91,8 +91,6 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
return fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index); return fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index);
} }
else { else {
$id_graph = uniqid();
$graph = array(); $graph = array();
$graph['data'] = $chart_data; $graph['data'] = $chart_data;
$graph['width'] = $width; $graph['width'] = $width;
@ -102,7 +100,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$graph['xaxisname'] = $xaxisname; $graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname; $graph['yaxisname'] = $yaxisname;
serialize_in_temp($graph, $id_graph); $id_graph = serialize_in_temp($graph);
return "<img src='include/graphs/functions_pchart.php?graph_type=area&id_graph=" . $id_graph . "'>"; return "<img src='include/graphs/functions_pchart.php?graph_type=area&id_graph=" . $id_graph . "'>";
} }
@ -118,8 +116,6 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
return fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index); return fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index);
} }
else { else {
$id_graph = uniqid();
//Stack the data //Stack the data
stack_data($chart_data, $legend, $color); stack_data($chart_data, $legend, $color);
@ -130,9 +126,9 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
$graph['color'] = $color; $graph['color'] = $color;
$graph['legend'] = $legend; $graph['legend'] = $legend;
serialize_in_temp($graph, $id_graph); $id_graph = serialize_in_temp($graph);
return "<img src='http://127.0.0.1/pandora_console/include/graphs/functions_pchart.php?graph_type=stacked_area&id_graph=" . $id_graph . "' />"; return "<img src='include/graphs/functions_pchart.php?graph_type=stacked_area&id_graph=" . $id_graph . "' />";
} }
} }
@ -148,8 +144,6 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
return fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index); return fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index);
} }
else { else {
$id_graph = uniqid();
$graph = array(); $graph = array();
$graph['data'] = $chart_data; $graph['data'] = $chart_data;
$graph['width'] = $width; $graph['width'] = $width;
@ -157,9 +151,9 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
$graph['color'] = $color; $graph['color'] = $color;
$graph['legend'] = $legend; $graph['legend'] = $legend;
serialize_in_temp($graph, $id_graph); $id_graph = serialize_in_temp($graph);
return "<img src='http://127.0.0.1/pandora_console/include/graphs/functions_pchart.php?graph_type=line&id_graph=" . $id_graph . "' />"; return "<img src='include/graphs/functions_pchart.php?graph_type=line&id_graph=" . $id_graph . "' />";
} }
} }
@ -172,9 +166,6 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
return fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index); return fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index);
} }
else { else {
$id_graph = uniqid();
$graph = array(); $graph = array();
$graph['data'] = $chart_data; $graph['data'] = $chart_data;
$graph['width'] = $width; $graph['width'] = $width;
@ -182,12 +173,35 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$graph['color'] = $color; $graph['color'] = $color;
$graph['legend'] = $legend; $graph['legend'] = $legend;
serialize_in_temp($graph, $id_graph); $id_graph = serialize_in_temp($graph);
return "<img src='http://127.0.0.1/pandora_console/include/graphs/functions_pchart.php?graph_type=line&id_graph=" . $id_graph . "' />"; return "<img src='include/graphs/functions_pchart.php?graph_type=line&id_graph=" . $id_graph . "' />";
} }
} }
function kiviat_graph($graph_type, $flash_chart, $chart_data, $width, $height, $no_data_image) {
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
}
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$id_graph = serialize_in_temp($graph);
return "<img src='include/graphs/functions_pchart.php?graph_type=".$graph_type."&id_graph=" . $id_graph . "' />";
}
function radar_graph($flash_chart, $chart_data, $width, $height, $no_data_image) {
return kiviat_graph('radar', $flash_chart, $chart_data, $width, $height, $no_data_image);
}
function polar_graph($flash_chart, $chart_data, $width, $height, $no_data_image) {
return kiviat_graph('polar', $flash_chart, $chart_data, $width, $height, $no_data_image);
}
function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array(), $legend = array(), $xaxisname = "", $yaxisname = "") { function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array(), $legend = array(), $xaxisname = "", $yaxisname = "") {
if($flash_chart) { if($flash_chart) {
echo fs_hbar_chart (array_values($chart_data), array_keys($chart_data), $width, $height); echo fs_hbar_chart (array_values($chart_data), array_keys($chart_data), $width, $height);

View File

@ -46,18 +46,6 @@ function fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_i
$data2 = array(); $data2 = array();
$count = 0; $count = 0;
foreach($chart_data as $i =>$values) { foreach($chart_data as $i =>$values) {
// $count = 0;
// $step = 10;
// $num_vlines = 0;
//
// if ($count++ % $step == 0) {
// $show_name = '1';
// $num_vlines++;
// }
// else {
// $show_name = '0';
// }
$count++; $count++;
$show_name = '0'; $show_name = '0';
if (($count % $step) == 0) { if (($count % $step) == 0) {
@ -69,6 +57,9 @@ function fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_i
'hoverText=' . $long_index[$i] . 'hoverText=' . $long_index[$i] .
';showName=' . $show_name); ';showName=' . $show_name);
} }
else {
$chart->addCategory($i, 'showName=' . $show_name);
}
$c = 0; $c = 0;
foreach($values as $i2 => $value) { foreach($values as $i2 => $value) {
@ -198,18 +189,6 @@ function fs_line_graph($chart_data, $width, $height, $color, $legend, $long_inde
$data2 = array(); $data2 = array();
$count = 0; $count = 0;
foreach($chart_data as $i =>$values) { foreach($chart_data as $i =>$values) {
// $count = 0;
// $step = 10;
// $num_vlines = 0;
//
// if ($count++ % $step == 0) {
// $show_name = '1';
// $num_vlines++;
// }
// else {
// $show_name = '0';
// }
$count++; $count++;
$show_name = '0'; $show_name = '0';
if (($count % $step) == 0) { if (($count % $step) == 0) {
@ -221,6 +200,9 @@ function fs_line_graph($chart_data, $width, $height, $color, $legend, $long_inde
'hoverText=' . $long_index[$i] . 'hoverText=' . $long_index[$i] .
';showName=' . $show_name); ';showName=' . $show_name);
} }
else {
$chart->addCategory($i, 'showName=' . $show_name);
}
$c = 0; $c = 0;
foreach($values as $i2 => $value) { foreach($values as $i2 => $value) {
@ -310,7 +292,7 @@ function fs_line_graph($chart_data, $width, $height, $color, $legend, $long_inde
$output = '<div id="' . $div_id. '" style="z-index:1;"></div>'; $output = '<div id="' . $div_id. '" style="z-index:1;"></div>';
$output .= '<script language="JavaScript" src="include/graphs/FusionCharts/FusionCharts.js"></script>'; //$output .= '<script language="JavaScript" src="include/graphs/FusionCharts/FusionCharts.js"></script>';
$output .= '<script type="text/javascript"> $output .= '<script type="text/javascript">
<!-- <!--
function pie_' . $chart_id . ' () { function pie_' . $chart_id . ' () {
@ -472,11 +454,6 @@ function fs_area_graph($chart_data, $width, $height, $color, $legend, $long_inde
/////////////////////////////// ///////////////////////////////
// Returns the number of seconds since the Epoch for a date in the format dd/mm/yyyy // Returns the number of seconds since the Epoch for a date in the format dd/mm/yyyy
function date_to_epoch ($date) { function date_to_epoch ($date) {
$date_array = explode ('/', $date); $date_array = explode ('/', $date);

View File

@ -124,8 +124,6 @@ switch($graph_type) {
} }
break; break;
case 'polar':
case 'radar':
case 'progress': case 'progress':
case 'area': case 'area':
case 'stacked_area': case 'stacked_area':
@ -148,6 +146,8 @@ switch($graph_type) {
} }
break; break;
case 'polar':
case 'radar':
case 'pie3d': case 'pie3d':
case 'pie2d': case 'pie2d':
break; break;
@ -208,7 +208,7 @@ switch($graph_type) {
break; break;
case 'polar': case 'polar':
case 'radar': case 'radar':
pch_radar_graph($graph_type, $data_values, $data_keys, $width, $height); pch_kiviat_graph($graph_type, array_values($data), array_keys($data), $width, $height);
break; break;
case 'progress': case 'progress':
pch_progress_graph($graph_type, $data_keys, $data_values, $width, $height, $xaxisname, $yaxisname); pch_progress_graph($graph_type, $data_keys, $data_values, $width, $height, $xaxisname, $yaxisname);
@ -272,7 +272,7 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width, $heig
$myPicture->stroke(); $myPicture->stroke();
} }
function pch_radar_graph ($graph_type, $data_values, $legend_values, $width, $height) { function pch_kiviat_graph ($graph_type, $data_values, $legend_values, $width, $height) {
/* CAT:Radar/Polar charts */ /* CAT:Radar/Polar charts */
/* Create and populate the pData object */ /* Create and populate the pData object */
@ -511,13 +511,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 */