Yet Another D3 DAG Sample code
Photo by Pixabay from Pexels.com |
In many cases when we need visualize relations and associations between entities, graph visualization tools are valuable. One of the great open source libraries for rendering graphs on web pages is D3.js. I use it in the past and yesterday, I spent some time to play with it. I have created a simple directed acyclic graph, DAG with it. The source code is in https://github.com/dennisseah/d3_dag.
D3.js is widely used because it is easy to learn and there are abundant of great examples. Recently, I used it for Microsoft Summer Hackathon where we used its map and charting API. Images of them can be found in my previous blog, deaths due to police actions in USA.
When talk about D3.js, it is almost impossible to miss this guy, Mike Bostock who is the creator of D3.js. Before his creation, it is extremely painful to draw on svg. And even if we are able to create svg drawings, they usually looks ugly. :-)
This is short blog to share my code in https://github.com/dennisseah/d3_dag. In there, you can see how to draw a node with a circle (stroke without fill), edges with arrowheads, tooltip (when mouse hover nodes and edges), and how to handle browser resize event.
demo at https://dennisseah.github.io/d3_dag/index.html
Comments
Post a Comment