Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added support for preserving Cartesian coordinates. #77

Closed
wants to merge 1 commit into from

3 participants

@timdcrain

Currently node positions are not preserved when re-scaling the graph. This patch lets Cartesian coordinates be preserved if specified.

@computermacgyver computermacgyver referenced this pull request in oxfordinternetinstitute/gephi-plugins
Open

Sigma and Gephi have inverse y axes #5

@computermacgyver

This has been noted by several users of my gephi plugin using Sigma, and it would be great to get this pulled into the main repository.

@jacomyal
Owner

I cannot merge this pull request since the code has recently been completely rewritten. Sorry, for this.
The old version is still accessible in the deprecated-v0.1 branch.

@jacomyal jacomyal closed this
@jacomyal
Owner

But it would be easy to port in the current version. The scaling part is now in the related middleware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 4, 2013
  1. @timdcrain
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/core/graph.js
View
16 src/core/graph.js
@@ -31,7 +31,8 @@ function Graph() {
// - 'outside'
scalingMode: 'inside',
nodesPowRatio: 0.5,
- edgesPowRatio: 0
+ edgesPowRatio: 0,
+ cartesian: false
};
/**
@@ -468,6 +469,10 @@ function Graph() {
yMax += margin;
yMin -= margin;
+ // x- and y-ratios for preserving cartesian coordinates.
+ var xScale = w / (2 * Math.max(Math.abs(xMax), Math.abs(xMin)) + 2 * margin);
+ var yScale = h / (2 * Math.max(Math.abs(yMax), Math.abs(yMin)) + 2 * margin);
+
scale = self.p.scalingMode == 'outside' ?
Math.max(w / Math.max(xMax - xMin, 1),
h / Math.max(yMax - yMin, 1)) :
@@ -504,8 +509,13 @@ function Graph() {
node['displaySize'] = node['size'] * a + b;
if (!node['fixed']) {
- node['displayX'] = (node['x'] - (xMax + xMin) / 2) * scale + w / 2;
- node['displayY'] = (node['y'] - (yMax + yMin) / 2) * scale + h / 2;
+ if (self.p.cartesian) {
+ node['displayX'] = node['x'] * xScale + w / 2;
+ node['displayY'] = -node['y'] * yScale + h / 2;
+ } else {
+ node['displayX'] = (node['x'] - (xMax + xMin) / 2) * scale + w / 2;
+ node['displayY'] = (node['y'] - (yMax + yMin) / 2) * scale + h / 2;
+ }
}
});
Something went wrong with that request. Please try again.