Sigma.js, draw graphs using canvas from javascript

Using HTML5 canvas is leading to interesting and amazing tools, a library that can generate dynamic charts directly from javascript as Sigma.js.

Among the features that make an interesting Sigma.js library are:

  • The ability to chain methods
  • Events management
  • Ability to add plugins, use files GEXF, ForceAtlas2 algorithms, …
  • Api simple and accessible
  • Custom painted graphic maintenance
  • Insertion using frames

So How to use it
First we initialize the object with the DOM sigma container which include our chart.

var sigInst = sigma.init(domElement);

The resulting object will allow us to start working with the graphic:

  'label': 'Hello'
  'label': 'World!'

Examples can help provide a clearer idea of ​​the capabilities of the library.

Sigma.js is an amazing JavaScript library for visualization of graphs. The documentation doesn’t really give a complete ‘Hello world !’ example so we have one to get kickstarted. It is using jQuery, that is not quite  necessary but it gives some good utility functions that could be advantageous.

<!DOCTYPE html>
    <title>Sigma.js Hello World</title>
    <script src=""></script>
    <script src=""></script>
    <script type="text/javascript">
        // Use jquery to wait for DOM to be fully loaded
        $(document).ready(function () {
            // Use jquery to retrieve the div with id 'sig'
            var domElement = $('#sig')[0];
            // Let sigma.js populate the div
            var sigInst = sigma.init(domElement);
            // Use curved edges and make the nodes a bit bigger
            // Add a simple graph
            // NOTE! addEdge needs to take three parameters,
            // the first one being the name of the edge itself
            sigInst.addNode('hello', {
            }).addNode('world', {
                    }).addEdge('helloworld', 'hello', 'world').draw();
    <style type="text/css">
        /* Set a height on the div or it will have zero height */
        .sigma {
            height: 200px;
<div class="sigma" id="sig"></div>


example :


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top