When working with large amounts of data, you are likely to encounter situations where the data must be represented visually with the help of graphs.
A graph is a structure that is equivalent to a set of objects in which some pairs of objects are in a certain sense “related”. They are basically mathematical structures used to model pairwise relationships between objects. (Wikipedia)
If you implement everything yourself, visually representing the data in the form of graphs will take a significant amount of time in writing the code for managing the structure of the graph. In this post, we’ve created a list of some of the best free JavaScript chart viewer libraries that will do all the heavy lifting for you.
People generally use the terms graphics and graphics interchangeably. We’ve also got you covered with a list of the best free JavaScript chart libraries if you were looking for those instead of chart display libraries.
1. D3.js
The first library that comes to mind whenever you perform any operation related to displaying any type of data in the form of charts or graphs in D3.js. D3 is short for Data-Driven Documents. It uses a combination of HTML, SVG and CSS to create a visual representation of the data.
The library basically allows you to bind arbitrary data to the DOM. All kinds of charts and graphs based on this data can then be created. The library gives you access to several methods and functions that you can use to make item selections. It also allows you to dynamically set the property values of different elements based on the data provided.
You can visit the D3 Graph Library website to see all the possibilities. Contains a number of different charts and graphs to show you the capabilities of D3.js.
An important thing to keep in mind is that the library does not include built-in methods to help you create bars or graphs directly by calling a single method. You will have to implement that functionality yourself. However, it comes with a lot of support features to help you do all of these things relatively easily.
2. Neo4j
As mentioned above, D3.js is a powerful library for creating all kinds of charts and diagrams. However, it takes a lot of work to create any type of graphic display. One way to overcome this limitation is to use D3.js-based support libraries which do all the basic operations for you.
An example of such a library is Neo4j. It has several useful features such as compatibility with multiple data formats, force simulations, double-click callouts, and custom node colors based on node type. You can also show information about different nodes and their relationships to each other within an information panel.
You can zoom and pan the graph. The library also has automatic fit and automatic relationship orientation functions. Dragging a knot will make it sticky and clicking on it again will return it to its initial non-sticky state.
You can also provide callbacks for different events using options such as onNodeClick
, onNodeDoubleClick
, onNodeDragStart
, onNodeDragEnd
etc. The example on the website adds a group of new nodes connected to the original node on each double click event.
3. Reaction graph D3
React D3 Graph is another D3.js-based graph generation library that allows you to create interactive and configurable graphs with React.
The library comes with a main graph component that will allow you to build the actual graph once you have passed all relevant data to it. You can also optionally provide configuration information and callback functions to handle user events such as node click and link click.
Note that this library is not prepackaged with React and D3.js. You will need to install these libraries separately. This gives you the freedom to independently choose separate versions of the libraries as long as they are above the minimum requirement.
There are a number of configuration options you can specify for each graph, such as to make it directional, zoom in focus, change animation duration while focusing, or use pan and zoom behavior. You can also disable any graph manipulation related to drag and drop or make the graph completely static.
4. VivaGraphJS
VivaGraphJS is a dependency-free library that you can use to render graphics. The library is extensible and includes support for multiple rendering engines and layout algorithms. There are many related modules that you can install to get the required functionality in your charts. This includes support for basic events, forced direction chart layouts, and storing chart data in JSON format.
The library offers many customization options. You can change the look of nodes and links with little effort. Likewise, you have full control over the layout algorithm and media used to display the chart. For example, you can tell the library to use WeBGL to render your graphics instead of the SVG it uses by default.
All the graphs you see on the webpage will have a different structure based on factors like the number of nodes and the number of connecting edges, etc. You can use a number of parameters such as springLength
, springCoeff
And gravity
etc. to fine-tune the physics so that the graphs you render look good.
5. Graphology
The Graphology library is a robust and multipurpose package written in JavaScript and TypeScript. The purpose of the library is to add support for multiple chart types using the same unified interface. This allows you to create a wide variety of graphs that can be direct, undirected or mixed. You can also decide functions such as whether to allow automatic looping or support parallel edges.
Charts created using graphology can generate events for a wide variety of actions such as adding or removing a node as well as adding or removing a border. There are also events that are triggered with updates to node or edge attributes.
You can also include many standard support libraries in your project for additional functionality. This includes things like the canvas package for rendering to canvas or the shortest path package with functions for applying common search algorithms such as the Dijkstra algorithm.
A separate library that works very well with Graphology is Sigma.js. It gives you access to a WebGL renderer and helps you create interactive charts.
6. Cytoscape.js
Cytoscape.js is another great library for graph theory visualization and data analysis. You can use it to view all kinds of relational data such as social network connections or biological data. The library comes with a graph theory model and an optional renderer to display your interactive graphs. It’s an all-in-one package to handle all your graphics needs.
The library is highly optimized and comes with good browser support. Support for browsers dates back to IE10 with partial support for IE9. All modern browsers enjoy fantastic support. The library also supports the use of selectors for filtering and querying charts. It also uses style sheets to keep data separate from the presentation.
There is built-in support for standard gestures on both desktop and mobile devices. It supports set theory operations and includes graph theory algorithms such as BFS and PageRank. You can be sure of the quality of the library because it is used by large companies such as Amazon and Google, as well as government organizations.
You can read the Cytoscape.js documentation to get started with the library.
7. Pergola
Arbor is a simple graph display library that was built using web workers and the jQuery library as a base. Unlike other libraries on this list, Arbor doesn’t aim to be a complete all-in-one solution.
It simply provides an efficient and forced layout algorithm along with other abstractions for organizing graphs. It also comes with built-in support for handling screen refresh events. This simply means that the rendering of the data on the web page is left to the developer. You are free to use canvas, SVG or HTML elements to create the graphic according to the needs of your project.
8. Strength chart
You can use the Force Graph library to render forced graphs on the HTML5 canvas. Although the library uses the HTML5 canvas for rendering, it relies on the D3 strength library to take care of the underlying physics. There is support for zooming and panning on the canvas. You can also drag nodes around or listen to click and hover events for nodes and their links.
There are many ways to control the style of nodes and links. You can also use a variety of methods to control how different chart elements are displayed.
What if you want to render your chart in 3D? Fortunately, the library also has a 3D version which relies on WebGL and ThreeJS to handle rendering. The underlying physics of the graph is taken care of by the D3 force 3D library or the ngraph library.
Final thoughts
Visualizing complicated data in the form of graphs can help us easily understand the relationship between different entities. Charts will help you convey data that is too large and complicated to be explained easily with just textual information.
In this post, we have given you a brief overview of some of the most popular JavaScript libraries that help you visualize information in the form of graphs. One of these libraries will likely meet the needs of your project. However, you can also search the graph display libraries on GitHub for more options.