您好,我正在 MacOS 上的 Xamarin 6.1.5 上运行 我已经安装了 FSharp.Charting 0.90.14
这是我第一次尝试使用它
无论我尝试编译还是在 F# 交互中尝试,我都会收到这种错误
(Chart.Line [ for x in 1.0 .. 100.0 -> (x, x ** 2.0) ]).ShowChart();;
System.ArgumentNullException: Value cannot be null. Parameter name: key at System.ThrowHelper.ThrowArgumentNullException (...)
编辑1 我确实很傻,没有安装Gtk版本
编辑2 上面的一行代码在 F# 交互式中“有效”。执行需要一些不寻常的时间,但我看到带有图表的窗口。无法将鼠标悬停在图表上并查看坐标,但也许它不是默认设置? 另外,我不明白如何关闭图表出现的窗口。 一切都好吗?
最佳答案
您是否尝试在 Mac 上使用 FSharp.Charting
包而不是 FSharp.Charting.Gtk
,正如文档所说的那样?
参见https://fslab.org/FSharp.Charting/ReferencingTheLibrary.html
编辑:回答原始问题的编辑:不,不应该有警告。这就是它对我的作用:
$ fsharpi
F# Interactive for F# 4.1
Freely distributed under the Apache 2.0 Open Source License
For help type #help;;
> #load "packages/FSharp.Charting.Gtk.0.90.14/FSharp.Charting.Gtk.fsx" ;;
[Loading /Users/avysk/Projects/_Sandbox/testfsharpcharting/packages/FSharp.Charting.Gtk.0.90.14/FSharp.Charting.Gtk.fsx]
namespace FSI_0002.FSharp.Charting
val verifyMac : unit -> bool
val isMac : bool
module FsiAutoShow = begin
end
> open FSharp.Charting ;;
> (Chart.Line [ for x in 1.0 .. 100.0 -> (x, x ** 2.0) ]).ShowChart();;
Binding session to '/Users/avysk/Projects/_Sandbox/testfsharpcharting/packages/FSharp.Charting.Gtk.0.90.14/lib/net40/OxyPlot.dll'...
Binding session to '/Users/avysk/Projects/_Sandbox/testfsharpcharting/packages/FSharp.Charting.Gtk.0.90.14/lib/net40/OxyPlot.GtkSharp.dll'...
val it : unit = ()
(窗口立即出现。)
关于MacOS 上的 F# 图表 (Xamarin),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42524242/