From 8eb3a982e1f785ed4e22aac3c8398391004ccf1a Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Mon, 1 Jun 2020 14:48:53 +0200 Subject: [PATCH] Fixed error in gauges --- pandora_console/include/chart_generator.php | 1 + pandora_console/include/functions_graph.php | 9 +++++- pandora_console/include/graphs/fgraph.php | 6 ++-- .../include/graphs/functions_d3.php | 5 +-- pandora_console/include/graphs/pandora.d3.js | 32 +++++++++++-------- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/pandora_console/include/chart_generator.php b/pandora_console/include/chart_generator.php index edd8208b05..7a61677b85 100644 --- a/pandora_console/include/chart_generator.php +++ b/pandora_console/include/chart_generator.php @@ -189,6 +189,7 @@ if (file_exists('languages/'.$user_language.'.mo') === true) { echo '
'; switch ($type_graph_pdf) { case 'combined': + $params['pdf'] = true; echo graphic_combined_module( $module_list, $params, diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 5a1d482e1d..1f45714edb 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2003,6 +2003,12 @@ function graphic_combined_module( } } + if (isset($params['pdf']) === true && $params['pdf'] === true) { + $transitionDuration = 0; + } else { + $transitionDuration = 500; + } + $output = stacked_gauge( $graph_values, $new_width, @@ -2018,7 +2024,8 @@ function graphic_combined_module( $config['fontpath'], $fixed_font_size, '', - $homeurl + $homeurl, + $transitionDuration ); break; diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 1d79129610..6f341381c5 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -638,7 +638,8 @@ function stacked_gauge( $font='', $font_size='', $unit='', - $homeurl='' + $homeurl='', + $transitionDuration=500 ) { include_once 'functions_d3.php'; @@ -656,7 +657,8 @@ function stacked_gauge( $unit, $font, ($font_size + 2), - $no_data_image + $no_data_image, + $transitionDuration ); } diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 659270744a..8719531abc 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -294,7 +294,8 @@ function d3_gauges( $unit, $font, $font_size, - $no_data_image + $no_data_image, + $transitionDuration ) { global $config; @@ -310,7 +311,7 @@ function d3_gauges( $output .= ""; return $output; diff --git a/pandora_console/include/graphs/pandora.d3.js b/pandora_console/include/graphs/pandora.d3.js index bfebebe99c..d308514ce3 100644 --- a/pandora_console/include/graphs/pandora.d3.js +++ b/pandora_console/include/graphs/pandora.d3.js @@ -1005,7 +1005,8 @@ function createGauge( critical_inverse, font_size, height, - font + font, + transitionDuration ) { var gauges; @@ -1014,7 +1015,8 @@ function createGauge( label: etiqueta, min: undefined != min ? min : 0, max: undefined != max ? max : 100, - font_size: font_size + font_size: font_size, + transitionDuration: transitionDuration }; if (value == null) { @@ -1128,7 +1130,7 @@ function createGauge( gauges = new Gauge(name, config, font); gauges.render(); - gauges.redraw(value); + gauges.redraw(value, config.transitionDuration); $(".gauge>text").each(function() { label = $(this).text(); @@ -1155,12 +1157,17 @@ function createGauge( $(this).text(text); } }); - config = false; - max_warning2 = false; - min_warning2 = false; } -function createGauges(data, width, height, font_size, no_data_image, font) { +function createGauges( + data, + width, + height, + font_size, + no_data_image, + font, + transitionDuration +) { var nombre, label, minimun_warning, @@ -1211,7 +1218,8 @@ function createGauges(data, width, height, font_size, no_data_image, font) { critical_inverse, font_size, height, - font + font, + transitionDuration ); } } @@ -1247,7 +1255,7 @@ function Gauge(placeholderName, configuration, font) { this.config.yellowColor = configuration.yellowColor || "#FF9900"; this.config.redColor = configuration.redColor || "#DC3912"; - this.config.transitionDuration = configuration.transitionDuration || 500; + this.config.transitionDuration = configuration.transitionDuration; }; this.render = function() { @@ -1481,11 +1489,7 @@ function Gauge(placeholderName, configuration, font) { var pointer = pointerContainer.selectAll("path"); pointer .transition() - .duration( - undefined != transitionDuration - ? transitionDuration - : this.config.transitionDuration - ) + .duration(undefined != transitionDuration ? transitionDuration : 0) //.delay(0) //.ease("linear") //.attr("transform", function(d)