2011-04-14 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_graph.php: added function "graph_custom_sql_graph2". * include/graphs/fgraph.php: added as $homedir parameter in some functions. * include/functions_reporting.php: changed to new engine. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4226 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
dd4ad732e7
commit
5bb3cbc7c6
|
@ -1,3 +1,11 @@
|
||||||
|
2011-04-14 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_graph.php: added function "graph_custom_sql_graph2".
|
||||||
|
|
||||||
|
* include/graphs/fgraph.php: added as $homedir parameter in some functions.
|
||||||
|
|
||||||
|
* include/functions_reporting.php: changed to new engine.
|
||||||
|
|
||||||
2011-04-14 Sergio Martin <sergio.martin@artica.es>
|
2011-04-14 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* include/graphs/functions_pchart.php
|
* include/graphs/functions_pchart.php
|
||||||
|
|
|
@ -1223,4 +1223,66 @@ function grafico_eventos_usuario2 ($width, $height) {
|
||||||
|
|
||||||
return pie3d_graph($config['flash_charts'], $data, $width, $height);
|
return pie3d_graph($config['flash_charts'], $data, $width, $height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a custom SQL-defined graph
|
||||||
|
*
|
||||||
|
* @param integer ID of report content, used to get SQL code to get information for graph
|
||||||
|
* @param integer height graph height
|
||||||
|
* @param integer width graph width
|
||||||
|
* @param integer Graph type 1 vbar, 2 hbar, 3 pie
|
||||||
|
*/
|
||||||
|
function graph_custom_sql_graph2 ($id, $width, $height, $type = 'sql_graph_vbar', $only_image = false, $homedir) {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$report_content = get_db_row ('treport_content', 'id_rc', $id);
|
||||||
|
if ($report_content["external_source"] != ""){
|
||||||
|
$sql = safe_output ($report_content["external_source"]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sql = get_db_row('treport_custom_sql', 'id', $report_content["treport_custom_sql_id"]);
|
||||||
|
$sql = safe_output($sql['sql']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data_result = get_db_all_rows_sql ($sql);
|
||||||
|
|
||||||
|
if ($data_result === false)
|
||||||
|
$data_result = array ();
|
||||||
|
|
||||||
|
$data = array ();
|
||||||
|
|
||||||
|
$count = 0;
|
||||||
|
foreach ($data_result as $data_item) {
|
||||||
|
$count++;
|
||||||
|
switch ($type) {
|
||||||
|
case 'sql_graph_vbar': // vertical bar
|
||||||
|
$data[$data_item["label"]]['g'] = $data_item["value"];
|
||||||
|
break;
|
||||||
|
case 'sql_graph_hbar': // horizontal bar
|
||||||
|
$data[$data_item["label"]]['g'] = $data_item["value"];
|
||||||
|
break;
|
||||||
|
case 'sql_graph_pie': // Pie
|
||||||
|
$data[$data_item["label"]] = $data_item["value"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$flash_charts = $config['flash_charts'];
|
||||||
|
|
||||||
|
if ($only_image) {
|
||||||
|
$flash_charts = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case 'sql_graph_vbar': // vertical bar
|
||||||
|
return hbar_graph($flash_charts, $data, $width, $height, array(), array(), "", "", false, $homedir);
|
||||||
|
break;
|
||||||
|
case 'sql_graph_hbar': // horizontal bar
|
||||||
|
return vbar_graph($flash_charts, $data, $width, $height, array(), array(), "", "", $homedir);
|
||||||
|
break;
|
||||||
|
case 'sql_graph_pie': // Pie
|
||||||
|
return pie3d_graph($flash_charts, $data, $width, $height, __("other"), $homedir);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -2423,8 +2423,8 @@ function render_report_html_item ($content, $table, $report, $mini = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array ();
|
$data = array ();
|
||||||
|
|
||||||
$data[0] = '<img src="include/fgraph.php?tipo='.$content["type"].'&report_id='.$content["id_rc"].'&width='.$sizgraph_w.'&pure=1" border="0" alt="">';
|
$data[0] = graph_custom_sql_graph2($content["id_rc"], $sizgraph_w, 200, $content["type"], true);
|
||||||
|
|
||||||
array_push($table->data, $data);
|
array_push($table->data, $data);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
|
||||||
// If is called from index
|
// If is called from index
|
||||||
if(file_exists('include/functions.php')) {
|
if(file_exists('include/functions.php')) {
|
||||||
include_once('include/functions.php');
|
include_once('include/functions.php');
|
||||||
|
@ -105,7 +106,8 @@ function slicesbar_graph($chart_data, $width, $height, $colors, $font, $round_co
|
||||||
return "<img src='include/graphs/functions_pchart.php?graph_type=slicebar&id_graph=".$id_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 = "", $homedir="") {
|
||||||
if($flash_chart) {
|
if($flash_chart) {
|
||||||
echo fs_2d_column_chart ($chart_data, $width, $height);
|
echo fs_2d_column_chart ($chart_data, $width, $height);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +123,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
|
||||||
|
|
||||||
$id_graph = serialize_in_temp($graph);
|
$id_graph = serialize_in_temp($graph);
|
||||||
|
|
||||||
echo "<img src='include/graphs/functions_pchart.php?graph_type=vbar&id_graph=".$id_graph."'>";
|
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?graph_type=vbar&id_graph=".$id_graph."'>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +262,8 @@ 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);
|
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 = "", $force_height = true) {
|
function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array(),
|
||||||
|
$legend = array(), $xaxisname = "", $yaxisname = "", $force_height = true, $homedir="") {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -277,19 +280,19 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
|
||||||
|
|
||||||
$id_graph = serialize_in_temp($graph);
|
$id_graph = serialize_in_temp($graph);
|
||||||
|
|
||||||
echo "<img src='include/graphs/functions_pchart.php?graph_type=hbar&id_graph=".$id_graph."'>";
|
return "<img src='".$homedir."include/graphs/functions_pchart.php?graph_type=hbar&id_graph=".$id_graph."'>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pie3d_graph($flash_chart, $chart_data, $width, $height, $others_str = "other") {
|
function pie3d_graph($flash_chart, $chart_data, $width, $height, $others_str = "other", $homedir="") {
|
||||||
return pie_graph('3d', $flash_chart, $chart_data, $width, $height, $others_str);
|
return pie_graph('3d', $flash_chart, $chart_data, $width, $height, $others_str, $homedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pie2d_graph($flash_chart, $chart_data, $width, $height, $others_str = "other") {
|
function pie2d_graph($flash_chart, $chart_data, $width, $height, $others_str = "other", $homedir="") {
|
||||||
return pie_graph('2d', $flash_chart, $chart_data, $width, $height, $others_str);
|
return pie_graph('2d', $flash_chart, $chart_data, $width, $height, $others_str, $homedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height, $others_str) {
|
function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height, $others_str = "other", $homedir="") {
|
||||||
// This library allows only 8 colors
|
// This library allows only 8 colors
|
||||||
$max_values = 8;
|
$max_values = 8;
|
||||||
|
|
||||||
|
@ -331,10 +334,10 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height, $oth
|
||||||
|
|
||||||
switch($graph_type) {
|
switch($graph_type) {
|
||||||
case "2d":
|
case "2d":
|
||||||
return "<img src='include/graphs/functions_pchart.php?graph_type=pie2d&id_graph=".$id_graph."'>";
|
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?graph_type=pie2d&id_graph=".$id_graph."'>";
|
||||||
break;
|
break;
|
||||||
case "3d":
|
case "3d":
|
||||||
return "<img src='include/graphs/functions_pchart.php?graph_type=pie3d&id_graph=".$id_graph."'>";
|
return "<img src='" . $homedir . "include/graphs/functions_pchart.php?graph_type=pie3d&id_graph=".$id_graph."'>";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue