</tr>
<tr>
+ <td><strong>underlayCallback</strong></td>
+ <td><code>function(canvas, area, dygraph)</code></td>
+ <td><code>null</code></td>
+ <td>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.
+ <div class="tests">Tests:
+ <a href="tests/underlay-callback.html">underlay-callback</a>
+ <a href="tests/highlighted-region.html">highlighted-region</a>
+ </div>
+ </td>
+ </tr>
+
+ <tr>
<td><strong>strokeWidth</strong></td>
<td><code>0.5, 2.0</code></td>
<td><code>1.0</code></td>
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) {
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);
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';