首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在fsx脚本文件中使用FSharpChart

如何在fsx脚本文件中使用FSharpChart
EN

Stack Overflow用户
提问于 2012-08-03 23:18:49
回答 1查看 2.1K关注 0票数 11

我想在我的项目中使用带有fsx脚本文件的FSharpChart。我使用Nuget下载并引用了MSDN.FSharpChart.dll,我的代码如下所示

代码语言:javascript
复制
#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中运行这个脚本时,什么也没有显示。

怎么啦?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-04 00:01:50

为了使图表从FSI中显示出来,您应该将FSharpChart.fsx预加载到FSI会话中,如下面的代码片段所示:

代码语言:javascript
复制
#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管道:

代码语言:javascript
复制
#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)
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11798568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档