ConceptDiagram
Build concept diagrams as plain Elixir data, then render them to Mermaid or Graphviz DOT.
A concept diagram is a set of labelled nodes connected by labelled, directed edges. Describe one with a small, pipeline-friendly API and turn it into diagram source you can drop straight into Markdown (Mermaid) or render with Graphviz (DOT).
Installation
Add concept_diagram to your deps in mix.exs:
def deps do
[{:concept_diagram, "~> 0.1.0"}]
endUsage
ConceptDiagram.new(direction: :left_right)
|> ConceptDiagram.add_edge("Survey data", "Themes", "coded into")
|> ConceptDiagram.add_edge("Themes", "Framework", "organised as")
|> ConceptDiagram.to_mermaid()produces:
flowchart LR
n0["Survey data"]
n1["Themes"]
n2["Framework"]
n0 -->|coded into| n1
n1 -->|organised as| n2
Nodes referenced by an edge are created automatically. Render the same diagram as
Graphviz DOT with ConceptDiagram.to_dot/1, or build one from a list of triples:
ConceptDiagram.from_triples([
{"Cause", "leads to", "Effect"},
{"Effect", "feeds back into", "Cause"}
])
|> ConceptDiagram.to_dot()
Labels are escaped for each target format, and :direction (:top_down,
:bottom_up, :left_right, :right_left) controls the layout.
About
ConceptDiagram is maintained by the team behind
Vizcept, an AI concept diagram generator. If you would
rather describe a diagram in plain English and let AI lay it out, try the
AI concept diagram generator; this library is its
code-first companion for producing diagram source programmatically.
License
Released under the MIT License.