|
|
@ -5,7 +5,7 @@ var Component = require('./Component'); |
|
|
|
/** |
|
|
|
* Legend for Graph2d |
|
|
|
*/ |
|
|
|
function Legend(body, options, side) { |
|
|
|
function Legend(body, options, side, linegraphOptions) { |
|
|
|
this.body = body; |
|
|
|
this.defaultOptions = { |
|
|
|
enabled: true, |
|
|
@ -23,6 +23,7 @@ function Legend(body, options, side) { |
|
|
|
} |
|
|
|
this.side = side; |
|
|
|
this.options = util.extend({},this.defaultOptions); |
|
|
|
this.linegraphOptions = linegraphOptions; |
|
|
|
|
|
|
|
this.svgElements = {}; |
|
|
|
this.dom = {}; |
|
|
@ -105,7 +106,7 @@ Legend.prototype.redraw = function() { |
|
|
|
var activeGroups = 0; |
|
|
|
for (var groupId in this.groups) { |
|
|
|
if (this.groups.hasOwnProperty(groupId)) { |
|
|
|
if (this.groups[groupId].visible == true) { |
|
|
|
if (this.groups[groupId].visible == true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] == true)) { |
|
|
|
activeGroups++; |
|
|
|
} |
|
|
|
} |
|
|
@ -158,7 +159,7 @@ Legend.prototype.redraw = function() { |
|
|
|
var content = ''; |
|
|
|
for (var groupId in this.groups) { |
|
|
|
if (this.groups.hasOwnProperty(groupId)) { |
|
|
|
if (this.groups[groupId].visible == true) { |
|
|
|
if (this.groups[groupId].visible == true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] == true)) { |
|
|
|
content += this.groups[groupId].content + '<br />'; |
|
|
|
} |
|
|
|
} |
|
|
@ -182,7 +183,7 @@ Legend.prototype.drawLegendIcons = function() { |
|
|
|
|
|
|
|
for (var groupId in this.groups) { |
|
|
|
if (this.groups.hasOwnProperty(groupId)) { |
|
|
|
if (this.groups[groupId].visible == true) { |
|
|
|
if (this.groups[groupId].visible == true && (this.linegraphOptions.visibility[groupId] === undefined || this.linegraphOptions.visibility[groupId] == true)) { |
|
|
|
this.groups[groupId].drawIcon(x, y, this.svgElements, this.svg, iconWidth, iconHeight); |
|
|
|
y += iconHeight + this.options.iconSpacing; |
|
|
|
} |
|
|
|