2012-08-03 5 views
11

Ich möchte FSharpChart mit einer fsx-Skriptdatei in meinem Projekt verwenden. Ich heruntergeladen und verwiesen die MSDN.FSharpChart.dll mit Nuget und mein Code wie folgt aussiehtSo verwenden Sie FSharpChart aus fsx-Skriptdatei

#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 

Der Weg richtig ist, weil VS 2012 bietet mir Intellisense und kennt den MSDN.FSharp Namespace. Das Problem ist, dass wenn ich dieses Skript in FSI ausführen, nichts angezeigt wird.

Was ist los?

Antwort

7

Um Ihr Diagramm von FSI zeigen bis machen Sie FSharpChart.fsx in Ihre FSI-Sitzung wie in einem Snippet unter Vorspannung sollte:

#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.08.23: Zum Vergleich, die gleiche Grafik off FSharpChart.dll Visualisierung würde einige WinForms Sanitär erfordern:

#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 nicht Teil des Nuget Pakets ist, aber ich es auf dem authorw Internet. Bedeutet es, dass dieses Paket nicht für F #, sondern für C# ist? –

+1

Es dient zum Erstellen von F # WinForm/WPF-Anwendungen mit FSharpChart-Bibliothek. –

+0

Ich erinnere mich, #loading die fsx-Datei dauert eine lange Zeit und bietet das gleiche wie nur Bezug auf die niget dll – nicolas