netjsongraph.js
netjsongraph.js copied to clipboard
Add a way to redraw graph by supplying new data
is it possible to read in an updated json-file without redrawing everything (avoiding the funny animation at the beginning)? e.g. delete or add 1 link.
I think it's possible, I'd love this library to be able to handle this feature nicely.
I would also love to allow avoiding the funny animation in the beginning!
In my pull-request, I introduced init()
, reInit()
and destroy()
functions but perhaps a dynamic solution like web-socket could be more cool...
Nice animations can be reduced a lot just setting animationAtStart
to false ;)
@geekplux we should definitely do this! Do you remember we discussed about it? I'm setting it for the second phase.
Let me clarify, I think we need to create a way to easily update the graph with a function/method or something like that, so we can update the graph as we get new data from a server.
I see what you mean.
@geekplux great. Notice how different people asked for the same feature in #31 and #26. If you implement this feature we can implement it straightaway in django-netjsongraph, that would be nice.
at battlemesh10 we tried to have some kind of auto-refresh with 'animationAtStart = false' and this block:
around line 209:
if(!opts.animationAtStart) {
opts.linkStrength = 10; // was '2'
opts.friction = 0.0; // was '0.3'
opts.gravity = 0;
}
but this is not enough, it still "jump" during every reload. see this example here: http://intercity-vpn.de/networks/giancarlo/meshrdf/netjson.html
@bittorf I've created a new issue regarding disabling the animation in https://github.com/netjson/netjsongraph.js/issues/42
@geekplux what's the status of this issue?
done
@geekplux how can I test this?
like this:
new Netjsongraph('url').load(newData).render()
@geekplux is this actually implemented? I'm trying something like this:
<script type="text/javascript">
graph = new d3.netJsonGraph("/graph-json")
function update_graph() {
fetch("/graph-json", { method: 'GET' })
.then(res => res.json())
.catch(error => console.error('Error:', error))
.then(response => graph.load(response).render());
}
</script>
The graph object is just empty
@aparcar you can have a try to use my version which in develop branch and refactor folder