我的F#图库在项目中不工作 [英] My F# Chart Library doesn't work in a project

查看:109
本文介绍了我的F#图库在项目中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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,我也做了。

Hello, I'm trying to play with the F# in PROJECT mode NOT a script. So far I have the code above as well as it told me to add a reference to System.Drawing which I also did.

我有0错误或警告,当我编译它运行完美。出现控制台屏幕,但没有其他发生。图表不显示或任何东西。

I have 0 errors or warnings when I compile and it runs perfectly fine. The console screen appears but nothing else happens. The graph just doesn't show up or anything.

我已经在交互式窗口中尝试过了,它在那里工作得很好。任何想法?

I HAVE tried this in the interactive window and it works perfectly fine there. Any ideas?

推荐答案

As @ s952163提到,你可以将它包装到Winforms。但是, ShowChart()已经返回 System.Windows.Form 值。所以,只要你用 Application.Run(f)来抽运事件,这个代码也可以正常工作:

As @s952163 mentioned, you could wrap it to Winforms. However, ShowChart() already returns System.Windows.Form value. So, as long as you're pumping events with Application.Run(f), this code works fine too:

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

这篇关于我的F#图库在项目中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆