Igo*_*man 11 f# fsi fsharpchart f#-charting
我想在我的项目中使用FSharpChart和fsx脚本文件.我使用Nuget下载并引用了MSDN.FSharpChart.dll,我的代码如下所示
#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为我提供了intellisense并且知道MSDN.FSharp命名空间.问题是当我在FSI中运行此脚本时,没有显示任何内容.
怎么了?
为了使您的图表显示在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;;
更新08/23/2012: 
为了进行比较,可视化相同的图表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)
| 归档时间: | 
 | 
| 查看次数: | 1974 次 | 
| 最近记录: |