如何使Haskell Chart example1适用于Diagrams后端? [英] How to get Haskell Chart example1 working for Diagrams backend?
问题描述
Haskell图表库的示例输出看起来很棒.他们都使用我无法正确安装的Cairo后端,因此我想使用Diagrams后端尝试该库.
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.
但是,对我而言,如何执行此操作并不明显.特别是, def
是未定义的.
However, it is not obvious to me how to do this. In particular, def
is undefined.
有人可以帮助我入门并向我展示如何修改源代码示例1 ,以便它可以在图表后端运行?
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?
推荐答案
有问题的 def
是开罗后端的 renderableToFile
的 FileOptions
参数.它具有默认实例.
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"
这篇关于如何使Haskell Chart example1适用于Diagrams后端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!