On a web page I want to dynamically render very basic flow diagrams, i.e. a few boxes joined by lines. Ideally the user could then click on one of these boxes (DIVs
?) and be taken to a different page. Resorting to Flash seems like an overkill. Is anyone aware of any client-side (i.e. server agnostic
) Javascript or CSS library/technique
that may help achieve this?
A flowchart is a pictorial representation of system transactions, definitions, solutions or analysis of a problem, process or procedure. It documents a sequenced flow of important aspects and/or actions and can simplify complex relationships.
JavaScript Flowchart is a visual representation of a process in which each step in the process is represented by a different shape and contains a short description of the process step. The JavaScript Diagram library offers various feature sets to build flowcharts with ease.
Reactome's DiagramJs widget is our diagram viewer in an ordinary JavaScript API. It is meant to be reused by third party resources in order to display Reactome Pathway Diagrams directly in their web pages and enable users to interact with them.
Does the rendering have to be client side?
If yes, you could try Processing:
http://ejohn.org/blog/processingjs/
If you can do it server side, then Graphviz is a good choice.
http://www.graphviz.org/
The best and simplest I found is js-graph.it.
It has also this useful feature: deciding the orientation of the flow. For example, in my case I have a document workflow, so I need it to flow towards the right side.
An even simpler alternative is wz_jsGraphics. In my case I draw the arrows like this:
/**Draw an arrow made of 3 lines.
* Requires wz_jsGraphics (http://www.walterzorn.de/en/jsgraphics/jsgraphics_e.htm).
* @canvas a jsGraphics object used as canvas
* @blockFrom id of the object from which the arrow starts
* @blockTo id of the object where the arrow ends with a arrowhead
*/
function drawArrow(canvas, blockFrom, blockTo){
//blocks
var f = $("#" + blockFrom);
var t = $("#" + blockTo);
//lines positions and measures
var p1 = { left: f.position().left + f.outerWidth(), top: f.position().top + f.outerHeight()/2 };
var p4 = { left: t.position().left, top: t.position().top + t.outerHeight()/2 };
var mediumX = Math.abs(p4.left - p1.left)/2;
var p2 = { left: p1.left + mediumX, top: p1.top };
var p3 = { left: p1.left + mediumX, top: p4.top };
//line A
canvas.drawLine(p1.left, p1.top, p2.left, p2.top);
//line B
canvas.drawLine(p2.left, p2.top, p3.left, p3.top);
//line C
canvas.drawLine(p3.left, p3.top, p4.left, p4.top);
//arrowhead
canvas.drawLine(p4.left - 7, p4.top - 4, p4.left, p4.top);
canvas.drawLine(p4.left - 7, p4.top + 4, p4.left, p4.top);
}
var jg = new jsGraphics('myCanvasDiv');
drawArrow(jg, 'myFirstBlock', 'mySecondBlock');
jg.paint();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With