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