forcegraph: only draw clients when zoomed in
This commit is contained in:
parent
ccc5f0f526
commit
1a6a4329b5
|
@ -380,31 +380,32 @@ define(["d3"], function (d3) {
|
||||||
// -- draw clients --
|
// -- draw clients --
|
||||||
ctx.save()
|
ctx.save()
|
||||||
ctx.beginPath()
|
ctx.beginPath()
|
||||||
nodes.filter(visibleNodes).forEach(function (d) {
|
if (scale > 0.9)
|
||||||
var clients = d.o.node.statistics.clients
|
nodes.filter(visibleNodes).forEach(function (d) {
|
||||||
if (clients === 0)
|
var clients = d.o.node.statistics.clients
|
||||||
return
|
if (clients === 0)
|
||||||
|
return
|
||||||
|
|
||||||
var startDistance = 16
|
var startDistance = 16
|
||||||
var radius = 3
|
var radius = 3
|
||||||
var a = 1.2
|
var a = 1.2
|
||||||
var startAngle = Math.PI
|
var startAngle = Math.PI
|
||||||
|
|
||||||
for (var orbit = 0, i = 0; i < clients; orbit++) {
|
for (var orbit = 0, i = 0; i < clients; orbit++) {
|
||||||
var distance = startDistance + orbit * 2 * radius * a
|
var distance = startDistance + orbit * 2 * radius * a
|
||||||
var n = Math.floor((Math.PI * distance) / (a * radius))
|
var n = Math.floor((Math.PI * distance) / (a * radius))
|
||||||
var delta = clients - i
|
var delta = clients - i
|
||||||
|
|
||||||
for (var j = 0; j < Math.min(delta, n); i++, j++) {
|
for (var j = 0; j < Math.min(delta, n); i++, j++) {
|
||||||
var angle = 2 * Math.PI / n * j
|
var angle = 2 * Math.PI / n * j
|
||||||
var x = d.x + distance * Math.cos(angle + startAngle)
|
var x = d.x + distance * Math.cos(angle + startAngle)
|
||||||
var y = d.y + distance * Math.sin(angle + startAngle)
|
var y = d.y + distance * Math.sin(angle + startAngle)
|
||||||
|
|
||||||
ctx.moveTo(x, y)
|
ctx.moveTo(x, y)
|
||||||
ctx.arc(x, y, radius, 0, 2 * Math.PI)
|
ctx.arc(x, y, radius, 0, 2 * Math.PI)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
|
|
||||||
ctx.fillStyle = clientColor
|
ctx.fillStyle = clientColor
|
||||||
ctx.fill()
|
ctx.fill()
|
||||||
|
|
Loading…
Reference in a new issue