this.options = {}; // TODO(danvk): remove, use attr_ instead.
Dygraph.update(this.options, options ? options : {});
this.datasets = new Array();
- this.annotations = new Array()
+ this.annotations = new Array();
};
DygraphLayout.prototype.attr_ = function(name) {
this.datasets[setname] = set_xy;
};
-// TODO(danvk): CONTRACT remove
DygraphLayout.prototype.setAnnotations = function(ann) {
// The Dygraph object's annotations aren't parsed. We parse them here and
// save a copy.
var parse = this.attr_('xValueParser');
for (var i = 0; i < ann.length; i++) {
var a = {};
- if (!ann[i].x) {
+ if (!ann[i].xval && !ann[i].x) {
this.dygraph_.error("Annotations must have an 'x' property");
return;
}
if (ann[i].icon &&
- !(ann[i].hasOwnProperty('iconWidth') &&
- ann[i].hasOwnProperty('iconHeight'))) {
- this.dygraph_.error("Must set iconWidth and iconHeight when setting " +
+ !(ann[i].hasOwnProperty('width') &&
+ ann[i].hasOwnProperty('height'))) {
+ this.dygraph_.error("Must set width and height when setting " +
"annotation.icon property");
return;
}
Dygraph.update(a, ann[i]);
- a.xval = parse(a.x);
+ if (!a.xval) a.xval = parse(a.x);
this.annotations.push(a);
}
};
name: setName
};
- // limit the x, y values so they do not overdraw
- if (point.y <= 0.0) {
- point.y = 0.0;
- }
- if (point.y >= 1.0) {
- point.y = 1.0;
- }
this.points.push(point);
}
}
"position": "absolute",
"fontSize": this.options.axisLabelFontSize + "px",
"zIndex": 10,
- "overflow": "hidden",
+ "overflow": "hidden"
};
var bindEvt = function(eventName, classEventName, p, self) {
div.className += " " + a.cssClass;
}
- var width = a.hasOwnProperty('height') ? a.height : 20;
- var height = a.hasOwnProperty('width') ? a.width : 16;
+ var width = a.hasOwnProperty('width') ? a.width : 16;
+ var height = a.hasOwnProperty('height') ? a.height : 16;
if (a.hasOwnProperty('icon')) {
var img = document.createElement("img");
img.src = a.icon;
- img.width = width = a.iconWidth;
- img.height = height = a.iconHeight;
+ img.width = width;
+ img.height = height;
div.appendChild(img);
} else if (p.annotation.hasOwnProperty('shortText')) {
div.appendChild(document.createTextNode(p.annotation.shortText));
}
div.style.left = (p.canvasx - width / 2) + "px";
- div.style.top = (p.canvasy - height - tick_height) + "px";
+ if (a.attachAtBottom) {
+ div.style.top = (this.area.h - height - tick_height) + "px";
+ } else {
+ div.style.top = (p.canvasy - height - tick_height) + "px";
+ }
div.style.width = width + "px";
div.style.height = height + "px";
div.title = p.annotation.text;
var ctx = this.element.getContext("2d");
ctx.strokeStyle = this.colors[p.name];
ctx.beginPath();
- ctx.moveTo(p.canvasx, p.canvasy);
- ctx.lineTo(p.canvasx, p.canvasy - 2 - tick_height);
+ if (!a.attachAtBottom) {
+ ctx.moveTo(p.canvasx, p.canvasy);
+ ctx.lineTo(p.canvasx, p.canvasy - 2 - tick_height);
+ } else {
+ ctx.moveTo(p.canvasx, this.area.h);
+ ctx.lineTo(p.canvasx, this.area.h - 2 - tick_height);
+ }
ctx.closePath();
ctx.stroke();
}