Browse Source

forcegraph: fix rendering on hidpi devices

Nils Schneider 9 years ago
parent
commit
c0ab6b7406
1 changed files with 7 additions and 2 deletions
  1. 7 2
      lib/forcegraph.js

+ 7 - 2
lib/forcegraph.js

@@ -364,8 +364,13 @@ define(["d3"], function (d3) {
     }
 
     function resizeCanvas() {
-      canvas.width = el.offsetWidth
-      canvas.height = el.offsetHeight
+      var r = window.devicePixelRatio
+      canvas.width = el.offsetWidth * r
+      canvas.height = el.offsetHeight * r
+      canvas.style.width = el.offsetWidth + "px"
+      canvas.style.height = el.offsetHeight + "px"
+      ctx.resetTransform()
+      ctx.scale(r, r)
       redraw()
     }