X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=dygraph-utils.js;h=bf936658aaa27d2d2ccbd13487bad7f7b18e1962;hb=8f0efe6bb5598ea9ba2c875b8f4f57dc931f0616;hp=f4bb2ffccdabce5207cc62d63402e1fa39fbdcf0;hpb=6ec8f3c24060951faaeb57ebe4d6066b5e123280;p=dygraphs.git diff --git a/dygraph-utils.js b/dygraph-utils.js index f4bb2ff..bf93665 100644 --- a/dygraph-utils.js +++ b/dygraph-utils.js @@ -735,13 +735,13 @@ Dygraph.getContextPixelRatio = function(context) { context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || - context.backingStorePixelRatio; - if (devicePixelRatio !== undefined && - backingStorePixelRatio !== undefined) { + context.backingStorePixelRatio || 1; + if (devicePixelRatio !== undefined) { return devicePixelRatio / backingStoreRatio; } else { - // If either value is undefined, the ratio is meaningless so we want to - // return 1. + // At least devicePixelRatio must be defined for this ratio to make sense. + // We default backingStoreRatio to 1: this does not exist on some browsers + // (i.e. desktop Chrome). return 1; } } catch (e) { @@ -1148,7 +1148,13 @@ Dygraph.toRGB_ = function(colorStr) { div.style.backgroundColor = colorStr; div.style.visibility = 'hidden'; document.body.appendChild(div); - var rgbStr = window.getComputedStyle(div, null).backgroundColor; + var rgbStr; + if (window.getComputedStyle) { + rgbStr = window.getComputedStyle(div, null).backgroundColor; + } else { + // IE8 + rgbStr = div.currentStyle.backgroundColor; + } document.body.removeChild(div); var bits = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(rgbStr); return {