A simple Haskell/Scotty web service for rendering Graphviz documents
  • HTML 34.8%
  • CSS 34.3%
  • Haskell 21.6%
  • JavaScript 9.3%
Find a file
Dan f255874cfc Update README.md
a wee update
2016-05-20 12:32:16 +02:00
Graphviz Server returns base64-encoded image 2012-12-31 18:24:51 +04:00
static Readme 2012-12-31 18:48:32 +04:00
.gitignore Initial commit, semi-working renderer 2012-12-28 20:40:16 +04:00
graphviz-render.cabal Server returns base64-encoded image 2012-12-31 18:24:51 +04:00
LICENSE Initial commit, semi-working renderer 2012-12-28 20:40:16 +04:00
Main.hs Initial commit, semi-working renderer 2012-12-28 20:40:16 +04:00
README.md Update README.md 2016-05-20 12:32:16 +02:00
Render Initial commit, semi-working renderer 2012-12-28 20:40:16 +04:00
Setup.hs Initial commit, semi-working renderer 2012-12-28 20:40:16 +04:00
test.dot Initial commit, semi-working renderer 2012-12-28 20:40:16 +04:00
test.png Initial commit, semi-working renderer 2012-12-28 20:40:16 +04:00

Embedding Graphviz in HTML Pages

Original idea by Yi Wang

A screenshot is worth a thousand words: graphviz embedded graphviz renderer

Serving

A simple web-service was written in Haskell, which invokes Graphviz and returns a base64-encoded image upon a POST request.

Rendering

Dynamic rendering can be done with simple AJAX code

    var d = $(dot_source_element).val();
    $.post(graphviz_server_path, d, function(data) {
      $(output_element).html('<img src=\"data:image/png;base64,' + data + '\" />');
    });

Things that are missing

  • Caching
  • Proper error handling

Set up guide

  1. Download Haskell platform (or obtain Haskell in any other way) and update the repository information:

    cabal update

  2. Make sure you have Graphviz installed

  3. Install scotty using cabal:

    cabal install scotty
    ```
    
    
  4. Check out the source code to your machine and build it:

    git clone git://github.com/co-dan/graphviz-render.git
    cd graphviz-render
    cabal build
    

Then you can run the graphviz-render binary and you'll get a server running on port 3000

  1. Play around with test.html and test2.html.