Partager via


FSharp.Charting - Wrapping the System.Windows.Forms.DataVisualization.Charting Charting Types (was FSharpChart)

[ Edit: The latest version of FSharp.Charting can be found here ]

I'm just back from giving an F# talk at Microsoft TechDays in Sweden, which was a very enjoyable trip.

One of the things I show in my talks these days is the use of the .NET 4.0 charting controls with F# to display some data from F# Interactive in Visual Studio 2010. This uses a sample set of wrappers we've developed which we're calling FSharpChart. This was inspired by the LChart sample started by Luca Bolognese. These are thin F# wrappers over the charting types in the System.Windows.Forms.DataVisualization.Charting namespace.

In FSharpChart. we've used a number of interesting F# techniques to get the design to scale to the full set of .NET 4.0 charting controls.  This is one of the reasons we're releasing this sample - to show interesting F# design techniques, as well as to light up useful .NET 4.0 functionality with F# 2.0 in Visual Studio 2010.

For example:

   open FSharp.Charting

   [ for f in 1.0 .. 0.1 .. 10.0 -> f, sin (f * 2.0) + cos f ]

   |> Chart.Line

gives the chart below. Many more samples are shown in the documentation,

 

The sample itself is interesting from a number of persepctives

  • Charts display automatically in F# interactive when you evaluate an expression of "chart" type
     .
  • There are numerous interesting F# coding techniques displayed. We'll walk through some of those in future blog posts.
     
  • The same basic shape of charting controls is supported by ASP.NET. This sample doesn't wrap those, but we may do that in future versions.

Don

 

FSharpChart-0.2.zip

Comments

  • Anonymous
    April 01, 2011
    This charting library is extremely cool! I quite like Luca Bolognese's original wrapper too:)

  • Anonymous
    May 26, 2011
    it is suggested to replace all occurrences of static member inline with just static member in the library. Otherwise there would be compiling errors.

  • Anonymous
    May 28, 2013
    The comment has been removed