爲了達到這個目的,你應該把你的圖表換成FSharp.Charting.ChartTypes.ChartControl
並且照顧正確的對接。你也不應該混合來自FSharp的Chart
。與Chart
從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
'form.Controls.Add myChart'? – ildjarn
我的意思是控制代替原始代碼中的容器。仍然不起作用。我想有一個像ChartControl的地方 – vidi