I'm looking for a simple pure JavaScript library which does not use canvas from HTML5 and provides drawing graphs.

Something similar to Sigma and Cytoscape Web would be perfect.

http://sigmajs.org/ (this one covers all my needs except pure JavaScript) http://cytoscapeweb.cytoscape.org/

The library is supposed to have such features:

  1. drawing nodes and edges between them (directed or not)
  2. changing position of each node using drag-and-drop (not obliged but with possibility to add event listener to each node)
  3. other features like highlighting edges and scaling would be big advantages too
  • 1
    What you mean with does not use canvas from HTML5? And why sigma is not a pure Javascript library?
    – MarcoL
    Commented Aug 26, 2014 at 13:12
  • 1
    If it doesn't use canvas, what are you expecting to render to? DOM elements? SVG? Why not canvas? Commented Oct 10, 2014 at 15:15

2 Answers 2


Most probably d3.js, is what you want. It uses HTML5/CSS/SVG to draw. You probably want to use Force Layout. It has drag and drop support and you can just style your graph with CSS.


As mentioned, d3.js should work fine. It should use SVGs for drawing, so drawing of nodes works, as does styling with CSS (see example). Here is an example from http://bl.ocks.org/jose187/4733747:

simple network graph


<!DOCTYPE html>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v2.min.js?2.9.3"></script>

.link {
  stroke: #aaa;

.node text {

.node circle{


var width = 960,
    height = 500

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

var force = d3.layout.force()
    .size([width, height]);

d3.json("graphFile.json", function(json) {

  var link = svg.selectAll(".link")
      .attr("class", "link")
    .style("stroke-width", function(d) { return Math.sqrt(d.weight); });

  var node = svg.selectAll(".node")
      .attr("class", "node")


      .attr("dx", 12)
      .attr("dy", ".35em")
      .text(function(d) { return d.name });

  force.on("tick", function() {
    link.attr("x1", function(d) { return d.source.x; })
        .attr("y1", function(d) { return d.source.y; })
        .attr("x2", function(d) { return d.target.x; })
        .attr("y2", function(d) { return d.target.y; });

    node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.