From fbfcb4aeb96e1100fdb096b09d2e42ff96b56754 Mon Sep 17 00:00:00 2001 From: m-lopez-f <miguel.lopez@artica.es> Date: Thu, 21 Jan 2016 11:56:15 +0100 Subject: [PATCH] Fixed legend of custom vertical/horizontal graphs. Tiquet: #3180 (cherry picked from commit 414cc1c6ee566d3ed64118fa27fca1bb4fff7955) --- pandora_console/include/functions_graph.php | 5 +++- .../include/graphs/flot/pandora.flot.js | 26 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 078f949aec..85ecb6badb 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1412,10 +1412,13 @@ function graphic_combined_module ($module_list, $weight_list, $period, ' AND utimestamp > ' . (int) $datelimit . ' AND utimestamp < ' . (int) $date); + $agent_name = io_safe_output( + modules_get_agentmodule_agent_name ($module)); + if ($labels[$module] != '') $label = $labels[$module]; else - $label = $module_data['nombre']; + $label = $agent_name . " - " .$module_data['nombre']; $temp[$label]['g'] = $temp_data; } diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index a2f68cdb43..21644f5682 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -352,7 +352,12 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark, //yAxisHeight = $('#' + graph_id + ' .yAxis .tickLabel') //.css('height').split('px')[0]; - //i = 0; + i = 0; + $('#' + graph_id + ' .yAxis .tickLabel').each(function() { + $(this).css('display','none'); + $(this).addClass("legend_"+i); + i++; + }); $('#' + graph_id + ' .xAxis .tickLabel').each(function() { /* @@ -468,6 +473,7 @@ $.fn.HUseTooltip = function () { $(this).bind("plothover", function (event, pos, item) { if (item) { if ((previousLabel != item.series.label) || (previousPoint != item.seriesIndex)) { + $('.legend_'+previousPoint).hide(); previousPoint = item.seriesIndex; previousLabel = item.series.label; $("#tooltip").remove(); @@ -476,7 +482,7 @@ $.fn.HUseTooltip = function () { var y = item.datapoint[1]; var color = item.series.color; - + $('.legend_'+y).show(); showTooltip(item.pageX, item.pageY, color, @@ -484,6 +490,7 @@ $.fn.HUseTooltip = function () { } } else { $("#tooltip").remove(); + $('.legend_'+previousPoint).hide(); previousPoint = null; } }); @@ -492,15 +499,17 @@ $.fn.VUseTooltip = function () { $(this).bind("plothover", function (event, pos, item) { if (item) { if ((previousLabel != item.series.label) || (previousPoint != item.seriesIndex)) { + $('.legend_'+previousPoint).hide(); previousPoint = item.seriesIndex; previousLabel = item.series.label; + $("#tooltip").remove(); var x = item.datapoint[0]; var y = item.datapoint[1]; - - var color = item.series.color; + var color = item.series.color; + $('.legend_'+x).show(); showTooltip(item.pageX, item.pageY, color, @@ -508,6 +517,7 @@ $.fn.VUseTooltip = function () { } } else { $("#tooltip").remove(); + $('.legend_'+previousPoint).hide(); previousPoint = null; } }); @@ -614,7 +624,9 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, i = 0; $('#'+graph_id+' .xAxis .tickLabel').each(function() { - tickTop = $(this).css('transform',"rotate(20deg)"); + $(this).css('display','none'); + $(this).addClass("legend_"+i); + i++; //~ tickNewTop = parseInt(parseInt(tickTop) - (yAxisHeight/2)-3); //~ $(this).css('top', tickNewTop+'px'); //~ @@ -627,7 +639,6 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, //~ inCanvasValuePos = parseInt(pixelPerValue * ($('#value_'+i+'_'+graph_id).html())); //~ //~ $('#value_'+i+'_'+graph_id).css('left',plot.offset().left + inCanvasValuePos - $('#value_'+i+'_'+graph_id).css('width').split('px')[0] - 3); - //~ i++; }); // When resize the window, adjust the values @@ -642,6 +653,9 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, //~ i++; //~ }); //~ }); + + + $('#'+graph_id+' .yAxis .tickLabel').each(function() { label = parseFloat($(this).text()); text = label.toLocaleString();