title: Assigning hyperlinks to nodes in dagre-d3
body: <p>I am using this graph <a href="http://cpettitt.github.io/project/dagre-d3/latest/demo/tcp-state-diagram.html" rel="nofollow">http://cpettitt.github.io/project/dagre-d3/latest/demo/tcp-state-diagram.html</a>. I need when clicked on nodes it should be directed to some web address.</p>
  
  <p>I tried this:</p>
  
  <pre><code>&lt;    html xmlns:xlink="http://www.w3.org/1999/xlink"&gt;
      &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
  
      &lt;style&gt;
          body {
              font: 300 14px 'Helvetica Neue', Helvetica;
          }
  
          .node circle {
              stroke: #333;
              fill: #ff0000;
          }
  
          .edgePath path {
              stroke: #00ff90; /* Arrow color */
              fill: #ff0000; /* Arrow Tip color */
              stroke-width: 1.5px;
          }
          /* Make it obvious the node is clickable */
          .node.clickable {
              cursor: pointer;
              text-decoration: underline;
          }
  
      &lt;/style&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;`svg width=960 height=600&gt;&lt;g /&gt;&lt;/svg&gt;`
      &lt;script src="http://d3js.org/d3.v3.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://cpettitt.github.io/project/dagre-d3/v0.2.9/dagre-d3.js"&gt;&lt;/script&gt;
      &lt;script src="dagre-d3.js"&gt;&lt;/script&gt;
      &lt;!--&lt;script src="lib/dagre-d3.core.js"&gt;&lt;/script&gt;
      &lt;script src="lib/graphlib.js"&gt;&lt;/script&gt;
      &lt;script src="lib/intersect/index.js"&gt;&lt;/script&gt;
      &lt;script src="lib/intersect/intersect-circle.js"&gt;&lt;/script&gt;
      &lt;script src="lib/intersect/intersect-ellipse.js"&gt;&lt;/script&gt;
      &lt;script src="lib/intersect/intersect-line.js"&gt;&lt;/script&gt;
      &lt;script src="lib/intersect/intersect-node.js"&gt;&lt;/script&gt;
      &lt;script src="lib/intersect/intersect-polygon.js"&gt;&lt;/script&gt;
      &lt;script src="lib/intersect/intersect-rect.js"&gt;&lt;/script&gt;
      &lt;script src="lib/version.js"&gt;&lt;/script&gt;--&gt;
      &lt;script&gt;
          var g = new dagreD3.graphlib.Graph().setGraph({});
  
          // States and transitions from RFC 793
          var states = ["CLOSED", "LISTEN", "SYN RCVD", "SYN SENT",
          "ESTAB", "FINWAIT-1", "CLOSE WAIT", "FINWAIT-2",
          "CLOSING", "LAST-ACK", "TIME WAIT"];
  
          // Automatically label each of the nodes
          states.forEach(function (state) { g.setNode(state, { label: state, shape: "circle", href: 'https://github.com/cpettitt/dagre-d3' }); });
  
          // Set up the edges
          g.setEdge("CLOSED", "LISTEN", { label: "open" });
          g.setEdge("LISTEN", "SYN RCVD", { label: "rcv SYN" });
          g.setEdge("LISTEN", "SYN SENT", { label: "send" });
          g.setEdge("LISTEN", "CLOSED", { label: "close" });
          g.setEdge("SYN RCVD", "FINWAIT-1", { label: "close" });
          g.setEdge("SYN RCVD", "ESTAB", { label: "rcv ACK of SYN" });
          g.setEdge("SYN SENT", "SYN RCVD", { label: "rcv SYN" });
          g.setEdge("SYN SENT", "ESTAB", { label: "rcv SYN, ACK" });
          g.setEdge("SYN SENT", "CLOSED", { label: "close" });
          g.setEdge("ESTAB", "FINWAIT-1", { label: "close" });
          g.setEdge("ESTAB", "CLOSE WAIT", { label: "rcv FIN" });
          g.setEdge("FINWAIT-1", "FINWAIT-2", { label: "rcv ACK of FIN" });
          g.setEdge("FINWAIT-1", "CLOSING", { label: "rcv FIN" });
          g.setEdge("CLOSE WAIT", "LAST-ACK", { label: "close" });
          g.setEdge("FINWAIT-2", "TIME WAIT", { label: "rcv FIN" });
          g.setEdge("CLOSING", "TIME WAIT", { label: "rcv ACK of FIN" });
          g.setEdge("LAST-ACK", "CLOSED", { label: "rcv ACK of FIN" });
          g.setEdge("TIME WAIT", "CLOSED", { label: "timeout=2MSL" });
  
          // Set some general styles
          g.nodes().forEach(function (v) {
              var node = g.node(v);
              node.rx = node.ry = 4;
          });
  
          // Add some custom colors based on state
          g.node('CLOSED').style = "fill: #f77";
          g.node('ESTAB').style = "fill: #7f7";
  
          var svg = d3.select("svg"),
          inner = svg.select("g");
  
          // Set up zoom support
          var zoom = d3.behavior.zoom().on("zoom", function () {
              inner.attr("transform", "translate(" + d3.event.translate + ")" +
              "scale(" + d3.event.scale + ")");
          });
          svg.call(zoom);
  
          // Create the renderer
          var render = new dagreD3.render();
  
          // Run the renderer. This is what draws the final graph.
          render(inner, g);
  
          // Center the graph
          var initialScale = 0.75;
          zoom
          .translate([(svg.attr("width") - g.graph().width * initialScale) / 2, 20])
          .scale(initialScale)
          .event(svg);
          svg.attr('height', g.graph().height * initialScale + 40);
          &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I tried this concept : <a href="http://jsbin.com/siyorezedi/1/edit?html,css,js,output" rel="nofollow">http://jsbin.com/siyorezedi/1/edit?html,css,js,output</a></p>
  
  <p>but my nodes are not clickable and no error is thrown.</p>
  
  <p>Can anyone please tell me where am I going wrong?
  Thanking you very much.</p>