X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-canvas.js;h=d6570d12ea1d7e034659be8b0a55fb7d757b0aef;hb=eee806a0323c685c0ba9f9e40d80f050ac587d64;hp=9ac88be7d8d7fdcf66b5f3b1f98903a57ed9c600;hpb=0e23cfc6960a43d8d03a86be2236f8ede092b602;p=dygraphs.git diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 9ac88be..d6570d1 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -70,7 +70,7 @@ DygraphLayout.prototype.setAnnotations = function(ann) { return; } Dygraph.update(a, ann[i]); - if (!a.xval) a.xval = parse(a.x); + if (!a.xval) a.xval = parse(a.x, this.dygraph_); this.annotations.push(a); } }; @@ -334,12 +334,18 @@ DygraphCanvasRenderer.prototype.attr_ = function(x) { DygraphCanvasRenderer.prototype.computeArea_ = function() { var area = { // TODO(danvk): per-axis setting. - x: this.attr_('yAxisLabelWidth') + 2 * this.attr_('axisTickSize'), + x: 0, y: 0 }; + if (this.attr_('drawYAxis')) { + area.x = this.attr_('yAxisLabelWidth') + 2 * this.attr_('axisTickSize'); + } + area.w = this.width - area.x - this.attr_('rightGap'); - area.h = this.height - this.attr_('axisLabelFontSize') - - 2 * this.attr_('axisTickSize'); + area.h = this.height; + if (this.attr_('drawXAxis')) { + area.h -= this.attr_('axisLabelFontSize') + 2 * this.attr_('axisTickSize'); + } // Shrink the drawing area to accomodate additional y-axes. if (this.dygraph_.numAxes() == 2) { @@ -433,6 +439,14 @@ DygraphCanvasRenderer.isSupported = function(canvasName) { }; /** + * @param { [String] } colors Array of color strings. Should have one entry for + * each series to be rendered. + */ +DygraphCanvasRenderer.prototype.setColors = function(colors) { + this.colorScheme_ = colors; +}; + +/** * Draw an X/Y grid on top of the existing plot */ DygraphCanvasRenderer.prototype.render = function() { @@ -452,7 +466,7 @@ DygraphCanvasRenderer.prototype.render = function() { var ticks = this.layout.yticks; ctx.save(); ctx.strokeStyle = this.attr_('gridLineColor'); - ctx.lineWidth = this.attr_('axisLineWidth'); + ctx.lineWidth = this.attr_('gridLineWidth'); for (var i = 0; i < ticks.length; i++) { // TODO(danvk): allow secondary axes to draw a grid, too. if (ticks[i][0] != 0) continue; @@ -470,7 +484,7 @@ DygraphCanvasRenderer.prototype.render = function() { var ticks = this.layout.xticks; ctx.save(); ctx.strokeStyle = this.attr_('gridLineColor'); - ctx.lineWidth = this.attr_('axisLineWidth'); + ctx.lineWidth = this.attr_('gridLineWidth'); for (var i=0; i