X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FUtil.js;h=0e2c25d609d67275390ae04ed28fd695915d1b1c;hb=0a0885d1383321a67155fcf1cb12c583cdd89ef2;hp=8a14e065507845089f803ca4f5f374576e04a9bb;hpb=5bcc58b46734fb5c9e821ed041318cb53127feb5;p=dygraphs.git diff --git a/auto_tests/tests/Util.js b/auto_tests/tests/Util.js index 8a14e06..0e2c25d 100644 --- a/auto_tests/tests/Util.js +++ b/auto_tests/tests/Util.js @@ -91,7 +91,9 @@ Util.samplePixel = function(canvas, x, y) { // TODO(danvk): Any performance issues with this? var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); - var i = 4 * (x + imageData.width * y); + var scale = Dygraph.getContextPixelRatio(ctx); + + var i = 4 * (x * scale + imageData.width * y * scale); var d = imageData.data; return [d[i], d[i+1], d[i+2], d[i+3]]; }; @@ -131,3 +133,11 @@ Util.overrideXMLHttpRequest = function(data) { return FakeXMLHttpRequest; }; +/** + * Format a date as 2000/01/23 + * @param {number} dateMillis Millis since epoch. + * @return {string} The date formatted as YYYY-MM-DD. + */ +Util.formatDate = function(dateMillis) { + return Dygraph.dateString_(dateMillis).slice(0, 10); // 10 == "YYYY/MM/DD".length +};