X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=plugins%2Fchart-labels.js;h=5fbbdc5c830435c132872588de759cee7f415e54;hb=HEAD;hp=aa563374c1403d6970c15c12794da15365e31cdd;hpb=1748a51c025b83c37fcf4c15ec0303de8aaf1a42;p=dygraphs.git diff --git a/plugins/chart-labels.js b/plugins/chart-labels.js deleted file mode 100644 index aa56337..0000000 --- a/plugins/chart-labels.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @license - * Copyright 2012 Dan Vanderkam (danvdk@gmail.com) - * MIT-licensed (http://opensource.org/licenses/MIT) - */ -Dygraph.Plugins.ChartLabels = (function() { - -// TODO(danvk): move chart label options out of dygraphs and into the plugin. - -var chart_labels = function() { - this.title_div_ = null; - this.xlabel_div_ = null; - this.ylabel_div_ = null; - this.y2label_div_ = null; -}; - -chart_labels.prototype.toString = function() { - return "ChartLabels Plugin"; -}; - -chart_labels.prototype.activate = function(g) { - return { - layout: this.layout, - // clearChart: this.clearChart, - drawChart: this.drawChart - }; -}; - -// QUESTION: should there be a plugin-utils.js? -var createDivInRect = function(r) { - var div = document.createElement('div'); - div.style.position = 'absolute'; - div.style.left = r.x + 'px'; - div.style.top = r.y + 'px'; - div.style.width = r.w + 'px'; - div.style.height = r.h + 'px'; - return div; -}; - -// Detach and null out any existing nodes. -chart_labels.prototype.detachLabels_ = function() { - var els = [ this.title_div_, - this.xlabel_div_, - this.ylabel_div_, - this.y2label_div_ ]; - for (var i = 0; i < els.length; i++) { - var el = els[i]; - if (!el) continue; - if (el.parentNode) el.parentNode.removeChild(el); - } - - this.title_div_ = null; - this.xlabel_div_ = null; - this.ylabel_div_ = null; - this.y2label_div_ = null; -}; - -chart_labels.prototype.layout = function(e) { - this.detachLabels_(); - - var g = e.dygraph; - var div = e.chart_div; - if (g.getOption('title')) { - // QUESTION: should this return an absolutely-positioned div instead? - var title_rect = e.reserveSpaceTop(g.getOption('titleHeight')); - this.title_div_ = createDivInRect(title_rect); - this.title_div_.innerHTML = g.getOption('title'); - this.title_div_.style.textAlign = 'center'; - this.title_div_.style.fontSize = (g.getOption('titleHeight') - 8) + 'px'; - this.title_div_.style.fontWeight = 'bold'; - div.appendChild(this.title_div_); - } - -/* - if (g.getOption('xlabel')) { - var x_rect = e.reserveSpaceBottom(g.getOption('xLabelHeight')); - } - - if (g.getOption('ylabel')) { - var y_rect = e.reserveSpaceLeft(0); - } - - if (g.getOption('y2label')) { - var y2_rect = e.reserveSpaceRight(0); - } - */ -}; - -chart_labels.prototype.drawChart = function(e) { - var g = e.dygraph; - if (this.title_div_) { - this.title_div_.innerHTML = g.getOption('title'); - } -}; - -chart_labels.prototype.clearChart = function() { -}; - -chart_labels.prototype.destroy = function() { - detachLabels(); -}; - - -return chart_labels; -})();