为了实现这一点,您应该将图表包装到FSharp.Charting.ChartTypes.ChartControl并注意正确的对接。此外,您不应将ChartFSharp.Charting 与Chartfrom混合使用System.Windows.Forms.DataVisualization.Charting。
一个很好的起点可能是以下与当前 FSharp.Charting v0.90.5 一起使用的功能齐全的示例;还需要参考System.Drawing和System.Windows.Forms:
open System
open FSharp.Charting
open FSharp.Charting.ChartTypes
open System.Drawing
open System.Windows.Forms
[<STAThread; EntryPoint>]
let main args =
let myChart = [for x in 0.0 .. 0.1 .. 6.0 -> sin x + cos (2.0 * x)]
|> Chart.Line |> Chart.WithYAxis(Title="Test")
let myChartControl = new ChartControl(myChart, Dock=DockStyle.Fill)
let lbl = new Label(Text="my label")
let form = new Form(Visible = true, TopMost = true, Width = 700, Height = 500)
form.Controls.Add lbl
form.Controls.Add(myChartControl)
do Application.Run(form) |> ignore
0