Skip to content

Instantly share code, notes, and snippets.

@michaelhood
Last active December 10, 2015 15:08
Show Gist options
  • Save michaelhood/4452095 to your computer and use it in GitHub Desktop.
Save michaelhood/4452095 to your computer and use it in GitHub Desktop.
fix github network graph for chrome retina
/*
MIT: https://raw.github.com/github/hubot/1455b62e5b6daffeacb7472db83ccf6502396bea/LICENSE.md
refs:
http://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html
http://www.html5rocks.com/en/tutorials/canvas/hidpi/
https://code.google.com/p/chromium/issues/detail?id=127852 (WONTFIX)
*/
(function(doc) {
var can = $("#ng canvas")[0];
if (!can) { return false; }
var canOW = can.width,
canOH = can.height,
context = can.getContext("2d");
var devicePixelRatio = window.devicePixelRatio || 1;
// in case chromium aren't the only team ignoring pragmatism.
var backingStoreRatio = context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio || 1;
var ratio = devicePixelRatio / backingStoreRatio;
if (ratio === 1) { return; }
can.width = canOW*ratio;
can.height = canOH*ratio;
can.style.width = canOW+'px';
can.style.height = canOH+'px';
context.scale(ratio, ratio);
}(document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment