fixed errors grapgh

This commit is contained in:
daniel 2018-02-21 11:54:24 +01:00
parent 25242e19d4
commit 4b654bd87d
4 changed files with 580 additions and 212 deletions

View File

@ -2792,65 +2792,123 @@ function validate_address($address){
return true;
}
function color_graph_array($series_suffix){
function color_graph_array($series_suffix, $compare = false){
global $config;
//////////////////////////////////////////////////
// Color commented not to restrict serie colors //
//////////////////////////////////////////////////
$color['event' . $series_suffix] =
array( 'border' => '#ff0000',
'color' => '#ff0000',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['alert' . $series_suffix] =
array( 'border' => '#ff7f00',
'color' => '#ff7f00',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['unknown' . $series_suffix] =
array( 'border' => '#999999',
'color' => '#999999',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['no_data'.$series_suffix] =
array( 'border' => '#000000',
'color' => '#f2c40e',
'alpha' => CHART_DEFAULT_ALPHA
if(!$compare) {
$color['event' . $series_suffix] =
array( 'border' => '#ff0000',
'color' => '#ff0000',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['max'.$series_suffix] =
array( 'border' => '#000000',
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA
);
$color['sum'.$series_suffix] =
array( 'border' => '#000000',
'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA
);
$color['min'.$series_suffix] =
array( 'border' => '#000000',
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA
$color['alert' . $series_suffix] =
array( 'border' => '#ff7f00',
'color' => '#ff7f00',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['unit'.$series_suffix] =
array( 'border' => null,
'color' => '#0097BC',
'alpha' => 10
$color['unknown' . $series_suffix] =
array( 'border' => '#999999',
'color' => '#999999',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['no_data'.$series_suffix] =
array( 'border' => '#000000',
'color' => '#f2c40e',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['max'.$series_suffix] =
array( 'border' => '#000000',
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA
);
$color['sum'.$series_suffix] =
array( 'border' => '#000000',
'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA
);
$color['min'.$series_suffix] =
array( 'border' => '#000000',
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA
);
$color['unit'.$series_suffix] =
array( 'border' => null,
'color' => '#0097BC',
'alpha' => 10
);
$color['percentil'.$series_suffix] =
array( 'border' => '#000000',
'color' => '#0097BC',
'alpha' => CHART_DEFAULT_ALPHA
);
}
else{
$color['event' . $series_suffix] =
array( 'border' => '#ff0000',
'color' => '#ff66cc',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['alert' . $series_suffix] =
array( 'border' => '#ffff00',
'color' => '#ffff00',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['unknown' . $series_suffix] =
array( 'border' => '#999999',
'color' => '#E1E1E1',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['no_data'.$series_suffix] =
array( 'border' => '#000000',
'color' => '#f2c40e',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['max'.$series_suffix] =
array( 'border' => '#000000',
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA
);
$color['sum'.$series_suffix] =
array( 'border' => '#000000',
'color' => '#99ffff',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['min'.$series_suffix] =
array( 'border' => '#000000',
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA
);
$color['unit'.$series_suffix] =
array( 'border' => null,
'color' => '#0097BC',
'alpha' => 10
);
$color['percentil'.$series_suffix] =
array( 'border' => '#000000',
'color' => '#003333',
'alpha' => CHART_DEFAULT_ALPHA
);
$color['percentil'.$series_suffix] =
array( 'border' => '#000000',
'color' => '#0097BC',
'alpha' => CHART_DEFAULT_ALPHA
);
}
return $color;
}

View File

@ -227,6 +227,125 @@ function get_statwin_graph_statistics ($chart_array, $series_suffix = '') {
return $stats;
}
function grafico_modulo_sparse_data_chart_new (
$agent_module_id,
$date_array,
$data_module_graph,
$show_elements_graph,
$format_graph,
$series_suffix
) {
global $config;
$data = db_get_all_rows_filter ('tagente_datos',
array ('id_agente_modulo' => (int)$agent_module_id,
"utimestamp > '". $date_array['start_date']. "'",
"utimestamp < '". $date_array['final_date'] . "'",
'order' => 'utimestamp ASC'),
array ('datos', 'utimestamp'), 'AND', $data_module_graph['history_db']);
// Get previous data
$previous_data = modules_get_previous_data (
$agent_module_id,
$date_array['start_date']
);
if ($previous_data !== false) {
$previous_data['utimestamp'] = $date_array['start_date'];
unset($previous_data['id_agente_modulo']);
array_unshift ($data, $previous_data);
}
// Get next data
$nextData = modules_get_next_data (
$agent_module_id,
$date_array['final_date']
);
if ($nextData !== false) {
unset($nextData['id_agente_modulo']);
array_push ($data, $nextData);
}
else if (count ($data) > 0) {
// Propagate the last known data to the end of the interval
$nextData = array(
'datos' => $data[count($data)-1]['datos'],
'utimestamp' => $date_array['final_date'],
);
array_push ($data, $nextData);
}
if ($data === false) {
$data = array ();
}
// Check available data
if (count ($data) < 1) {
//if (!$graphic_type) {
return fs_error_image ();
//}
//graphic_error ();
}
$array_data = array();
$min_value = PHP_INT_MAX-1;
$max_value = PHP_INT_MIN+1;
$array_percentil = array();
foreach ($data as $k => $v) {
//convert array
if($show_elements_graph['flag_overlapped']){
$array_data["sum" . $series_suffix]['data'][$k] = array(
($v['utimestamp'] + $date_array['period'] )* 1000,
$v['datos']
);
}
else{
$array_data["sum" . $series_suffix]['data'][$k] = array(
$v['utimestamp'] * 1000,
$v['datos']
);
}
//min
if($min_value > $v['datos']){
$min_value = $v['datos'];
}
//max
if($max_value < $v['datos']){
$max_value = $v['datos'];
}
//avg
$sum_data += $v['datos'];
$count_data++;
//percentil
if (!is_null($show_elements_graph['percentil']) && $show_elements_graph['percentil']) {
$array_percentil[] = $v['datos'];
}
}
$array_data["sum" . $series_suffix]['min'] = $min_value;
$array_data["sum" . $series_suffix]['max'] = $max_value;
$array_data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;
if (!is_null($show_elements_graph['percentil']) && $show_elements_graph['percentil'] && !$show_elements_graph['flag_overlapped']) {
$percentil_result = get_percentile($show_elements_graph['percentil'], $array_percentil);
$array_data["percentil" . $series_suffix]['data'][0] = array(
$date_array['start_date'] * 1000,
$percentil_result
);
$array_data["percentil" . $series_suffix]['data'][1] = array(
$date_array['final_date'] * 1000,
$percentil_result
);
}
return $array_data;
}
function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_index,
$data, $data_i, $previous_data, $resolution, $interval, $period, $datelimit,
$projection, $avg_only = false, $uncompressed_module = false,
@ -537,7 +656,8 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
function grafico_modulo_sparse_data_new(
$agent_module_id, $date_array,
$data_module_graph, $show_elements_graph,
$format_graph, $exception_interval_graph ) {
$format_graph, $exception_interval_graph,
$series_suffix, $str_series_suffix) {
global $config;
global $array_data;
@ -546,22 +666,30 @@ function grafico_modulo_sparse_data_new(
global $legend;
global $series_type;
$series_suffix = 1;
if($show_elements_graph['fullscale']){
$array_data = fullscale_data_new(
$agent_module_id,
$date_array,
$agent_module_id,
$date_array,
$show_elements_graph['show_unknown'],
$show_elements_graph['percentil']
$show_elements_graph['percentil'],
$series_suffix,
$str_series_suffix,
$show_elements_graph['flag_overlapped']
);
}
else{
$array_data = grafico_modulo_sparse_data_chart_new (
$agent_module_id,
$date_array,
$data_module_graph,
$show_elements_graph,
$format_graph,
$series_suffix
);
}
if($show_elements_graph['percentil']){
$percentil_value = $array_data['percentil' . $series_suffix]['data'][0][0];
$percentil_value = $array_data['percentil' . $series_suffix]['data'][0][1];
}
else{
$percentil_value = 0;
@ -574,71 +702,119 @@ function grafico_modulo_sparse_data_new(
$avg = $array_data['sum'. $series_suffix]['avg'];
}
if( $show_elements_graph['show_unknown'] &&
isset($array_data['unknown' . $series_suffix]) &&
is_array($array_data['unknown' . $series_suffix]['data']) ){
foreach ($array_data['unknown' . $series_suffix]['data'] as $key => $s_date) {
if ($s_date[1] == 1) {
$array_data['unknown' . $series_suffix]['data'][$key] = array($s_date[0], $max * 1.05);
}
}
}
if ($show_elements_graph['show_events'] ||
$show_elements_graph['show_alerts'] ) {
if(!$show_elements_graph['flag_overlapped']){
$events = db_get_all_rows_filter (
'tevento',
array ('id_agentmodule' => $agent_module_id,
"utimestamp > " . $date_array['start_date'],
"utimestamp < " . $date_array['final_date'],
'order' => 'utimestamp ASC'
),
false,
'AND',
$data_module_graph['history_db']
);
$alerts_array = array();
$events_array = array();
if($events && is_array($events)){
$i=0;
foreach ($events as $k => $v) {
if (strpos($v["event_type"], "alert") !== false){
$alerts_array['data'][$i] = array( ($v['utimestamp']*1000) , $max * 1.10);
if($show_elements_graph['fullscale']){
if( $show_elements_graph['show_unknown'] &&
isset($array_data['unknown' . $series_suffix]) &&
is_array($array_data['unknown' . $series_suffix]['data']) ){
foreach ($array_data['unknown' . $series_suffix]['data'] as $key => $s_date) {
if ($s_date[1] == 1) {
$array_data['unknown' . $series_suffix]['data'][$key] = array($s_date[0], $max * 1.05);
}
}
else{
$events_array['data'][$i] = array( ($v['utimestamp']*1000) , $max * 1.2);
}
$i++;
}
}
else{
if( $show_elements_graph['show_unknown'] ) {
$unknown_events = db_get_module_ranges_unknown(
$agent_module_id,
$date_array['start_date'],
$date_array['final_date'],
$data_module_graph['history_db']
);
if($unknown_events !== false){
foreach ($unknown_events as $key => $s_date) {
if( isset($s_date['time_from']) ){
$array_data['unknown' . $series_suffix]['data'][] = array(
($s_date['time_from'] - 1) * 1000,
0
);
$array_data['unknown' . $series_suffix]['data'][] = array(
$s_date['time_from'] * 1000,
$max * 1.05
);
}
else{
$array_data['unknown' . $series_suffix]['data'][] = array(
$date_array['start_date'] * 1000,
$max * 1.05
);
}
if( isset($s_date['time_to']) ){
$array_data['unknown' . $series_suffix]['data'][] = array(
$s_date['time_to'] * 1000,
$max * 1.05
);
$array_data['unknown' . $series_suffix]['data'][] = array(
($s_date['time_to'] + 1) * 1000,
0
);
}
else{
$array_data['unknown' . $series_suffix]['data'][] = array(
$date_array['final_date'] * 1000,
$max * 1.05
);
}
}
}
}
}
if ($show_elements_graph['show_events'] ||
$show_elements_graph['show_alerts'] ) {
$events = db_get_all_rows_filter (
'tevento',
array ('id_agentmodule' => $agent_module_id,
"utimestamp > " . $date_array['start_date'],
"utimestamp < " . $date_array['final_date'],
'order' => 'utimestamp ASC'
),
false,
'AND',
$data_module_graph['history_db']
);
/*
// Get the last event after inverval to know if graph start on unknown
$prev_event = db_get_row_filter (
'tevento',
array ('id_agentmodule' => $agent_module_id,
"utimestamp <= $datelimit",
'order' => 'utimestamp DESC'
),
false,
'AND',
$search_in_history_db
);
*/
}
$alerts_array = array();
$events_array = array();
if($show_elements_graph['show_events']){
$array_data['event' . $series_suffix] = $events_array;
}
if($events && is_array($events)){
$i=0;
foreach ($events as $k => $v) {
if (strpos($v["event_type"], "alert") !== false){
if($show_elements_graph['flag_overlapped']){
$alerts_array['data'][$i] = array( ($v['utimestamp'] + $date_array['period'] *1000) , $max * 1.10);
}
else{
$alerts_array['data'][$i] = array( ($v['utimestamp']*1000) , $max * 1.10);
}
}
else{
if($show_elements_graph['flag_overlapped']){
$events_array['data'][$i] = array( ($v['utimestamp'] + $date_array['period'] *1000) , $max * 1.2);
}
else{
$events_array['data'][$i] = array( ($v['utimestamp']*1000) , $max * 1.2);
}
}
$i++;
}
}
}
if($show_elements_graph['show_events']){
$array_data['event' . $series_suffix] = $events_array;
}
if($show_elements_graph['show_alerts']){
$array_data['alert' . $series_suffix] = $alerts_array;
if($show_elements_graph['show_alerts']){
$array_data['alert' . $series_suffix] = $alerts_array;
}
}
if ($show_elements_graph['return_data'] == 1) {
@ -658,11 +834,9 @@ function grafico_modulo_sparse_data_new(
$caption = array();
}
//XXX
//$graph_stats = get_statwin_graph_statistics($chart, $series_suffix);
$color = color_graph_array($series_suffix);
$color = color_graph_array($series_suffix, $show_elements_graph['flag_overlapped']);
foreach ($color as $k => $v) {
if(is_array($array_data[$k])){
@ -1157,23 +1331,101 @@ if($flash_chart && $entra_por){
$exception_interval_graph['max_only'] = $max_only;
$exception_interval_graph['min_only'] = $min_only;
$series_suffix =1;
$$series_suffix_str = '';
if ($show_elements_graph['compare'] !== false) {
$series_suffix = 2;
$series_suffix_str = ' (' . __('Previous') . ')';
$date_array_prev['final_date'] = $date_array['start_date'];
$date_array_prev['start_date'] = $date_array['start_date'] - $date_array['period'];
$date_array_prev['period'] = $date_array['period'];
if ($show_elements_graph['compare'] === 'overlapped') {
$show_elements_graph['flag_overlapped'] = 1;
}
else{
$show_elements_graph['flag_overlapped'] = 0;
}
grafico_modulo_sparse_data_new(
$agent_module_id, $date_array_prev,
$data_module_graph, $show_elements_graph,
$format_graph, $exception_interval_graph,
$series_suffix, $series_suffix_str
);
switch ($show_elements_graph['compare']) {
case 'separated':
case 'overlapped':
// Store the chart calculated
$array_data_prev = $array_data;
$legend_prev = $legend;
$series_type_prev = $series_type;
$color_prev = $color;
$caption_prev = $caption;
break;
}
}
$series_suffix = 1;
$series_suffix_str = '';
$show_elements_graph['flag_overlapped'] = 0;
grafico_modulo_sparse_data_new(
$agent_module_id, $date_array, $data_module_graph,
$show_elements_graph, $format_graph,
$exception_interval_graph
$agent_module_id, $date_array,
$data_module_graph, $show_elements_graph,
$format_graph, $exception_interval_graph,
$series_suffix, $str_series_suffix
);
if($show_elements_graph['compare']){
if ($show_elements_graph['compare'] === 'overlapped') {
$array_data = array_merge($array_data, $array_data_prev);
$legend = array_merge($legend, $legend_prev);
$color = array_merge($color, $color_prev);
}
}
if (empty($array_data)) {
//XXXX
return graph_nodata_image($width, $height);
return '<img src="' . $no_data_image . '" />';
}
//XXX
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
return flot_area_graph_new(
if ($show_elements_graph['compare'] === 'separated') {
return flot_area_graph_new(
$agent_module_id,
$array_data,
$color,
$legend,
$series_type,
$date_array,
$data_module_graph,
$show_elements_graph,
$format_graph,
$water_mark,
$series_suffix_str
) .
'<br>'
.
flot_area_graph_new(
$agent_module_id,
$array_data_prev,
$color,
$legend,
$series_type,
$date_array,
$data_module_graph,
$show_elements_graph,
$format_graph,
$water_mark,
$series_suffix_str
);
}
else{
return flot_area_graph_new(
$agent_module_id,
$array_data,
$color,
@ -1186,7 +1438,7 @@ if($flash_chart && $entra_por){
$water_mark,
$series_suffix_str
);
}
die();
}
@ -4898,8 +5150,10 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
function fullscale_data_new (
$agent_module_id, $date_array,
$show_unknown = 0, $show_percentil = 0 ){
$show_unknown = 0, $show_percentil = 0,
$series_suffix, $str_series_suffix = '',
$compare = false){
global $config;
$data_uncompress =
db_uncompress_module_data(
@ -4910,7 +5164,6 @@ function fullscale_data_new (
$data = array();
$previous_data = 0;
$series_suffix = 1;
$min_value = PHP_INT_MAX-1;
$max_value = PHP_INT_MIN+1;
$flag_unknown = 0;
@ -4920,17 +5173,24 @@ function fullscale_data_new (
if (isset($v["type"]) && $v["type"] == 1) { # skip unnecesary virtual data
continue;
}
$real_date = $v['utimestamp'] * 1000; // * 1000 need js utimestam mlsecond
if($compare){ // * 1000 need js utimestam mlsecond
$real_date = ($v['utimestamp'] + $date_array['period']) * 1000;
}
else{
$real_date = $v['utimestamp'] * 1000;
}
if ($v["datos"] === NULL) {
// Unknown
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
}
else{
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
$flag_unknown = 1;
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
}
else{
$data["unknown" . $series_suffix]['data'][] = array( ($real_date - 1) , 0);
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
$flag_unknown = 1;
}
}
$data["sum" . $series_suffix]['data'][] = array($real_date , $previous_data);
@ -4946,9 +5206,11 @@ function fullscale_data_new (
//normal
$previous_data = $v["datos"];
$data["sum" . $series_suffix]['data'][] = array($real_date , $v["datos"]);
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
$flag_unknown = 0;
if(!$compare){
if($flag_unknown){
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
$flag_unknown = 0;
}
}
}
@ -4967,7 +5229,7 @@ function fullscale_data_new (
//avg count
$count_data++;
if($show_percentil){
if($show_percentil && !$compare){
$array_percentil[] = $v["datos"];
}
@ -4975,13 +5237,25 @@ function fullscale_data_new (
}
}
if($show_percentil){
if($show_percentil && !$compare){
$percentil_result = get_percentile($show_percentil, $array_percentil);
$data["percentil" . $series_suffix]['data'][] = array($date_array['start_date'] * 1000 , $percentil_result);
$data["percentil" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $percentil_result);
if($compare){
$data["percentil" . $series_suffix]['data'][] = array( ($date_array['start_date'] + $date_array['period']) * 1000 , $percentil_result);
$data["percentil" . $series_suffix]['data'][] = array( ($date_array['final_date'] + $date_array['period']) * 1000 , $percentil_result);
}
else{
$data["percentil" . $series_suffix]['data'][] = array($date_array['start_date'] * 1000 , $percentil_result);
$data["percentil" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $percentil_result);
}
}
// Add missed last data
$data["sum" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $last_data);
if($compare){
$data["sum" . $series_suffix]['data'][] = array( ($date_array['final_date'] + $date_array['period']) * 1000 , $last_data);
}
else{
$data["sum" . $series_suffix]['data'][] = array($date_array['final_date'] * 1000 , $last_data);
}
$data["sum" . $series_suffix]['min'] = $min_value;
$data["sum" . $series_suffix]['max'] = $max_value;
$data["sum" . $series_suffix]['avg'] = $sum_data/$count_data;

View File

@ -869,6 +869,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
yellow_up, red_up, yellow_inverse, red_inverse,
series_suffix_str, dashboard, vconsole, xaxisname,background_color,legend_color,
short_data) {
console.log(legend_events);
var threshold = true;
var thresholded = false;
@ -2282,6 +2283,7 @@ function axis_thresholded (threshold_data, y_min, y_max, red_threshold, extremes
normal_down: 0,
down: null
};
// Resize the y axis to display all intervals
$.each(threshold_data, function() {
if (/_up/.test(this.id)){
@ -2322,14 +2324,12 @@ function axis_thresholded (threshold_data, y_min, y_max, red_threshold, extremes
? yaxis_resize['up'] + margin_up_or_down
: y_min;
}
return y;
}
function add_threshold (data_base, threshold_data, y_min, y_max,
red_threshold, extremes, red_up) {
var datas = new Array ();
$.each(data_base, function() {
// Prepared to turning series
//if(showed[this.id.split('_')[1]]) {
@ -2370,9 +2370,7 @@ function add_threshold (data_base, threshold_data, y_min, y_max,
}
datas.push(this);
});
return datas;
}
function reduceText (text, maxLength) {
@ -2382,8 +2380,6 @@ function reduceText (text, maxLength) {
return str_cut + '...' + text.substr(-firstSlideEnd - 3);
}
function pandoraFlotAreaNew(
graph_id, values, legend, agent_module_id,
series_type, watermark, date_array,
@ -2391,23 +2387,10 @@ function pandoraFlotAreaNew(
format_graph, force_integer, series_suffix_str,
background_color, legend_color, short_data
) {
var threshold = true;
var thresholded = false;
if(format_graph.unit){
var unit = format_graph.unit;
}
else{
var unit = '';
}
//XXXX
var type = 'area_simple';
var xaxisname = 'xaxisname';
var labels_long = '';
var min_check = 0;
var water_mark = '';
console.log(series_suffix_str);
console.log('asdasdasdas');
//vars
var unit = format_graph.unit ? format_graph.unit : '';
var homeurl = format_graph.homeurl;
var font_size = format_graph.font_size;
var font = format_graph.font;
@ -2416,6 +2399,27 @@ function pandoraFlotAreaNew(
var vconsole = show_elements_graph.vconsole;
var dashboard = show_elements_graph.dashboard;
var menu = show_elements_graph.menu;
var max_x = date_array['final_date'] *1000;
//for threshold
var threshold = true;
var thresholded = false;
var yellow_threshold = parseFloat (data_module_graph.w_min);
var red_threshold = parseFloat (data_module_graph.c_min);
var yellow_up = parseFloat (data_module_graph.w_max);
var red_up = parseFloat (data_module_graph.c_max);
var yellow_inverse = parseInt(data_module_graph.w_inv);
var red_inverse = parseInt(data_module_graph.c_inv);
//XXXX
var type = 'area_simple';
var xaxisname = 'xaxisname';
var labels_long = '';
var min_check = 0;
var water_mark = '';
var legend_events = null;
var legend_alerts = null;
switch (type) {
case 'line_simple':
@ -2474,7 +2478,7 @@ function pandoraFlotAreaNew(
data_base.push({
id: 'serie_' + i,
data: value.data,
label: index,
label: index + series_suffix_str,
color: value.color,
lines: {
show: line_show,
@ -2487,17 +2491,7 @@ function pandoraFlotAreaNew(
i++;
}
});
max_x = date_array['final_date'] *1000;
console.log(max_x);
var yellow_threshold = parseFloat (data_module_graph.w_min);
var red_threshold = parseFloat (data_module_graph.c_min);
var yellow_up = parseFloat (data_module_graph.w_max);
var red_up = parseFloat (data_module_graph.c_max);
var yellow_inverse = data_module_graph.w_inv;
var red_inverse = data_module_graph.c_inv;
console.log(series_suffix_str);
// If threshold and up are the same, that critical or warning is disabled
if (yellow_threshold == yellow_up){
yellow_inverse = false;
@ -2526,7 +2520,6 @@ function pandoraFlotAreaNew(
if (threshold) {
// Warning interval. Change extremes depends on critical interval
if (yellow_inverse && red_inverse) {
console.log('entra');
if (red_only_min && yellow_only_min) {
// C: |-------- |
// W: |········==== |
@ -3032,7 +3025,8 @@ function pandoraFlotAreaNew(
if (unit != "") {
xaxisname = xaxisname + " (" + unit + ")"
}
var maxticks = date_array['period'] / 3600 /6;
var options = {
series: {
stack: stacked,
@ -3056,7 +3050,9 @@ function pandoraFlotAreaNew(
xaxes: [{
axisLabelFontSizePixels: font_size,
mode: "time",
tickFormatter: xFormatter
tickFormatter: xFormatter,
tickSize: [maxticks, 'hour'],
labelWidth: 70
}],
yaxes: [{
tickFormatter: yFormatter,
@ -3149,22 +3145,54 @@ function pandoraFlotAreaNew(
factor = dataInSelection / dataInPlot;
new_steps = parseInt(factor * steps);
plot = $.plot($('#' + graph_id), data_base,
$.extend(true, {}, options, {
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to},
xaxes: [ {
tickFormatter: xFormatter,
color: ''
} ],
legend: { show: true }
}));
var maxticks_zoom = dataInSelection / 3600000 / 6;
flag_caca = 0;
if(maxticks_zoom < 0.005){
flag_caca = 1;
maxticks_zoom = dataInSelection / 60000 / 6;
if(maxticks_zoom < 0.005){
maxticks_zoom = 1;
}
}
console.log(maxticks_zoom);
if(flag_caca == 0){
plot = $.plot($('#' + graph_id), data_base,
$.extend(true, {}, options, {
grid: { borderWidth: 1, hoverable: true, autoHighlight: false},
xaxis: { min: ranges.xaxis.from,
max: ranges.xaxis.to
},
xaxes: [ {
mode: "time",
tickFormatter: xFormatter,
tickSize: [maxticks_zoom, 'hour']
} ],
legend: { show: true }
}));
}
else{
plot = $.plot($('#' + graph_id), data_base,
$.extend(true, {}, options, {
grid: { borderWidth: 1, hoverable: true, autoHighlight: false},
xaxis: { min: ranges.xaxis.from,
max: ranges.xaxis.to
},
xaxes: [ {
mode: "time",
tickFormatter: xFormatter,
tickSize: [maxticks_zoom, 'minute']
} ],
legend: { show: true }
}));
}
if (thresholded) {
var zoom_data_threshold = new Array ();
var y_recal = axis_thresholded(threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max,
red_threshold, extremes, red_up);
plot = $.plot($('#' + graph_id), data_base,
$.extend(true, {}, options, {
yaxis: {
@ -3299,7 +3327,7 @@ function pandoraFlotAreaNew(
$('#timestamp_'+graph_id).hide();
}
var label_aux = series.label;
var label_aux = series.label + series_suffix_str;
// The graphs of points type and unknown graphs will dont be updated
@ -3393,7 +3421,7 @@ function pandoraFlotAreaNew(
dataset = plot.getData();
for (i = 0; i < dataset.length; ++i) {
var series = dataset[i];
var label_aux = series.label;
var label_aux = series.label + series_suffix_str;
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).html(label_aux);
}
@ -3429,10 +3457,17 @@ function pandoraFlotAreaNew(
var result_date_format = 0;
// if(time_format_y > 86400000){ //DAY
var monthNames = [
"Jan", "Feb", "Mar",
"Apr", "May", "Jun",
"Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"
];
result_date_format =
(d.getDate() <10?'0':'') + d.getDate() + "/" +
(d.getMonth()<9?'0':'') + (d.getMonth() + 1) + "/" +
(d.getDate() <10?'0':'') + d.getDate() + " " +
//(d.getMonth()<9?'0':'') + (d.getMonth() + 1) + "/" +
monthNames[d.getMonth()] + " " +
d.getFullYear() + "\n" +
(d.getHours()<10?'0':'') + d.getHours() + ":" +
(d.getMinutes()<10?'0':'') + d.getMinutes() + ":" +
@ -3446,7 +3481,7 @@ function pandoraFlotAreaNew(
}
*/
//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>';
return '<div class='+font+' style="font-size:'+font_size+'pt; margin-top:15px;">'+result_date_format+'</div>';
}
function yFormatter(v, axis) {
@ -3462,6 +3497,7 @@ function pandoraFlotAreaNew(
}
function lFormatter(v, item) {
console.log(v);
return '<div style="font-size:'+font_size+'pt;">'+v+'</div>';
// Prepared to turn series with a checkbox
//return '<div style=color:;font-size:'+font_size+'pt><input type="checkbox" id="' + graph_id + '_' + item.id +'" checked="checked" class="check_serie_'+graph_id+'">'+v+'</div>';
@ -3522,17 +3558,17 @@ function pandoraFlotAreaNew(
red_threshold, extremes, red_up);
plot = $.plot($('#' + graph_id), data_base,
$.extend(true, {}, options, {
yaxis: {
max: y_recal.max,
min: y_recal.min
},
xaxis: {
mode:"time",
min: plot.getAxes().xaxis.min,
max: plot.getAxes().xaxis.max
}
}));
$.extend(true, {}, options, {
yaxis: {
max: y_recal.max,
min: y_recal.min
},
xaxis: {
//mode:"time",
//min: plot.getAxes().xaxis.min,
//max: plot.getAxes().xaxis.max
}
}));
datas = add_threshold (data_base, threshold_data, plot.getAxes().yaxis.min, plot.getAxes().yaxis.max,
red_threshold, extremes, red_up);

View File

@ -586,7 +586,7 @@ function flot_area_graph_new (
html_debug_print($water_mark);
html_debug_print($series_suffix_str);
*/
//html_debug_print($series_suffix_str);
$background_style = '';
switch ($format_graph['background']) {
default: