Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Conversation

@wimrijnders
Copy link

Fix for issue #2938.

In the saveAndLoad example, node id's got replaced by array id's, leading to inconsistent data. This PR ensures that node id's are always used.

Copy link

@rasmusblockzero rasmusblockzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, and solves the problem. Well done.

One minor loopstyle comment

Perhaps a separate commit but maybe the util should be changed to

function getScaleFreeNetwork(nodeCount, prefix) {
  .... 

    if (i == 1) {
      var from = i;
      var to = 0;
      edges.push({
        from: prefix + from,
        to: prefix + to
      });

To make this easy to test (imagen that might be interesting in other examples too)

function getNodeById(data, id) {
var foundNode;

data.forEach(function(node) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a minor thing but in this looping an old fashioned
for(var i=0 )
has the benefit of being able to
break;
or even a
return node;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

function getEdgeData(data) {
var networkEdges = [];

data.forEach(function(node, index, array) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

array variable no longer needed, could be kept for consistency perhaps

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Also removed index

@wimrijnders
Copy link
Author

It looks good to me, and solves the problem. Well done.

👍 Thanks

Perhaps a separate commit but maybe the util should be changed to...

At this moment, I do not see the utility of adding a prefix parameter. If you feel that it is a worthwhile addition, feel free to make an issue for this (preferably with motivation).

@rasmusblockzero
Copy link

rasmusblockzero commented Apr 21, 2017 via email

Copy link
Contributor

@bradh bradh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems OK.

@yotamberk yotamberk merged commit a58b92c into visjs:develop May 5, 2017
@wimrijnders wimrijnders deleted the PR34 branch May 5, 2017 07:01
@mojoaxel mojoaxel added this to the Minor Release v4.20 milestone May 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants