Skip to content

Commit

Permalink
Handle off-graph legends a little more explicitly, we don't want to h…
Browse files Browse the repository at this point in the history
…ave legends multiplying and stuff, there's an 'original flot' issue for this.
  • Loading branch information
rfunduk committed Aug 4, 2008
1 parent daa297b commit 976579a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions jquery.flot.js
Expand Up @@ -1576,10 +1576,15 @@
} }


function insertLegend() { function insertLegend() {
target.find(".legend").remove(); // remove legends from the appropriate container
if (options.legend.container != null) {
options.legend.container.find('table.legend_table').remove();
}
else {
target.find('.legend').remove();
}


if (!options.legend.show) if (!options.legend.show) { return; }
return;


var fragments = []; var fragments = [];
var rowStarted = false; var rowStarted = false;
Expand All @@ -1606,7 +1611,7 @@
fragments.push('</tr>'); fragments.push('</tr>');


if (fragments.length > 0) { if (fragments.length > 0) {
var table = '<table style="font-size:smaller;color:' + options.grid.color + '">' + fragments.join("") + '</table>'; var table = '<table class="legend_table" style="font-size:smaller;color:' + options.grid.color + '">' + fragments.join("") + '</table>';
if (options.legend.container != null) if (options.legend.container != null)
options.legend.container.append(table); options.legend.container.append(table);
else { else {
Expand All @@ -1620,7 +1625,9 @@
pos += 'right:' + (m + plotOffset.right + RIGHT_SIDE_BUFFER) + 'px;'; pos += 'right:' + (m + plotOffset.right + RIGHT_SIDE_BUFFER) + 'px;';
else if (p.charAt(1) == "w") else if (p.charAt(1) == "w")
pos += 'left:' + (m + plotOffset.left) + 'px;'; pos += 'left:' + (m + plotOffset.left) + 'px;';

var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(target); var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(target);

if (options.legend.backgroundOpacity != 0.0) { if (options.legend.backgroundOpacity != 0.0) {
// put in the transparent background // put in the transparent background
// separately to avoid blended labels and // separately to avoid blended labels and
Expand Down

0 comments on commit 976579a

Please sign in to comment.