this.layout = layout;
this.element = element;
this.elementContext = elementContext;
- this.container = this.element.parentNode;
this.height = this.element.height;
this.width = this.element.width;
// --- check whether everything is ok before we return
// NOTE(konigsberg): isIE is never defined in this object. Bug of some sort.
- if (!this.isIE && !(DygraphCanvasRenderer.isSupported(this.element)))
+ if (!this.isIE && !(Dygraph.isCanvasSupported(this.element)))
throw "Canvas is not supported.";
// internal state
this.area = layout.getPlotArea();
- this.container.style.position = "relative";
- this.container.style.width = this.width + "px";
// Set up a clipping area for the canvas (and the interaction canvas).
// This ensures that we don't overdraw.
};
/**
- * Checks whether the browser supports the <canvas> tag.
- * @private
- */
-DygraphCanvasRenderer.isSupported = function(canvasName) {
- var canvas = null;
- try {
- if (typeof(canvasName) == 'undefined' || canvasName === null) {
- canvas = document.createElement("canvas");
- } else {
- canvas = canvasName;
- }
- canvas.getContext("2d");
- }
- catch (e) {
- var ie = navigator.appVersion.match(/MSIE (\d\.\d)/);
- var opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
- if ((!ie) || (ie[1] < 6) || (opera))
- return false;
- return true;
- }
- return true;
-};
-
-/**
* This method is responsible for drawing everything on the chart, including
* lines, error bars, fills and axes.
* It is called immediately after clear() on every frame, including during pans
for (var idx = 0; idx < pointsOnLine.length; idx++) {
var cb = pointsOnLine[idx];
ctx.save();
- drawPointCallback(
+ drawPointCallback.call(e.dygraph,
e.dygraph, e.setName, ctx, cb[0], cb[1], color, pointSize, cb[2]);
ctx.restore();
}
var fillGraph = g.getBooleanOption("fillGraph", setName);
if (fillGraph) {
- Dygraph.warn("Can't use fillGraph option with error bars");
+ console.warn("Can't use fillGraph option with error bars");
}
var ctx = e.drawingContext;
var last_x, is_first = true;
while (iter.hasNext) {
var point = iter.next();
- if (!Dygraph.isOK(point.y)) {
+ if (!Dygraph.isOK(point.y) && !stepPlot) {
prevX = NaN;
if (point.y_stacked !== null && !isNaN(point.y_stacked)) {
baseline[point.canvasx] = area.h * point.y_stacked + area.y;
}
} else {
- newYs = [ point.canvasy, axisY ];
+ if (isNaN(point.canvasy) && stepPlot) {
+ newYs = [ area.y + area.h, axisY ];
+ } else {
+ newYs = [ point.canvasy, axisY ];
+ }
}
if (!isNaN(prevX)) {
ctx.moveTo(prevX, prevYs[0]);