How to get Haskell Chart example1 working for Diagrams backend?

▼魔方 西西 提交于 2021-01-28 06:17:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!