使用 FSharp.Charting 绘制 Deedle DataFrame 或 Series 时,FSLAB 可以方便地重载各种 Chart 函数以直接使用 Series。所以我可以做Series(x,y) |> Chart.Column
例子。但是在编译 Deedle 和 FSharp.Charting 时直接引用,并且需要将 Series 转换为 Series.observationsSeries(x,y) |> Series.observations |> Chart.Column
有没有办法避免Series.observations
?还是我需要为所有不同的图表功能定义扩展方法?这是Plotting Deedle 框架中建议的内容
这是我在 FSI 或 .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