* Copyright 2012 Dan Vanderkam (danvdk@gmail.com)
* MIT-licensed (http://opensource.org/licenses/MIT)
*/
+/*global Dygraph:false */
+
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;
return {
layout: this.layout,
// clearChart: this.clearChart,
- drawChart: this.drawChart
+ didDrawChart: this.didDrawChart
};
};
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.
inner_div.style.OTransform = val; // Opera
inner_div.style.msTransform = val; // IE9
- if (typeof(document.documentMode) !== 'undefined' &&
- document.documentMode < 9) {
- // We're dealing w/ an old version of IE, so we have to rotate the text
- // using a BasicImage transform. This uses a different origin of rotation
- // than HTML5 rotation (top left of div vs. its center).
- inner_div.style.filter =
- 'progid:DXImageTransform.Microsoft.BasicImage(rotation=' +
- (axis == 1 ? '3' : '1') + ')';
- inner_div.style.left = '0px';
- 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_();
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';
}
};
-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');
};
chart_labels.prototype.destroy = function() {
- detachLabels();
+ this.detachLabels_();
};