forcegraph: do not use global ctx when preparing labels
This commit is contained in:
parent
e36d3b1a6a
commit
8ff0f789f8
|
@ -557,20 +557,19 @@ define(["d3"], function (d3) {
|
||||||
|
|
||||||
var name = nodeName(d)
|
var name = nodeName(d)
|
||||||
|
|
||||||
ctx.font = "11px Roboto"
|
|
||||||
var offset = 8
|
var offset = 8
|
||||||
var lineWidth = 3
|
var lineWidth = 3
|
||||||
var width = ctx.measureText(name).width
|
|
||||||
var buffer = document.createElement("canvas")
|
var buffer = document.createElement("canvas")
|
||||||
var r = window.devicePixelRatio
|
var r = window.devicePixelRatio
|
||||||
var bctx = buffer.getContext("2d")
|
var bctx = buffer.getContext("2d")
|
||||||
|
bctx.font = "11px Roboto"
|
||||||
|
var width = bctx.measureText(name).width
|
||||||
var scale = zoomBehavior.scaleExtent()[1] * r
|
var scale = zoomBehavior.scaleExtent()[1] * r
|
||||||
buffer.width = (width + 2 * lineWidth) * scale
|
buffer.width = (width + 2 * lineWidth) * scale
|
||||||
buffer.height = (16 + 2 * lineWidth) * scale
|
buffer.height = (16 + 2 * lineWidth) * scale
|
||||||
bctx.scale(scale, scale)
|
bctx.scale(scale, scale)
|
||||||
bctx.textBaseline = "middle"
|
bctx.textBaseline = "middle"
|
||||||
bctx.textAlign = "center"
|
bctx.textAlign = "center"
|
||||||
bctx.font = ctx.font
|
|
||||||
bctx.lineWidth = lineWidth
|
bctx.lineWidth = lineWidth
|
||||||
bctx.lineCap = "round"
|
bctx.lineCap = "round"
|
||||||
bctx.strokeStyle = "rgba(255, 255, 255, 0.8)"
|
bctx.strokeStyle = "rgba(255, 255, 255, 0.8)"
|
||||||
|
|
Loading…
Reference in a new issue