anvaka / VivaGraphJS

Graph drawing library for JavaScript
Other
3.75k stars 425 forks source link

Feedback: svg(type, inconvenient attribute specification) #121

Closed valtih1978 closed 9 years ago

valtih1978 commented 9 years ago

Thank you for creating comparison of alternatives. I want to give some feedback on VivaGraph implementaion. I had some experience in javascripting SVG genration and came to design like

createSvg(elementType, attributes)

where attributes is a dictionary. You use it like

svg('circle', {x:10, y:10, r:2, 'stroke-width':4})

instead of your's

svg('circle').attr('x', 1).attr('y', 2).attr('r',3).attr('stroke-width', 4)

which you exemplify for rendering the graph. One should understand that r:a is utter optimum. It is terrible waste to write 6 sintaxical pieces for attr('',) whereas single-char ideal : is available. We should save verbosity, storage space and typing time and understand that evil exists. Waste is the Evil.

anvaka commented 9 years ago

I like your design very much!

anvaka commented 9 years ago

I've just added this into simplesvg module. Here is online demo and the source code

simplesvg will replace Viva.Graph.svg() method in version 0.7.x.

valtih1978 commented 9 years ago

Nice to see :). Actually, i have realized that I could add a wrapper function myself into my project. But examples would look nicer indeed if the neat coding is available right 'in the box'.

I would also like to know if it is possible to stop dynamic layout after graph stabilizes more or less (to save power. you remember that [Evil = Waste](http://en.wikipedia.org/wiki/Equality %28mathematics%29#Identities) and energy/killing nature waste is not exception, you see the concept of optimizing and making something beautiful stretches far beyound writing the code) but I do not know where to ask. I am actually doing a graph editor (you should be able to edit node names and add/remove nodes/edges) for such project but cannot find the ready available example.

anvaka commented 9 years ago

simplesvg is now part of the library (starting from 0.7.0), which also comes with suggested attributes API improvements.

As for the stop - the force directed layout will stop itself if it finds movement in the graph are very small. However this will highly depend on your physics settings. Physics settings cannot be universally selected for all kinds of graphs, so you need to play with them to find what suits your needs.

After all if nothing helps you can use renderer.pause() method to pause it manually.