mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
fixed errors in graphs
This commit is contained in:
parent
badfd83b0d
commit
d7da009804
@ -68,9 +68,7 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
|
||||||
<title>Pandora FMS Graph (<?php echo agents_get_alias($agent_id) . ' - ' . $interface_name; ?>)</title>
|
<title>Pandora FMS Graph (<?php echo agents_get_alias($agent_id) . ' - ' . $interface_name; ?>)</title>
|
||||||
|
|
||||||
<link rel="stylesheet" href="styles/pandora.css" type="text/css" />
|
<link rel="stylesheet" href="styles/pandora.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" />
|
<link rel="stylesheet" href="styles/pandora_minimal.css" type="text/css" />
|
||||||
<link rel="stylesheet" href="styles/jquery-ui-1.10.0.custom.css" type="text/css" />
|
<link rel="stylesheet" href="styles/jquery-ui-1.10.0.custom.css" type="text/css" />
|
||||||
@ -108,7 +106,6 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
|
|||||||
$type_graph_pdf = $_GET['type_graph_pdf'];
|
$type_graph_pdf = $_GET['type_graph_pdf'];
|
||||||
|
|
||||||
if($type_graph_pdf == 'combined'){
|
if($type_graph_pdf == 'combined'){
|
||||||
echo '<p> Grafica molona para combinadaaaaaaaaaaaaa</p>';
|
|
||||||
echo '<div>';
|
echo '<div>';
|
||||||
echo graphic_combined_module(
|
echo graphic_combined_module(
|
||||||
$module_list,
|
$module_list,
|
||||||
@ -118,9 +115,8 @@ if (file_exists ('languages/'.$user_language.'.mo')) {
|
|||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
elseif($type_graph_pdf == 'sparse'){
|
elseif($type_graph_pdf == 'sparse'){
|
||||||
echo '<p> Grafica molona para ' . $params['agent_module_id'] . '</p>';
|
|
||||||
echo '<div>';
|
echo '<div>';
|
||||||
echo grafico_modulo_sparse ($params);
|
echo grafico_modulo_sparse($params);
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -3006,6 +3006,21 @@ function color_graph_array($series_suffix, $compare = false){
|
|||||||
function series_type_graph_array($data, $show_elements_graph){
|
function series_type_graph_array($data, $show_elements_graph){
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
if(isset($show_elements_graph['stacked'])){
|
||||||
|
switch ($show_elements_graph['stacked']) {
|
||||||
|
case 2:
|
||||||
|
case 4:
|
||||||
|
$type_graph = 'line';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$type_graph = 'area';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$type_graph = $show_elements_graph['type_graph'];
|
||||||
|
}
|
||||||
|
|
||||||
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'){
|
||||||
@ -3015,11 +3030,11 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(strpos($key, 'summatory') !== false){
|
if(strpos($key, 'summatory') !== false){
|
||||||
$data_return['series_type'][$key] = 'area';
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
$data_return['legend'][$key] = __('Summatory series') . ' ' . $str;
|
$data_return['legend'][$key] = __('Summatory series') . ' ' . $str;
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'average') !== false){
|
elseif(strpos($key, 'average') !== false){
|
||||||
$data_return['series_type'][$key] = 'area';
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
$data_return['legend'][$key] = __('Average series') . ' ' . $str;
|
$data_return['legend'][$key] = __('Average series') . ' ' . $str;
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'sum') !== false || strpos($key, 'baseline') !== false){
|
elseif(strpos($key, 'sum') !== false || strpos($key, 'baseline') !== false){
|
||||||
@ -3029,7 +3044,7 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
$data_return['series_type'][$key] = 'boolean';
|
$data_return['series_type'][$key] = 'boolean';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$data_return['series_type'][$key] = 'area';
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3112,11 +3127,11 @@ function series_type_graph_array($data, $show_elements_graph){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif(strpos($key, 'projection') !== false){
|
elseif(strpos($key, 'projection') !== false){
|
||||||
$data_return['series_type'][$key] = 'area';
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
$data_return['legend'][$key] = __('Projection') . ' ' . $str;
|
$data_return['legend'][$key] = __('Projection') . ' ' . $str;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$data_return['series_type'][$key] = 'area';
|
$data_return['series_type'][$key] = $type_graph;
|
||||||
$data_return['legend'][$key] = $key;
|
$data_return['legend'][$key] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3146,15 +3161,26 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = fal
|
|||||||
if($module_list){
|
if($module_list){
|
||||||
$module_list = urlencode(json_encode($module_list));
|
$module_list = urlencode(json_encode($module_list));
|
||||||
}
|
}
|
||||||
html_debug_print("phantomjs " . $file_js . " " . $url . " '" . $type_graph_pdf . "' '" . $params_encode_json . "' '" . $params_combined . "' '" . $module_list . "' " . $img_path . " " . $width_img . " " . $height_img, true);
|
|
||||||
$result = exec("phantomjs " . $file_js . " " . $url . " '" . $type_graph_pdf . "' '" . $params_encode_json . "' '" . $params_combined . "' '" . $module_list . "' " . $img_path . " " . $width_img . " " . $height_img);
|
|
||||||
html_debug_print($result, true);
|
|
||||||
return '<img src="' . $img_url . '" />';
|
|
||||||
|
|
||||||
//html_debug_print('entrando en llamada a phantom.js.......', true);
|
$result = exec(
|
||||||
//header('Content-Type: image/png;');
|
"phantomjs " . $file_js . " " .
|
||||||
//return '<img src="data:image/jpg;base64, '.$result.'" />';
|
$url . " '" .
|
||||||
//return "<img src='/var/www/html/pandora_console/attachment/imagen_". $params['agent_module_id'] .".png' alt='la imagen bonica'>";
|
$type_graph_pdf . "' '" .
|
||||||
|
$params_encode_json . "' '" .
|
||||||
|
$params_combined . "' '" .
|
||||||
|
$module_list . "' " .
|
||||||
|
$img_path . " " .
|
||||||
|
$width_img . " " .
|
||||||
|
$height_img . " " .
|
||||||
|
$params['return_img_base_64']
|
||||||
|
);
|
||||||
|
|
||||||
|
if($params['return_img_base_64']){
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return '<img src="' . $img_url . '" />';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6668,37 +6668,39 @@ function api_get_graph_module_data($id, $thrash1, $other, $thrash2) {
|
|||||||
$start_date = $other['data'][4];
|
$start_date = $other['data'][4];
|
||||||
$date = strtotime($start_date);
|
$date = strtotime($start_date);
|
||||||
|
|
||||||
|
|
||||||
$homeurl = '../';
|
$homeurl = '../';
|
||||||
$ttl = 1;
|
$ttl = 1;
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
$config['flash_charts'] = 0;
|
$config['flash_charts'] = 0;
|
||||||
|
|
||||||
$image = grafico_modulo_sparse ($id, $period, $draw_events,
|
$params =array(
|
||||||
$width, $height , $label, null,
|
'agent_module_id' => $id,
|
||||||
$draw_alerts, $avg_only, false,
|
'period' => $period,
|
||||||
$date, '', 0, 0,true,
|
'show_events' => $draw_events,
|
||||||
false, $homeurl, $ttl);
|
'width' => $width,
|
||||||
|
'height' => $height,
|
||||||
|
'show_alerts' => $draw_alerts,
|
||||||
|
'date' => $date,
|
||||||
|
'unit' => '',
|
||||||
|
'baseline' => 0,
|
||||||
|
'return_data' => 0,
|
||||||
|
'show_title' => true,
|
||||||
|
'only_image' => true,
|
||||||
|
'homeurl' => $homeurl,
|
||||||
|
'compare' => false,
|
||||||
|
'show_unknown' => true,
|
||||||
|
'backgroundColor' => 'white',
|
||||||
|
'percentil' => null,
|
||||||
|
'type_graph' => $config['type_module_charts'],
|
||||||
|
'fullscale' => false,
|
||||||
|
'return_img_base_64' => true
|
||||||
|
);
|
||||||
|
|
||||||
preg_match("/<div class=\"nodata_text\">/",
|
$image = grafico_modulo_sparse($params);
|
||||||
$image, $match);
|
|
||||||
|
|
||||||
if (!empty($match[0])) {
|
header('Content-type: text/html');
|
||||||
echo "Error no data";
|
returnData('string', array('type' => 'string', 'data' => '<img src="data:image/jpeg;base64,' . $image . '">'));
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Extract url of the image from img tag
|
|
||||||
preg_match("/src='([^']*)'/i", $image, $match);
|
|
||||||
|
|
||||||
if (empty($match[1])) {
|
|
||||||
echo "Error getting graph";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
header('Content-type: image/png');
|
|
||||||
header('Location: ' . $match[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10039,7 +10041,6 @@ function api_set_delete_special_day($id_special_day, $thrash2, $thrash3, $thrash
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function api_get_module_graph($id_module, $thrash2, $other, $thrash4) {
|
function api_get_module_graph($id_module, $thrash2, $other, $thrash4) {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (defined ('METACONSOLE')) {
|
if (defined ('METACONSOLE')) {
|
||||||
@ -10077,67 +10078,37 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$graph_html = grafico_modulo_sparse(
|
$params =array(
|
||||||
$id_module, $graph_seconds, false, 600, 300, '',
|
'agent_module_id' => $id_module,
|
||||||
'', false, false, true, time(), '', 0, 0, true, true,
|
'period' => $graph_seconds,
|
||||||
ui_get_full_url(false) . '/', 1, false, '', false, true,
|
'show_events' => false,
|
||||||
true, 'white', null, false, false, $config['type_module_charts'],
|
'width' => $width,
|
||||||
false, false);
|
'height' => $height,
|
||||||
|
'show_alerts' => false,
|
||||||
|
'date' => time(),
|
||||||
|
'unit' => '',
|
||||||
|
'baseline' => 0,
|
||||||
|
'return_data' => 0,
|
||||||
|
'show_title' => true,
|
||||||
|
'only_image' => true,
|
||||||
|
'homeurl' => ui_get_full_url(false) . '/',
|
||||||
|
'compare' => false,
|
||||||
|
'show_unknown' => true,
|
||||||
|
'backgroundColor' => 'white',
|
||||||
|
'percentil' => null,
|
||||||
|
'type_graph' => $config['type_module_charts'],
|
||||||
|
'fullscale' => false,
|
||||||
|
'return_img_base_64' => true,
|
||||||
|
'image_treshold' => $graph_threshold
|
||||||
|
);
|
||||||
|
|
||||||
$graph_image_file_encoded = false;
|
$graph_html = grafico_modulo_sparse($params);
|
||||||
if (preg_match("/<img src='(.+)'./", $graph_html, $matches)) {
|
|
||||||
$file_url = $matches[1];
|
|
||||||
|
|
||||||
if (preg_match("/\?(.+)&(.+)&(.+)&(.+)/", $file_url,$parameters)) {
|
|
||||||
array_shift ($parameters);
|
|
||||||
foreach ($parameters as $parameter){
|
|
||||||
$value = explode ("=",$parameter);
|
|
||||||
|
|
||||||
if (strcmp($value[0], "static_graph") == 0){
|
|
||||||
$static_graph = $value[1];
|
|
||||||
}
|
|
||||||
elseif (strcmp($value[0], "graph_type") == 0){
|
|
||||||
$graph_type = $value[1];
|
|
||||||
}
|
|
||||||
elseif (strcmp($value[0], "ttl") == 0){
|
|
||||||
$ttl = $value[1];
|
|
||||||
}
|
|
||||||
elseif (strcmp($value[0], "id_graph") == 0){
|
|
||||||
$id_graph = $value[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check values are OK
|
|
||||||
if ( (isset ($graph_type))
|
|
||||||
&& (isset ($ttl))
|
|
||||||
&& (isset ($id_graph))) {
|
|
||||||
$_GET["ttl"] = $ttl;
|
|
||||||
$_GET["id_graph"] = $id_graph;
|
|
||||||
$_GET["graph_type"] = $graph_type;
|
|
||||||
$_GET["static_graph"] = $static_graph;
|
|
||||||
$_GET["graph_threshold"] = $graph_threshold;
|
|
||||||
$_GET["id_module"] = $id_module;
|
|
||||||
}
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
include (__DIR__ . "/graphs/functions_pchart.php");
|
|
||||||
$output = ob_get_clean();
|
|
||||||
|
|
||||||
$graph_image_file_encoded = base64_encode($output);
|
|
||||||
if (empty($graph_image_file_encoded)) {
|
|
||||||
// returnError('error_module_graph', __(''));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if($other['data'][1]){
|
if($other['data'][1]){
|
||||||
header('Content-type: text/html');
|
header('Content-type: text/html');
|
||||||
returnData('string', array('type' => 'string', 'data' => '<img src="data:image/jpeg;base64,' . $graph_image_file_encoded . '">'));
|
returnData('string', array('type' => 'string', 'data' => '<img src="data:image/jpeg;base64,' . $graph_html . '">'));
|
||||||
} else {
|
} else {
|
||||||
returnData('string', array('type' => 'string', 'data' => $graph_image_file_encoded));
|
returnData('string', array('type' => 'string', 'data' => $graph_html));
|
||||||
}
|
|
||||||
// To show only the base64 code, call returnData as:
|
|
||||||
// returnData('string', array('type' => 'string', 'data' => $graph_image_file_encoded));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,7 +695,10 @@ function grafico_modulo_sparse_data(
|
|||||||
'time_interval' => 300,
|
'time_interval' => 300,
|
||||||
'array_data_create' => 0,
|
'array_data_create' => 0,
|
||||||
'show_legend' => true,
|
'show_legend' => true,
|
||||||
'show_overview' => true
|
'show_overview' => true,
|
||||||
|
'return_img_base_64' => false,
|
||||||
|
'image_treshold' => false,
|
||||||
|
'graph_combined' => false
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
function grafico_modulo_sparse ($params) {
|
function grafico_modulo_sparse ($params) {
|
||||||
@ -847,6 +850,18 @@ function grafico_modulo_sparse ($params) {
|
|||||||
$params['array_data_create'] = 0;
|
$params['array_data_create'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isset($params['return_img_base_64'])){
|
||||||
|
$params['return_img_base_64'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($params['image_treshold'])){
|
||||||
|
$params['image_treshold'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($params['graph_combined'])){
|
||||||
|
$params['graph_combined'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
$params['font'] = $config['fontpath'];
|
$params['font'] = $config['fontpath'];
|
||||||
$params['font-size'] = $config['font_size'];
|
$params['font-size'] = $config['font_size'];
|
||||||
|
|
||||||
@ -1155,7 +1170,7 @@ function graphic_combined_module (
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($id_graph == 0) {
|
if ($id_graph == 0) {
|
||||||
$params_combined['stacked'] = CUSTOM_GRAPH_LINE;
|
$params_combined['stacked'] = CUSTOM_GRAPH_AREA;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$params_combined['stacked'] = db_get_row('tgraph', 'id_graph', $id_graph);
|
$params_combined['stacked'] = db_get_row('tgraph', 'id_graph', $id_graph);
|
||||||
@ -1263,6 +1278,10 @@ function graphic_combined_module (
|
|||||||
$params['menu'] = false;
|
$params['menu'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isset($params['type_graph'])){
|
||||||
|
$params['type_graph'] = $config['type_module_charts'];
|
||||||
|
}
|
||||||
|
|
||||||
if(!isset($params['percentil'])){
|
if(!isset($params['percentil'])){
|
||||||
$params['percentil'] = null;
|
$params['percentil'] = null;
|
||||||
}
|
}
|
||||||
@ -1291,6 +1310,20 @@ function graphic_combined_module (
|
|||||||
$params['show_export_csv'] = true;
|
$params['show_export_csv'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!isset($params['return_img_base_64'])){
|
||||||
|
$params['return_img_base_64'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($params['image_treshold'])){
|
||||||
|
$params['image_treshold'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$params['graph_combined'] = true;
|
||||||
|
|
||||||
|
if(!isset($params['show_unknown'])){
|
||||||
|
$params['show_unknown'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
//XXXX
|
//XXXX
|
||||||
if($params['only_image']){
|
if($params['only_image']){
|
||||||
return generator_chart_to_pdf('combined', $params, $params_combined, $module_list);
|
return generator_chart_to_pdf('combined', $params, $params_combined, $module_list);
|
||||||
@ -1437,6 +1470,7 @@ function graphic_combined_module (
|
|||||||
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
|
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
|
||||||
$data_module_graph['module_id'] = $agent_module_id;
|
$data_module_graph['module_id'] = $agent_module_id;
|
||||||
|
|
||||||
|
|
||||||
//stract data
|
//stract data
|
||||||
$array_data_module = grafico_modulo_sparse_data(
|
$array_data_module = grafico_modulo_sparse_data(
|
||||||
$agent_module_id,
|
$agent_module_id,
|
||||||
@ -4016,6 +4050,7 @@ function fullscale_data (
|
|||||||
|
|
||||||
if ($v["datos"] === NULL) {
|
if ($v["datos"] === NULL) {
|
||||||
// Unknown
|
// Unknown
|
||||||
|
if($show_unknown){
|
||||||
if(!$compare){
|
if(!$compare){
|
||||||
if($flag_unknown){
|
if($flag_unknown){
|
||||||
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
|
$data["unknown" . $series_suffix]['data'][] = array($real_date , 1);
|
||||||
@ -4026,6 +4061,7 @@ function fullscale_data (
|
|||||||
$flag_unknown = 1;
|
$flag_unknown = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$data["sum" . $series_suffix]['data'][] = array($real_date , $previous_data);
|
$data["sum" . $series_suffix]['data'][] = array($real_date , $previous_data);
|
||||||
}
|
}
|
||||||
@ -4033,6 +4069,7 @@ function fullscale_data (
|
|||||||
//normal
|
//normal
|
||||||
$previous_data = $v["datos"];
|
$previous_data = $v["datos"];
|
||||||
$data["sum" . $series_suffix]['data'][] = array($real_date , $v["datos"]);
|
$data["sum" . $series_suffix]['data'][] = array($real_date , $v["datos"]);
|
||||||
|
if($show_unknown){
|
||||||
if(!$compare){
|
if(!$compare){
|
||||||
if($flag_unknown){
|
if($flag_unknown){
|
||||||
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
|
$data["unknown" . $series_suffix]['data'][] = array($real_date , 0);
|
||||||
@ -4040,6 +4077,7 @@ function fullscale_data (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($v["datos"]) && $v["datos"]){
|
if(isset($v["datos"]) && $v["datos"]){
|
||||||
//max
|
//max
|
||||||
|
@ -877,7 +877,8 @@ function pandoraFlotArea(
|
|||||||
var min_x = date_array['start_date'] *1000;
|
var min_x = date_array['start_date'] *1000;
|
||||||
var max_x = date_array['final_date'] *1000;
|
var max_x = date_array['final_date'] *1000;
|
||||||
var type = params.stacked;
|
var type = params.stacked;
|
||||||
var show_legend= params.show_legend;
|
var show_legend = params.show_legend;
|
||||||
|
var image_treshold = params.image_treshold;
|
||||||
|
|
||||||
if(typeof type === 'undefined' || type == ''){
|
if(typeof type === 'undefined' || type == ''){
|
||||||
type = params.type_graph;
|
type = params.type_graph;
|
||||||
@ -1481,7 +1482,7 @@ function pandoraFlotArea(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'line':
|
case 'line':
|
||||||
case 2:
|
case 2:
|
||||||
@ -1841,7 +1842,7 @@ if (vconsole) {
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
console.log(homeurl);
|
|
||||||
$('#menu_cancelzoom_' + graph_id).attr('src', homeurl + '/images/zoom_cross_grey.png');
|
$('#menu_cancelzoom_' + graph_id).attr('src', homeurl + '/images/zoom_cross_grey.png');
|
||||||
|
|
||||||
// currentRanges = ranges;
|
// currentRanges = ranges;
|
||||||
@ -2083,6 +2084,46 @@ console.log(homeurl);
|
|||||||
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
|
$('#overview_'+graph_id).bind('mouseout',resetInteractivity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(image_treshold){
|
||||||
|
if(!thresholded){
|
||||||
|
// Recalculate the y axis
|
||||||
|
var y_recal = axis_thresholded(
|
||||||
|
threshold_data,
|
||||||
|
plot.getAxes().yaxis.min,
|
||||||
|
plot.getAxes().yaxis.max,
|
||||||
|
red_threshold, extremes,
|
||||||
|
red_up
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
var y_recal = plot.getAxes().yaxis.max
|
||||||
|
}
|
||||||
|
|
||||||
|
datas_treshold = add_threshold (
|
||||||
|
data_base,
|
||||||
|
threshold_data,
|
||||||
|
plot.getAxes().yaxis.min,
|
||||||
|
plot.getAxes().yaxis.max,
|
||||||
|
red_threshold,
|
||||||
|
extremes,
|
||||||
|
red_up,
|
||||||
|
markins_graph
|
||||||
|
);
|
||||||
|
|
||||||
|
plot = $.plot($('#' + graph_id), datas_treshold,
|
||||||
|
$.extend(true, {}, options, {
|
||||||
|
yaxis: {
|
||||||
|
max: y_recal.max,
|
||||||
|
},
|
||||||
|
xaxis: {
|
||||||
|
min: plot.getAxes().xaxis.min,
|
||||||
|
max: plot.getAxes().xaxis.max
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
thresholded = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Reset interactivity styles
|
// Reset interactivity styles
|
||||||
function resetInteractivity(vconsole) {
|
function resetInteractivity(vconsole) {
|
||||||
$('#timestamp_'+graph_id).hide();
|
$('#timestamp_'+graph_id).hide();
|
||||||
@ -2546,7 +2587,14 @@ function add_threshold (data_base, threshold_data, y_min, y_max,
|
|||||||
threshold_array[index]['max'] = end;
|
threshold_array[index]['max'] = end;
|
||||||
threshold_array[index]['color'] = "red";
|
threshold_array[index]['color'] = "red";
|
||||||
} else {
|
} else {
|
||||||
end = extremes[this.id + '_1'];
|
var first = extremes[this.id + '_1'];
|
||||||
|
var second = extremes[this.id + '_2'];
|
||||||
|
if(first > second){
|
||||||
|
end = first;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
end = second;
|
||||||
|
}
|
||||||
threshold_array[index]['min'] = this.data[0][1];
|
threshold_array[index]['min'] = this.data[0][1];
|
||||||
threshold_array[index]['max'] = end;
|
threshold_array[index]['max'] = end;
|
||||||
threshold_array[index]['color'] = "yellow";
|
threshold_array[index]['color'] = "yellow";
|
||||||
@ -2596,7 +2644,7 @@ function add_threshold (data_base, threshold_data, y_min, y_max,
|
|||||||
var extreme_treshold_array = [];
|
var extreme_treshold_array = [];
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var flag = true;
|
var flag = true;
|
||||||
console.log(threshold_array);
|
|
||||||
$.each(threshold_array, function(index, value) {
|
$.each(threshold_array, function(index, value) {
|
||||||
flag = true;
|
flag = true;
|
||||||
extreme_treshold_array[i] = {
|
extreme_treshold_array[i] = {
|
||||||
|
@ -131,13 +131,19 @@ function flot_area_graph (
|
|||||||
|
|
||||||
///XXXXXXX los px caca
|
///XXXXXXX los px caca
|
||||||
// Parent layer
|
// Parent layer
|
||||||
$return = "<div class='parent_graph' style='width: " . ($params['width']) . "; height:" . ($params['height'] + 30) . "px; " . $background_style . "'>";
|
$return = "<div class='parent_graph' style='width: " . ($params['width']) . ";" . $background_style . "'>";
|
||||||
// Set some containers to legend, graph, timestamp tooltip, etc.
|
// Set some containers to legend, graph, timestamp tooltip, etc.
|
||||||
if($params['show_legend']){
|
if($params['show_legend']){
|
||||||
$return .= "<p id='legend_$graph_id' class='legend_graph' style='font-size:" . $params['font_size'] ."pt !important;'></p>";
|
$return .= "<p id='legend_$graph_id' class='legend_graph' style='font-size:" . $params['font_size'] ."pt !important;'></p>";
|
||||||
}
|
}
|
||||||
|
if(isset($params['graph_combined']) && $params['graph_combined'] &&
|
||||||
if(!isset($params['combined']) || !$params['combined']){
|
(!isset($params['from_interface']) || !$params['from_interface']) ){
|
||||||
|
$yellow_up = 0;
|
||||||
|
$red_up = 0;
|
||||||
|
$yellow_inverse = false;
|
||||||
|
$red_inverse = false;
|
||||||
|
}
|
||||||
|
elseif(!isset($params['combined']) || !$params['combined']){
|
||||||
$yellow_threshold = $data_module_graph['w_min'];
|
$yellow_threshold = $data_module_graph['w_min'];
|
||||||
$red_threshold = $data_module_graph['c_min'];
|
$red_threshold = $data_module_graph['c_min'];
|
||||||
// Get other required module datas to draw warning and critical
|
// Get other required module datas to draw warning and critical
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
var system = require('system');
|
var system = require('system');
|
||||||
|
|
||||||
if (system.args.length < 3 || system.args.length > 9) {
|
if (system.args.length < 3 || system.args.length > 10) {
|
||||||
phantom.exit(1);
|
phantom.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,6 +14,7 @@ var url_module_list = system.args[5];
|
|||||||
var output_filename = system.args[6];
|
var output_filename = system.args[6];
|
||||||
var _width = system.args[7];
|
var _width = system.args[7];
|
||||||
var _height = system.args[8];
|
var _height = system.args[8];
|
||||||
|
var base_64 = system.args[9];
|
||||||
|
|
||||||
if (!_width) {
|
if (!_width) {
|
||||||
_width = 750;
|
_width = 750;
|
||||||
@ -38,13 +39,17 @@ page.viewportSize = { width: _width, height: _height };
|
|||||||
//page.zoomFactor = 1.75;
|
//page.zoomFactor = 1.75;
|
||||||
|
|
||||||
page.open(finish_url, function start(status) {
|
page.open(finish_url, function start(status) {
|
||||||
page.includeJs('./javascript/pandora.js');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
page.onLoadFinished = function (status) {
|
page.onLoadFinished = function (status) {
|
||||||
|
if(!base_64){
|
||||||
page.render(output_filename, {format: 'png'});
|
page.render(output_filename, {format: 'png'});
|
||||||
//var base64 = page.renderBase64('JPG');
|
}
|
||||||
//console.log(base64);
|
else{
|
||||||
|
var base64 = page.renderBase64('png');
|
||||||
|
console.log(base64);
|
||||||
|
}
|
||||||
phantom.exit();
|
phantom.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user