From: Dan Vanderkam Date: Wed, 10 Nov 2010 16:35:34 +0000 (-0500) Subject: avoid passing layout to underlayCallback. Document underlayCallback X-Git-Tag: v1.0.0~609 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=0414310981ad4de3065fbb8de9cb1e9ed5b7ff8b;p=dygraphs.git avoid passing layout to underlayCallback. Document underlayCallback --- diff --git a/docs/index.html b/docs/index.html index 811b7b7..adc7c15 100644 --- a/docs/index.html +++ b/docs/index.html @@ -870,6 +870,20 @@ perl -ne 'BEGIN{print "Month,Nominal,Real\n"} chomp; ($m,$cpi,$low,$close,$high) + underlayCallback + function(canvas, area, dygraph) + null + When set, this callback gets called before the chart is drawn. It + allows you to draw underneath the chart. See the tests for more + details on how to use this. +
Tests: + underlay-callback + highlighted-region +
+ + + + strokeWidth 0.5, 2.0 1.0 diff --git a/dygraph-canvas.js b/dygraph-canvas.js index 29341e1..23e93a8 100644 --- a/dygraph-canvas.js +++ b/dygraph-canvas.js @@ -393,7 +393,7 @@ DygraphCanvasRenderer.prototype.render = function() { function halfDown(y){return Math.round(y)-0.5}; if (this.options.underlayCallback) { - this.options.underlayCallback(ctx, this.area, this.layout, this.dygraph_); + this.options.underlayCallback(ctx, this.area, this.dygraph_); } if (this.options.drawYGrid) { diff --git a/tests/highlighted-region.html b/tests/highlighted-region.html index 33d92e7..7852753 100644 --- a/tests/highlighted-region.html +++ b/tests/highlighted-region.html @@ -37,7 +37,7 @@ data, { labels: ['X', 'Est.', 'Actual'], - underlayCallback: function(canvas, area, layout, g) { + underlayCallback: function(canvas, area, g) { var bottom_left = g.toDomCoords(highlight_start, -20); var top_right = g.toDomCoords(highlight_end, +20); diff --git a/tests/underlay-callback.html b/tests/underlay-callback.html index 5c47582..075f893 100644 --- a/tests/underlay-callback.html +++ b/tests/underlay-callback.html @@ -26,8 +26,9 @@ showRoller: true, errorBars: true, - underlayCallback: function(canvas, area, layout) { - var splitHeight = area.h * (layout.yscale * (2.25 - layout.minyval)); + underlayCallback: function(canvas, area, g) { + var splitHeight = g.toDomCoords(null, 2.25)[1]; + canvas.fillStyle = 'pink'; canvas.fillRect(area.x, area.y + area.h, area.w, -splitHeight); canvas.fillStyle = 'lightblue';