X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=plugins%2Fchart-labels.js;h=2aaae269ac86199a6988967ab2e0de3ef9944221;hb=cb136039d06ace657e202c884f84569322ffdaf2;hp=5a109df624a27205137431cf33f8595fd94668df;hpb=1c177b6ad57510df852f238f6e063db53ce5a71a;p=dygraphs.git diff --git a/plugins/chart-labels.js b/plugins/chart-labels.js index 5a109df..2aaae26 100644 --- a/plugins/chart-labels.js +++ b/plugins/chart-labels.js @@ -5,7 +5,10 @@ */ Dygraph.Plugins.ChartLabels = (function() { +"use strict"; + // TODO(danvk): move chart label options out of dygraphs and into the plugin. +// TODO(danvk): only tear down & rebuild the DIVs when it's necessary. var chart_labels = function() { this.title_div_ = null; @@ -22,7 +25,7 @@ chart_labels.prototype.activate = function(g) { return { layout: this.layout, // clearChart: this.clearChart, - drawChart: this.drawChart + didDrawChart: this.didDrawChart }; }; @@ -57,7 +60,7 @@ chart_labels.prototype.detachLabels_ = function() { var createRotatedDiv = function(g, box, axis, classes, html) { // TODO(danvk): is this outer div actually necessary? - div = document.createElement("div"); + var div = document.createElement("div"); div.style.position = 'absolute'; if (axis == 1) { // NOTE: this is cheating. Should be positioned relative to the box. @@ -99,14 +102,14 @@ var createRotatedDiv = function(g, box, axis, classes, html) { inner_div.style.top = '0px'; } - class_div = document.createElement("div"); + var class_div = document.createElement("div"); class_div.className = classes; class_div.innerHTML = html; inner_div.appendChild(class_div); div.appendChild(inner_div); return div; -} +}; chart_labels.prototype.layout = function(e) { this.detachLabels_(); @@ -120,6 +123,7 @@ chart_labels.prototype.layout = function(e) { this.title_div_.style.textAlign = 'center'; this.title_div_.style.fontSize = (g.getOption('titleHeight') - 8) + 'px'; this.title_div_.style.fontWeight = 'bold'; + this.title_div_.style.zIndex = 10; var class_div = document.createElement("div"); class_div.className = 'dygraph-label dygraph-title'; @@ -168,7 +172,7 @@ chart_labels.prototype.layout = function(e) { } }; -chart_labels.prototype.drawChart = function(e) { +chart_labels.prototype.didDrawChart = function(e) { var g = e.dygraph; if (this.title_div_) { this.title_div_.children[0].innerHTML = g.getOption('title'); @@ -188,7 +192,7 @@ chart_labels.prototype.clearChart = function() { }; chart_labels.prototype.destroy = function() { - detachLabels(); + this.detachLabels_(); };