问题
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?
回答1:
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"
来源:https://stackoverflow.com/questions/22392233/how-to-get-haskell-chart-example1-working-for-diagrams-backend