Skip to content

Haskell EDSL to create documents with plots based on the C3.js library.

License

Notifications You must be signed in to change notification settings

andersjel/haskell-text-and-plots

Repository files navigation

The text-and-plots package

text-and-plots is a Haskell EDSL to create documents with embedded plots.

Here is an example:

import Text.DocL
import Data.Foldable (fold)

main = renderToFile "out.html" $ fold
  [ header "Stirling's approximation"
  , text $ fold
      [ "A simple approximation of the factorial function is given by "
      , "Stirling's approximation." ]
  , plot [1..50] (col "n" id)
      [ col "log(n!)" $ \n -> sum $ map log [1..n]
      , col "n log n - n" $ \n -> n * log n - n ]
  ]

The above code produces the output:

Stirling's approximation

A simple approximation of the factorial function is given by Stirling's approximation.

a plot

Details

The render function converts the document to HTML with plots based on the C3.js libray. text-and-plots does not try to wrap every aspect of the C3.js library, but instead exposes it directly if needed.

About

Haskell EDSL to create documents with plots based on the C3.js library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published