return ary;
}
+function makeNumbers(ary) {
+ var ret = [];
+ for (var i = 0; i < ary.length; i++) {
+ ret.push(parseFloat(ary[i]));
+ }
+ return ret;
+}
+
function getLegend() {
var legend = document.getElementsByClassName("dygraph-legend")[0];
return legend.textContent;
}
+AxisLabelsTestCase.prototype.kCloseFloat = 1.0e-10;
+
AxisLabelsTestCase.prototype.testMinusOneToOne = function() {
var opts = {
width: 480,
var graph = document.getElementById("graph");
var g = new Dygraph(graph, data, opts);
- assertEquals(["-0.1","-0.08","-0.06","-0.04","-0.02","0","0.02","0.04","0.06","0.08"], getYLabels());
+ assertEqualsDelta(makeNumbers(["-0.1","-0.08","-0.06","-0.04","-0.02","0","0.02","0.04","0.06","0.08"]),
+ makeNumbers(getYLabels()), this.kCloseFloat);
opts.valueRange = [-0.05, 0.05];
g.updateOptions(opts);
// TODO(danvk): why '1.00e-2' and not '0.01'?
- assertEquals(["-0.05","-0.04","-0.03","-0.02","-0.01","0","1.00e-2","0.02","0.03","0.04"], getYLabels());
+ assertEquals(makeNumbers(["-0.05","-0.04","-0.03","-0.02","-0.01","0","1.00e-2","0.02","0.03","0.04"]),
+ makeNumbers(getYLabels()));
opts.valueRange = [-0.01, 0.01];
g.updateOptions(opts);
- assertEquals(["-0.01","-8.00e-3","-6.00e-3","-4.00e-3","-2.00e-3","0","2.00e-3","4.00e-3","6.00e-3","8.00e-3"], getYLabels());
+ assertEquals(makeNumbers(["-0.01","-8.00e-3","-6.00e-3","-4.00e-3","-2.00e-3","0","2.00e-3","4.00e-3","6.00e-3","8.00e-3"]), makeNumbers(getYLabels()));
g.setSelection(1);
assertEquals('1: Y:0', getLegend());
drawPoints : true,
highlightCircleSize : 6,
pointClickCallback : function(evt, point) {
+ // chrome sez: 243 30 248 124, scroller.offsetLeft/Top = 8/8
+ // ff sez: 245 17 249 126, " "
+ console.log(evt.clientX, evt.clientY, evt.screenX, evt.screenY);
self.point = point;
}
}
};
+// This is usually something like 15, but for OS X Lion and its auto-hiding
+// scrollbars, it's 0. This is a large enough difference that we need to
+// consider it when synthesizing clicks.
+// Adapted from http://davidwalsh.name/detect-scrollbar-width
+ScrollingDivTestCase.prototype.detectScrollbarWidth = function() {
+ // Create the measurement node
+ var scrollDiv = document.createElement("div");
+ scrollDiv.style.width = "100px";
+ scrollDiv.style.height = "100px";
+ scrollDiv.style.overflow = "scroll";
+ scrollDiv.style.position = "absolute";
+ scrollDiv.style.top = "-9999px";
+ document.body.appendChild(scrollDiv);
+
+ // Get the scrollbar width
+ var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
+
+ // Delete the DIV
+ document.body.removeChild(scrollDiv);
+
+ return scrollbarWidth;
+};
+
ScrollingDivTestCase.prototype.tearDown = function() {
};
var clickOn4_40 = {
clientX: 244,
- clientY: 20,
+ clientY: 30 - this.detectScrollbarWidth(),
screenX: 416,
screenY: 160
};