Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change constant layout to become circular layout #47

Open
shashankg77 opened this issue Jul 30, 2013 · 0 comments
Open

Change constant layout to become circular layout #47

shashankg77 opened this issue Jul 30, 2013 · 0 comments

Comments

@shashankg77
Copy link

I'm trying to change the constant layout option to a circular layout which doesn't care about the number of crosses and just arranges the nodes in the form of a circle. The algo I'm using is:

var r = Math.min(this.width, this.height) / 2;

/* Where to start the circle. */
var dx = this.width / 2;
var dy = this.height / 2;

/* Calculate the step so that the vertices are equally apart. _/
var step = 2_Math.PI / graph.vertexCount;
var t = 0; // Start at "angle" 0.

for (var i = 0; i<graph.vertices.length; i++) {
var v = graph.vertices[i];
v.x = Math.round(r_Math.cos(t) + dx);
v.y = Math.round(r_Math.sin(t) + dy);
t = t + step;
}

I'm not able to figure out how to incorporate the algo into Viva so as to make it a circular layout. Any help is appreciated. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant