From 8ff0f789f8b6de40c5e6c8e909d79adc4c6ddd0b Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 19 Apr 2015 03:46:09 +0200 Subject: [PATCH] forcegraph: do not use global ctx when preparing labels --- lib/forcegraph.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/forcegraph.js b/lib/forcegraph.js index 2b266c5..10fd665 100644 --- a/lib/forcegraph.js +++ b/lib/forcegraph.js @@ -557,20 +557,19 @@ define(["d3"], function (d3) { var name = nodeName(d) - ctx.font = "11px Roboto" var offset = 8 var lineWidth = 3 - var width = ctx.measureText(name).width var buffer = document.createElement("canvas") var r = window.devicePixelRatio var bctx = buffer.getContext("2d") + bctx.font = "11px Roboto" + var width = bctx.measureText(name).width var scale = zoomBehavior.scaleExtent()[1] * r buffer.width = (width + 2 * lineWidth) * scale buffer.height = (16 + 2 * lineWidth) * scale bctx.scale(scale, scale) bctx.textBaseline = "middle" bctx.textAlign = "center" - bctx.font = ctx.font bctx.lineWidth = lineWidth bctx.lineCap = "round" bctx.strokeStyle = "rgba(255, 255, 255, 0.8)"