netjsongraph.js icon indicating copy to clipboard operation
netjsongraph.js copied to clipboard

Add a way to redraw graph by supplying new data

Open bittorf opened this issue 8 years ago • 14 comments

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.

bittorf avatar Aug 27 '15 11:08 bittorf

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!

nemesifier avatar Aug 27 '15 14:08 nemesifier

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 ;)

gubi avatar Aug 30 '15 04:08 gubi

@geekplux we should definitely do this! Do you remember we discussed about it? I'm setting it for the second phase.

nemesifier avatar May 31 '17 14:05 nemesifier

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.

nemesifier avatar May 31 '17 14:05 nemesifier

I see what you mean.

geekplux avatar May 31 '17 15:05 geekplux

@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.

nemesifier avatar May 31 '17 15:05 nemesifier

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 avatar Jun 16 '17 12:06 bittorf

@bittorf I've created a new issue regarding disabling the animation in https://github.com/netjson/netjsongraph.js/issues/42

nemesifier avatar Jun 16 '17 12:06 nemesifier

@geekplux what's the status of this issue?

nemesifier avatar Jul 21 '17 16:07 nemesifier

done

geekplux avatar Jul 21 '17 18:07 geekplux

@geekplux how can I test this?

nemesifier avatar Jul 26 '17 08:07 nemesifier

like this:

new Netjsongraph('url').load(newData).render()

geekplux avatar Jul 26 '17 10:07 geekplux

@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 avatar Feb 12 '18 22:02 aparcar

@aparcar you can have a try to use my version which in develop branch and refactor folder

geekplux avatar Feb 13 '18 04:02 geekplux