11

プロジェクトで 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

VS 2012 は IntelliSense を提供し、MSDN.FSharp 名前空間を認識しているため、パスは正しいです。問題は、このスクリプトを FSI で実行すると、何も表示されないことです。

なにが問題ですか?

4

1 に答える 1

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;;

更新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)
于 2012-08-03T16:01:49.573 に答える