Comments (6)
Hi,
We can perhaps use the moveNode
method (http://visjs.org/docs/network/#methods) for move just a node. I think there is actually no way to move all nodes, with some animation.
The moveNode
method is not yet in visNetwork
, but it's quite simple to add this feature using a visNetworkProxy
,object.
from visnetwork.
You can also try to use setData
with visSetData
for passing new data (in your case same data with new coordinate), and see what happened ....? This method delete all previous data.
from visnetwork.
For some dynamically change with shiny
, you can now have a look to new features visUpdateNodes
and visUpdateEdges
. Related to #50
from visnetwork.
Hi,
I made a simple example of the use of moveNode as you suggested, see here:
https://gist.github.com/FrissAnalytics/ecf8cfc756b5fcbb8766
Basically you have an original set of x,y coordinates and a target set of x,y coordinates for each node and then you create a convex combination of the two for each node and move the node to that position. In the example I've set up a tick event every 10ms, with a total animation time of 500ms. In the loop I compute what lambda (l) in the convex combination should be at a given iteration (k).
In the example all nodes start at 0,0, and then move into the position as computed by the force layout. Obviously it's just a toy example.
It sort of works, but my javascript code skill is very limited so for something useful a better implementation can be made for sure. Also, in the example there is no easing function. I don't know if this approach makes sense, but I think it can be made to work.
Obviously I would be nicer if the guys from vis.js made a function like this, but certainly for your extension to include layouts from iGraph a transition from one layout to another would be very cool.
Do you see a better way?
kind regards, Herman
from visnetwork.
fyi: I send a request to the vis.js authors to add an options to the moveNode method:
from visnetwork.
Hey I made this function, for animating Nodes using requestAnimationFrame instead of setTimeout.
function moveNodeAnim(nodeId, finX, finY, duration) {
let startPos = network.getPositions([nodeId])[nodeId];
let startX = startPos.x;
let startY = startPos.y;
let startTime = performance.now();
let _duration = duration || 1000;
let move = (function () {
let time = performance.now();
let deltaTime = (time - startTime) / _duration;
let currentX = startX + ((finX - startX) * deltaTime);
let currentY = startY + ((finY - startY) * deltaTime);
if (deltaTime >= 1) {
network.moveNode(nodeId, finX, finY);
} else
{
network.moveNode(nodeId, currentX, currentY);
window.requestAnimationFrame(move);
}
});
move();
}
from visnetwork.
Related Issues (20)
- Adding Two Search Bars to Networks
- Specifying Order of Points in visNetwork
- Can't change figure size in R markdown HOT 1
- Network background image
- arrows.to.type Documentation HOT 1
- Node labels cause extreme node sizes, and can't use ellipsis on node labels HOT 1
- Default colors listed in visNodes() documentation still incorrect
- Edge Labels in VisNetwork?
- Display information of the nodes when an edge is selected HOT 1
- Highlight Edges with Color Column HOT 1
- Access network instance from script
- HOWTO receive event when node is selected HOT 1
- Is it possible to rotate FontAwesome icons with visNetwork?
- Does anyone know how to save a drag and drop graph in Rshiny after drawing a flowchart with visNetwork
- `visHclust()` throws `Error in match.names(clabs, names(xi)) : names do not match previous names` when using reference manual code
- Blank visNetwork in RStudio HOT 1
- When node is selected, only label highlighted edges and only display direct edges
- problems with color of the border of nodes in visLegend
- Multiple SelectedBy within one visNetwork html page
- Color problems in nodes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from visnetwork.