forcegraph: just clear the whole canvas

This commit is contained in:
Nils Schneider 2015-08-01 16:28:45 +02:00
parent c13e648cc6
commit 76fb29d5d8

View File

@ -120,8 +120,6 @@ define(["d3"], function (d3) {
} }
} }
var translateP, scaleP
function onPanZoom() { function onPanZoom() {
savedPanZoom = {translate: zoomBehavior.translate(), savedPanZoom = {translate: zoomBehavior.translate(),
scale: zoomBehavior.scale()} scale: zoomBehavior.scale()}
@ -258,32 +256,15 @@ define(["d3"], function (d3) {
var scale = zoomBehavior.scale() var scale = zoomBehavior.scale()
var links = intLinks.filter(visibleLinks) var links = intLinks.filter(visibleLinks)
var xExtent = d3.extent(intNodes, function (d) { return d.px }) ctx.save()
var yExtent = d3.extent(intNodes, function (d) { return d.py }) ctx.setTransform(1, 0, 0, 1, 0, 0)
ctx.clearRect(0, 0, canvas.width, canvas.height)
if (translateP) { ctx.restore()
ctx.save()
ctx.translate(translateP[0], translateP[1])
ctx.scale(scaleP, scaleP)
ctx.clearRect(xExtent[0] - margin, yExtent[0] - margin,
xExtent[1] - xExtent[0] + 2 * margin,
yExtent[1] - yExtent[0] + 2 * margin)
ctx.restore()
}
ctx.save() ctx.save()
ctx.translate(translate[0], translate[1]) ctx.translate(translate[0], translate[1])
ctx.scale(scale, scale) ctx.scale(scale, scale)
if (!translateP)
ctx.clearRect(xExtent[0] - margin, yExtent[0] - margin,
xExtent[1] - xExtent[0] + 2 * margin,
yExtent[1] - yExtent[0] + 2 * margin)
// Remeber last translate/scale state
translateP = translate
scaleP = scale
var clientColor = "rgba(230, 50, 75, 1.0)" var clientColor = "rgba(230, 50, 75, 1.0)"
var unknownColor = "#D10E2A" var unknownColor = "#D10E2A"
var nodeColor = "#F2E3C6" var nodeColor = "#F2E3C6"