2012-08-03 19 views
11

我想在我的项目中将FSharpChart与fsx脚本文件一起使用。我下载并使用引用的的NuGet和MSDN.FSharpChart.dll我的代码看起来像这样如何从fsx脚本文件使用FSharpChart

#r @"..\packages\MSDN.FSharpChart.dll.0.60\lib\MSDN.FSharpChart.dll" 
open System.Drawing 
open MSDN.FSharp.Charting 

[for x in 0.0 .. 0.1 .. 6.0 -> sin x + cos (2.0 * x)] 
    |> FSharpChart.Line 

的路径是正确的,因为VS 2012为我提供了智能感知和知道MSDN.FSharp命名空间。问题是,当我在FSI中运行这个脚本时,没有显示任何内容。

出了什么问题?

回答

7

为了使您的图表从FSI显示你应该在下面的一个片段预装FSharpChart.fsx到您的FSI会议,如:

#load @"<your path here>\FSharpChart.fsx" 
[for x in 0.0 .. 0.1 .. 6.0 -> sin x + cos (2.0 * x)] 
|> MSDN.FSharp.Charting.FSharpChart.Line;; 

UPDATE 2012年8月23日: 为了比较,可视化在同一个图表关FSharpChart.dll需要一些的WinForms管道:

#r @"<your path here>\MSDN.FSharpChart.dll" 
#r "System.Windows.Forms.DataVisualization.dll" 
open System.Windows.Forms 
open MSDN.FSharp.Charting 

let myChart = [for x in 0.0 .. 0.1 .. 6.0 -> sin x + cos (2.0 * x)] 
       |> FSharpChart.Line 

let form = new Form(Visible = true, TopMost = true, Width = 700, Height = 500) 
let ctl = new ChartControl(myChart, Dock = DockStyle.Fill) 
form.Controls.Add(ctl) 
+1

FSharpChart.fsx不是NuGet包的一部分,但我发现它的authorw网络上。这是否意味着这个软件包不适用于F#而是C#? – 2012-08-03 16:04:56

+1

它用FSharpChart库构建F#WinForm/WPF应用程序。 – 2012-08-03 16:09:31

+0

我记得#加载fsx文件需要很长时间,并提供相同的参考nuget的dll – nicolas 2012-08-22 18:06:53

相关问题