Skip to content

Latest commit

 

History

History
65 lines (46 loc) · 1.63 KB

README.md

File metadata and controls

65 lines (46 loc) · 1.63 KB

Generic Graphviz

documentation can be found on pursuit

consists of 3 parts (which probably now are seperate modules..):

  1. Dot-Lang typed representation and Dot-Lang code-generator. here
  2. Generic Graph generator (takes an arbituary ADT and generates a graph for it) (this repository)
  3. Bindings for Graphviz here

Example

-- your data type
data Tree' a = Leaf' | Node' (Tree' a) a (Tree' a)

-- derive generic
derive instance treeGeneric :: Generic (Tree' a) _

-- create instances for the needed type classes
instance treeEdges :: Edges a => Edges (Tree' a) where
  edges x = genericEdges x
instance treeDotRepr ::  Edges a => GraphRepr (Tree' a) where
  toGraph = genericToGraph

example :: String
example = renderToSvg Dot $ toGraph $
  Node' Leaf' 3 (Node' (Node' Leaf' 5 Leaf') 4 Leaf')
-- example = "...<svg><g>...</g>...</svg>..."

example will be:

screenshot

see full example for imports

see todo mvc example for a larger example

Features

  • generic graph generation
  • after npm install: usable from nodejs backend
  • graphviz-images can be rendered to Chrome's WebDev Console (using console.log)

TODOs

  • Refactor into multiple libraries
  • support entire DOT language in data model
  • allow custom edges in GenericGraph
  • add effects to console.image
  • move viz.js call into a WebWorker

Testing

run tests:

$ pulp test