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

* include/graphs/functions_pchart.php
	include/graphs/functions_gd.php
	include/graphs/fgraph.php: Added x and y
	axis name possibility to line, stacked line and
	stacked area graphs. 
	Added dual posibility of calling to functions_gd 
	(thorugh url and with function call).  
	Clean code.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4219 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-04-14 08:25:41 +00:00
parent c4046575a3
commit d96efd8120
4 changed files with 109 additions and 8 deletions

View File

@ -1,3 +1,14 @@
2011-04-14 Sergio Martin <sergio.martin@artica.es>
* include/graphs/functions_pchart.php
include/graphs/functions_gd.php
include/graphs/fgraph.php: Added x and y
axis name possibility to line, stacked line and
stacked area graphs.
Added dual posibility of calling to functions_gd
(thorugh url and with function call).
Clean code.
2011-04-14 Junichi Satoh <junichi@rworks.jp>
* extras/pandoradb_migrate_v3.2_to_v4.0.sql,

View File

@ -10,7 +10,6 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// If is called from index
if(file_exists('include/functions.php')) {
include_once('include/functions.php');
@ -59,6 +58,39 @@ switch($graph_type) {
break;
}
function histogram($chart_data, $width, $height, $font, $max, $title, $mode) {
$graph = array();
$graph['data'] = $chart_data;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['font'] = $font;
$graph['max'] = $max;
$graph['title'] = $title;
$graph['mode'] = $mode;
$id_graph = serialize_in_temp($graph);
return "<img src='include/graphs/functions_gd.php?graph_type=histogram&id_graph=".$id_graph."'>";
}
function progressbar($progress, $width, $height, $title, $font, $mode = 1, $out_of_lim_str = false, $out_of_lim_image = false) {
$graph = array();
$graph['progress'] = $progress;
$graph['width'] = $width;
$graph['height'] = $height;
$graph['out_of_lim_str'] = $out_of_lim_str;
$graph['out_of_lim_image'] = $out_of_lim_image;
$graph['title'] = $title;
$graph['font'] = $font;
$graph['mode'] = $mode;
$id_graph = serialize_in_temp($graph);
return "<img src='include/graphs/functions_gd.php?graph_type=progressbar&id_graph=".$id_graph."'>";
}
function slicesbar_graph($chart_data, $width, $height, $colors, $font, $round_corner) {
$graph = array();
$graph['data'] = $chart_data;
@ -126,7 +158,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
}
}
function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $long_index, $no_data_image) {
function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "") {
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
@ -145,6 +177,8 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$id_graph = serialize_in_temp($graph);
@ -152,7 +186,7 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
}
}
function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $long_index, $no_data_image) {
function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "") {
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
}
@ -170,6 +204,8 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$id_graph = serialize_in_temp($graph);
@ -177,7 +213,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
}
}
function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $long_index, $no_data_image) {
function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "") {
if (empty($chart_data)) {
return '<img src="' . $no_data_image . '" />';
}
@ -192,6 +228,8 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
$graph['height'] = $height;
$graph['color'] = $color;
$graph['legend'] = $legend;
$graph['xaxisname'] = $xaxisname;
$graph['yaxisname'] = $yaxisname;
$id_graph = serialize_in_temp($graph);

View File

@ -12,6 +12,60 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// If is called from index
if(file_exists('include/functions.php')) {
include_once('include/functions.php');
include_once('include/functions_html.php');
include_once('include/graphs/functions_utils.php');
} // If is called through url
else if(file_exists('../functions.php')) {
include_once('../functions.php');
include_once('../functions_html.php');
include_once('../functions_html.php');
include_once('functions_utils.php');
}
$id_graph = get_parameter('id_graph', false);
if($id_graph) {
if (!$id_graph) {
exit;
}
$graph = unserialize_in_temp($id_graph);
if (!isset($graph)) {
exit;
}
$graph_type = get_parameter('graph_type', '');
switch($graph_type) {
case 'histogram':
gd_histogram ($graph['width'],
$graph['height'],
$graph['mode'],
json_decode($graph['data'], true),
$graph['max'],
$graph['font'],
$graph['title']);
break;
case 'progressbar':
gd_progress_bar ($graph['width'],
$graph['height'],
$graph['progress'],
$graph['title'],
$graph['font'],
$graph['out_of_lim_str'],
$graph['out_of_lim_image'],
$graph['mode']);
break;
}
}
function gd_histogram ($width, $height, $mode, $data, $max_value, $font, $title) {
// $title is for future use
$nvalues = count($data);

View File

@ -593,12 +593,10 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
if (isset($size['Height'])) {
/* Define the chart area */
//$myPicture->setGraphArea(40,$size['Height'],$width,$height - 90);
$myPicture->setGraphArea(40,$size['Height'],$width,$height - $margin_bottom);
}
else {
/* Define the chart area */
//$myPicture->setGraphArea(40, 5,$width,$height - 90);
$myPicture->setGraphArea(40, 5,$width,$height - $margin_bottom);
}