var context = this.element.getContext("2d");
- var labelStyle = {"style":
- {"position": "absolute",
- "fontSize": this.options.axisLabelFontSize + "px",
- "zIndex": 10,
- "color": this.options.axisLabelColor.toRGBString(),
- "width": this.options.axisLabelWidth + "px",
- "overflow": "hidden"
+ var labelStyle = {
+ "position": "absolute",
+ "fontSize": this.options.axisLabelFontSize + "px",
+ "zIndex": 10,
+ "color": this.options.axisLabelColor.toRGBString(),
+ "width": this.options.axisLabelWidth + "px",
+ "overflow": "hidden"
+ };
+ var makeDiv = function(txt) {
+ var div = document.createElement("div");
+ for (var name in labelStyle) {
+ div.style[name] = labelStyle[name];
}
+ div.appendChild(document.createTextNode(txt));
+ return div;
};
// axis lines
context.strokeStyle = this.options.axisLineColor.toRGBString();
context.lineWidth = this.options.axisLineWidth;
-
if (this.options.drawYAxis) {
if (this.layout.yticks) {
for (var i = 0; i < this.layout.yticks.length; i++) {
context.closePath();
context.stroke();
- var label = DIV(labelStyle, tick[1]);
+ var label = makeDiv(tick[1]);
var top = (y - this.options.axisLabelFontSize / 2);
if (top < 0) top = 0;
context.closePath();
context.stroke();
- var label = DIV(labelStyle, tick[1]);
+ var label = makeDiv(tick[1]);
label.style.textAlign = "center";
label.style.bottom = "0px";