fixed water mark in graphs

This commit is contained in:
daniel 2018-06-07 09:15:45 +02:00
parent 867e00c50d
commit 7834869977
6 changed files with 42 additions and 38 deletions

View File

@ -3179,6 +3179,7 @@ function generator_chart_to_pdf($type_graph_pdf, $params, $params_combined = fal
return $result;
}
else{
$config["temp_images"][] = $img_url;
return '<img src="' . $img_url . '" />';
}
}

View File

@ -976,8 +976,15 @@ function grafico_modulo_sparse ($params) {
return $array_data;
}
//XXX
//esto lo tenia la bool
$series_type_array = series_type_graph_array(
$array_data,
$params
);
$series_type = $series_type_array['series_type'];
$legend = $series_type_array['legend'];
if($config["fixed_graph"] == false){
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url(
@ -987,17 +994,7 @@ function grafico_modulo_sparse ($params) {
false
)
);
$series_type_array = series_type_graph_array(
$array_data,
$params
);
$series_type = $series_type_array['series_type'];
$legend = $series_type_array['legend'];
//esto la sparse
//setup_watermark($water_mark, $water_mark_file, $water_mark_url);
}
$data_module_graph['series_suffix'] = $series_suffix;
@ -1318,12 +1315,11 @@ function graphic_combined_module (
$params['image_treshold'] = false;
}
$params['graph_combined'] = true;
if(!isset($params['show_unknown'])){
$params['show_unknown'] = false;
}
$params['graph_combined'] = true;
//XXXX
if($params['only_image']){
return generator_chart_to_pdf('combined', $params, $params_combined, $module_list);
@ -1425,11 +1421,22 @@ function graphic_combined_module (
$ttl = $params['ttl'];
$background_color = $params['backgroundColor'];
$datelimit = $date_array["start_date"];
$fixed_font_size = $config['font_size'];
$flash_charts = false;
if($config["fixed_graph"] == false){
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url(
"/images/logo_vertical_water.png",
false,
false,
false
)
);
}
//XXX no se que hacen
$fixed_font_size = $config['font_size'];
$water_mark = '';
$long_index = '';
$color = array();
@ -1439,7 +1446,6 @@ function graphic_combined_module (
case CUSTOM_GRAPH_STACKED_AREA:
case CUSTOM_GRAPH_AREA:
case CUSTOM_GRAPH_LINE:
$date_array = array();
$date_array["period"] = $params['period'];
$date_array["final_date"] = $params['date'];
@ -1470,7 +1476,6 @@ function graphic_combined_module (
$data_module_graph['c_inv'] = $module_data['critical_inverse'];
$data_module_graph['module_id'] = $agent_module_id;
//stract data
$array_data_module = grafico_modulo_sparse_data(
$agent_module_id,
@ -1546,7 +1551,6 @@ function graphic_combined_module (
$series_type = $series_type_array['series_type'];
$legend = $series_type_array['legend'];
//XXXXXXREVISAR
$threshold_data = array();
if ($params_combined['from_interface']) {
$yellow_threshold = 0;
@ -1656,7 +1660,7 @@ function graphic_combined_module (
$threshold_data['red_inverse'] = (bool)$red_inverse;
}
$show_elements_graph['threshold_data'] = $threshold_data;
$params['threshold_data'] = $threshold_data;
}
$output = area_graph(
@ -1674,7 +1678,6 @@ function graphic_combined_module (
break;
case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD:
case CUSTOM_GRAPH_BULLET_CHART:
if($params_combined['stacked'] == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$acumulador = 0;
foreach ($module_list as $module_item) {

View File

@ -230,6 +230,8 @@ function area_graph(
include_once('functions_flot.php');
//setup_watermark($water_mark, $water_mark_file, $water_mark_url);
return flot_area_graph(
$agent_module_id,
$array_data,

View File

@ -857,7 +857,7 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul
function pandoraFlotArea(
graph_id, values, legend, agent_module_id,
series_type, watermark, date_array,
series_type, water_mark, date_array,
data_module_graph, params,
force_integer,
background_color, legend_color, short_data,
@ -900,7 +900,7 @@ function pandoraFlotArea(
//XXXX ver que hay que hacer
var labels_long = '';
var min_check = 0;
var water_mark = '';
var legend_events = null;
var legend_alerts = null;
@ -2303,9 +2303,11 @@ if (vconsole) {
}
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'));
adjust_menu(graph_id, plot, parent_height, width, show_legend);
}
//adjust_menu(graph_id, plot, parent_height, width, show_legend);
}
}
@ -2340,22 +2342,21 @@ function adjust_menu(graph_id, plot, parent_height, width, show_legend) {
}
function set_watermark(graph_id, plot, watermark_src) {
console.log('entra por la watermark');
var img = new Image();
img.src = watermark_src;
var context = plot.getCanvas().getContext('2d');
// Once it's loaded draw the image on the canvas.
img.addEventListener('load', function () {
//~ // Now resize the image: x, y, w, h.
// Now resize the image: x, y, w, h.
var down_ticks_height = 0;
if ($('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height') != undefined) {
down_ticks_height = $('#'+graph_id+' .yAxis .tickLabel').eq(0).css('height').split('px')[0];
}
var left_pos = parseInt(context.canvas.width - 3) - $('#watermark_image_'+graph_id)[0].width;
var top_pos = 6;
var left_pos = parseInt(context.canvas.width) - $('#watermark_image_'+graph_id)[0].width - 30;
var top_pos = 7;
//var top_pos = parseInt(context.canvas.height - down_ticks_height - 10) - $('#watermark_image_'+graph_id)[0].height;
//var left_pos = 380;
context.drawImage(this, left_pos, top_pos);

View File

@ -222,10 +222,8 @@ function flot_area_graph (
style='margin:0px; margin-top:30px; margin-bottom:50px; display:none; width: ".$params['width']."; height: 200px;'></div>";
}
//XXXXTODO
$water_mark = '';
if ($water_mark != '') {
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='$water_mark'></div>";
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='" . $water_mark['url'] . "'></div>";
$watermark = 'true';
}
else {

View File

@ -136,7 +136,6 @@ function setup_watermark($water_mark, &$water_mark_file, &$water_mark_url) {
if (!is_array($water_mark)) {
$water_mark_file = $water_mark;
$water_mark_url = '';
return;
}