open FSharp.Charting
open System
[<EntryPoint>]
let main argv =
printfn "%A" argv
let x = Chart.Line [ for x in -100 .. 100 -> x, pown x 3]
let y = Console.ReadKey();
0 //return an integer exit code
您好,我正在尝试使用 PROJECT 模式 NOT 脚本中的F#。到目前为止,我有上面的代码以及它告诉我添加对System.Drawing的引用,我也做了。
编译时我有0个错误或警告,它运行得非常好。出现控制台屏幕但没有其他事情发生。图表没有显示或任何东西。
我已经在交互式窗口中尝试了这个,它在那里工作得很好。有什么想法吗?
答案 0 :(得分:7)
正如@ s952163所提到的,你可以把它包装成Winforms。但是,ShowChart()
已经返回System.Windows.Form
值。所以,只要您使用Application.Run(f)
抽取事件,此代码也可以正常运行:
[<EntryPoint>]
let main argv =
printfn "%A" argv
let f = (Chart.Line [ for x in -100 .. 100 -> x, pown x 3]).ShowChart()
System.Windows.Forms.Application.Run(f)
0
答案 1 :(得分:3)
你应该将它包装在Winforms中。请参阅:How to display an FSharp.Charting graph in an existing form?
非常准确的例子:
open FSharp.Charting
open System
open System.Windows.Forms
[<STAThread>]
[<EntryPoint>]
let main argv =
printfn "%A" argv
let chart = Chart.Line [ for x in -100 .. 100 -> x, pown x 3]
let f1 = new Form(Visible = true, TopMost = true, Width = 700, Height = 500)
f1.Controls.Add(new ChartTypes.ChartControl(chart, Dock = DockStyle.Fill))
Application.Run(f1)
0 // return an integer exit code
请参考System.Drawing,System.Windows.Forms,System.Windows.Forms.DataVisualization