CallbackTestCase.prototype.tearDown = function() {
};
- var data = "X,a\,b,c\n" +
- "10,-1,1,2\n" +
- "11,0,3,1\n" +
- "12,1,4,2\n" +
- "13,0,2,3\n";
+var data = "X,a\,b,c\n" +
+ "10,-1,1,2\n" +
+ "11,0,3,1\n" +
+ "12,1,4,2\n" +
+ "13,0,2,3\n";
/**
var h_row;
var h_pts;
- var highlightCallback = function(e, x, pts, row) {
+ var highlightCallback = function(e, x, pts, row) {
h_row = row;
h_pts = pts;
};
CallbackTestCase.prototype.testDrawPointCallback_disabled = function() {
var called = false;
- var callback = function() {
+ var callback = function() {
called = true;
};
CallbackTestCase.prototype.testDrawPointCallback_enabled = function() {
var called = false;
- var callback = function() {
+ var callback = function() {
called = true;
};
assertTrue(called);
};
-// TODO * @fileoverview Test cases for drawPointCallback and drawHighlightCallback
+
+/**
+ * Test that drawPointCallback is called when drawPoints is true
+ */
+CallbackTestCase.prototype.testDrawPointCallback_pointSize = function() {
+ var pointSize = 0;
+ var count = 0;
+
+ var callback = function(g, seriesName, canvasContext, cx, cy, color, pointSizeParam) {
+ pointSize = pointSizeParam;
+ count++;
+ };
+
+ var graph = document.getElementById("graph");
+ var g = new Dygraph(graph, data, {
+ drawPoints : true,
+ drawPointCallback : callback
+ });
+
+ assertEquals(1.5, pointSize);
+ assertEquals(12, count); // one call per data point.
+
+ var g = new Dygraph(graph, data, {
+ drawPoints : true,
+ drawPointCallback : callback,
+ pointSize : 8
+ });
+
+ assertEquals(8, pointSize);
+};
+
+/**
+ * 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)
+ *
+ */
+CallbackTestCase.prototype.testDrawHighlightCallbackIsCalled = function() {
+ var called = false;
+
+ var drawHighlightCallback = function() {
+ called = true;
+ };
+
+ var graph = document.getElementById("graph");
+ var g = new Dygraph(graph, data,
+ {
+ width: 100,
+ height : 100,
+ drawHighlightCallback : drawHighlightCallback
+ });
+
+ assertFalse(called);
+ DygraphOps.dispatchMouseMove(g, 13, 10);
+ assertTrue(called);
+};