mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
fixed errors
This commit is contained in:
parent
eb7cdc7c90
commit
f85a8b513a
@ -2824,183 +2824,165 @@ function validate_address($address){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function color_graph_array($series_suffix, $compare = false){
|
function color_graph_array(){
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
|
||||||
// Color commented not to restrict serie colors //
|
|
||||||
//////////////////////////////////////////////////
|
|
||||||
$color_series = array();
|
$color_series = array();
|
||||||
|
|
||||||
$color_series[0] = array(
|
$color_series[0] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => $config['graph_color1'],
|
'color' => $config['graph_color1'],
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//XXX Hablar con Sancho del tema de los slices
|
||||||
|
/*
|
||||||
|
$color_series[1] = array(
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color2'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
$color_series[2] = array(
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color3'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
$color_series[1] = array(
|
$color_series[1] = array(
|
||||||
'border' => '#000000',
|
|
||||||
'color' => $config['graph_color2'],
|
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
|
||||||
);
|
|
||||||
$color_series[2] = array(
|
|
||||||
'border' => '#000000',
|
|
||||||
'color' => $config['graph_color3'],
|
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
|
||||||
);
|
|
||||||
$color_series[3] = array(
|
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => $config['graph_color4'],
|
'color' => $config['graph_color4'],
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[4] = array(
|
$color_series[2] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => $config['graph_color5'],
|
'color' => $config['graph_color5'],
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[5] = array(
|
$color_series[3] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => $config['graph_color6'],
|
'color' => $config['graph_color6'],
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[6] = array(
|
$color_series[4] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => $config['graph_color7'],
|
'color' => $config['graph_color7'],
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[7] = array(
|
$color_series[5] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => $config['graph_color8'],
|
'color' => $config['graph_color8'],
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[8] = array(
|
$color_series[6] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => $config['graph_color9'],
|
'color' => $config['graph_color9'],
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[9] = array(
|
$color_series[7] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => $config['graph_color10'],
|
'color' => $config['graph_color10'],
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[11] = array(
|
$color_series[8] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => COL_GRAPH9,
|
'color' => COL_GRAPH9,
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[12] = array(
|
$color_series[9] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => COL_GRAPH10,
|
'color' => COL_GRAPH10,
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[13] = array(
|
$color_series[10] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => COL_GRAPH11,
|
'color' => COL_GRAPH11,
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[14] = array(
|
$color_series[11] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => COL_GRAPH12,
|
'color' => COL_GRAPH12,
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
$color_series[15] = array(
|
$color_series[12] = array(
|
||||||
'border' => '#000000',
|
'border' => '#000000',
|
||||||
'color' => COL_GRAPH13,
|
'color' => COL_GRAPH13,
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//XXX Colores fijos para eventos, alertas, desconocidos, percentil, overlapped, summatory, average, projection
|
||||||
|
$color_series['event'] = array(
|
||||||
|
'border' => '#ff0000',
|
||||||
|
'color' => '#ff66cc',
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
$color_series['alert'] = array(
|
||||||
if($id_widget_dashboard){
|
'border' => '#ffff00',
|
||||||
$opcion = unserialize(db_get_value_filter('options','twidget_dashboard',array('id' => $id_widget_dashboard)));
|
'color' => '#ffff00',
|
||||||
foreach ($module_list as $key => $value) {
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
if(!empty($opcion[$value])){
|
);
|
||||||
$color[$key]['color'] = $opcion[$value];
|
|
||||||
|
$color_series['unknown'] = array(
|
||||||
|
'border' => '#999999',
|
||||||
|
'color' => '#E1E1E1',
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
|
$color_series['percentil'] = array(
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => '#003333',
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
|
$color_series['projection'] = array(
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color8'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
|
$color_series['overlapped'] = array(
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color9'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
|
$color_series['summatory'] = array(
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color7'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
|
$color_series['average'] = array(
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => $config['graph_color10'],
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
|
$color_series['no_data'] = array(
|
||||||
|
'border' => '#000000',
|
||||||
|
'color' => '#f2c40e',
|
||||||
|
'alpha' => CHART_DEFAULT_ALPHA
|
||||||
|
);
|
||||||
|
|
||||||
|
$color_series['unit'] = array(
|
||||||
|
'border' => null,
|
||||||
|
'color' => '#0097BC',
|
||||||
|
'alpha' => 10
|
||||||
|
);
|
||||||
|
//XXXXXXXX
|
||||||
|
/*
|
||||||
|
if($id_widget_dashboard){
|
||||||
|
$opcion = unserialize(db_get_value_filter('options','twidget_dashboard',array('id' => $id_widget_dashboard)));
|
||||||
|
foreach ($module_list as $key => $value) {
|
||||||
|
if(!empty($opcion[$value])){
|
||||||
|
$color[$key]['color'] = $opcion[$value];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
if(!$compare) {
|
return $color_series;
|
||||||
$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
|
|
||||||
);
|
|
||||||
|
|
||||||
$color['sum'.$series_suffix] =
|
|
||||||
$color_series[$series_suffix];
|
|
||||||
|
|
||||||
$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['sum'.$series_suffix] =
|
|
||||||
$color_series[$series_suffix];
|
|
||||||
|
|
||||||
$color['unit'.$series_suffix] =
|
|
||||||
array( 'border' => null,
|
|
||||||
'color' => '#0097BC',
|
|
||||||
'alpha' => 10
|
|
||||||
);
|
|
||||||
|
|
||||||
$color['percentil'.$series_suffix] =
|
|
||||||
array( 'border' => '#000000',
|
|
||||||
'color' => '#003333',
|
|
||||||
'alpha' => CHART_DEFAULT_ALPHA
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function series_type_graph_array($data, $show_elements_graph){
|
function series_type_graph_array($data, $show_elements_graph){
|
||||||
@ -3021,6 +3003,8 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
$type_graph = $show_elements_graph['type_graph'];
|
$type_graph = $show_elements_graph['type_graph'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$color_series = color_graph_array();
|
||||||
|
$i = 0;
|
||||||
if(isset($data) && is_array($data)){
|
if(isset($data) && is_array($data)){
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
if($show_elements_graph['compare'] == 'overlapped'){
|
if($show_elements_graph['compare'] == 'overlapped'){
|
||||||
@ -3031,11 +3015,13 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
|
|
||||||
if(strpos($key, 'summatory') !== false){
|
if(strpos($key, 'summatory') !== false){
|
||||||
$data_return['series_type'][$key] = $type_graph;
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
$data_return['legend'][$key] = __('Summatory series') . ' ' . $str;
|
$data_return['legend'][$key] = __('Summatory series') . ' ' . $str;
|
||||||
|
$data_return['color'][$key] = $color_series['summatory'];
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'average') !== false){
|
elseif(strpos($key, 'average') !== false){
|
||||||
$data_return['series_type'][$key] = $type_graph;
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
$data_return['legend'][$key] = __('Average series') . ' ' . $str;
|
$data_return['legend'][$key] = __('Average series') . ' ' . $str;
|
||||||
|
$data_return['color'][$key] = $color_series['average'];
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'sum') !== false || strpos($key, 'baseline') !== false){
|
elseif(strpos($key, 'sum') !== false || strpos($key, 'baseline') !== false){
|
||||||
switch ($value['id_module_type']) {
|
switch ($value['id_module_type']) {
|
||||||
@ -3085,24 +3071,37 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
)
|
)
|
||||||
) . ' ' . $str;
|
) . ' ' . $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($show_elements_graph['compare'] == 'overlapped'){
|
||||||
|
$data_return['color'][$key] = $color_series['overlapped'];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$data_return['color'][$key] = $color_series[$i];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'event') !== false){
|
elseif(strpos($key, 'event') !== false){
|
||||||
$data_return['series_type'][$key] = 'points';
|
$data_return['series_type'][$key] = 'points';
|
||||||
if($show_elements_graph['show_events']){
|
if($show_elements_graph['show_events']){
|
||||||
$data_return['legend'][$key] = __('Events') . ' ' . $str;
|
$data_return['legend'][$key] = __('Events') . ' ' . $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data_return['color'][$key] = $color_series['event'];
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'alert') !== false){
|
elseif(strpos($key, 'alert') !== false){
|
||||||
$data_return['series_type'][$key] = 'points';
|
$data_return['series_type'][$key] = 'points';
|
||||||
if($show_elements_graph['show_alerts']){
|
if($show_elements_graph['show_alerts']){
|
||||||
$data_return['legend'][$key] = __('Alert') . ' ' . $str;
|
$data_return['legend'][$key] = __('Alert') . ' ' . $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data_return['color'][$key] = $color_series['alert'];
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'unknown') !== false){
|
elseif(strpos($key, 'unknown') !== false){
|
||||||
$data_return['series_type'][$key] = 'unknown';
|
$data_return['series_type'][$key] = 'unknown';
|
||||||
if($show_elements_graph['show_unknown']){
|
if($show_elements_graph['show_unknown']){
|
||||||
$data_return['legend'][$key] = __('Unknown') . ' ' . $str;
|
$data_return['legend'][$key] = __('Unknown') . ' ' . $str;
|
||||||
}
|
}
|
||||||
|
$data_return['color'][$key] =$color_series['unknown'];
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'percentil') !== false){
|
elseif(strpos($key, 'percentil') !== false){
|
||||||
$data_return['series_type'][$key] = 'percentil';
|
$data_return['series_type'][$key] = 'percentil';
|
||||||
@ -3125,14 +3124,18 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
)
|
)
|
||||||
) . ' ' . $str;
|
) . ' ' . $str;
|
||||||
}
|
}
|
||||||
|
$data_return['color'][$key] =$color_series['percentil'];
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'projection') !== false){
|
elseif(strpos($key, 'projection') !== false){
|
||||||
$data_return['series_type'][$key] = $type_graph;
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
$data_return['legend'][$key] = __('Projection') . ' ' . $str;
|
$data_return['legend'][$key] = __('Projection') . ' ' . $str;
|
||||||
|
$data_return['color'][$key] = $color_series['projection'];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$data_return['series_type'][$key] = $type_graph;
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
$data_return['legend'][$key] = $key;
|
$data_return['legend'][$key] = $key;
|
||||||
|
$data_return['color'][$key] = $color_series[$i];
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $data_return;
|
return $data_return;
|
||||||
|
@ -918,8 +918,6 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
|
|||||||
array_push($return, $end_array);
|
array_push($return, $end_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
// html_debug_print($return);
|
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ function grafico_modulo_sparse_data(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//XXX Para un tipo de reports en concreto habria que optimizar que la tabla que crea coincida con los datos documentar
|
//XXX Esto es para un tipo especifico de report que consiste en pasarle un intervalo y hacer suma media y avg.
|
||||||
if($params['force_interval'] != ''){
|
if($params['force_interval'] != ''){
|
||||||
$period_time_interval = $date_array['period'] * 1000;
|
$period_time_interval = $date_array['period'] * 1000;
|
||||||
$start_period = $date_array['start_date'] * 1000;
|
$start_period = $date_array['start_date'] * 1000;
|
||||||
@ -646,17 +646,6 @@ function grafico_modulo_sparse_data(
|
|||||||
return $array_data;
|
return $array_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$color = color_graph_array(
|
|
||||||
$series_suffix,
|
|
||||||
$params['flag_overlapped']
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($color as $k => $v) {
|
|
||||||
if(is_array($array_data[$k])){
|
|
||||||
$array_data[$k]['color'] = $v['color'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$array_events_alerts[$series_suffix] = $events;
|
$array_events_alerts[$series_suffix] = $events;
|
||||||
|
|
||||||
return $array_data;
|
return $array_data;
|
||||||
@ -981,7 +970,8 @@ function grafico_modulo_sparse ($params) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$series_type = $series_type_array['series_type'];
|
$series_type = $series_type_array['series_type'];
|
||||||
$legend = $series_type_array['legend'];
|
$legend = $series_type_array['legend'];
|
||||||
|
$color = $series_type_array['color'];
|
||||||
|
|
||||||
if($config["fixed_graph"] == false){
|
if($config["fixed_graph"] == false){
|
||||||
$water_mark = array(
|
$water_mark = array(
|
||||||
@ -1005,6 +995,7 @@ function grafico_modulo_sparse ($params) {
|
|||||||
$array_data,
|
$array_data,
|
||||||
$legend,
|
$legend,
|
||||||
$series_type,
|
$series_type,
|
||||||
|
$color,
|
||||||
$date_array,
|
$date_array,
|
||||||
$data_module_graph,
|
$data_module_graph,
|
||||||
$params,
|
$params,
|
||||||
@ -1024,13 +1015,15 @@ function grafico_modulo_sparse ($params) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$series_type = $series_type_array['series_type'];
|
$series_type = $series_type_array['series_type'];
|
||||||
$legend = $series_type_array['legend'];
|
$legend = $series_type_array['legend'];
|
||||||
|
$color = $series_type_array['color'];
|
||||||
|
|
||||||
$return .= area_graph(
|
$return .= area_graph(
|
||||||
$agent_module_id,
|
$agent_module_id,
|
||||||
$array_data_prev,
|
$array_data_prev,
|
||||||
$legend,
|
$legend,
|
||||||
$series_type,
|
$series_type,
|
||||||
|
$color,
|
||||||
$date_array,
|
$date_array,
|
||||||
$data_module_graph,
|
$data_module_graph,
|
||||||
$params,
|
$params,
|
||||||
@ -1049,6 +1042,7 @@ function grafico_modulo_sparse ($params) {
|
|||||||
$array_data,
|
$array_data,
|
||||||
$legend,
|
$legend,
|
||||||
$series_type,
|
$series_type,
|
||||||
|
$color,
|
||||||
$date_array,
|
$date_array,
|
||||||
$data_module_graph,
|
$data_module_graph,
|
||||||
$params,
|
$params,
|
||||||
@ -1436,7 +1430,6 @@ function graphic_combined_module (
|
|||||||
|
|
||||||
//XXX arreglar estas
|
//XXX arreglar estas
|
||||||
$long_index = '';
|
$long_index = '';
|
||||||
$color = array();
|
|
||||||
|
|
||||||
switch ($params_combined['stacked']) {
|
switch ($params_combined['stacked']) {
|
||||||
default:
|
default:
|
||||||
@ -1501,17 +1494,6 @@ function graphic_combined_module (
|
|||||||
|
|
||||||
$percentil_value = $array_data['percentil' . $i]['data'][0][1];
|
$percentil_value = $array_data['percentil' . $i]['data'][0][1];
|
||||||
|
|
||||||
$color = color_graph_array(
|
|
||||||
$series_suffix,
|
|
||||||
$params['flag_overlapped']
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($color as $k => $v) {
|
|
||||||
if(is_array($array_data[$k])){
|
|
||||||
$array_data[$k]['color'] = $v['color'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($config["fixed_graph"] == false){
|
if($config["fixed_graph"] == false){
|
||||||
$water_mark = array(
|
$water_mark = array(
|
||||||
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
|
||||||
@ -1548,6 +1530,7 @@ function graphic_combined_module (
|
|||||||
|
|
||||||
$series_type = $series_type_array['series_type'];
|
$series_type = $series_type_array['series_type'];
|
||||||
$legend = $series_type_array['legend'];
|
$legend = $series_type_array['legend'];
|
||||||
|
$color = $series_type_array['color'];
|
||||||
|
|
||||||
$threshold_data = array();
|
$threshold_data = array();
|
||||||
if ($params_combined['from_interface']) {
|
if ($params_combined['from_interface']) {
|
||||||
@ -1666,6 +1649,7 @@ function graphic_combined_module (
|
|||||||
$array_data,
|
$array_data,
|
||||||
$legend,
|
$legend,
|
||||||
$series_type,
|
$series_type,
|
||||||
|
$color,
|
||||||
$date_array,
|
$date_array,
|
||||||
$data_module_graph,
|
$data_module_graph,
|
||||||
$params,
|
$params,
|
||||||
@ -1768,6 +1752,8 @@ function graphic_combined_module (
|
|||||||
$width = 1024;
|
$width = 1024;
|
||||||
$height = 50;
|
$height = 50;
|
||||||
|
|
||||||
|
$color = color_graph_array();
|
||||||
|
|
||||||
$output = stacked_bullet_chart(
|
$output = stacked_bullet_chart(
|
||||||
$graph_values,
|
$graph_values,
|
||||||
$width,
|
$width,
|
||||||
@ -1856,6 +1842,8 @@ function graphic_combined_module (
|
|||||||
|
|
||||||
$graph_values = $temp;
|
$graph_values = $temp;
|
||||||
|
|
||||||
|
$color = color_graph_array();
|
||||||
|
|
||||||
$width = 200;
|
$width = 200;
|
||||||
$height = 200;
|
$height = 200;
|
||||||
|
|
||||||
@ -1922,6 +1910,8 @@ function graphic_combined_module (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$color = color_graph_array();
|
||||||
|
|
||||||
$graph_values = $temp;
|
$graph_values = $temp;
|
||||||
|
|
||||||
$width = 1024;
|
$width = 1024;
|
||||||
@ -2041,6 +2031,8 @@ function graphic_combined_module (
|
|||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
|
$color = color_graph_array();
|
||||||
|
|
||||||
$graph_values = $temp;
|
$graph_values = $temp;
|
||||||
|
|
||||||
return stacked_thermometers(
|
return stacked_thermometers(
|
||||||
@ -2125,9 +2117,11 @@ function graphic_combined_module (
|
|||||||
|
|
||||||
$graph_values = $temp;
|
$graph_values = $temp;
|
||||||
|
|
||||||
$width = 1024;
|
$width = 1024;
|
||||||
$height = 500;
|
$height = 500;
|
||||||
|
|
||||||
|
$color = color_graph_array();
|
||||||
|
|
||||||
$output = ring_graph(
|
$output = ring_graph(
|
||||||
true,
|
true,
|
||||||
$graph_values,
|
$graph_values,
|
||||||
|
@ -221,7 +221,7 @@ function vbar_graph(
|
|||||||
|
|
||||||
function area_graph(
|
function area_graph(
|
||||||
$agent_module_id, $array_data,
|
$agent_module_id, $array_data,
|
||||||
$legend, $series_type, $date_array,
|
$legend, $series_type, $color, $date_array,
|
||||||
$data_module_graph, $params, $water_mark,
|
$data_module_graph, $params, $water_mark,
|
||||||
$array_events_alerts) {
|
$array_events_alerts) {
|
||||||
global $config;
|
global $config;
|
||||||
@ -235,6 +235,7 @@ function area_graph(
|
|||||||
$array_data,
|
$array_data,
|
||||||
$legend,
|
$legend,
|
||||||
$series_type,
|
$series_type,
|
||||||
|
$color,
|
||||||
$date_array,
|
$date_array,
|
||||||
$data_module_graph,
|
$data_module_graph,
|
||||||
$params,
|
$params,
|
||||||
|
@ -213,10 +213,9 @@
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
alert('There was an error exporting the data');
|
alert('There was an error exporting the data');
|
||||||
console.log(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plot.exportDataJSON = function (args) {
|
plot.exportDataJSON = function (args) {
|
||||||
//amount = plot.getOptions().export.type,
|
//amount = plot.getOptions().export.type,
|
||||||
//options = options || {};
|
//options = options || {};
|
||||||
@ -261,7 +260,7 @@
|
|||||||
// Throw errors
|
// Throw errors
|
||||||
var processDataObject = function (dataObject) {
|
var processDataObject = function (dataObject) {
|
||||||
var result;
|
var result;
|
||||||
console.log(dataObject);
|
|
||||||
if (typeof dataObject === 'undefined')
|
if (typeof dataObject === 'undefined')
|
||||||
throw new Error('Empty parameter');
|
throw new Error('Empty parameter');
|
||||||
|
|
||||||
@ -404,11 +403,10 @@ console.log(dataObject);
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
alert('There was an error exporting the data');
|
alert('There was an error exporting the data');
|
||||||
console.log(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$.plot.plugins.push({
|
$.plot.plugins.push({
|
||||||
init: init,
|
init: init,
|
||||||
options: options,
|
options: options,
|
||||||
|
@ -302,15 +302,14 @@ function pandoraFlotPieCustom(graph_id, values, labels, width,
|
|||||||
$(this).text(legend[j]);
|
$(this).text(legend[j]);
|
||||||
j++;
|
j++;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($('input[name="custom_graph"]').val()) {
|
if ($('input[name="custom_graph"]').val()) {
|
||||||
$('.legend>div').css('right',($('.legend>div').height()*-1));
|
$('.legend>div').css('right',($('.legend>div').height()*-1));
|
||||||
$('.legend>table').css('right',($('.legend>div').height()*-1));
|
$('.legend>table').css('right',($('.legend>div').height()*-1));
|
||||||
}
|
}
|
||||||
//$('.legend>table').css('border',"1px solid #E2E2E2");
|
//$('.legend>table').css('border',"1px solid #E2E2E2");
|
||||||
$('.legend>table').css('background-color',"transparent");
|
$('.legend>table').css('background-color',"transparent");
|
||||||
|
|
||||||
|
|
||||||
var pielegends = $('#'+graph_id+' .pieLabelBackground');
|
var pielegends = $('#'+graph_id+' .pieLabelBackground');
|
||||||
pielegends.each(function () {
|
pielegends.each(function () {
|
||||||
$(this).css('transform', "rotate(-35deg)").css('color', 'black');
|
$(this).css('transform', "rotate(-35deg)").css('color', 'black');
|
||||||
@ -324,7 +323,8 @@ function pandoraFlotPieCustom(graph_id, values, labels, width,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pandoraFlotHBars(graph_id, values, labels, water_mark,
|
function pandoraFlotHBars(graph_id, values, labels, water_mark,
|
||||||
maxvalue, water_mark, separator, separator2, font, font_size, background_color, tick_color, min, max) {
|
maxvalue, water_mark, separator, separator2, font, font_size,
|
||||||
|
background_color, tick_color, min, max) {
|
||||||
|
|
||||||
var colors_data = ['#FC4444','#FFA631','#FAD403','#5BB6E5','#F2919D','#80BA27'];
|
var colors_data = ['#FC4444','#FFA631','#FAD403','#5BB6E5','#F2919D','#80BA27'];
|
||||||
values = values.split(separator2);
|
values = values.split(separator2);
|
||||||
@ -857,7 +857,7 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
|
|||||||
|
|
||||||
function pandoraFlotArea(
|
function pandoraFlotArea(
|
||||||
graph_id, values, legend, agent_module_id,
|
graph_id, values, legend, agent_module_id,
|
||||||
series_type, water_mark, date_array,
|
series_type, color, water_mark, date_array,
|
||||||
data_module_graph, params,
|
data_module_graph, params,
|
||||||
force_integer, background_color,
|
force_integer, background_color,
|
||||||
legend_color, short_data, events_array
|
legend_color, short_data, events_array
|
||||||
@ -896,14 +896,9 @@ function pandoraFlotArea(
|
|||||||
//XXXXX
|
//XXXXX
|
||||||
var markins_graph = true;
|
var markins_graph = true;
|
||||||
|
|
||||||
//XXXX ver que hay que hacer
|
|
||||||
var labels_long = '';
|
|
||||||
var min_check = 0;
|
|
||||||
|
|
||||||
var legend_events = null;
|
var legend_events = null;
|
||||||
var legend_alerts = null;
|
var legend_alerts = null;
|
||||||
|
|
||||||
|
|
||||||
// If threshold and up are the same, that critical or warning is disabled
|
// If threshold and up are the same, that critical or warning is disabled
|
||||||
if (yellow_threshold == yellow_up){
|
if (yellow_threshold == yellow_up){
|
||||||
yellow_inverse = false;
|
yellow_inverse = false;
|
||||||
@ -1481,7 +1476,7 @@ function pandoraFlotArea(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(type);
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'line':
|
case 'line':
|
||||||
case 2:
|
case 2:
|
||||||
@ -1510,6 +1505,7 @@ console.log(type);
|
|||||||
|
|
||||||
i=0;
|
i=0;
|
||||||
$.each(values, function (index, value) {
|
$.each(values, function (index, value) {
|
||||||
|
|
||||||
if (typeof value.data !== "undefined") {
|
if (typeof value.data !== "undefined") {
|
||||||
if(index.search("alert") >= 0){
|
if(index.search("alert") >= 0){
|
||||||
fill_color = '#ff7f00';
|
fill_color = '#ff7f00';
|
||||||
@ -1562,11 +1558,11 @@ console.log(type);
|
|||||||
//in graph stacked unset percentil
|
//in graph stacked unset percentil
|
||||||
if( ! ( (type == 1) && ( /percentil/.test(index) ) == true ) &&
|
if( ! ( (type == 1) && ( /percentil/.test(index) ) == true ) &&
|
||||||
! ( (type == 3) && ( /percentil/.test(index) ) == true ) ){
|
! ( (type == 3) && ( /percentil/.test(index) ) == true ) ){
|
||||||
data_base.push({
|
data_base.push({
|
||||||
id: 'serie_' + i,
|
id: 'serie_' + i,
|
||||||
data: value.data,
|
data: value.data,
|
||||||
label: index,
|
label: index,
|
||||||
color: value.color,
|
color: color[index]['color'],
|
||||||
lines: {
|
lines: {
|
||||||
show: line_show,
|
show: line_show,
|
||||||
fill: filled,
|
fill: filled,
|
||||||
@ -1672,7 +1668,7 @@ console.log(type);
|
|||||||
$('#'+graph_id).css('height', hDiff);
|
$('#'+graph_id).css('height', hDiff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(vconsole);
|
|
||||||
/*
|
/*
|
||||||
if (vconsole) {
|
if (vconsole) {
|
||||||
var myCanvas = plot.getCanvas();
|
var myCanvas = plot.getCanvas();
|
||||||
@ -2303,7 +2299,6 @@ if (vconsole) {
|
|||||||
|
|
||||||
if (!dashboard) {
|
if (!dashboard) {
|
||||||
if (water_mark){
|
if (water_mark){
|
||||||
console.log($('#watermark_image_'+graph_id));
|
|
||||||
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
set_watermark(graph_id, plot, $('#watermark_image_'+graph_id).attr('src'));
|
||||||
}
|
}
|
||||||
//adjust_menu(graph_id, plot, parent_height, width, show_legend);
|
//adjust_menu(graph_id, plot, parent_height, width, show_legend);
|
||||||
|
@ -102,7 +102,7 @@ function include_javascript_dependencies_flot_graph($return = false) {
|
|||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
function flot_area_graph (
|
function flot_area_graph (
|
||||||
$agent_module_id, $array_data,
|
$agent_module_id, $array_data,
|
||||||
$legend, $series_type, $date_array,
|
$legend, $series_type, $color, $date_array,
|
||||||
$data_module_graph, $params, $water_mark,
|
$data_module_graph, $params, $water_mark,
|
||||||
$array_events_alerts ) {
|
$array_events_alerts ) {
|
||||||
|
|
||||||
@ -270,6 +270,7 @@ function flot_area_graph (
|
|||||||
$values = json_encode($array_data);
|
$values = json_encode($array_data);
|
||||||
$legend = json_encode($legend);
|
$legend = json_encode($legend);
|
||||||
$series_type = json_encode($series_type);
|
$series_type = json_encode($series_type);
|
||||||
|
$color = json_encode($color);
|
||||||
$date_array = json_encode($date_array);
|
$date_array = json_encode($date_array);
|
||||||
$data_module_graph = json_encode($data_module_graph);
|
$data_module_graph = json_encode($data_module_graph);
|
||||||
$params = json_encode($params);
|
$params = json_encode($params);
|
||||||
@ -285,6 +286,7 @@ function flot_area_graph (
|
|||||||
"JSON.parse('$legend'), \n" .
|
"JSON.parse('$legend'), \n" .
|
||||||
"'$agent_module_id', \n" .
|
"'$agent_module_id', \n" .
|
||||||
"JSON.parse('$series_type'), \n" .
|
"JSON.parse('$series_type'), \n" .
|
||||||
|
"JSON.parse('$color'), \n" .
|
||||||
"'$watermark', \n" .
|
"'$watermark', \n" .
|
||||||
"JSON.parse('$date_array'), \n" .
|
"JSON.parse('$date_array'), \n" .
|
||||||
"JSON.parse('$data_module_graph'), \n" .
|
"JSON.parse('$data_module_graph'), \n" .
|
||||||
|
@ -382,14 +382,7 @@ switch ($graph_type) {
|
|||||||
$font, $antialiasing, $rgb_color, $xaxisname, $yaxisname, false,
|
$font, $antialiasing, $rgb_color, $xaxisname, $yaxisname, false,
|
||||||
$legend, $fine_colors, $water_mark, $font_size);
|
$legend, $fine_colors, $water_mark, $font_size);
|
||||||
break;
|
break;
|
||||||
case 'stacked_area':
|
default:
|
||||||
case 'area':
|
|
||||||
case 'line':
|
|
||||||
pch_vertical_graph($graph_type, $data_keys, $data_values, $width,
|
|
||||||
$height, $rgb_color, $xaxisname, $yaxisname, false, $legend,
|
|
||||||
$font, $antialiasing, $water_mark, $font_size,
|
|
||||||
$backgroundColor, $unit, $series_type, $graph_threshold, $id_module);
|
|
||||||
break;
|
|
||||||
case 'threshold':
|
case 'threshold':
|
||||||
pch_threshold_graph($graph_type, $data_keys, $data_values, $width,
|
pch_threshold_graph($graph_type, $data_keys, $data_values, $width,
|
||||||
$height, $font, $antialiasing, $xaxisname, $yaxisname, $title,
|
$height, $font, $antialiasing, $xaxisname, $yaxisname, $title,
|
||||||
@ -875,585 +868,6 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
|
|||||||
$myPicture->stroke();
|
$myPicture->stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
|
||||||
$rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false,
|
|
||||||
$legend = array(), $font, $antialiasing, $water_mark = '', $font_size,
|
|
||||||
$backgroundColor = 'white', $unit = '', $series_type = array(),
|
|
||||||
$graph_threshold = false, $id_module) {
|
|
||||||
|
|
||||||
global $config;
|
|
||||||
|
|
||||||
/* Create and populate the pData object */
|
|
||||||
$MyData = new pData();
|
|
||||||
$MyData->addPoints(array(20,22,25,5,12,8,30,8),"Probe 1");
|
|
||||||
//$MyData->addPoints(array(3,12,15,8,8,5,-5),"Probe 2");
|
|
||||||
$MyData->setSerieTicks("Probe 2",4);
|
|
||||||
$MyData->setAxisName(0,"Temperatures");
|
|
||||||
$MyData->addPoints(array(1296299019,1296302903,1296307001,1296308071,1296309901,1296318931, 1296318941, 1296318942,1296338941),"Labels");
|
|
||||||
$MyData->setSerieDescription("Labels","Timestamp");
|
|
||||||
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE,"H:i");
|
|
||||||
$MyData->setAbscissa("Labels");
|
|
||||||
|
|
||||||
/* Create the pChart object */
|
|
||||||
$myPicture = new pImage(700,230,$MyData);
|
|
||||||
|
|
||||||
/* Draw the background */
|
|
||||||
$Settings = array("R"=>170, "G"=>183, "B"=>87);
|
|
||||||
$myPicture->drawFilledRectangle(0,0,700,230,$Settings);
|
|
||||||
|
|
||||||
/* Overlay with a gradient */
|
|
||||||
$Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
|
|
||||||
$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,$Settings);
|
|
||||||
$myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));
|
|
||||||
|
|
||||||
/* Add a border to the picture */
|
|
||||||
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
|
|
||||||
|
|
||||||
/* Write the picture title */
|
|
||||||
$myPicture->setFontProperties(array("FontName" =>$font, "FontSize" => $font_size));
|
|
||||||
$myPicture->drawText(10,13,"drawStepChart() - draw a step chart",array("R"=>255,"G"=>255,"B"=>255));
|
|
||||||
|
|
||||||
/* Write the chart title */
|
|
||||||
$myPicture->setFontProperties(array("FontName" =>$font, "FontSize" => $font_size));
|
|
||||||
$myPicture->drawText(250,55,"Average temperature",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
|
|
||||||
|
|
||||||
/* Draw the scale and the 1st chart */
|
|
||||||
$myPicture->setGraphArea(60,60,450,190);
|
|
||||||
$myPicture->drawFilledRectangle(60,60,450,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
|
|
||||||
$myPicture->drawScale(array("DrawSubTicks"=>TRUE,"LabelShowBoundaries"=>TRUE,"ScaleModeAuto"=>TRUE));
|
|
||||||
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
|
||||||
$myPicture->setFontProperties(array("FontName" =>$font, "FontSize" => $font_size));
|
|
||||||
$myPicture->drawAreaChart(array("BreakVoid"=>FALSE, "BreakR"=>234, "BreakG"=>55, "BreakB"=>26, "DisplayValues"=>FALSE,"DisplayColor"=>DISPLAY_AUTO,"ScaleModeAuto"=>TRUE));
|
|
||||||
$myPicture->setShadow(FALSE);
|
|
||||||
|
|
||||||
/* Write the chart legend */
|
|
||||||
$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
|
|
||||||
|
|
||||||
$myPicture->stroke();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// CAT:Vertical Charts
|
|
||||||
if (!is_array($legend) || empty($legend)) {
|
|
||||||
unset($legend);
|
|
||||||
}
|
|
||||||
if (is_array(reset($data))) {
|
|
||||||
$data2 = array();
|
|
||||||
foreach ($data as $i =>$values) {
|
|
||||||
$c = 0;
|
|
||||||
foreach ($values as $i2 => $value) {
|
|
||||||
$data2[$i2][$i] = $value;
|
|
||||||
$c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$data = $data2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$data = array($data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and populate the pData object
|
|
||||||
$MyData = new pData();
|
|
||||||
|
|
||||||
foreach ($data as $i => $values) {
|
|
||||||
if (isset($legend)) {
|
|
||||||
$point_id = $legend[$i];
|
|
||||||
// Translate the id of serie to legend of id
|
|
||||||
if (!empty($series_type)) {
|
|
||||||
if (!isset($series_type[$point_id])) {
|
|
||||||
$series_type[$point_id] = $series_type[$i];
|
|
||||||
unset($series_type[$i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$point_id = $i;
|
|
||||||
}
|
|
||||||
|
|
||||||
$MyData->addPoints($values, $point_id);
|
|
||||||
|
|
||||||
if (!empty($rgb_color)) {
|
|
||||||
$MyData->setPalette($point_id,
|
|
||||||
array(
|
|
||||||
"R" => $rgb_color[$i]['color']["R"],
|
|
||||||
"G" => $rgb_color[$i]['color']["G"],
|
|
||||||
"B" => $rgb_color[$i]['color']["B"],
|
|
||||||
"BorderR" => $rgb_color[$i]['border']["R"],
|
|
||||||
"BorderG" => $rgb_color[$i]['border']["G"],
|
|
||||||
"BorderB" => $rgb_color[$i]['border']["B"],
|
|
||||||
"Alpha" => $rgb_color[$i]['alpha']));
|
|
||||||
$palette_color = array();
|
|
||||||
if (isset($rgb_color[$i]['color'])) {
|
|
||||||
$palette_color["R"] = $rgb_color[$i]['color']["R"];
|
|
||||||
$palette_color["G"] = $rgb_color[$i]['color']["G"];
|
|
||||||
$palette_color["B"] = $rgb_color[$i]['color']["B"];
|
|
||||||
}
|
|
||||||
if (isset($rgb_color[$i]['color'])) {
|
|
||||||
$palette_color["BorderR"] = $rgb_color[$i]['border']["R"];
|
|
||||||
$palette_color["BorderG"] = $rgb_color[$i]['border']["G"];
|
|
||||||
$palette_color["BorderB"] = $rgb_color[$i]['border']["B"];
|
|
||||||
}
|
|
||||||
if (isset($rgb_color[$i]['color'])) {
|
|
||||||
$palette_color["Alpha"] = $rgb_color[$i]['Alpha'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$MyData->setPalette($point_id, $palette_color);
|
|
||||||
}
|
|
||||||
// The weight of the line is not calculated in pixels, so it needs to be transformed
|
|
||||||
$reduction_coefficient = 0.31;
|
|
||||||
$MyData->setSerieWeight($point_id, $config['custom_graph_width'] * $reduction_coefficient);
|
|
||||||
}
|
|
||||||
$MyData->setAxisName(0,$unit);
|
|
||||||
$MyData->addPoints($index,"Xaxis");
|
|
||||||
$MyData->setSerieDescription("Xaxis", $xaxisname);
|
|
||||||
$MyData->setAbscissa("Xaxis");
|
|
||||||
$MyData->setAxisDisplay(0, AXIS_FORMAT_TWO_SIGNIFICANT, 0);
|
|
||||||
|
|
||||||
switch ($backgroundColor) {
|
|
||||||
case 'white':
|
|
||||||
$transparent = false;
|
|
||||||
$fontColor = array('R' => 0, 'G' => 0, 'B' => 0);
|
|
||||||
break;
|
|
||||||
case 'black':
|
|
||||||
$transparent = false;
|
|
||||||
$fontColor = array('R' => 200, 'G' => 200, 'B' => 200);
|
|
||||||
break;
|
|
||||||
case 'transparent':
|
|
||||||
$transparent = true;
|
|
||||||
// $fontColor = array('R' => 0, 'G' => 0, 'B' => 0);
|
|
||||||
// Now the color of the text will be grey
|
|
||||||
$fontColor = array('R' => 200, 'G' => 200, 'B' => 200);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//Create the pChart object
|
|
||||||
$myPicture = new pImage($width, $height + $font_size, $MyData, $transparent,
|
|
||||||
$backgroundColor, $fontColor);
|
|
||||||
|
|
||||||
// Turn of Antialiasing
|
|
||||||
$myPicture->Antialias = $antialiasing;
|
|
||||||
|
|
||||||
// Add a border to the picture
|
|
||||||
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
|
|
||||||
|
|
||||||
//Set the default font
|
|
||||||
$myPicture->setFontProperties(
|
|
||||||
array("FontName" =>$font, "FontSize" => $font_size));
|
|
||||||
|
|
||||||
// By default, set a top margin of 5 px
|
|
||||||
$top_margin = 5;
|
|
||||||
if (isset($legend)) {
|
|
||||||
//Set horizontal legend if is posible
|
|
||||||
$legend_mode = LEGEND_HORIZONTAL;
|
|
||||||
$size = $myPicture->getLegendSize(
|
|
||||||
array("Style" => LEGEND_NOBORDER,"Mode" => $legend_mode));
|
|
||||||
if ($size['Width'] > ($width - 5)) {
|
|
||||||
$legend_mode = LEGEND_VERTICAL;
|
|
||||||
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the top margin to add the legend Height
|
|
||||||
$top_margin = $size['Height'];
|
|
||||||
|
|
||||||
//Write the chart legend
|
|
||||||
$myPicture->drawLegend($width - $size['Width'], 8,
|
|
||||||
array("Style" => LEGEND_NOBORDER, "Mode" => $legend_mode));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Calculate the bottom margin from the size of string in each index
|
|
||||||
$max_chars = graph_get_max_index($index);
|
|
||||||
$margin_bottom = $font_size * $max_chars;
|
|
||||||
|
|
||||||
$water_mark_height = 0;
|
|
||||||
$water_mark_width = 0;
|
|
||||||
if (!empty($water_mark)) {
|
|
||||||
$size_water_mark = getimagesize($water_mark);
|
|
||||||
$water_mark_height = $size_water_mark[1];
|
|
||||||
$water_mark_width = $size_water_mark[0];
|
|
||||||
|
|
||||||
$myPicture->drawFromPNG(
|
|
||||||
($width - $water_mark_width),
|
|
||||||
$top_margin,
|
|
||||||
$water_mark);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the max number of scale
|
|
||||||
$max_all = 0;
|
|
||||||
|
|
||||||
$serie_ne_zero = false;
|
|
||||||
foreach ($data as $serie) {
|
|
||||||
$max_this_serie = max($serie);
|
|
||||||
if ($max_this_serie > $max_all) {
|
|
||||||
$max_all = $max_this_serie;
|
|
||||||
}
|
|
||||||
// Detect if all serie is equal to zero or not
|
|
||||||
if ($serie != 0)
|
|
||||||
$serie_ne_zero = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the number of digits of the scale
|
|
||||||
$digits_left = 0;
|
|
||||||
while ($max_all > 1) {
|
|
||||||
$digits_left ++;
|
|
||||||
$max_all /= 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the number is less than 1 we count the decimals
|
|
||||||
// Also check if the serie is not all equal to zero (!$serie_ne_zero)
|
|
||||||
if ($digits_left == 0 and !$serie_ne_zero) {
|
|
||||||
while($max_all < 1) {
|
|
||||||
$digits_left ++;
|
|
||||||
$max_all *= 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$chart_size = ($digits_left * $font_size) + 20;
|
|
||||||
|
|
||||||
$min_data = 0;
|
|
||||||
$max_data = 0;
|
|
||||||
foreach ($data as $k => $v) {
|
|
||||||
if(min($v) < $min_data){
|
|
||||||
$min_data = min($v);
|
|
||||||
}
|
|
||||||
if(max($v) > $max_data){
|
|
||||||
$max_data = max($v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$chart_margin = 36;
|
|
||||||
|
|
||||||
//Area depends on yaxisname
|
|
||||||
if ($yaxisname != '') {
|
|
||||||
$chart_margin += $chart_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
$myPicture->setGraphArea($chart_margin, $top_margin,
|
|
||||||
$width,
|
|
||||||
($height - $margin_bottom));
|
|
||||||
|
|
||||||
if($graph_threshold){
|
|
||||||
$sql_treshold = 'select min_critical, max_critical, min_warning, max_warning, critical_inverse, warning_inverse from tagente_modulo where id_agente_modulo =' . $id_module;
|
|
||||||
$treshold_position = db_get_all_rows_sql($sql_treshold);
|
|
||||||
|
|
||||||
//min, max and inverse critical and warning
|
|
||||||
$p_min_crit = $treshold_position[0]['min_critical'];
|
|
||||||
$p_max_crit = $treshold_position[0]['max_critical'];
|
|
||||||
$p_inv_crit = $treshold_position[0]['critical_inverse'];
|
|
||||||
$p_min_warn = $treshold_position[0]['min_warning'];
|
|
||||||
$p_max_warn = $treshold_position[0]['max_warning'];
|
|
||||||
$p_inv_warn = $treshold_position[0]['warning_inverse'];
|
|
||||||
|
|
||||||
//interval warning
|
|
||||||
$print_rectangle_warning = 1;
|
|
||||||
if($p_min_warn == "0.00" && $p_max_warn == "0.00" && $p_inv_warn == 0){
|
|
||||||
$print_rectangle_warning = 0;
|
|
||||||
}
|
|
||||||
if($print_rectangle_warning){
|
|
||||||
if($p_inv_warn){
|
|
||||||
if($p_max_warn == 0){
|
|
||||||
$p_max_warn = $p_min_warn;
|
|
||||||
$p_min_warn = "none";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$p_max_warn_inv = $p_min_warn;
|
|
||||||
$p_min_warn_inv = $min_data + 2;
|
|
||||||
|
|
||||||
$p_min_warn = $p_max_warn;
|
|
||||||
if($p_max_warn > $max_data){
|
|
||||||
$p_max_warn = $p_max_warn + 21;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$p_max_warn = $max_data + 21;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if($p_max_warn == 0){
|
|
||||||
if($max_data > $p_min_warn){
|
|
||||||
$p_max_warn = $max_data + 21;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$p_max_warn = $p_min_warn + 21;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//interval critical
|
|
||||||
$print_rectangle_critical = 1;
|
|
||||||
if($p_min_crit == "0.00" && $p_max_crit == "0.00" && $p_inv_crit == 0){
|
|
||||||
$print_rectangle_critical = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($print_rectangle_critical){
|
|
||||||
if($p_inv_crit){
|
|
||||||
if($p_max_crit == 0){
|
|
||||||
$p_max_crit = $p_min_crit;
|
|
||||||
$p_min_crit = "none";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$p_max_crit_inv = $p_min_crit;
|
|
||||||
$p_min_crit_inv = $min_data + 2;
|
|
||||||
|
|
||||||
$p_min_crit = $p_max_crit;
|
|
||||||
if($p_inv_warn){
|
|
||||||
if($p_max_crit < $p_max_warn){
|
|
||||||
$p_max_crit = $p_max_warn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if($p_max_crit > $max_data){
|
|
||||||
$p_max_crit = $p_max_crit + 21;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$p_max_crit = $max_data + 21;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if($p_max_crit == 0){
|
|
||||||
if($p_max_warn > $p_min_crit){
|
|
||||||
$p_max_crit = $p_max_warn;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if($max_data > $p_min_crit){
|
|
||||||
$p_max_crit = $max_data + 21;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$p_max_crit = $p_min_crit + 21;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check size scale
|
|
||||||
//Which of the thresholds is higher?
|
|
||||||
if($p_max_crit > $p_max_warn){
|
|
||||||
$check_scale = $p_max_crit;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$check_scale = $p_max_warn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($p_min_crit < $p_min_warn){
|
|
||||||
$check_scale_min = $p_min_crit;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$check_scale_min = $p_min_warn;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Is the threshold higher than our maximum?
|
|
||||||
if($max_data > $check_scale){
|
|
||||||
$check_scale = $max_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($min_data < $check_scale_min){
|
|
||||||
$check_scale_min = $min_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ManualScale = array( 0 => array("Min" => $check_scale_min, "Max" => $check_scale) );
|
|
||||||
$mode = SCALE_MODE_MANUAL;
|
|
||||||
|
|
||||||
// Draw the scale
|
|
||||||
$scaleSettings = array(
|
|
||||||
"GridR" => 200,
|
|
||||||
"GridG" => 200,
|
|
||||||
"GridB" => 200,
|
|
||||||
"GridAlpha" => 30,
|
|
||||||
"DrawSubTicks" => true,
|
|
||||||
"CycleBackground" => true,
|
|
||||||
"BackgroundAlpha1" => 35,
|
|
||||||
"BackgroundAlpha2" => 35,
|
|
||||||
"Mode" => $mode,
|
|
||||||
"ManualScale" => $ManualScale,
|
|
||||||
"LabelRotation" => 40,
|
|
||||||
"XMargin" => 0,
|
|
||||||
"MinDivHeight" => 15,
|
|
||||||
"TicksFontSize" => $font_size - 1);
|
|
||||||
|
|
||||||
$scaleSettings['AxisR'] = '200';
|
|
||||||
$scaleSettings['AxisG'] = '200';
|
|
||||||
$scaleSettings['AxisB'] = '200';
|
|
||||||
$scaleSettings['TickR'] = '200';
|
|
||||||
$scaleSettings['TickG'] = '200';
|
|
||||||
$scaleSettings['TickB'] = '200';
|
|
||||||
|
|
||||||
$myPicture->drawScale($scaleSettings);
|
|
||||||
|
|
||||||
|
|
||||||
//values
|
|
||||||
$scale_max = $myPicture->DataSet->Data["Axis"][0]["ScaleMax"];
|
|
||||||
$scale_min = $myPicture->DataSet->Data["Axis"][0]["ScaleMin"];
|
|
||||||
|
|
||||||
$position_y1 = $myPicture->GraphAreaY1;
|
|
||||||
$position_y2 = $myPicture->GraphAreaY2;
|
|
||||||
|
|
||||||
$position1 = $myPicture->GraphAreaX1;
|
|
||||||
$position3 = $myPicture->GraphAreaX2;
|
|
||||||
|
|
||||||
$cte = ($position_y2 - $position_y1) / ($scale_max - $scale_min);
|
|
||||||
|
|
||||||
//warning
|
|
||||||
if($print_rectangle_warning){
|
|
||||||
$RectangleSettings = array("R"=>255,"G"=>255,"B"=>000,"Dash"=>TRUE,"DashR"=>170,"DashG"=>220,"DashB"=>190);
|
|
||||||
if($p_min_warn == "none"){
|
|
||||||
$p_min_warn = $scale_min;
|
|
||||||
}
|
|
||||||
|
|
||||||
$position2 = ($scale_max - $p_min_warn)*$cte + $position_y1;
|
|
||||||
$position4 = ($scale_max - $p_max_warn)*$cte + $position_y1;
|
|
||||||
|
|
||||||
$myPicture->drawFilledRectangle($position1, floor($position2),
|
|
||||||
$position3, floor($position4),
|
|
||||||
$RectangleSettings);
|
|
||||||
if($p_inv_warn){
|
|
||||||
$position2 = ($scale_max - $p_min_warn_inv)*$cte + $position_y1;
|
|
||||||
$position4 = ($scale_max - $p_max_warn_inv)*$cte + $position_y1;
|
|
||||||
$myPicture->drawFilledRectangle($position1, floor($position2),
|
|
||||||
$position3, floor($position4),
|
|
||||||
$RectangleSettings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//critical
|
|
||||||
if($print_rectangle_critical){
|
|
||||||
$RectangleSettings = array("R"=>248,"G"=>000,"B"=>000,"Dash"=>TRUE,"DashR"=>170,"DashG"=>220,"DashB"=>190);
|
|
||||||
|
|
||||||
if($p_min_crit == "none"){
|
|
||||||
$p_min_crit = $scale_min;
|
|
||||||
}
|
|
||||||
|
|
||||||
$position2 = ($scale_max - $p_min_crit)*$cte + $position_y1;
|
|
||||||
$position4 = ($scale_max - $p_max_crit)*$cte + $position_y1;
|
|
||||||
$myPicture->drawFilledRectangle($position1, $position2,
|
|
||||||
$position3, $position4,
|
|
||||||
$RectangleSettings);
|
|
||||||
|
|
||||||
if($p_inv_crit){
|
|
||||||
$position2 = ($scale_max - $p_min_crit_inv)*$cte + $position_y1;
|
|
||||||
$position4 = ($scale_max - $p_max_crit_inv)*$cte + $position_y1;
|
|
||||||
$myPicture->drawFilledRectangle($position1, $position2,
|
|
||||||
$position3, $position4,
|
|
||||||
$RectangleSettings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
|
|
||||||
$ManualScale = array( 0 => array(
|
|
||||||
"Min" => $min_data,
|
|
||||||
"Max" => $max_data
|
|
||||||
));
|
|
||||||
//html_debug("MAX: $max_data, ROUND: $max_round", true);
|
|
||||||
$mode = SCALE_MODE_MANUAL;
|
|
||||||
|
|
||||||
//Draw the scale
|
|
||||||
$scaleSettings = array(
|
|
||||||
"GridR" => 200,
|
|
||||||
"GridG" => 200,
|
|
||||||
"GridB" => 200,
|
|
||||||
"GridAlpha" => 30,
|
|
||||||
"DrawSubTicks" => true,
|
|
||||||
"CycleBackground" => true,
|
|
||||||
"BackgroundAlpha1" => 35,
|
|
||||||
"BackgroundAlpha2" => 35,
|
|
||||||
"Mode" => $mode,
|
|
||||||
"ManualScale" => $ManualScale,
|
|
||||||
"LabelRotation" => 40,
|
|
||||||
"XMargin" => 0,
|
|
||||||
"MinDivHeight" => 15,
|
|
||||||
"TicksFontSize" => $font_size - 1);
|
|
||||||
|
|
||||||
$scaleSettings['AxisR'] = '200';
|
|
||||||
$scaleSettings['AxisG'] = '200';
|
|
||||||
$scaleSettings['AxisB'] = '200';
|
|
||||||
$scaleSettings['TickR'] = '200';
|
|
||||||
$scaleSettings['TickG'] = '200';
|
|
||||||
$scaleSettings['TickB'] = '200';
|
|
||||||
|
|
||||||
$myPicture->drawScale($scaleSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Turn on shadow computing
|
|
||||||
//$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
|
||||||
|
|
||||||
switch ($graph_type) {
|
|
||||||
case 'stacked_area':
|
|
||||||
$ForceTransparency = "-1";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$ForceTransparency = "100";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Draw the chart
|
|
||||||
$settings = array(
|
|
||||||
"ForceTransparency" => 20,
|
|
||||||
"Gradient" => TRUE,
|
|
||||||
"GradientMode" => GRADIENT_EFFECT_CAN,
|
|
||||||
"DisplayValues" => $show_values,
|
|
||||||
"DisplayZeroValues" => FALSE,
|
|
||||||
"DisplayR" => 100,
|
|
||||||
"DisplayZeros" => FALSE,
|
|
||||||
"DisplayG" => 100,
|
|
||||||
"DisplayB" => 100,
|
|
||||||
"DisplayShadow" => TRUE,
|
|
||||||
"Surrounding" => 5,
|
|
||||||
"AroundZero" => TRUE);
|
|
||||||
|
|
||||||
if (empty($series_type)) {
|
|
||||||
switch($graph_type) {
|
|
||||||
case "stacked_area":
|
|
||||||
case "area":
|
|
||||||
$myPicture->drawAreaChart($settings);
|
|
||||||
break;
|
|
||||||
case "line":
|
|
||||||
$myPicture->drawLineChart($settings);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Hiden all series for to show each serie as type
|
|
||||||
foreach ($series_type as $id => $type) {
|
|
||||||
$MyData->setSerieDrawable($id, false);
|
|
||||||
}
|
|
||||||
foreach ($series_type as $id => $type) {
|
|
||||||
$MyData->setSerieDrawable($id, true); //Enable the serie to paint
|
|
||||||
switch ($type) {
|
|
||||||
default:
|
|
||||||
case 'area':
|
|
||||||
$myPicture->drawAreaChart($settings);
|
|
||||||
break;
|
|
||||||
//~ case "points":
|
|
||||||
//~ $myPicture->drawPlotChart($settings);
|
|
||||||
//~ break;
|
|
||||||
case "line":
|
|
||||||
$myPicture->drawLineChart($settings);
|
|
||||||
break;
|
|
||||||
case 'boolean':
|
|
||||||
switch($graph_type) {
|
|
||||||
case "stacked_area":
|
|
||||||
case "area":
|
|
||||||
$myPicture->drawFilledStepChart($settings);
|
|
||||||
break;
|
|
||||||
case "line":
|
|
||||||
$myPicture->drawStepChart($settings);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$MyData->setSerieDrawable($id, false); //Disable the serie to paint the rest
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Render the picture
|
|
||||||
$myPicture->stroke();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
function pch_threshold_graph ($graph_type, $index, $data, $width, $height, $font,
|
function pch_threshold_graph ($graph_type, $index, $data, $width, $height, $font,
|
||||||
$antialiasing, $xaxisname = "", $yaxisname = "", $title = "",
|
$antialiasing, $xaxisname = "", $yaxisname = "", $title = "",
|
||||||
$show_values = false, $show_legend = false, $font_size) {
|
$show_values = false, $show_legend = false, $font_size) {
|
||||||
|
@ -637,7 +637,6 @@ function post_process_select_init_unit(name,selected) {
|
|||||||
$('#' + name + '_select').change(function() {
|
$('#' + name + '_select').change(function() {
|
||||||
var value = $('#' + name + '_select').val();
|
var value = $('#' + name + '_select').val();
|
||||||
$('#' + name + '_select option[value='+ value +']').attr("selected",true);
|
$('#' + name + '_select option[value='+ value +']').attr("selected",true);
|
||||||
console.log(value);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,6 @@ if ($view_graph) {
|
|||||||
|
|
||||||
$("#stacked").change(function(){
|
$("#stacked").change(function(){
|
||||||
if ($(this).val() == '4') {
|
if ($(this).val() == '4') {
|
||||||
console.log($(this).val());
|
|
||||||
$("#thresholdDiv").show();
|
$("#thresholdDiv").show();
|
||||||
$(".stacked").show();
|
$(".stacked").show();
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user