F#使用Winforms DataVisualization制作条形图 [英] F# Make Bar Chart with Winforms DataVisualization
问题描述
我想用Winforms和F#制作条形图。我已经看到许多其他C#示例使用 System.Windows.Forms.DataVisualization.Charting
制作图表,尽管当我尝试打开该库时会说未定义名称空间。
I want to make a bar Chart with Winforms and F#. I have seen many other C# examples making a chart with System.Windows.Forms.DataVisualization.Charting
although when i try to open that library then it says then namespace is not defined.
像这样的 let chart = new Chart()
这样简单的操作由于库没有被定义我接受它。尽管我已经看到人们在C#中执行此操作。 F#的正确方法是什么?
Something as simple as this let chart = new Chart()
doesn't work due to the namespace of the library not being defined i take it. Though I have seen people do this in C#. What is the correct way for F#?
有人能这么热情地向我展示如何在F#中制作图表并指向条形图的正确方向吗?
Can someone be so kind to show me how to make a chart in F# and point me in the right direction of a bar Chart?
推荐答案
您将需要引用正确的程序集,然后可以打开
像这样的命名空间(相当于C#使用
):
You will need to reference the correct assembly then you can open
the namespace (equivalent of C# using
) like this:
open System.Windows.Forms.DataVisualization.Charting
但是,在您遵循这条路线之前,我强烈建议您使用 FSharp.Charting ,它是包装器 DataVisualization.Charting
,并且更容易在F#中使用。
However, before you go down this route, I would strongly recommend you use FSharp.Charting, which is a wrapper arround DataVisualization.Charting
and much easier to work with in F#.
这是使用 DataVisualization.Charting
这篇关于F#使用Winforms DataVisualization制作条形图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!