Merge http://github.com/danvk/dygraphs into custom-points
[dygraphs.git] / auto_tests / tests / callback.js
CommitLineData
1c6b239c 1/**
2 * @fileoverview Test cases for the callbacks.
3 *
4 * @author uemit.seren@gmail.com (Ümit Seren)
5 */
6
7var CallbackTestCase = TestCase("callback");
8
9CallbackTestCase.prototype.setUp = function() {
10 document.body.innerHTML = "<div id='graph'></div>";
11};
12
13CallbackTestCase.prototype.tearDown = function() {
14};
15
16 var data = "X,a\,b,c\n" +
17 "10,-1,1,2\n" +
18 "11,0,3,1\n" +
19 "12,1,4,2\n" +
20 "13,0,2,3\n";
21
22
23 /**
24 * This tests that when the function idxToRow_ returns the proper row and the onHiglightCallback
25 * is properly called when the first series is hidden (setVisibility = false)
26 *
27 */
28 CallbackTestCase.prototype.testHighlightCallbackIsCalled = function() {
29 var h_row;
30 var h_pts;
31
32 var highlightCallback = function(e, x, pts, row) {
33 h_row = row;
34 h_pts = pts;
35 };
36
37
38
39 var graph = document.getElementById("graph");
40 var g = new Dygraph(graph, data,
41 {
42 width: 100,
43 height : 100,
44 visibility: [false, true, true],
45 highlightCallback : highlightCallback,
46 });
47
48 DygraphOps.dispatchMouseMove(g, 13, 10);
49
50 //check correct row is returned
51 assertEquals(3, h_row);
52 //check there are only two points (because first series is hidden)
53 assertEquals(2, h_pts.length);
54 };