*
* @constructor
*/
-var legend = function() {
+var Legend = function() {
this.legend_div_ = null;
this.is_generated_div_ = false; // do we own this div, or was it user-specified?
};
-legend.prototype.toString = function() {
+Legend.prototype.toString = function() {
return "Legend Plugin";
};
* @param {Dygraph} g Graph instance.
* @return {object.<string, function(ev)>} Mapping of event names to callbacks.
*/
-legend.prototype.activate = function(g) {
+Legend.prototype.activate = function(g) {
var div;
var divWidth = g.getOption('labelsDivWidth');
"overflow": "hidden"};
// TODO(danvk): get rid of labelsDivStyles? CSS is better.
- Dygraph.update(messagestyle, g.getOption('labelsDivStyles'));
+ utils.update(messagestyle, g.getOption('labelsDivStyles'));
div = document.createElement("div");
div.className = "dygraph-legend";
for (var name in messagestyle) {
return str.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
};
-legend.prototype.select = function(e) {
+Legend.prototype.select = function(e) {
var xValue = e.selectedX;
var points = e.selectedPoints;
var row = e.selectedRow;
this.legend_div_.style.top = topLegend + "px";
}
- var html = legend.generateLegendHTML(e.dygraph, xValue, points, this.one_em_width_, row);
+ var html = Legend.generateLegendHTML(e.dygraph, xValue, points, this.one_em_width_, row);
this.legend_div_.innerHTML = html;
this.legend_div_.style.display = '';
};
-legend.prototype.deselect = function(e) {
+Legend.prototype.deselect = function(e) {
var legendMode = e.dygraph.getOption('legend');
if (legendMode !== 'always') {
this.legend_div_.style.display = "none";
var oneEmWidth = calculateEmWidthInDiv(this.legend_div_);
this.one_em_width_ = oneEmWidth;
- var html = legend.generateLegendHTML(e.dygraph, undefined, undefined, oneEmWidth, null);
+ var html = Legend.generateLegendHTML(e.dygraph, undefined, undefined, oneEmWidth, null);
this.legend_div_.innerHTML = html;
};
-legend.prototype.didDrawChart = function(e) {
+Legend.prototype.didDrawChart = function(e) {
this.deselect(e);
};
* - its top edge is flush with the top edge of the charting area
* @private
*/
-legend.prototype.predraw = function(e) {
+Legend.prototype.predraw = function(e) {
// Don't touch a user-specified labelsDiv.
if (!this.is_generated_div_) return;
* Called when dygraph.destroy() is called.
* You should null out any references and detach any DOM elements.
*/
-legend.prototype.destroy = function() {
+Legend.prototype.destroy = function() {
this.legend_div_ = null;
};
* 'always'}) and with dashed lines.
* @param {number} row The selected row index.
*/
-legend.generateLegendHTML = function(g, x, sel_points, oneEmWidth, row) {
+Legend.generateLegendHTML = function(g, x, sel_points, oneEmWidth, row) {
// TODO(danvk): deprecate this option in place of {legend: 'never'}
if (g.getOption('showLabelsOnHighlight') !== true) return '';
return dash;
};
-export default legend;
+export default Legend;