X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=src%2Fplugins%2Flegend.js;h=2e667d24997b060ffdc55ad55151fc83810a459c;hb=2cfded32d5da38aad8d9617654569f3e3f1c420d;hp=95a161c6aad593cd1b174a66112f26018915bdaa;hpb=6ecc073934b76e5076f917112a24ff7094857730;p=dygraphs.git diff --git a/src/plugins/legend.js b/src/plugins/legend.js index 95a161c..2e667d2 100644 --- a/src/plugins/legend.js +++ b/src/plugins/legend.js @@ -26,12 +26,12 @@ import * as utils from '../dygraph-utils'; * * @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"; }; @@ -50,7 +50,7 @@ var generateLegendDashHTML; * @param {Dygraph} g Graph instance. * @return {object.} Mapping of event names to callbacks. */ -legend.prototype.activate = function(g) { +Legend.prototype.activate = function(g) { var div; var divWidth = g.getOption('labelsDivWidth'); @@ -77,7 +77,7 @@ legend.prototype.activate = function(g) { "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) { @@ -122,7 +122,7 @@ var escapeHTML = function(str) { return str.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; @@ -156,12 +156,12 @@ legend.prototype.select = function(e) { 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"; @@ -171,11 +171,11 @@ legend.prototype.deselect = function(e) { 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); }; @@ -188,7 +188,7 @@ legend.prototype.didDrawChart = function(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; @@ -205,7 +205,7 @@ legend.prototype.predraw = function(e) { * 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; }; @@ -222,7 +222,7 @@ legend.prototype.destroy = function() { * '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 ''; @@ -362,4 +362,4 @@ generateLegendDashHTML = function(strokePattern, color, oneEmWidth) { return dash; }; -export default legend; +export default Legend;