Merge branch '1827-Graficas_TIP_eje_x_no_mantiene_ratio' into 'develop'

1827 graficas tip eje x no mantiene ratio

See merge request artica/pandorafms!1538
This commit is contained in:
vgilc 2018-06-14 10:12:05 +02:00
commit 3a4f3a38be
11 changed files with 132 additions and 227 deletions

View File

@ -2926,8 +2926,6 @@ function chooseType() {
$("#row_agent").show();
$("#row_module").show();
$("#row_period").show();
$("#row_show_in_landscape").show();
$("#row_time_compare_overlapped").show();
$("#row_historical_db_check").hide();
break;
@ -2937,8 +2935,6 @@ function chooseType() {
$("#row_module").show();
$("#row_period1").show();
$("#row_estimate").show();
$("#row_show_in_two_columns").show();
$("#row_show_in_landscape").show();
$("#row_historical_db_check").hide();
break;
@ -2957,8 +2953,6 @@ function chooseType() {
$("#row_description").show();
$("#row_period").show();
$("#row_custom_graph").show();
$("#row_show_in_two_columns").show();
$("#row_show_in_landscape").show();
$("#row_historical_db_check").hide();
break;
@ -3116,9 +3110,7 @@ function chooseType() {
$("#row_description").show();
$("#row_query").show();
$("#row_max_items").show();
$("#row_show_in_two_columns").show();
$("#row_dyn_height").show();
$("#row_show_in_landscape").show();
$("#row_servers").show();
$("#row_historical_db_check").show();
break;

View File

@ -3053,10 +3053,20 @@ function series_type_graph_array($data, $show_elements_graph){
if($show_elements_graph['id_widget_dashboard']){
$opcion = unserialize(db_get_value_filter('options','twidget_dashboard',array('id' => $show_elements_graph['id_widget_dashboard'])));
foreach ($opcion as $key => $value) {
if($show_elements_graph['graph_combined']){
foreach ($show_elements_graph['modules_id'] as $key => $value) {
$color_series[$key] = array(
'border' => '#000000',
'color' => $opcion[$value],
'alpha' => CHART_DEFAULT_ALPHA
);
}
}
else{
$color_series[0] = array(
'border' => '#000000',
'color' => $opcion['avg'],
'color' => $opcion['max'],
'alpha' => CHART_DEFAULT_ALPHA
);
}

View File

@ -43,7 +43,7 @@ function config_create_value ($token, $value) {
*/
function config_update_value ($token, $value) {
global $config;
$config['flash_charts'] = true;
// Include functions_io to can call __() function
include_once($config['homedir'] . '/include/functions_io.php');

View File

@ -701,7 +701,8 @@ function grafico_modulo_sparse_data(
'show_overview' => true,
'return_img_base_64' => false,
'image_treshold' => false,
'graph_combined' => false
'graph_combined' => false,
'zoom' => 1
);
*/
function grafico_modulo_sparse ($params) {
@ -873,7 +874,7 @@ function grafico_modulo_sparse ($params) {
$params['grid_color'] = '#C1C1C1';
$params['legend_color'] = '#636363';
$params['font'] = $config['fontpath'];
$params['font-size'] = $config['font_size'];
$params['font_size'] = $config['font_size'];
$params['short_data'] = $config['short_module_graph_data'];
if($params['only_image']){
@ -1084,22 +1085,6 @@ function grafico_modulo_sparse ($params) {
return $return;
}
function graph_get_formatted_date($timestamp, $format1, $format2) {
global $config;
if ($config['flash_charts']) {
$date = date("$format1 $format2", $timestamp);
}
else {
$date = date($format1, $timestamp);
if ($format2 != '') {
$date .= "\n".date($format2, $timestamp);
}
}
return $date;
}
/**
* Produces a combined/user defined graph
*
@ -1168,6 +1153,8 @@ function graphic_combined_module (
$params_combined
) {
global $config;
if(!isset($params_combined['from_interface'])){
$params_combined['from_interface'] = false;
}
@ -1182,11 +1169,11 @@ function graphic_combined_module (
}
}
else {
if ($id_graph == 0) {
if ($params_combined['id_graph'] == 0) {
$params_combined['stacked'] = CUSTOM_GRAPH_AREA;
}
else {
$params_combined['stacked'] = db_get_row('tgraph', 'id_graph', $id_graph);
$params_combined['stacked'] = db_get_row('tgraph', 'id_graph', $params_combined['id_graph']);
}
}
}
@ -1334,6 +1321,7 @@ function graphic_combined_module (
}
$params['graph_combined'] = true;
$params_combined['graph_combined'] = true;
if($params['only_image']){
return generator_chart_to_pdf('combined', $params, $params_combined, $module_list);
@ -1348,13 +1336,15 @@ function graphic_combined_module (
$params['grid_color'] = '#C1C1C1';
$params['legend_color'] = '#636363';
$params['font'] = $config['fontpath'];
$params['font-size'] = $config['font_size'];
$params['font_size'] = $config['font_size'];
$params['short_data'] = $config['short_module_graph_data'];
global $config;
global $graphic_type;
$sources = false;
if ($params_combined['id_graph'] == 0) {
$count_modules = count($module_list);
@ -1402,6 +1392,13 @@ function graphic_combined_module (
}
}
if($module_list){
$params_combined['modules_id'] = $module_list;
}
else{
$params_combined['modules_id'] = $modules;
}
if(isset($summatory)){
$params_combined['summatory'] = $summatory;
}
@ -1543,6 +1540,8 @@ function graphic_combined_module (
}
if($params_combined['projection'] && is_array($params_combined['projection'])){
$date_array_projection = max($params_combined['projection']);
$date_array['final_date'] = $date_array_projection[0] / 1000;
$array_data['projection']['data']= $params_combined['projection'];
}
@ -2252,7 +2251,7 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0, $return =
'backgroundColor' => '#f9faf9',
'type_graph' => 'area',
'font' => $config['fontpath'],
'font-size' => $config['font_size'],
'font_size' => $config['font_size'],
'array_data_create' => $data_array,
'show_overview' => false,
'show_export_csv' => false,
@ -4123,7 +4122,7 @@ function graph_netflow_aggregate_area ($data, $period, $width, $height, $unit =
'backgroundColor' => 'white',
'type_graph' => 'area',
'font' => $config['fontpath'],
'font-size' => $config['font_size'],
'font_size' => $config['font_size'],
'array_data_create' => $chart
);
@ -4184,7 +4183,7 @@ function graph_netflow_total_area ($data, $period, $width, $height, $unit = '',
'backgroundColor' => 'white',
'type_graph' => 'area',
'font' => $config['fontpath'],
'font-size' => $config['font_size'],
'font_size' => $config['font_size'],
'array_data_create' => $chart
);

View File

@ -6295,77 +6295,12 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
$report,
$content);
$graphs = db_get_all_rows_field_filter ("tgraph_source",
"id_graph", $content['id_gs']);
$modules = array ();
$weights = array ();
if ($graphs === false)
$graphs = array();
$labels = array();
foreach ($graphs as $graph_item) {
if ($type_report == 'automatic_graph') {
array_push ($modules, array(
'module' => $graph_item['id_agent_module'],
'server' => $graph_item['id_server']));
}
else {
array_push ($modules, $graph_item['id_agent_module']);
}
if (in_array('label',$content['style'])) {
if (defined('METACONSOLE')) {
$server_name = $content['server_name'];
$connection = metaconsole_get_connection($server_name);
if (!metaconsole_load_external_db($connection)) {
//ui_print_error_message ("Error connecting to ".$server_name);
continue;
}
$item = array('type' => 'custom_graph',
'id_agent' =>modules_get_agentmodule_agent($graph_item['id_agent_module']),
'id_agent_module'=>$graph_item['id_agent_module']);
}
else {
$item = array('type' => 'custom_graph',
'id_agent' =>modules_get_agentmodule_agent($graph_item['id_agent_module']),
'id_agent_module'=>$graph_item['id_agent_module']);
}
$label = reporting_label_macro($item, $content['style']['label']);
$labels[$graph_item['id_agent_module']] = $label;
if (defined('METACONSOLE')) {
//Restore db connection
metaconsole_restore_db();
}
}
array_push ($weights, $graph_item["weight"]);
}
if ($config['metaconsole'] && $type_report != 'automatic_graph') {
$id_meta = metaconsole_get_id_server($content["server_name"]);
$server = metaconsole_get_connection_by_id ($id_meta);
metaconsole_connect($server);
}
$graphs = db_get_all_rows_field_filter ("tgraph", "id_graph", $content['id_gs']);
$return['chart'] = '';
// Get chart
//reporting_set_conf_charts($width, $height, $only_image, $type,
// $content, $ttl);
$width =null;
$height =null;
//height for bullet chart
/*
if($graph['stacked'] != 4){
$height += count($modules) * REPORTING_CUSTOM_GRAPH_LEGEND_EACH_MODULE_VERTICAL_SIZE;
}
else{
if(!$only_image){
$height = 50;
}
}
*/
$width =null;
$height =null;
switch ($type) {
case 'dinamic':
@ -6379,17 +6314,16 @@ $height =null;
'only_image' => $pdf,
'homeurl' => ui_get_full_url(false, false, false, false),
'ttl' => $ttl,
'percentil' => $graph["percentil"],
'fullscale' => $graph["fullscale"],
'percentil' => $graphs[0]["percentil"],
'fullscale' => $graphs[0]["fullscale"],
);
$params_combined = array(
'weight_list' => $weights,
'stacked' => $graph["stacked"],
'labels' => $labels,
'summatory' => $graph["summatory_series"],
'average' => $graph["average_series"],
'modules_series' => $graph["modules_series"]
'stacked' => $graphs[0]["stacked"],
'summatory' => $graphs[0]["summatory_series"],
'average' => $graphs[0]["average_series"],
'modules_series' => $graphs[0]["modules_series"],
'id_graph' => $content['id_gs']
);
$return['chart'] = graphic_combined_module(

View File

@ -965,6 +965,8 @@ function visual_map_print_item($mode = "read", $layoutData,
$height = 480;
}
$graphs = db_get_all_rows_field_filter ("tgraph", "id_graph", $layoutData['id_custom_graph']);
$params =array(
'period' => $period,
'width' => $width,
@ -978,7 +980,11 @@ function visual_map_print_item($mode = "read", $layoutData,
);
$params_combined = array(
'id_graph' => $layoutData['id_custom_graph']
'id_graph' => $layoutData['id_custom_graph'],
'stacked' => $graphs[0]["stacked"],
'summatory' => $graphs[0]["summatory_series"],
'average' => $graphs[0]["average_series"],
'modules_series' => $graphs[0]["modules_series"]
);
if ($layoutData['label_position']=='left') {

View File

@ -861,12 +861,11 @@ function pandoraFlotArea( graph_id, values, legend,
series_type, color, water_mark, date_array,
data_module_graph, params, events_array
) {
//diferents vars
var unit = params.unit ? params.unit : '';
var homeurl = params.homeurl;
var font_size = params.font_size;
var font = params.font;
var font_size = parseInt(params.font_size);
var font = params.font.split("/").pop().split(".").shift();
var width = params.width;
var height = params.height;
var vconsole = params.vconsole;
@ -874,7 +873,7 @@ function pandoraFlotArea( graph_id, values, legend,
var menu = params.menu;
var min_x = date_array['start_date'] *1000;
var max_x = date_array['final_date'] *1000;
var type = params.stacked;
var type = parseInt(params.stacked);
var show_legend = params.show_legend;
var image_treshold = params.image_treshold;
var short_data = params.short_data;
@ -1580,12 +1579,10 @@ function pandoraFlotArea( graph_id, values, legend,
});
// The first execution, the graph data is the base data
datas = data_base;
datas = data_base;
// minTickSize
var count_data = datas[0].data.length;
var min_tick = datas[0].data[0][0];
var max_tick = datas[0].data[count_data - 1][0];
var number_ticks = 8;
if(vconsole){
@ -1593,7 +1590,7 @@ function pandoraFlotArea( graph_id, values, legend,
}
var maxticks = date_array['period'] / 3600 / number_ticks;
console.log(grid_color);
var options = {
series: {
stack: stacked,
@ -1623,27 +1620,29 @@ console.log(grid_color);
},
xaxis: {
min: min_x,
max: max_x
max: max_x,
font: {
size: font_size + 2,
color: legend_color,
family: font+'Font'
}
},
xaxes: [{
axisLabelUseCanvas: true,
axisLabelFontSizePixels: font_size,
axisLabelFontFamily: font+'Font',
axisLabelPadding: 0,
mode: "time",
timezone: "browser",
localTimezone: true,
//tickFormatter: xFormatter,
tickSize: [maxticks, 'hour']
}],
yaxis: {
font: {
size: font_size + 2,
color: legend_color,
family: font+'Font'
},
},
yaxes: [{
tickFormatter: yFormatter,
color: '',
alignTicksWithAxis: 1,
labelWidth: 30,
position: 'left',
font: font,
reserveSpace: true
position: 'left'
}],
legend: {
position: 'se',
@ -1725,27 +1724,29 @@ if (vconsole) {
},
xaxis: {
min: date_array.start_date * 1000,
max: date_array.final_date * 1000
max: date_array.final_date * 1000,
font: {
size: font_size + 2,
color: legend_color,
family: font+'Font'
}
},
xaxes: [{
axisLabelUseCanvas: true,
axisLabelFontSizePixels: font_size,
axisLabelFontFamily: font+'Font',
axisLabelPadding: 0,
mode: "time",
timezone: "browser",
localTimezone: true,
//tickFormatter: xFormatter,
tickSize: [maxticks, 'hour']
}],
yaxis: {
font: {
size: font_size + 2,
color: legend_color,
family: font+'Font'
},
},
yaxes: [{
tickFormatter: yFormatter,
color: '',
alignTicksWithAxis: 1,
labelWidth: 30,
position: 'left',
font: font,
reserveSpace: true
position: 'left'
}],
legend: {
position: 'se',
@ -1755,8 +1756,6 @@ if (vconsole) {
});
}
$('#legend_' + graph_id + ' .legendLabel').css('color', legend_color);
// Adjust overview when main chart is resized
$('#overview_'+graph_id).resize(function(){
update_left_width_canvas(graph_id);
@ -1800,31 +1799,31 @@ if (vconsole) {
},
xaxis: {
min: ranges.xaxis.from,
max: ranges.xaxis.to
max: ranges.xaxis.to,
font: {
size: font_size + 2,
color: legend_color,
family: font+'Font'
}
},
xaxes: [{
axisLabelUseCanvas: true,
axisLabelFontSizePixels: font_size,
axisLabelFontFamily: font+'Font',
axisLabelPadding: 0,
mode: "time",
timezone: "browser",
localTimezone: true,
//tickFormatter: xFormatter,
tickSize: [maxticks_zoom, 'hour']
}],
yaxis:{
min: ranges.yaxis.from,
max: ranges.yaxis.to
max: ranges.yaxis.to,
font: {
size: font_size + 2,
color: legend_color,
family: font+'Font'
},
},
yaxes: [{
tickFormatter: yFormatter,
color: '',
alignTicksWithAxis: 1,
labelWidth: 30,
position: 'left',
font: font,
reserveSpace: true,
position: 'left'
}],
legend: {
show: true
@ -1841,31 +1840,31 @@ if (vconsole) {
},
xaxis: {
min: ranges.xaxis.from,
max: ranges.xaxis.to
max: ranges.xaxis.to,
font: {
size: font_size + 2,
color: legend_color,
family: font+'Font'
}
},
xaxes: [{
axisLabelUseCanvas: true,
axisLabelFontSizePixels: font_size,
axisLabelFontFamily: font+'Font',
axisLabelPadding: 0,
mode: "time",
timezone: "browser",
localTimezone: true,
//tickFormatter: xFormatter,
tickSize: [maxticks_zoom, 'hour']
}],
yaxis:{
min: ranges.yaxis.from,
max: ranges.yaxis.to
max: ranges.yaxis.to,
font: {
size: font_size + 2,
color: legend_color,
family: font+'Font'
},
},
yaxes: [{
tickFormatter: yFormatter,
color: '',
alignTicksWithAxis: 1,
labelWidth: 30,
position: 'left',
font: font,
reserveSpace: true,
position: 'left'
}],
legend: {
show: true
@ -1930,6 +1929,11 @@ if (vconsole) {
$('#timestamp_'+graph_id).height() +
$('#legend_' + graph_id).height());
$('#timestamp_'+graph_id).css('color', legend_color);
$('#timestamp_'+graph_id).css('font-size', font_size + 2);
$('#timestamp_'+graph_id).css('font-family', font + 'Font');
$('#timestamp_'+graph_id).css('color', legend_color);
if (timesize+timenewpos > canvaslimit) {
$('#timestamp_'+graph_id).css('left', timenewpos - timesize);
}
@ -1990,14 +1994,7 @@ if (vconsole) {
);
}
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).css('font-size',font_size+'pt');
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).css('color', legend_color);
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).css('font-family',font);
$('#legend_' + graph_id + ' .legendLabel').eq(i).css('color', legend_color);
i++;
}
@ -2163,34 +2160,13 @@ if (vconsole) {
$('#legend_' + graph_id + ' .legendLabel')
.eq(i).html(label_aux);
}
$('#legend_' + graph_id + ' .legendLabel').css('color', legend_color);
plot.clearCrosshair();
if(!vconsole){
overview.clearCrosshair();
}
}
// Format functions
function xFormatter(v, axis) {
var d = new Date(v);
var result_date_format = 0;
var monthNames = [
"Jan", "Feb", "Mar",
"Apr", "May", "Jun",
"Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"
];
result_date_format = (d.getDate() <10?'0':'') + d.getDate() + " " +
monthNames[d.getMonth()] + " " +
d.getFullYear() + "\n" +
(d.getHours()<10?'0':'') + d.getHours() + ":" +
(d.getMinutes()<10?'0':'') + d.getMinutes() + ":" +
(d.getSeconds()<10?'0':'') + d.getSeconds();
return '<div class='+font+' style="font-size:'+font_size+'pt; margin-top:15px;">'+result_date_format+'</div>';
}
function yFormatter(v, axis) {
axis.datamin = 0;
if (short_data) {
@ -2207,25 +2183,19 @@ if (vconsole) {
// Get only two decimals
formatted = round_with_decimals(formatted, 100);
return '<div class='+font+' style="font-size:'+font_size+'pt;">'+formatted+'</div>';
return formatted;
}
function lFormatter(v, item) {
return '<div style="font-size:'+font_size+'pt;">'+legend[v]+'</div>';
return '<span style="color:'+legend_color+'">'+legend[v]+'</span>';
}
$('#overview_' + graph_id).css('display', 'none');
if (menu) {
var parent_height;
$('#menu_overview_' + graph_id).click(function() {
$('#overview_' + graph_id).toggle();
/*
if($('#overview_' + graph_id).css('visibility') == 'visible'){
$('#overview_' + graph_id).css('visibility', 'hidden');
}
else{
$('#overview_' + graph_id).css('visibility', 'visible');
}
*/
});
$("#menu_export_csv_"+graph_id)

View File

@ -137,7 +137,7 @@ function flot_area_graph (
$return = "<div class='parent_graph' style='width: " . ($params['width']) . ";" . $background_style . "'>";
// Set some containers to legend, graph, timestamp tooltip, etc.
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; color:" . $params['legend_color'] . " !important;'></p>";
}
if(isset($params['graph_combined']) && $params['graph_combined'] &&
(!isset($params['from_interface']) || !$params['from_interface']) ){
@ -222,7 +222,7 @@ function flot_area_graph (
if (!$vconsole){
$return .= "<div id='overview_$graph_id' class='overview_graph'
style='margin:0px; margin-top:30px; margin-bottom:50px; display:none; width: ".$params['width']."; height: 200px;'></div>";
style='margin:0px; margin-top:30px; margin-bottom:50px; width: ".$params['width']."; height: 200px;'></div>";
}
if ($water_mark != '') {

View File

@ -4629,13 +4629,11 @@ form ul.form_flex li ul li{
border: 0px;
}
/*
.yAxis.y1Axis > .tickLabel {
white-space: nowrap;
line-height: 1.05em!important;
width: auto!important;
}
*/
.pandora_confirm_dialog .ui-dialog-buttonset {
display: flex;

View File

@ -384,6 +384,9 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent);
$table->rowclass[] = '';
$form_table = html_print_table($table, true);
$form_table .= '<div style="width:100%; text-align:right;">' .
html_print_submit_button(__('Reload'), "submit", false,
'class="sub upd"', true) . "</div>";
unset($table);
@ -400,14 +403,6 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent);
$table->data[] = $data;
$table->rowclass[] = '';
$data = array();
$data[0] = '<div style="width:100%; text-align:right;">' .
html_print_submit_button(__('Reload'), "submit", false,
'class="sub upd"', true) .
"</div>";
$table->data[] = $data;
$table->rowclass[] = '';
$params['body_text'] .= html_print_table($table, true);
$params['body_text'] .= '</form>';
$params['body_text'] .= '</div>'; // outer

View File

@ -104,6 +104,7 @@ if ($view_graph) {
$events = $graph["events"];
$description = $graph["description"];
$stacked = (int) get_parameter ('stacked', -1);
$percentil = ($graph['percentil']) ? 1 : null;
$check = get_parameter('threshold',false);
$fullscale = ($graph['fullscale']) ? 1 : null;
@ -117,13 +118,13 @@ if ($view_graph) {
if ($stacked == CUSTOM_GRAPH_BULLET_CHART || $stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD)
$height = 50;
if ($stacked == CUSTOM_GRAPH_GAUGE ){
// Use the defined graph height, that's why
// the user can setup graph height.
$height = $graph["height"];
}
$name = $graph["name"];
if (($graph["private"]==1) && ($graph["id_user"] != $id_user)) {
db_pandora_audit("ACL Violation",