From abca64e007a90a7ec05bff40ac151eafb1a8b97a Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 15 Nov 2016 17:04:33 +0100 Subject: [PATCH] Added new changes of data precision to pandora 6. Part is to the ticket #4114 --- pandora_console/godmode/setup/setup_visuals.php | 10 +++++++++- pandora_console/include/graphs/flot/pandora.flot.js | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 2ea814410f..5c1658ef04 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -403,7 +403,7 @@ if (!enterprise_installed()) { } $table_chars->data[$row][0] = __('Data precision for reports'); -$table_chars->data[$row][1] = html_print_input_text ('graph_precision', $config["graph_precision"], '', 5, 5, true, $disabled_graph_precision); +$table_chars->data[$row][1] = html_print_input_text ('graph_precision', $config["graph_precision"], '', 5, 5, true, $disabled_graph_precision, false, "onChange=\"change_precision()\""); $row++; $table_chars->data[$row][0] = __('Default line thickness for the Custom Graph.'); @@ -741,6 +741,14 @@ function display_custom_report_front (show) { } +function change_precision() { + console.log("AAAA"); + var value = $("#text-graph_precision").val(); + if ((value < 0) || (value > 5)) { + $("#text-graph_precision").val(1); + } +} + function showPreview() { var img_value = $('#custom_report_front_logo').val(); diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 0ecf092e23..217f731b65 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -1697,6 +1697,15 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, } var y = series.data[j][1]; + var how_bigger = ""; + if (y > 1000000) { + how_bigger = "M"; + y = y / 1000000; + } + else if (y > 1000) { + how_bigger = "K"; + y = y / 1000; + } if (currentRanges == null || (currentRanges.xaxis.from < j && j < currentRanges.xaxis.to)) { $('#timestamp_'+graph_id).show(); @@ -1736,7 +1745,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend, // The graphs of points type and unknown graphs will dont be updated if (serie_types[i] != 'points' && series.label != $('#hidden-unknown_text').val()) { $('#legend_' + graph_id + ' .legendLabel') - .eq(i).html(label_aux + '= ' + parseFloat(y).toFixed(2) + ' ' + unit); + .eq(i).html(label_aux + '= ' + parseFloat(y).toFixed(precision_graph) + how_bigger + ' ' + unit); console.log($('#legend_' + graph_id + ' .legendLabel')); }