From: Klaus Weidner Date: Fri, 27 Apr 2012 17:55:04 +0000 (-0700) Subject: Add auto test for isolated and gap points. X-Git-Tag: v1.0.0~271^2~2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=41273327c7eb2aaa777194f48516e69784aef7f1;p=dygraphs.git Add auto test for isolated and gap points. --- diff --git a/auto_tests/tests/callback.js b/auto_tests/tests/callback.js index 4d0b172..e2f425f 100644 --- a/auto_tests/tests/callback.js +++ b/auto_tests/tests/callback.js @@ -123,6 +123,48 @@ CallbackTestCase.prototype.testDrawPointCallback_pointSize = function() { }; /** + * Test that drawPointCallback is called for isolated points when + * drawPoints is false, and also for gap points if that's enabled. + */ +CallbackTestCase.prototype.testDrawPointCallback_isolated = function() { + var xvalues = []; + + var g; + var callback = function(g, seriesName, canvasContext, cx, cy, color, pointSizeParam) { + var dx = g.toDataXCoord(cx); + xvalues.push(dx); + Dygraph.Circles.DEFAULT.apply(this, arguments); + }; + + var graph = document.getElementById("graph"); + var testdata = [[10, 2], [11, 3], [12, NaN], [13, 2], [14, NaN], [15, 3]]; + var graphOpts = { + labels: ['X', 'Y'], + valueRange: [0, 4], + drawPoints : false, + drawPointCallback : callback, + pointSize : 8 + }; + + // Test that isolated points get drawn + g = new Dygraph(graph, testdata, graphOpts); + assertEquals(2, xvalues.length); + assertEquals(13, xvalues[0]); + assertEquals(15, xvalues[1]); + + // Test that isolated points + gap points get drawn when drawGapPoints is set. + // This should add one point at the right edge of the segment at x=11, but not + // at the graph edge at x=10. + xvalues = []; // Reset for new test + graphOpts.drawGapPoints = true; + g = new Dygraph(graph, testdata, graphOpts); + assertEquals(3, xvalues.length); + assertEquals(11, xvalues[0]); + assertEquals(13, xvalues[1]); + assertEquals(15, xvalues[2]); +}; + +/** * This tests that when the function idxToRow_ returns the proper row and the onHiglightCallback * is properly called when the first series is hidden (setVisibility = false) *