D3 is a visual library of JavaScript, you can make a very beautiful table, which has a very interesting mechanics diagram, can be easily dragged, etc., but on the update of the operation of the online introduction of the few, the following describes the mechanics of the update, first look at an example (http:// example.codeboy.me/d3/force-layout.html, click the following image once to add directly to the ENTER key:
CSDN cannot insert an IFRAME, please click on the link above to view.
The way to draw a graph can basically be divided into SVG and canvas two, both have advantages and disadvantages, not for the future screen is larger, SVG more advantages, and SVG can be very convenient for event interaction.
Take a look at this mechanical diagram to achieve the specific: the overall code
Update Explanation
The update is only updated with the update () function, which is divided into the following data update mechanics diagram reload data append corresponding edges and nodes (enter) remove unwanted elements (remove) perform force.start () operation
As long as in order, the new node can be well added. Example Description
There are a few examples that need to be explained.
Force.on ("tick", function (d) {...}) the calculated user draws a line between only two circles, and of course it makes it easier to add arrows and fewer overlapping operations.
The var nodes_labels = Svg.selectall ("text") is annotated only for the first point, which prompts for a click action, and can also be annotated for all points. Summary
D3 's GitHub (Https://github.com/mbostock/d3/wiki/Gallery) on a number of examples, you can find their favorite to learn, but also need to have a certain degree of SVG learning, to facilitate our own some improvements.