Use flowchart.js in the browser
masterTo use flowchart.js in a web application, include the flowchart.js library and the Raphaël library. Both are available via CDNJS.
Note: Raphaël is a required dependency for rendering.
repository·master·Indexed 27 days ago
https://github.com/adrai/flowchart.jsA Domain Specific Language (DSL) and SVG renderer for creating flowcharts. It allows users to define nodes and connections separately to enable node reuse and easy styling. The library supports various node types including start, end, operation, condition, and parallel, and requires the Raphaël library for rendering. It provides a FlowChart API to parse the DSL into a structured format for web or Node.js environments.
To use flowchart.js in a web application, include the flowchart.js library and the Raphaël library. Both are available via CDNJS.
Note: Raphaël is a required dependency for rendering.
The following styling features are available in current versions:
v1.17.0.flowstate introduced in v1.3.0.v1.3.1).font, font-family, and font-weight (introduced in v1.2.9).v1.7.0).arrow-end option (introduced in v1.2.3) and the arrow-text attribute for symbols (introduced in v1.9.0).The following layout configuration options are available:
scale: Allows scaling the chart (introduced in v1.4.0).maxWidth: Sets a maximum width for the chart (introduced in v1.2.6).v1.7.0).You can apply custom CSS-like styling to specific paths in a flowchart using the @> operator and a JSON-like object for properties such as stroke, stroke-width, and arrow-end.
Example:
st@>op1({"stroke":"Red"})@>cond({"stroke":"Red","stroke-width":6,"arrow-end":"classic-wide-long"})@>e({"stroke":"Red"})v1.12.0, you can bind onclick functions to chart nodes, allowing for interactive flowcharts.Nodes are defined using the following syntax:
nodeName=>nodeType: nodeText[|flowstate][:>urlLink]
nodeName: The variable name used to reference the node in connections.nodeType: The shape/type of the node (see Node Types).nodeText: The text displayed inside the node. Newlines are supported.|flowstate (optional): Extra styling for the node.:>urlLink (optional): A URL to link to when the node is clicked. Use [blank] at the end of the URL to open in a new tab.Warning: Avoid using the following symbols in your nodeText: =>, ->, :>, |, @>, and :$.
Connections are defined separately from node definitions using the -> operator.
nodeVar1->nodeVar2
You can specify the direction a connection leaves a node using: left, right, top, or bottom. This is added inside parentheses after the node variable.
Some node types require or support specific parameters in parentheses (spec1, spec2):
condition: Requires a logical specification (yes or no).cond(yes, right)->nextNode1cond(no, bottom)->nextNode2parallel: Requires a path specification (path1, path2, or path3).para(path1, top)->nextNode1para(path2, bottom)->nextNode2start, operation, inputoutput, subroutine: Support an optional direction.op1(left)->nextYou can add custom names to branches using the @ symbol inside the parentheses:
cond(true@linear)->io
v1.11.0 introduced the parallel component, allowing you to represent parallel processes in your flowchart.v1.18.0, flowchart.js supports new node types for input and output symbols in your flowchart definitions.v1.8.0, the Conditional symbol was updated to support 'true' or 'false' labels in addition to the standard 'yes' and 'no' labels.You can make nodes clickable by appending the :> operator followed by a URL.
[blank] to the URL.[blank].Example:
st=>start: Start:>http://www.google.com[blank]
e=>end: End:>http://www.yahoo.comWhen initializing or customizing a flowchart, you can provide an options object to override the default styling and behavior. The following keys are available for configuration:
x: Horizontal offset (default: 0)y: Vertical offset (default: 0)scale: Scaling factor (default: 1)line-width: Thickness of lines (default: 3)line-length: Length of lines (default: 50)text-margin: Margin around text (default: 10)font-size: Size of the text (default: 14)font-color: Color of the text (default: 'black')line-color: Color of the lines (default: 'black')element-color: Color of the element borders (default: 'black')fill: Background fill color for elements (default: 'white')class: CSS class applied to the flowchart (default: 'flowchart')yes-text: Text used for positive condition branches (default: 'yes')no-text: Text used for negative condition branches (default: 'no')arrow-end: Style of the arrow head (default: 'block')The symbols object allows you to define specific styles for different node types. Each key in symbols can take an object of properties to override defaults for that specific node type.