我想在我的项目中使用带有fsx脚本文件的FSharpChart。我使用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路径是正确的,因为VS2012为我提供了智能感知,并且知道MSDN.FSharp名称空间。问题是,当我在FSI中运行这个脚本时,什么也没有显示。
怎么啦?
发布于 2012-08-04 00:01:50
为了使图表从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;;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)https://stackoverflow.com/questions/11798568
复制相似问题