1

The example outputs for Haskell's chart library look great. They all use the Cairo backend which I cannot install properly, so I'd like to try out the library using the Diagrams backend.

However, it is not obvious to me how to do this. In particular, def is undefined.

Can someone help me get started and show me how to modify the source code for example 1 so that it can run using the Diagrams backend?

  • I'm not familiar with the chart library, but `def` is part of `Data.Default.Class`, which is one of the imports in that example. Did you forget to copy that line? If not, I think you should provide an exact error message (and code if you did more than just substitute `Diagrams` for `Cairo` in the backend import). – raymonad Mar 13 '14 at 22:37
  • I took the example code verbatim, and changed the Cairo import to a Diagrams import. So, either the Cairo backend defines `def` and the Diagrams backend doesn't, or the example is incomplete. –  Mar 13 '14 at 22:43
  • So then by '`def` is undefined' you meant that a `Default` instance was missing? That's why I asked for the exact error. – raymonad Mar 13 '14 at 23:08

1 Answers1

3

The problematic def is the FileOptions argument to the Cairo backend's renderableToFile. This has a Default instance.

To render with the Diagrams backend, replace the call to renderToFile with renderableToSVGFile from the Diagrams backend:

main = renderableToSVGFile chart 800 600 "example.svg"
robx
  • 2,221
  • 1
  • 14
  • 31