When plotting a Deedle DataFrame or Series with FSharp.Charting FSLAB conveniently overloads the various Chart functions to work with Series directly. So I can do Series(x,y) |> Chart.Column
for example. However when compiling Deedle and FSharp.Charting is referenced directly and the Series needs to be cast to Series.observations Series(x,y) |> Series.observations |> Chart.Column
Is there a way to avoid Series.observations
? Or do I need to define an extension method for all the different Charting functions? Which is what is suggested in Plotting Deedle frame
Here's the code I used that works both in FSI or .exe:
#if INTERACTIVE
#load @"..\..\FSLAB\packages\FsLab\FsLab.fsx"
#r @"Deedle"
#r @"Fsharp.Charting"
#endif
open System
open Deedle
open FSharp.Charting
open FSharp.Charting.ChartTypes
open System.Drawing
open System.Windows.Forms
[<STAThread>]
[<EntryPoint>]
let main argv =
let x = ['a'..'j'] |> List.map string
let y = [1..10]
let chart1 = Series(x,y) |> Series.observations |> Chart.Column
let myChartControl = new ChartControl(chart1, Dock=DockStyle.Fill)
let form = new Form(Visible = true, TopMost = true, Width = 700, Height = 500)
form.Controls.Add(myChartControl)
do Application.Run(form) |> ignore
The convenient overloads are defined in the FsLab.fsx
file that gets loaded when you reference FsLab from a script file. You can see them in the source code here.
We'd like to move those to a dll
you could reference, but for now, the easiest option is to copy the helpers into a separate file in your project and just have a local copy.