F# Charting on MacOS (Xamarin)

199 Views Asked by At

Hi I'm running on Xamarin 6.1.5 on MacOS I've installed FSharp.Charting 0.90.14

its the first time I'm trying to use it

whether i try to compile or i try in F# interactive, i get this kind of error

(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 (...)

EDIT1 I was very stupid indeed and did not install the Gtk version

EDIT2 the above one-liner code in F# interactive "works". It takes some unusual time to execute, but i see the window with the chart. It is not possible to hover on the chart and see coordinates, but maybe its not a default setting ? also, i don't understand how to CLOSE the window where the chart appears. Is everything alright ?

1

There are 1 best solutions below

0
On

Aren't you trying to use FSharp.Charting package on Mac instead of FSharp.Charting.Gtk, as documentation says you to do?

See https://fslab.org/FSharp.Charting/ReferencingTheLibrary.html

Edit: answering to the edit of the original question: no, there should be no warnings. That's how it works for me:

$ 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 = ()

(The window appears immediately.)