2012-03-08 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php include/graphs/functions_flot.php include/graphs/flot/pandora.flot.js include/graphs/fgraph.php operation/agentes/stat_win.php: Fixed some graph bugs, change the string graph from bars to area and added formatting to xAxis of area graphs git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5725 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
3393dbeddb
commit
9a15d57273
|
@ -1,3 +1,13 @@
|
||||||
|
2012-03-08 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* include/functions_graph.php
|
||||||
|
include/graphs/functions_flot.php
|
||||||
|
include/graphs/flot/pandora.flot.js
|
||||||
|
include/graphs/fgraph.php
|
||||||
|
operation/agentes/stat_win.php: Fixed some graph bugs, change the
|
||||||
|
string graph from bars to area and added formatting to xAxis of
|
||||||
|
area graphs
|
||||||
|
|
||||||
2012-03-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
2012-03-08 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||||
|
|
||||||
* godmode/agentes/module_manager.php
|
* godmode/agentes/module_manager.php
|
||||||
|
|
|
@ -2412,11 +2412,11 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
||||||
|
|
||||||
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
||||||
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
|
'url' => $config['homeurl'] . "/images/logo_vertical_water.png");
|
||||||
|
|
||||||
return vbar_graph($flash_chart, $chart, $width, $height, $color,
|
return area_graph($flash_chart, $chart, $width, $height, $color,
|
||||||
$legend, "", $unit, $homeurl,
|
$legend, array(), '', "", $unit, $homeurl,
|
||||||
$water_mark,
|
$water_mark,
|
||||||
$config['fontpath'], $config['font_size'], true, 1, true, $adapt_key);
|
$config['fontpath'], $config['font_size'], $unit, 1, array(), array(), 0, 0, $adapt_key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
|
function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event,
|
||||||
|
|
|
@ -223,7 +223,7 @@ function threshold_graph($flash_chart, $chart_data, $width, $height, $ttl = 1) {
|
||||||
function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
||||||
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homeurl="",
|
$long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homeurl="",
|
||||||
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $series_type = array(),
|
$water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $series_type = array(),
|
||||||
$chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key = '') {
|
$chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key = '', $force_integer = false) {
|
||||||
|
|
||||||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
|
||||||
}
|
}
|
||||||
|
|
||||||
if($flash_chart) {
|
if($flash_chart) {
|
||||||
return flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $series_type, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key);
|
return flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $series_type, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key, $force_integer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$graph = array();
|
$graph = array();
|
||||||
|
|
|
@ -56,6 +56,7 @@ function pandoraFlotPie(graph_id, values, labels, nseries, width, font_size, wat
|
||||||
legends.each(function () {
|
legends.each(function () {
|
||||||
// fix the widths so they don't jump around
|
// fix the widths so they don't jump around
|
||||||
$(this).css('width', $(this).width()+5);
|
$(this).css('width', $(this).width()+5);
|
||||||
|
$(this).css('font-size', font_size+'pt');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
|
@ -249,8 +250,6 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
|
||||||
series: {
|
series: {
|
||||||
shadowSize: 0.1
|
shadowSize: 0.1
|
||||||
},
|
},
|
||||||
crosshair: { mode: 'xy' },
|
|
||||||
selection: { mode: 'x', color: '#777' },
|
|
||||||
grid: {
|
grid: {
|
||||||
hoverable: true,
|
hoverable: true,
|
||||||
clickable: true,
|
clickable: true,
|
||||||
|
@ -436,14 +435,14 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
||||||
function xFormatter(v, axis) {
|
function xFormatter(v, axis) {
|
||||||
for(i = 0; i < acumulate_data.length; i++) {
|
for(i = 0; i < acumulate_data.length; i++) {
|
||||||
if(acumulate_data[i] == v) {
|
if(acumulate_data[i] == v) {
|
||||||
return '<span style=\'font-size: 7pt\'>' + legend[i] + '</span>';
|
return '<span style=\'font-size: 6pt\'>' + legend[i] + '</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors, type, serie_types, water_mark, width, max_x, homeurl, unit, font_size, menu, events, event_ids, legend_events, alerts, alert_ids, legend_alerts, yellow_threshold, red_threshold, separator, separator2) {
|
function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors, type, serie_types, water_mark, width, max_x, homeurl, unit, font_size, menu, events, event_ids, legend_events, alerts, alert_ids, legend_alerts, yellow_threshold, red_threshold, force_integer, separator, separator2) {
|
||||||
|
|
||||||
var threshold = true;
|
var threshold = true;
|
||||||
var thresholded = false;
|
var thresholded = false;
|
||||||
|
@ -735,7 +734,8 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
||||||
|
|
||||||
if(currentRanges == null || (currentRanges.xaxis.from < j && j < currentRanges.xaxis.to)) {
|
if(currentRanges == null || (currentRanges.xaxis.from < j && j < currentRanges.xaxis.to)) {
|
||||||
$('#timestamp_'+graph_id).show();
|
$('#timestamp_'+graph_id).show();
|
||||||
if(width < 400) {
|
// If no legend, the timestamp labels are short and with value
|
||||||
|
if(legends.length == 0) {
|
||||||
$('#timestamp_'+graph_id).text(labels[j] + ' (' + parseFloat(y).toFixed(2) + ')');
|
$('#timestamp_'+graph_id).text(labels[j] + ' (' + parseFloat(y).toFixed(2) + ')');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -870,7 +870,9 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
||||||
}
|
}
|
||||||
|
|
||||||
function yFormatter(v, axis) {
|
function yFormatter(v, axis) {
|
||||||
return '<div style=font-size:'+font_size+'pt>'+v+' '+unit+'</div>';
|
var formatted = number_format(v,force_integer,unit);
|
||||||
|
|
||||||
|
return '<div style=font-size:'+font_size+'pt>'+formatted+'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function lFormatter(v, item) {
|
function lFormatter(v, item) {
|
||||||
|
@ -915,6 +917,8 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
||||||
});
|
});
|
||||||
|
|
||||||
plot = $.plot($('#'+graph_id), datas, options);
|
plot = $.plot($('#'+graph_id), datas, options);
|
||||||
|
|
||||||
|
plot.setSelection(currentRanges);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#menu_cancelzoom_'+graph_id).click(function() {
|
$('#menu_cancelzoom_'+graph_id).click(function() {
|
||||||
|
@ -927,6 +931,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, colors,
|
||||||
|
|
||||||
$('#menu_cancelzoom_'+graph_id).attr('src',homeurl+'/images/zoom_cross.disabled.png');
|
$('#menu_cancelzoom_'+graph_id).attr('src',homeurl+'/images/zoom_cross.disabled.png');
|
||||||
overview.clearSelection();
|
overview.clearSelection();
|
||||||
|
currentRanges = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Adjust the menu image on top of the plot
|
// Adjust the menu image on top of the plot
|
||||||
|
@ -1039,3 +1044,30 @@ function check_adaptions(graph_id) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function number_format(number, force_integer, unit) {
|
||||||
|
if(force_integer) {
|
||||||
|
if(Math.round(number) != number) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var decimals = 2;
|
||||||
|
var factor = 10 * decimals;
|
||||||
|
number = Math.round(number*factor)/factor
|
||||||
|
}
|
||||||
|
|
||||||
|
var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||||
|
var pos = 0;
|
||||||
|
while(1){
|
||||||
|
if (number >= 1000) { //as long as the number can be divided by 1000
|
||||||
|
pos++; //Position in array starting with 0
|
||||||
|
number = number / 1000;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return number+' '+shorts[pos]+unit;
|
||||||
|
}
|
||||||
|
|
|
@ -77,31 +77,31 @@ function include_javascript_dependencies_flot_graph($return = false) {
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
////////// AREA GRAPHS ////////
|
////////// AREA GRAPHS ////////
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
function flot_area_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '') {
|
function flot_area_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '', $force_integer = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_stacked', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key);
|
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_stacked', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key, $force_integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '') {
|
function flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '', $force_integer = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_simple', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key);
|
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_simple', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key, $force_integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '') {
|
function flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '', $force_integer = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'line_stacked', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key);
|
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'line_stacked', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key, $force_integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flot_line_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '') {
|
function flot_line_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '', $water_mark = '', $serie_types = array(), $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '', $force_integer = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'line_simple', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key);
|
return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'line_simple', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key, $force_integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $type, $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key) {
|
function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $type, $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key, $force_integer) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
include_javascript_dependencies_flot_graph();
|
include_javascript_dependencies_flot_graph();
|
||||||
|
@ -274,10 +274,18 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in
|
||||||
$serie_types = implode($separator, $serie_types2);
|
$serie_types = implode($separator, $serie_types2);
|
||||||
$colors = implode($separator, $colors);
|
$colors = implode($separator, $colors);
|
||||||
|
|
||||||
|
// transform into string to pass to javascript
|
||||||
|
if($force_integer) {
|
||||||
|
$force_integer = 'true';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$force_integer = 'false';
|
||||||
|
}
|
||||||
|
|
||||||
// Javascript code
|
// Javascript code
|
||||||
$return .= "<script type='text/javascript'>";
|
$return .= "<script type='text/javascript'>";
|
||||||
$return .= "//<![CDATA[\n";
|
$return .= "//<![CDATA[\n";
|
||||||
$return .= "pandoraFlotArea('$graph_id', '$values', '$labels', '$labels_long', '$legend', '$colors', '$type', '$serie_types', $watermark, $width, $max_x, '".$config['homeurl']."', '$unit', $font_size, $menu, '$events', '$event_ids', '$legend_events', '$alerts', '$alert_ids', '$legend_alerts', '$yellow_threshold', '$red_threshold', '$separator', '$separator2');";
|
$return .= "pandoraFlotArea('$graph_id', '$values', '$labels', '$labels_long', '$legend', '$colors', '$type', '$serie_types', $watermark, $width, $max_x, '".$config['homeurl']."', '$unit', $font_size, $menu, '$events', '$event_ids', '$legend_events', '$alerts', '$alert_ids', '$legend_alerts', '$yellow_threshold', '$red_threshold', $force_integer, '$separator', '$separator2');";
|
||||||
$return .= "\n//]]>";
|
$return .= "\n//]]>";
|
||||||
$return .= "</script>";
|
$return .= "</script>";
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ if ($refresh > 0) {
|
||||||
<script type='text/javascript' src='../../include/javascript/x_core.js'></script>
|
<script type='text/javascript' src='../../include/javascript/x_core.js'></script>
|
||||||
<script type='text/javascript' src='../../include/javascript/x_event.js'></script>
|
<script type='text/javascript' src='../../include/javascript/x_event.js'></script>
|
||||||
<script type='text/javascript' src='../../include/javascript/x_slide.js'></script>
|
<script type='text/javascript' src='../../include/javascript/x_slide.js'></script>
|
||||||
<script type='text/javascript' src='../../include/javascript/jquery-1.7.1.min.js'></script>
|
<script type='text/javascript' src='../../include/javascript/jquery-1.7.1.js'></script>
|
||||||
<script type='text/javascript'><!--
|
<script type='text/javascript'><!--
|
||||||
var defOffset = 2;
|
var defOffset = 2;
|
||||||
var defSlideTime = 220;
|
var defSlideTime = 220;
|
||||||
|
@ -162,7 +162,7 @@ $urlImage .= $_SERVER['SERVER_NAME'] . $config['homeurl'] . '/';
|
||||||
//
|
//
|
||||||
echo "<br>";
|
echo "<br>";
|
||||||
|
|
||||||
echo "<div style='margin-left:20px'>";
|
echo "<div style='margin-left:30px'>";
|
||||||
|
|
||||||
switch ($graph_type) {
|
switch ($graph_type) {
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
|
|
Loading…
Reference in New Issue