how to declare a variable by using viz.js?

Hi,

I made a Html by using via.js. I'd like to connect it to my database. I need to declare a variable as label in the graph, but it will show the variable's name as the label in the graph. Anyone can help me to solve this problem?

digraph G {
var temp = "c1";
a1 -> b3;
b2 -> a3;
a3 -> a0;
b2->temp; // it doesn't work. the label will be temp, not c1.
}

The call to Viz expects the

The call to Viz expects the first argument to be a string containing a legal graph described in the DOT language. Any substitutions you want need to be done in javascript before passing the string off to Viz. You can either build the graph up by concatenation:

  var temp = "c1";

  var g = "digraph G { a1 -> b3; b2 -> a3; a3 -> a0; b2->" + temp + "; }";

   Viz(g,"svg");

or use substitution

  var g = "digraph G { a1 -> b3; b2 -> a3; a3 -> a0; b2->temp; }";

   Viz(g.replace("temp",temp),"svg");

or any other comparable trick in javascript.

Recent comments