3
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

  • 1
    Are you using a fsharp script or source file (.fs or .fsx) and are you using Visual Studio or Vs Code? – JosephStevens Aug 13 '17 at 15:26
  • Yes . I'm using Visual Emprise 2017 –  Aug 14 '17 at 12:55
  • *If you were I , you can Uninstall + Install Visual Emprise .* This's reasons takes me many times . *Thank you everyone who help me in my difficulty .* –  Aug 15 '17 at 10:05

3 Answers3

9

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
Tomas Petricek
  • 240,744
  • 19
  • 378
  • 553
  • @AIRO2001 - Have you done a NuGet package restore, so that the `packages/FSharp.Charting` directory actually exists? – rmunn Aug 14 '17 at 01:21
  • I had created a minimal repo here: https://github.com/xuanduc987/FSharpChartingMinimal – xuanduc987 Aug 14 '17 at 14:17
  • @AIRO2001 - I don't use Visual Studio so I can't walk you through the process, but basically, there's an option somewhere in the menus called "Restore NuGet packages" (the wording might be a little different). Once you've run that, you should look in the `packages` folder that will appear in your project, find the one with `FSharp.Charting` in the name, and reference that. **IMPORTANT**: You must make sure the folder name in the `#I` line is correct (it might have a version number in it). See http://brandewinder.com/2016/02/06/10-fsharp-scripting-tips/ for more information. – rmunn Aug 15 '17 at 09:46
  • *If you were I , you can Uninstall + Install Visual Emprise .* This's reasons takes me many times . *Thank you everyone who help me in my difficulty .* –  Aug 15 '17 at 10:03
0

Add System.Drawing reference to your project via: Right click on references > Assemblies > FrameWork > System.Drawing

then try this code instead.

open FSharp.Charting

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

[<EntryPoint>]
let main argv = 0
JosephStevens
  • 1,668
  • 1
  • 15
  • 17
  • *If you were I , you can Uninstall + Install Visual Emprise .* This's reasons takes me many times . *Thank you everyone who help me in my difficulty .* –  Aug 15 '17 at 10:05
0

If you were I , you can Uninstall + Install Visual Emprise .

This's reasons takes me many times .

Thank you everyone who help me in my difficulty .