Fixed legend of custom vertical/horizontal graphs. Tiquet: #3180

(cherry picked from commit 414cc1c6ee)
This commit is contained in:
m-lopez-f 2016-01-21 11:56:15 +01:00
parent c811b8baca
commit fbfcb4aeb9
2 changed files with 24 additions and 7 deletions

View File

@ -1412,10 +1412,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
' AND utimestamp > ' . (int) $datelimit . ' AND utimestamp > ' . (int) $datelimit .
' AND utimestamp < ' . (int) $date); ' AND utimestamp < ' . (int) $date);
$agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($module));
if ($labels[$module] != '') if ($labels[$module] != '')
$label = $labels[$module]; $label = $labels[$module];
else else
$label = $module_data['nombre']; $label = $agent_name . " - " .$module_data['nombre'];
$temp[$label]['g'] = $temp_data; $temp[$label]['g'] = $temp_data;
} }

View File

@ -352,7 +352,12 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark,
//yAxisHeight = $('#' + graph_id + ' .yAxis .tickLabel') //yAxisHeight = $('#' + graph_id + ' .yAxis .tickLabel')
//.css('height').split('px')[0]; //.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() { $('#' + graph_id + ' .xAxis .tickLabel').each(function() {
/* /*
@ -468,6 +473,7 @@ $.fn.HUseTooltip = function () {
$(this).bind("plothover", function (event, pos, item) { $(this).bind("plothover", function (event, pos, item) {
if (item) { if (item) {
if ((previousLabel != item.series.label) || (previousPoint != item.seriesIndex)) { if ((previousLabel != item.series.label) || (previousPoint != item.seriesIndex)) {
$('.legend_'+previousPoint).hide();
previousPoint = item.seriesIndex; previousPoint = item.seriesIndex;
previousLabel = item.series.label; previousLabel = item.series.label;
$("#tooltip").remove(); $("#tooltip").remove();
@ -476,7 +482,7 @@ $.fn.HUseTooltip = function () {
var y = item.datapoint[1]; var y = item.datapoint[1];
var color = item.series.color; var color = item.series.color;
$('.legend_'+y).show();
showTooltip(item.pageX, showTooltip(item.pageX,
item.pageY, item.pageY,
color, color,
@ -484,6 +490,7 @@ $.fn.HUseTooltip = function () {
} }
} else { } else {
$("#tooltip").remove(); $("#tooltip").remove();
$('.legend_'+previousPoint).hide();
previousPoint = null; previousPoint = null;
} }
}); });
@ -492,15 +499,17 @@ $.fn.VUseTooltip = function () {
$(this).bind("plothover", function (event, pos, item) { $(this).bind("plothover", function (event, pos, item) {
if (item) { if (item) {
if ((previousLabel != item.series.label) || (previousPoint != item.seriesIndex)) { if ((previousLabel != item.series.label) || (previousPoint != item.seriesIndex)) {
$('.legend_'+previousPoint).hide();
previousPoint = item.seriesIndex; previousPoint = item.seriesIndex;
previousLabel = item.series.label; previousLabel = item.series.label;
$("#tooltip").remove(); $("#tooltip").remove();
var x = item.datapoint[0]; var x = item.datapoint[0];
var y = item.datapoint[1]; var y = item.datapoint[1];
var color = item.series.color;
var color = item.series.color;
$('.legend_'+x).show();
showTooltip(item.pageX, showTooltip(item.pageX,
item.pageY, item.pageY,
color, color,
@ -508,6 +517,7 @@ $.fn.VUseTooltip = function () {
} }
} else { } else {
$("#tooltip").remove(); $("#tooltip").remove();
$('.legend_'+previousPoint).hide();
previousPoint = null; previousPoint = null;
} }
}); });
@ -614,7 +624,9 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
i = 0; i = 0;
$('#'+graph_id+' .xAxis .tickLabel').each(function() { $('#'+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); //~ tickNewTop = parseInt(parseInt(tickTop) - (yAxisHeight/2)-3);
//~ $(this).css('top', tickNewTop+'px'); //~ $(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())); //~ 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); //~ $('#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 // When resize the window, adjust the values
@ -642,6 +653,9 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
//~ i++; //~ i++;
//~ }); //~ });
//~ }); //~ });
$('#'+graph_id+' .yAxis .tickLabel').each(function() { $('#'+graph_id+' .yAxis .tickLabel').each(function() {
label = parseFloat($(this).text()); label = parseFloat($(this).text());
text = label.toLocaleString(); text = label.toLocaleString();