863D3 canvas and Retina screens

function getRetinaRatio() { var devicePixelRatio = window.devicePixelRatio || 1 var c = document.createElement('canvas').getContext('2d') var backingStoreRatio = [ c.webkitBackingStorePixelRatio, c.mozBackingStorePixelRatio, c.msBackingStorePixelRatio, c.oBackingStorePixelRatio, c.backingStorePixelRatio, 1 ].reduce(function(a, b) { return a || b })

return devicePixelRatio / backingStoreRatio

}

var ratio = getRetinaRatio() var scaledWidth = width ratio var scaledHeight = height ratio

via http://bl.ocks.org/devgru/a9428ebd6e11353785f2