Search code examples
chartsf#f#-datafsharpchart

How to make Fsharp show Charting?


Chart.Line [ for x in 1.0 .. 100.0 -> (x, x ** 2.0) ]

I tried many times in order to see the Charting from Fsharp as F# Charting

I install some extensions which I think needed :

  • Fsharp.Charting
  • Fsharp.Chart
  • Fsharp.Charting.Gtk
  • Microsoft.Chart.Controls

But all it seems not enough for me to do . Could you give me some helpfull guide ? Thank you very much .

enter image description here

enter image description here


Solution

  • If you are running this from F# Interactive and you are referencing the library using the recommended method, then the loading registers a handler with F# Interactive that will open charts automatically when you run the line that creates a chart. That is, load the library using:

    #I "packages/FSharp.Charting"
    #load "FSharp.Charting.fsx"
    

    And then create chart using:

    Chart.Line [ for x in 1.0 .. 100.0 -> (x, x ** 2.0) ]
    

    If you are not inside a script, or if you are referencing just the dll (or if your editor handles F# Scripts differently than the standard editors - which I don't think should be the case), then you need to call Show method explicitly:

    Chart.Line [ for x in 1.0 .. 100.0 -> (x, x ** 2.0) ]
    |> Chart.Show