mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-26 23:35:02 +02:00
2013-01-30 Miguel de Dios <miguel.dedios@artica.es>
* operation/agentes/estado_generalagente.php, include/functions_graph.php, include/graphs/functions_flot.php, include/graphs/fgraph.php, include/graphs/flot/pandora.flot.js: fixed the graph of events, now the pie graphs in "flot mode" has a parammeter to force the position of legend. Fixes: #3602206 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7553 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
22271cefa4
commit
b613ab5a3d
@ -1,3 +1,13 @@
|
||||
2013-01-30 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* operation/agentes/estado_generalagente.php,
|
||||
include/functions_graph.php, include/graphs/functions_flot.php,
|
||||
include/graphs/fgraph.php, include/graphs/flot/pandora.flot.js:
|
||||
fixed the graph of events, now the pie graphs in "flot mode" has
|
||||
a parammeter to force the position of legend.
|
||||
|
||||
Fixes: #3602206
|
||||
|
||||
2013-01-30 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||
|
||||
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
|
||||
|
@ -50,14 +50,16 @@ function get_graph_statistics ($chart_array) {
|
||||
//Get minimum
|
||||
if ($stats['min'] == null) {
|
||||
$stats['min'] = $item;
|
||||
} else if ($item < $stats['min']) {
|
||||
}
|
||||
else if ($item < $stats['min']) {
|
||||
$stats['min'] = $item;
|
||||
}
|
||||
|
||||
//Get maximum
|
||||
if ($stats['max'] == null) {
|
||||
$stats['max'] = $item;
|
||||
} else if ($item > $stats['max']) {
|
||||
}
|
||||
else if ($item > $stats['max']) {
|
||||
$stats['max'] = $item;
|
||||
}
|
||||
|
||||
@ -1334,14 +1336,16 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
case "postgresql":
|
||||
$sql = sprintf ('SELECT COUNT(id_evento) as count_number, nombre
|
||||
$sql = sprintf ('SELECT COUNT(id_evento) AS count_number,
|
||||
nombre
|
||||
FROM tevento, tagente_modulo
|
||||
WHERE id_agentmodule = id_agente_modulo
|
||||
AND disabled = 0 AND tevento.id_agente = %d
|
||||
GROUP BY id_agentmodule, nombre LIMIT %d', $id_agent, $max_items);
|
||||
break;
|
||||
case "oracle":
|
||||
$sql = sprintf ('SELECT COUNT(id_evento) as count_number, dbms_lob.substr(nombre,4000,1) as nombre
|
||||
$sql = sprintf ('SELECT COUNT(id_evento) AS count_number,
|
||||
dbms_lob.substr(nombre,4000,1) AS nombre
|
||||
FROM tevento, tagente_modulo
|
||||
WHERE (id_agentmodule = id_agente_modulo
|
||||
AND disabled = 0 AND tevento.id_agente = %d) AND rownum <= %d
|
||||
@ -1358,13 +1362,16 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
foreach ($events as $event) {
|
||||
$data[$event['nombre'].' ('.$event['count_number'].')'] = $event["count_number"];
|
||||
$key = io_safe_output($event['nombre']) .
|
||||
' ('.$event['count_number'].')';
|
||||
$data[$key] = $event["count_number"];
|
||||
}
|
||||
|
||||
/* System events */
|
||||
$sql = "SELECT COUNT(*) FROM tevento WHERE id_agentmodule = 0 AND id_agente = $id_agent";
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM tevento
|
||||
WHERE id_agentmodule = 0 AND id_agente = $id_agent";
|
||||
$value = db_get_sql ($sql);
|
||||
if ($value > 0) {
|
||||
$data[__('System').' ('.$value.')'] = $value;
|
||||
@ -1376,7 +1383,7 @@ function graph_event_module ($width = 300, $height = 200, $id_agent) {
|
||||
|
||||
return pie3d_graph($config['flash_charts'], $data, $width, $height, __("other"),
|
||||
'', $water_mark,
|
||||
$config['fontpath'], $config['font_size']);
|
||||
$config['fontpath'], $config['font_size'], 1, "bottom");
|
||||
}
|
||||
|
||||
function progress_bar($progress, $width, $height, $title = '', $mode = 1, $value_text = false, $color = false, $options = false) {
|
||||
|
@ -434,19 +434,22 @@ 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 = '', $font_size = '', $ttl = 1) {
|
||||
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||
$font_size = '', $ttl = 1, $legend_position = false) {
|
||||
return pie_graph('3d', $flash_chart, $chart_data, $width, $height,
|
||||
$others_str, $homedir, $water_mark, $font, $font_size, $ttl);
|
||||
$others_str, $homedir, $water_mark, $font, $font_size, $ttl, $legend_position);
|
||||
}
|
||||
|
||||
function pie2d_graph($flash_chart, $chart_data, $width, $height,
|
||||
$others_str = "other", $homedir="", $water_mark = "", $font = '', $font_size = '', $ttl = 1) {
|
||||
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||
$font_size = '', $ttl = 1, $legend_position = false) {
|
||||
return pie_graph('2d', $flash_chart, $chart_data, $width, $height,
|
||||
$others_str, $homedir, $water_mark, $font, $font_size, $ttl);
|
||||
$others_str, $homedir, $water_mark, $font, $font_size, $ttl, $legend_position);
|
||||
}
|
||||
|
||||
function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
|
||||
$others_str = "other", $homedir="", $water_mark = "", $font = '', $font_size = '', $ttl = 1) {
|
||||
$others_str = "other", $homedir="", $water_mark = "", $font = '',
|
||||
$font_size = '', $ttl = 1, $legend_position = false) {
|
||||
|
||||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||
|
||||
@ -472,9 +475,13 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height,
|
||||
}
|
||||
|
||||
if ($flash_chart) {
|
||||
return flot_pie_chart(array_values($chart_data), array_keys($chart_data), $width, $height, $water_mark_url, $font, $font_size);
|
||||
return flot_pie_chart(array_values($chart_data),
|
||||
array_keys($chart_data), $width, $height, $water_mark_url,
|
||||
$font, $font_size, $legend_position);
|
||||
}
|
||||
else {
|
||||
//TODO SET THE LEGEND POSITION
|
||||
|
||||
$graph = array();
|
||||
$graph['data'] = $chart_data;
|
||||
$graph['width'] = $width;
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
*/
|
||||
|
||||
function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, water_mark, separator) {
|
||||
function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, water_mark, separator, legend_position, height) {
|
||||
var labels = labels.split(separator);
|
||||
var data = values.split(separator);
|
||||
|
||||
@ -33,12 +33,12 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
||||
};
|
||||
}
|
||||
|
||||
var plot = $.plot($('#'+graph_id), data,
|
||||
{
|
||||
var conf_pie = {
|
||||
series: {
|
||||
pie: {
|
||||
show: true,
|
||||
radius: 3/4,
|
||||
//offset: {top: -100},
|
||||
label: label_conf
|
||||
//$label_str
|
||||
}
|
||||
@ -50,7 +50,26 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
||||
hoverable: true,
|
||||
clickable: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
switch (legend_position) {
|
||||
case 'bottom':
|
||||
if (width > height)
|
||||
offset = - (height / 5);
|
||||
else
|
||||
offset = - (width / 5);
|
||||
conf_pie.series.pie.radius = 1 / 2.5;
|
||||
conf_pie.series.pie.offset =
|
||||
conf_pie.series.pie.offset = {top: offset};
|
||||
conf_pie.legend.position = "s";
|
||||
break;
|
||||
case 'right':
|
||||
default:
|
||||
//TODO FOR TOP OR LEFT OR RIGHT
|
||||
break;
|
||||
}
|
||||
|
||||
var plot = $.plot($('#'+graph_id), data, conf_pie);
|
||||
|
||||
var legends = $('#'+graph_id+' .legendLabel');
|
||||
legends.each(function () {
|
||||
|
@ -314,7 +314,9 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
||||
///////////////////////////////
|
||||
|
||||
// Prints a FLOT pie chart
|
||||
function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font = '', $font_size = 8) {
|
||||
function flot_pie_chart ($values, $labels, $width, $height, $water_mark,
|
||||
$font = '', $font_size = 8, $legend_position = '') {
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
||||
$series = sizeof($values);
|
||||
@ -324,6 +326,16 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font =
|
||||
|
||||
$graph_id = uniqid('graph_');
|
||||
|
||||
switch ($legend_position) {
|
||||
case 'bottom':
|
||||
$height = $height + (count($values) * 24);
|
||||
break;
|
||||
case 'right':
|
||||
default:
|
||||
//TODO FOR TOP OR LEFT OR RIGHT
|
||||
break;
|
||||
}
|
||||
|
||||
$return = "<div id='$graph_id' class='graph' style='width: ".$width."px; height: ".$height."px;'></div>";
|
||||
|
||||
if($water_mark != '') {
|
||||
@ -341,7 +353,9 @@ function flot_pie_chart ($values, $labels, $width, $height, $water_mark, $font =
|
||||
|
||||
$return .= "<script type='text/javascript'>";
|
||||
|
||||
$return .= "pandoraFlotPie('$graph_id', '$values', '$labels', '$series', '$width', $font_size, $water_mark, '$separator')";
|
||||
$return .= "pandoraFlotPie('$graph_id', '$values', '$labels',
|
||||
'$series', '$width', $font_size, $water_mark,
|
||||
'$separator', '$legend_position', '$height')";
|
||||
|
||||
$return .= "</script>";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user