From c0ab6b74068bbf10b98b8773efc09fadf33ee1ad Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sat, 11 Apr 2015 00:53:35 +0200 Subject: [PATCH] forcegraph: fix rendering on hidpi devices --- lib/forcegraph.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/forcegraph.js b/lib/forcegraph.js index 1d71ce8..0ff0931 100644 --- a/lib/forcegraph.js +++ b/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() }