MochiKit.Base.update(this.options, options);
this.layout = layout;
- this.element = MochiKit.DOM.getElement(element);
+ this.element = element;
this.container = this.element.parentNode;
// Stuff relating to Canvas on IE support
this.area.h = this.height - this.options.axisLabelFontSize -
2 * this.options.axisTickSize;
- MochiKit.DOM.updateNodeAttributes(this.container,
- {"style":{ "position": "relative", "width": this.width + "px"}});
+ this.container.style.position = "relative";
+ this.container.style.width = this.width + "px";
};
DygraphCanvasRenderer.prototype.clear = function() {
var context = this.element.getContext("2d");
}
catch (e) {
+ // TODO(danvk): this is broken, since MochiKit.Async is gone.
this.clearDelay = MochiKit.Async.wait(this.IEDelay);
this.clearDelay.addCallback(bind(this.clear, this));
return;
var context = this.element.getContext("2d");
context.clearRect(0, 0, this.width, this.height);
- MochiKit.Iter.forEach(this.xlabels, MochiKit.DOM.removeElement);
- MochiKit.Iter.forEach(this.ylabels, MochiKit.DOM.removeElement);
+ for (var i = 0; i < this.xlabels.length; i++) {
+ var el = this.xlabels[i];
+ el.parentNode.removeChild(el);
+ }
+ for (var i = 0; i < this.ylabels.length; i++) {
+ var el = this.ylabels[i];
+ el.parentNode.removeChild(el);
+ }
this.xlabels = new Array();
this.ylabels = new Array();
};
var canvas = null;
try {
if (MochiKit.Base.isUndefinedOrNull(canvasName))
- canvas = MochiKit.DOM.CANVAS({});
+ canvas = document.createElement("canvas");
else
- canvas = MochiKit.DOM.getElement(canvasName);
+ canvas = canvasName;
var context = canvas.getContext("2d");
}
catch (e) {
if (this.options.drawYAxis) {
if (this.layout.yticks) {
- var drawTick = function(tick) {
+ for (var i = 0; i < this.layout.yticks.length; i++) {
+ var tick = this.layout.yticks[i];
if (typeof(tick) == "function") return;
var x = this.area.x;
var y = this.area.y + tick[0] * this.area.h;
label.style.left = "0px";
label.style.textAlign = "right";
label.style.width = this.options.yAxisLabelWidth + "px";
- MochiKit.DOM.appendChildNodes(this.container, label);
+ this.container.appendChild(label);
this.ylabels.push(label);
- };
-
- MochiKit.Iter.forEach(this.layout.yticks, bind(drawTick, this));
+ }
// The lowest tick on the y-axis often overlaps with the leftmost
// tick on the x-axis. Shift the bottom tick up a little bit to
if (this.options.drawXAxis) {
if (this.layout.xticks) {
- var drawTick = function(tick) {
+ for (var i = 0; i < this.layout.xticks.length; i++) {
+ var tick = this.layout.xticks[i];
if (typeof(dataset) == "function") return;
var x = this.area.x + tick[0] * this.area.w;
label.style.left = left + "px";
label.style.width = this.options.xAxisLabelWidth + "px";
- MochiKit.DOM.appendChildNodes(this.container, label);
+ this.container.appendChild(label);
this.xlabels.push(label);
- };
-
- MochiKit.Iter.forEach(this.layout.xticks, bind(drawTick, this));
+ }
}
context.beginPath();
var partial = MochiKit.Base.partial;
//Update Points
- var updatePoint = function(point) {
+ for (var i = 0; i < this.layout.points.length; i++) {
+ var point = this.layout.points[i];
point.canvasx = this.area.w * point.x + this.area.x;
point.canvasy = this.area.h * point.y + this.area.y;
}
- MochiKit.Iter.forEach(this.layout.points, updatePoint, this);
// create paths
var isOK = function(x) { return x && !isNaN(x); };
var prevYs = [-1, -1];
var count = 0;
var yscale = this.layout.yscale;
- var errorTrapezoid = function(ctx_,point) {
+ // should be same color as the lines
+ var err_color = color.colorWithAlpha(0.15);
+ ctx.fillStyle = err_color.toRGBString();
+ ctx.beginPath();
+ for (var j = 0; j < this.layout.points.length; j++) {
+ var point = this.layout.points[j];
count++;
if (point.name == setName) {
if (!point.y || isNaN(point.y)) {
newYs[0] = this.area.h * newYs[0] + this.area.y;
newYs[1] = this.area.h * newYs[1] + this.area.y;
if (prevX >= 0) {
- ctx_.moveTo(prevX, prevYs[0]);
- ctx_.lineTo(point.canvasx, newYs[0]);
- ctx_.lineTo(point.canvasx, newYs[1]);
- ctx_.lineTo(prevX, prevYs[1]);
- ctx_.closePath();
+ ctx.moveTo(prevX, prevYs[0]);
+ ctx.lineTo(point.canvasx, newYs[0]);
+ ctx.lineTo(point.canvasx, newYs[1]);
+ ctx.lineTo(prevX, prevYs[1]);
+ ctx.closePath();
}
prevYs[0] = newYs[0];
prevYs[1] = newYs[1];
prevX = point.canvasx;
}
- };
- // should be same color as the lines
- var err_color = color.colorWithAlpha(0.15);
- ctx.fillStyle = err_color.toRGBString();
- ctx.beginPath();
- MochiKit.Iter.forEach(this.layout.points, partial(errorTrapezoid, ctx), this);
+ }
ctx.fill();
}
};