X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fcallback.js;h=9551eb024378a294a18ae3c4146a7a04fbce6b03;hb=1f882d071485210eaff9cc34483a1105affe8c75;hp=a26b7e7b085f8e496f2dea2c16c60f2027f5c928;hpb=470d42e152bd816333bb9879731c77340daaf7c1;p=dygraphs.git diff --git a/auto_tests/tests/callback.js b/auto_tests/tests/callback.js index a26b7e7..9551eb0 100644 --- a/auto_tests/tests/callback.js +++ b/auto_tests/tests/callback.js @@ -267,6 +267,7 @@ CallbackTestCase.prototype.testClosestPointCallbackCss2 = function() { */ CallbackTestCase.prototype.testNaNData = function() { var dataNaN = [ + [9, -1, NaN, NaN], [10, -1, 1, 2], [11, 0, 3, 1], [12, 1, 4, NaN], @@ -293,17 +294,68 @@ CallbackTestCase.prototype.testNaNData = function() { DygraphOps.dispatchMouseMove(g, 10.1, 0.9); //check correct row is returned - assertEquals(0, h_row); + assertEquals(1, h_row); // Explicitly test closest point algorithms var dom = g.toDomCoords(10.1, 0.9); - assertEquals(0, g.findClosestRow(dom[0])); + assertEquals(1, g.findClosestRow(dom[0])); var res = g.findClosestPoint(dom[0], dom[1]); - assertEquals(0, res.row); + assertEquals(1, res.row); assertEquals('b', res.seriesName); res = g.findStackedPoint(dom[0], dom[1]); - assertEquals(0, res.row); + assertEquals(1, res.row); assertEquals('c', res.seriesName); }; + +CallbackTestCase.prototype.testGapHighlight = function() { +var dataGap = [ + [1, null, 3], + [2, 2, null], + [3, null, 5], + [4, 4, null], + [5, null, 7], + [6, NaN, null], + [8, 8, null], + [10, 10, null]]; + + var h_row; + var h_pts; + + var highlightCallback = function(e, x, pts, row) { + h_row = row; + h_pts = pts; + }; + + var graph = document.getElementById("graph"); + var g = new Dygraph(graph, dataGap, { + width: 400, + height: 300, + //stackedGraph: true, + connectSeparatedPoints: true, + drawPoints: true, + labels: ['x', 'A', 'B'], + highlightCallback : highlightCallback + }); + + DygraphOps.dispatchMouseMove(g, 1.1, 10); + //point from series B + assertEquals(0, h_row); + assertEquals(1, h_pts.length); + assertEquals(3, h_pts[0].yval); + assertEquals('B', h_pts[0].name); + + DygraphOps.dispatchMouseMove(g, 6.1, 10); + // A is NaN at x=6 + assertEquals(1, h_pts.length); + assert(isNaN(h_pts[0].yval)); + assertEquals('A', h_pts[0].name); + + DygraphOps.dispatchMouseMove(g, 8.1, 10); + //point from series A + assertEquals(6, h_row); + assertEquals(1, h_pts.length); + assertEquals(8, h_pts[0].yval); + assertEquals('A', h_pts[0].name); +};