From ba4515266ca209829d6efa2b66ed47f0b57a866e Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Wed, 11 May 2011 23:57:12 -0400 Subject: [PATCH 1/1] add classes to x- and y-axis labels --- dygraph-canvas.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dygraph-canvas.js b/dygraph-canvas.js index c5eb835..3f24b80 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -521,14 +521,18 @@ DygraphCanvasRenderer.prototype._renderAxis = function() { width: this.attr_('axisLabelWidth') + "px", overflow: "hidden" }; - var makeDiv = function(txt) { + var makeDiv = function(txt, axis) { var div = document.createElement("div"); for (var name in labelStyle) { if (labelStyle.hasOwnProperty(name)) { div.style[name] = labelStyle[name]; } } - div.appendChild(document.createTextNode(txt)); + var inner_div = document.createElement("div"); + // TODO(danvk): separate class for secondary y-axis + inner_div.className = 'dygraph-axis-label dygraph-axis-label-' + axis; + inner_div.appendChild(document.createTextNode(txt)); + div.appendChild(inner_div); return div; }; @@ -555,7 +559,7 @@ DygraphCanvasRenderer.prototype._renderAxis = function() { context.closePath(); context.stroke(); - var label = makeDiv(tick[2]); + var label = makeDiv(tick[2], 'y'); var top = (y - this.attr_('axisLabelFontSize') / 2); if (top < 0) top = 0; @@ -620,7 +624,7 @@ DygraphCanvasRenderer.prototype._renderAxis = function() { context.closePath(); context.stroke(); - var label = makeDiv(tick[1]); + var label = makeDiv(tick[1], 'x'); label.style.textAlign = "center"; label.style.top = (y + this.attr_('axisTickSize')) + 'px'; -- 2.7.4