reconfigure charts
This commit is contained in:
parent
63e5d23288
commit
af9e11ffca
|
@ -777,6 +777,7 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||
$tmp_data["datos"] = $last_inserted_value;
|
||||
// debug purpose
|
||||
//$tmp_data["obs"] = "virtual data (raw)";
|
||||
$tmp_data["type"] = ($current_timestamp == $tstart || ($current_timestamp == $tend)?0:1); // virtual data
|
||||
|
||||
//Add order to avoid usort missorder in same utimestamp data cells
|
||||
$tmp_data["order"] = 1;
|
||||
|
@ -785,6 +786,7 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||
|
||||
$tmp_data["utimestamp"] = $current_raw_data["utimestamp"];
|
||||
$tmp_data["datos"] = $current_raw_data["datos"];
|
||||
$tmp_data["type"] = 0; // real data
|
||||
// debug purpose
|
||||
//$tmp_data["obs"] = "real data";
|
||||
//Add order to avoid usort missorder in same utimestamp data cells
|
||||
|
@ -883,7 +885,7 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||
if (count($return[$pool_id]['data']) == 0) {
|
||||
//insert first slice data
|
||||
$tmp_data["utimestamp"] = $current_timestamp;
|
||||
$tmp_data["datos"] = $last_inserted_value;
|
||||
$tmp_data["datos"] = $last_inserted_value;
|
||||
// debug purpose
|
||||
//$tmp_data["obs"] = "virtual data (empty)";
|
||||
array_push($return[$pool_id]["data"], $tmp_data);
|
||||
|
|
|
@ -915,15 +915,77 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$dashboard = false, $vconsole = false, $type_graph = 'area', $fullscale = false,
|
||||
$id_widget_dashboard = false,$force_interval = 0,$time_interval = 300,
|
||||
$max_only = 0, $min_only = 0) {
|
||||
|
||||
|
||||
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
||||
$flash_chart = $config['flash_charts'];
|
||||
|
||||
enterprise_include_once("include/functions_reporting.php");
|
||||
//XXX aqui empieza la obtencion de datos:
|
||||
//Es infernal la cantidad de parametros que se le mandan pasamos a un array para simplificar este proceso:
|
||||
|
||||
//date start final period
|
||||
$date_array = array();
|
||||
$date_array["start_date"] = $date - $period;
|
||||
$date_array["final_date"] = $date;
|
||||
$date_array["period"] = $period;
|
||||
|
||||
//show elements in the graph
|
||||
$show_elements_graph = array();
|
||||
$show_elements_graph['show_events'] = $show_events;
|
||||
$show_elements_graph['show_alerts'] = $show_alerts;
|
||||
$show_elements_graph['show_unknown'] = $show_unknown;
|
||||
$show_elements_graph['avg_only'] = $avg_only;
|
||||
$show_elements_graph['show_title'] = $show_title;
|
||||
$show_elements_graph['menu'] = $menu;
|
||||
$show_elements_graph['percentil'] = $percentil;
|
||||
$show_elements_graph['projection'] = $projection;
|
||||
$show_elements_graph['adapt_key'] = $adapt_key;
|
||||
$show_elements_graph['compare'] = $compare;
|
||||
$show_elements_graph['dashboard'] = $dashboard;
|
||||
$show_elements_graph['vconsole'] = $vconsole;
|
||||
$show_elements_graph['pure'] = $pure;
|
||||
$show_elements_graph['baseline'] = $baseline;
|
||||
$show_elements_graph['only_image'] = $only_image;
|
||||
$show_elements_graph['return_data'] = $return_data;
|
||||
$show_elements_graph['id_widget'] = $id_widget_dashboard;
|
||||
|
||||
//format of the graph
|
||||
$format_graph = array();
|
||||
$format_graph['width'] = $width;
|
||||
$format_graph['height'] = $height;
|
||||
$format_graph['type_graph'] = $type_graph;
|
||||
$format_graph['fullscale'] = $fullscale;
|
||||
$format_graph['unit_name'] = $unit_name;
|
||||
$format_graph['unit'] = $unit;
|
||||
$format_graph['title'] = $title;
|
||||
$format_graph['homeurl'] = $homeurl;
|
||||
$format_graph['ttl'] = $ttl;
|
||||
$format_graph['background'] = $backgroundColor;
|
||||
|
||||
//exception to change the interval of the graph and show media min max @enriquecd
|
||||
$exception_interval_graph['force_interval'] = $force_interval;
|
||||
$exception_interval_graph['time_interval'] = $time_interval;
|
||||
$exception_interval_graph['max_only'] = $max_only;
|
||||
$exception_interval_graph['min_only'] = $min_only;
|
||||
|
||||
/*
|
||||
html_debug_print('+++++++++++++++++Parámetros Que recibe la funcion++++++++++++++++++++++');
|
||||
html_debug_print('id_agente_modulo: ' . $agent_module_id);
|
||||
html_debug_print($date_array);
|
||||
html_debug_print($show_elements_graph);
|
||||
html_debug_print($format_graph);
|
||||
html_debug_print($exception_interval_graph);
|
||||
html_debug_print('+++++++++++++FIN Parámetros Que recibe la funcion++++++++++++++++++++++');
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enterprise_include_once("include/functions_reporting.php");
|
||||
|
||||
global $chart;
|
||||
global $color;
|
||||
global $color_prev;
|
||||
|
@ -960,7 +1022,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
case 'overlapped':
|
||||
// Store the chart calculated deleting index,
|
||||
// because will be over the current period
|
||||
$chart_prev = array_values($chart);
|
||||
$chart_prev = $chart;
|
||||
$legend_prev = $legend;
|
||||
$series_type_prev = $series_type;
|
||||
$color_prev = $color;
|
||||
|
@ -986,6 +1048,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
return $data_returned;
|
||||
}
|
||||
if ($compare === 'overlapped') {
|
||||
/*
|
||||
$i = 0;
|
||||
foreach ($chart as $k=>$v) {
|
||||
if (!isset($chart_prev[$i])) {
|
||||
|
@ -994,7 +1057,23 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$chart[$k] = array_merge($v,$chart_prev[$i]);
|
||||
$i++;
|
||||
}
|
||||
*/
|
||||
foreach ($chart_prev as $k => $v) {
|
||||
$chart[$k+$period]['sum2'] = $v['sum2'];
|
||||
//unset($chart[$k]);
|
||||
}
|
||||
|
||||
/*
|
||||
$chart["1517834070"]["sum2"] = "5";
|
||||
$chart["1517834075"]["sum2"] = "6";
|
||||
$chart["1517834080"]["sum2"] = "7";
|
||||
$chart["1517834085"]["sum2"] = "8";
|
||||
|
||||
$chart["1517834088"]["sum2"] = "3";
|
||||
*/
|
||||
ksort($chart);
|
||||
|
||||
//html_debug_print($chart);
|
||||
$legend = array_merge($legend, $legend_prev);
|
||||
$color = array_merge($color, $color_prev);
|
||||
}
|
||||
|
@ -4592,6 +4671,7 @@ function fullscale_data ( &$chart_data, &$chart_extra_data, &$long_index,
|
|||
$data_uncompress = db_uncompress_module_data($agent_module_id, $datelimit, $date);
|
||||
|
||||
$chart_data = array();
|
||||
$flag_unknown = 0;
|
||||
|
||||
$min_value = PHP_INT_MAX-1;
|
||||
$max_value = PHP_INT_MIN+1;
|
||||
|
@ -4600,10 +4680,13 @@ function fullscale_data ( &$chart_data, &$chart_extra_data, &$long_index,
|
|||
|
||||
$i=0;
|
||||
$current_event = $events[0];
|
||||
$prueba = array();
|
||||
|
||||
foreach ($data_uncompress as $k) {
|
||||
foreach ($k["data"] as $v) {
|
||||
$real_date = date("Y M d H:i:s", $v['utimestamp']);
|
||||
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
|
||||
continue;
|
||||
}
|
||||
$real_date = $v['utimestamp'];
|
||||
|
||||
if(!$flash_chart){
|
||||
$real_date = date("Y/M/d", $v['utimestamp']);
|
||||
|
@ -4614,7 +4697,7 @@ function fullscale_data ( &$chart_data, &$chart_extra_data, &$long_index,
|
|||
$event_ids = array();
|
||||
$alert_ids = array();
|
||||
while (isset($current_event) && ($v['utimestamp'] >= $current_event["utimestamp"]) ) {
|
||||
$event_date = date("Y M d H:i:s", $current_event['utimestamp']);
|
||||
$event_date = $current_event['utimestamp'];
|
||||
if(!$flash_chart){
|
||||
$event_date = date("Y/M/d", $current_event['utimestamp']);
|
||||
$event_date .= "\n";
|
||||
|
@ -4716,12 +4799,17 @@ function fullscale_data ( &$chart_data, &$chart_extra_data, &$long_index,
|
|||
$chart_data[$real_date]["unknown" . $series_suffix] = NULL;
|
||||
$previous_unknown = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
$last_data = $v["datos"];
|
||||
}
|
||||
}
|
||||
$series_type['event'.$series_suffix] = 'points';
|
||||
$series_type['alert'.$series_suffix] = 'points';
|
||||
$series_type['unknown'.$series_suffix] = 'unknown';
|
||||
|
||||
// Add missed last data
|
||||
$chart_data[$date]["sum" . $series_suffix] = $last_data;
|
||||
|
||||
if($boolean_graph){
|
||||
$series_type['sum'.$series_suffix] = 'boolean';
|
||||
}
|
||||
|
|
|
@ -880,7 +880,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
//XXX 1827
|
||||
//Translate datetime to utimestamp -> avoid convert datetime in server better...
|
||||
$.each(labels, function (i,v) {
|
||||
labels[i] = new Date(labels[i]).getTime();
|
||||
labels[i] = labels[i] * 1000;
|
||||
});
|
||||
|
||||
legend = legend.split(separator);
|
||||
|
@ -949,8 +949,8 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
switch (serie_types[i]) {
|
||||
case 'area':
|
||||
line_show = true;
|
||||
points_show = false;
|
||||
filled = true;
|
||||
points_show = false; // XXX - false
|
||||
filled = 0.2;
|
||||
steps_chart = false;
|
||||
break;
|
||||
case 'line':
|
||||
|
@ -989,20 +989,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
var normal = '#0f0';
|
||||
var warning = '#ff0';
|
||||
var critical = '#f00';
|
||||
|
||||
// setup background areas
|
||||
//vnormal_max = vwarning_min - 1;
|
||||
|
||||
var markings = null;
|
||||
|
||||
// Fill the grid background with weak threshold colors
|
||||
//~ markings = [
|
||||
//~ { color: normalw, yaxis: { from: -1,to: vnormal_max } },
|
||||
//~ { color: warningw, yaxis: { from: vwarning_min, to: vwarning_max } },
|
||||
//~ { color: criticalw, yaxis: { from: vcritical_min } },
|
||||
//~ { color: criticalw, yaxis: { to: -1 } }
|
||||
//~ ];
|
||||
|
||||
|
||||
var lineWidth = $('#hidden-line_width_graph').val() || 1;
|
||||
|
||||
// Data
|
||||
|
@ -1015,9 +1002,6 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
lines: {
|
||||
show: line_show,
|
||||
fill: filled,
|
||||
fillColor: {
|
||||
colors: [ { opacity: 0.5 }, { opacity: 1 } ]
|
||||
},
|
||||
lineWidth: lineWidth,
|
||||
steps: steps_chart
|
||||
},
|
||||
|
@ -1027,7 +1011,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
// Prepared to turn series with a checkbox
|
||||
// showed[i] = true;
|
||||
}
|
||||
console.log(data_base);
|
||||
//console.log(data_base);
|
||||
max_x = data_base[0]['data'][data_base[0]['data'].length -1][0];
|
||||
|
||||
if(min_check != 0){
|
||||
|
@ -1576,7 +1560,6 @@ console.log(data_base);
|
|||
borderWidth:1,
|
||||
borderColor: '#C1C1C1',
|
||||
tickColor: background_color,
|
||||
markings: markings,
|
||||
color: legend_color
|
||||
},
|
||||
xaxes: [{
|
||||
|
@ -1593,6 +1576,7 @@ console.log(data_base);
|
|||
axisLabelFontSizePixels: font_size,
|
||||
mode: "time",
|
||||
tickFormatter: xFormatter,
|
||||
// timeformat: "%Y/%m/%d %H:%M:%S",
|
||||
}],
|
||||
yaxes: [{
|
||||
tickFormatter: yFormatter,
|
||||
|
@ -1799,9 +1783,18 @@ console.log(data_base);
|
|||
$('#timestamp_'+graph_id).text(labels[j] + ' (' + (short_data ? parseFloat(y).toFixed(2) : parseFloat(y)) + ')');
|
||||
}
|
||||
else {
|
||||
$('#timestamp_'+graph_id).text(labels_long[j]);
|
||||
}
|
||||
var date_format = new Date(labels_long[j]*1000);
|
||||
|
||||
date_format =
|
||||
date_format.getDate() + "/" +
|
||||
(date_format.getMonth() + 1) + "/" +
|
||||
date_format.getFullYear() + "\n" +
|
||||
date_format.getHours() + ":" +
|
||||
date_format.getMinutes() + ":" +
|
||||
date_format.getSeconds();
|
||||
|
||||
$('#timestamp_'+graph_id).text(date_format);
|
||||
}
|
||||
//$('#timestamp_'+graph_id).css('top', plot.offset().top-$('#timestamp_'+graph_id).height()*1.5);
|
||||
|
||||
var timesize = $('#timestamp_'+graph_id).width();
|
||||
|
@ -1963,23 +1956,23 @@ console.log(data_base);
|
|||
var d = new Date(v);
|
||||
var result_date_format = 0;
|
||||
|
||||
if(time_format_y > 86400000){ //DAY
|
||||
// if(time_format_y > 86400000){ //DAY
|
||||
|
||||
result_date_format =
|
||||
d.getDate() + "/" +
|
||||
(d.getMonth() + 1) + "/" +
|
||||
(d.getDate() <10?'0':'') + d.getDate() + "/" +
|
||||
(d.getMonth()<9?'0':'') + (d.getMonth() + 1) + "/" +
|
||||
d.getFullYear() + "\n" +
|
||||
d.getHours() + ":" +
|
||||
d.getMinutes() + ":" +
|
||||
d.getSeconds(); //+ ":" + d.getMilliseconds();
|
||||
}
|
||||
(d.getHours()<10?'0':'') + d.getHours() + ":" +
|
||||
(d.getMinutes()<10?'0':'') + d.getMinutes() + ":" +
|
||||
(d.getSeconds()<10?'0':'') + d.getSeconds(); //+ ":" + d.getMilliseconds();
|
||||
/* }
|
||||
else{
|
||||
result_date_format =
|
||||
d.getHours() + ":" +
|
||||
d.getMinutes() + ":" +
|
||||
d.getSeconds(); //+ ":" + d.getMilliseconds();
|
||||
}
|
||||
|
||||
*/
|
||||
//extra_css = '';
|
||||
return '<div class='+font+' style="transform: rotate(-15deg); -ms-transform:rotate(-15deg); -moz-transform:rotate(-15deg); -webkit-transform:rotate(-15deg); -o-transform:rotate(-15deg); font-size:'+font_size+'pt; margin-top:15px;">'+result_date_format+'</div>';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue