Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a library for rendering basic flow diagrams in Javascript/CSS? [closed]

Tags:

javascript

css

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?

like image 598
David Harrison Avatar asked Aug 26 '08 09:08

David Harrison


People also ask

What is library flowchart?

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.

What is flowchart in JavaScript?

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.

What is diagram JS?

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.


2 Answers

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/

like image 65
Sergio Acosta Avatar answered Oct 19 '22 23:10

Sergio Acosta


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(); 
like image 26
bluish Avatar answered Oct 20 '22 01:10

bluish