- // Test that all elements are inside the bounds of the graph, set above
- var innerDiv = el.firstChild;
- for (var child = innerDiv.firstChild; child != null; child = child.nextSibling) {
- assertTrue(child.offsetLeft >= 0);
- assertTrue((child.offsetLeft + child.offsetWidth) <= 640);
- assertTrue(child.offsetTop >= 0);
- // TODO(flooey@google.com): Text sometimes linebreaks,
- // causing the labels to appear outside the allocated area.
- // assertTrue((child.offsetTop + child.offsetHeight) <= 350);
- }
-};
+it('testDrawPointCallback', function() {
+ var data = getData();
+
+ var results = { y : {}, y2 : {}};
+ var firstCallback = function(g, seriesName, ctx, canvasx, canvasy, color, radius) {
+ results.y[seriesName] = 1;
+ utils.Circles.DEFAULT(g, seriesName, ctx, canvasx, canvasy, color, radius);
+
+ };
+ var secondCallback = function(g, seriesName, ctx, canvasx, canvasy, color, radius) {
+ results.y2[seriesName] = 1;
+ utils.Circles.DEFAULT(g, seriesName, ctx, canvasx, canvasy, color, radius);
+ };
+
+ var g = new Dygraph(
+ document.getElementById("graph"),
+ data,
+ {
+ labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
+ drawPoints : true,
+ pointSize : 3,
+ series : {
+ 'Y3': {
+ axis: 'y2'
+ },
+ 'Y4': {
+ axis: 'y2'
+ }
+ },
+ axes: {
+ y2: {
+ drawPointCallback: secondCallback
+ }
+ },
+ drawPointCallback: firstCallback
+ }
+ );
+
+ assert.equal(1, results.y["Y1"]);
+ assert.equal(1, results.y["Y2"]);
+ assert.equal(1, results.y2["Y3"]);
+ assert.equal(1, results.y2["Y4"]);
+});
+
+// Test for http://code.google.com/p/dygraphs/issues/detail?id=436
+it('testRemovingSecondAxis', function() {
+ var data = getData();
+
+ var results = { y : {}, y2 : {}};
+
+ var g = new Dygraph(
+ document.getElementById("graph"),
+ data,
+ {
+ labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
+ drawPoints : true,
+ pointSize : 3,
+ series : {
+ 'Y4': {
+ axis: 'y2'
+ }
+ },
+ }
+ );
+
+ g.updateOptions({ series : { Y4 : { axis : 'y' } } });
+});
+
+});