X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=src%2Fdygraph-utils.js;h=54b6b6989a5f70ec7d7c5454599b4056ba5e8f94;hb=refs%2Fheads%2Fmaster;hp=8e972a6f10783d368938a9033060c39b041bf7f4;hpb=f0e472002843b5e61aa9467f97f755280c91a46b;p=dygraphs.git diff --git a/src/dygraph-utils.js b/src/dygraph-utils.js index 8e972a6..54b6b69 100644 --- a/src/dygraph-utils.js +++ b/src/dygraph-utils.js @@ -42,7 +42,7 @@ export var logRangeFraction = function(r0, r1, pct) { // Original calcuation: // pct = (log(x) - log(xRange[0])) / (log(xRange[1]) - log(xRange[0]))); // - // Multiply both sides by the right-side demoninator. + // Multiply both sides by the right-side denominator. // pct * (log(xRange[1] - log(xRange[0]))) = log(x) - log(xRange[0]) // // add log(xRange[0]) to both sides @@ -199,6 +199,7 @@ export function findPos(obj) { * @private */ export function pageX(e) { + if (e.isTouchOver) return (!e.changedTouches[0] || e.changedTouches[0].pageX < 0) ? 0 : e.changedTouches[0].pageX; return (!e.pageX || e.pageX < 0) ? 0 : e.pageX; }; @@ -211,6 +212,7 @@ export function pageX(e) { * @private */ export function pageY(e) { + if (e.isTouchOver) return (!e.changedTouches[0] || e.changedTouches[0].pageY < 0) ? 0 : e.changedTouches[0].pageY; return (!e.pageY || e.pageY < 0) ? 0 : e.pageY; }; @@ -265,7 +267,7 @@ export function isValidPoint(p, opt_allowNaNY) { }; /** - * Number formatting function which mimicks the behavior of %g in printf, i.e. + * Number formatting function which mimics the behavior of %g in printf, i.e. * either exponential or fixed format (without trailing 0s) is used depending on * the length of the generated string. The advantage of this format is that * there is a predictable upper bound on the resulting string length, @@ -377,7 +379,7 @@ export function hmsString_(hh, mm, ss, ms) { /** * Convert a JS date (millis since epoch) to a formatted string. * @param {number} time The JavaScript time value (ms since epoch) - * @param {boolean} utc Wether output UTC or local time + * @param {boolean} utc Whether output UTC or local time * @return {string} A date of one of these forms: * "YYYY/MM/DD", "YYYY/MM/DD HH:MM" or "YYYY/MM/DD HH:MM:SS" * @private @@ -686,17 +688,6 @@ export function getContextPixelRatio(context) { }; /** - * Checks whether the user is on an Android browser. - * Android does not fully support the tag, e.g. w/r/t/ clipping. - * @return {boolean} - * @private - */ -export function isAndroid() { - return (/Android/).test(navigator.userAgent); -}; - - -/** * TODO(danvk): use @template here when it's better supported for classes. * @param {!Array} array * @param {number} start @@ -852,7 +843,6 @@ var pixelSafeOptions = { 'highlightCallback': true, 'highlightCircleSize': true, 'interactionModel': true, - 'isZoomedIgnoreProgrammaticZoom': true, 'labelsDiv': true, 'labelsKMB': true, 'labelsKMG2': true, @@ -1226,6 +1216,12 @@ export function dateAxisLabelFormatter(date, granularity, opts) { if (frac === 0 || granularity >= DygraphTickers.Granularity.DAILY) { // e.g. '21 Jan' (%d%b) return zeropad(day) + ' ' + SHORT_MONTH_NAMES_[month]; + } else if (granularity < DygraphTickers.Granularity.SECONDLY) { + // e.g. 40.310 (meaning 40 seconds and 310 milliseconds) + var str = "" + millis; + return zeropad(secs) + "." + ('000'+str).substring(str.length); + } else if (granularity > DygraphTickers.Granularity.MINUTELY) { + return hmsString_(hours, mins, secs, 0); } else { return hmsString_(hours, mins, secs, millis); }