X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-canvas.js;h=123fa83a74989336478a14d7b9b47e47731ff917;hb=1e1bf7dfc2628a153f6b6b8c9b2b6b6d74390e6c;hp=b71044a88f1168cf7a1c8962de7baf709e185b73;hpb=e6d5314821c8972d803e8600171d5733e01e669a;p=dygraphs.git diff --git a/dygraph-canvas.js b/dygraph-canvas.js index b71044a..123fa83 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -30,14 +30,13 @@ DygraphLayout.prototype.addDataset = function(setname, set_xy) { 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; } @@ -49,7 +48,7 @@ DygraphLayout.prototype.setAnnotations = function(ann) { return; } Dygraph.update(a, ann[i]); - a.xval = parse(a.x); + if (!a.xval) a.xval = parse(a.x); this.annotations.push(a); } }; @@ -543,8 +542,8 @@ DygraphCanvasRenderer.prototype._renderAnnotations = function() { 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;